akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

double eps = 1e-10;
const int INF = 1e+9;
typedef pair<int, int> P;
typedef pair<int, P> pp;
const int MAX_N = 105000;

int M = 256;
int N, I[512];

int main() {
	while(cin >> N && N){
		int S, A, C;
		double minum = INF;
		REP(i, N){
			cin >> I[i + 1];
		}
		REP(s, 16)REP(a, 16)REP(c, 16){
			int O[256] = {0};
			int R = s;
			for(int i = 1; i <= N; ++i){
				R = ((a * R) + c) % M;
				O[(I[i] + R) % M]++;
			}
			double H = 0;
			REP(i, 256){
				if(O[i] > 0)
					H -= O[i] / (double)N * log(O[i] / (double)N);
			}
			if(H + eps < minum){
				minum = H;
				S = s;
				A = a;
				C = c;
			}
		}
		cout << S << " " << A << " " << C << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			double x=sc.nextInt();
			double h=sc.nextInt();
			if(x==0&&h==0){
				break;
			}
			double sh=Math.sqrt(h*h+(x/2)*(x/2));
			System.out.println(x*sh/2*4+x*x);
		}
	}
}

Measured memory_bytes: 17184
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;


        y = y>>1;
        x = x*x;
    }
    return res;
}
bool isPalindrome(string str)
{
    // Start from leftmost and rightmost corners of str
    int l = 0;
    int h = str.length()- 1;

    // Keep comparing characters while they are same
    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return false;
        }
    }
    return true;
}

signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int l;
cin>>l;
double x=((l*1.0)/3.0);
double y=x*x*x;
cout<<fixed<<setprecision(10)<<y<<endl;
}









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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

ll a[1000100];
map<ll, bool> pd;
int main() {
  ll n;
  cin >> n;
  rep(i, n) cin >> a[i];
  bool PC = true;
  rep(i, n) {
    ll x = a[i];
    if (x == 1) continue;
    while (x > 1) {
      bool xisprime = true;
      for (ll i = 2; i * i <= x; ++i) {
        if (x % i == 0) {
          xisprime = false;
          if (pd[i]) {
            PC = false;
            goto pce;
          }
          pd[i] = true;
          while (x % i == 0) x /= i;
          break;
        }
      }
      if (xisprime) {
        if (pd[x]) {
          PC = false;
          goto pce;
        }
        pd[x] = true;
        break;
      }
    }
  }
pce:
  if (PC) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  ll g = 0;
  rep(i, n) {
    g = gcd(g, a[i]);
    if (g == 1) break;
  }
  cout << (g == 1 ? "setwise coprime" : "not coprime") << endl;
}


Measured memory_bytes: 11428
#include<stdio.h>
int main(){
  char s[20],t[20];
  int i;
  scanf("%s %s",s,t);
  for(i=0;s[i];i++){
    if(s[i]!=t[i]){
      printf("No\n");
      return 0;
    }
  }
  if(t[i]==0||t[i+1]){
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  return 0;
}


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

using namespace std;

#define MOD 1000000007

long long dp[100001][2] = {};
vector<vector<int> > a;

void dfs(int now, int p) {
	long long w = 1, b = 1;
	for (int e : a[now]) {
		if (e == p) continue;
		dfs(e, now);
		(w *= dp[e][0] + dp[e][1]) %= MOD;
		(b *= dp[e][0]) %= MOD;
	}
	dp[now][0] = w; dp[now][1] = b;
}

int main() {
	int n; cin >> n;
	a.assign(n, vector<int>());
	for (int i = 0; i < n - 1; ++i) {
		int x, y; cin >> x >> y;
		x--, y--;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	dfs(0, -1);
	cout << (dp[0][0] + dp[0][1]) % MOD << endl;

	return 0;
}

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

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

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

	int N; string S; cin >> N >> S;

	int cnt[30];
	int ans = 0;

	for (int i = 0;i < N;i++){
		memset(cnt,0,sizeof(cnt));
		int sum = 0;
		for (int j = 0;j < N;j++){
			if(j < i){
				cnt[S[j]-'a']++;
			}else{
				if(cnt[S[j]-'a'] > 0){cnt[S[j]-'a'] = 0; sum++;}
			}
		}
		ans = max(ans,sum);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(s.size()<=n){
		cout<<s;
	}
	else{
		cout<<s.substr(0,n)<<"...";
	}

	return 0;
}


Measured memory_bytes: 3640
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> heights(n);
  vector<int> maxHeightOfConnocted(n); 
  int roada,roadb;
  for(int i = 0;i<n;i++){
    cin>>heights[i];
  }
  for(int i = 0;i<m;i++){
    cin>>roada>>roadb;
    --roada;
    --roadb;
    maxHeightOfConnocted[roada]=max(maxHeightOfConnocted[roada],heights[roadb]);
    maxHeightOfConnocted[roadb]=max(maxHeightOfConnocted[roadb],heights[roada]);
  }
  int ans=0;
  for(int i = 0;i<n;i++){
    if(heights[i]>maxHeightOfConnocted[i]){
      ans++;
    }
  }
  cout<<ans<<"\n";  
  return 0;
}

Measured memory_bytes: 4004
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Scanner;

class Main {
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
		
		ArrayDeque<Integer> list = new ArrayDeque<>();

		int n = scan.nextInt();
		
		for(int i=0; i<n; i++) {
			int query = scan.nextInt();
			int a = scan.nextInt();

			switch(query) {

			case 0:
				int b = scan.nextInt();
				if(a == 0) {
					list.addFirst(b);
				}else {
					list.addLast(b);
				}
				break;
					
			case 1:
				Iterator<Integer> ite = list.iterator();
				for(int j=0; j<a; j++) {
						ite.next();
					}
				System.out.println(ite.next());
				break;

				
			case 2:
				if(a == 0) {
					list.removeFirst();
				}else {
					list.removeLast();
				}
				break;
			}
		}
		
	}
}


Measured memory_bytes: 303236
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main () {
  int n;
  int t, a;
  int h[1010];
  cin >> n;
  cin >> t >> a;
  for (int i = 0; i < n; i++) cin >> h[i];
  
  int ans = 0;
  double min_diff = 100000.0;
  for (int i = 0; i < n; i++) {
    double diff = fabs(a - (t - 0.006 * h[i]));
    if (diff < min_diff) {
      min_diff = diff;
      ans = i + 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# AtCoder Beginner Contest 132
# B - Ordinary Number

n=int(input())
pls=list(map(int,input().split()))

ans=0

for i in range (n-2):
    a=pls[i]
    b=pls[i+1]
    c=pls[i+2]
    if a<b<c or c<b<a:
        ans+=1

print(ans)

Measured memory_bytes: 9116
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include<climits>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */

struct cmp
{
	bool operator() (pii a, pii b) {
		return (a.l < b.l);
	}
};

int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
int dp[100001][2];
int n, k;
int arr[101];

int go(int sum, int turn) {
	if (sum < 0) {
		return turn;
	}
	if (sum < arr[0]) {
		return turn ^ 1;

	}
	if (dp[sum][turn] != -1)
		return dp[sum][turn];


	for (int i = 0; i < n; i++) {
		int op2 = go(sum - arr[i] , turn ^ 1);
		//cout << op2 << " " << sum << " " << arr[i] << " " << turn << endl;
		if (op2 == turn )
		{
			return dp[sum][turn] = turn;
		}

	}
	return dp[sum][turn] = turn ^ 1;



}





signed main()
{
	haha
#ifndef ONLINE_JUDGE

	freopen("inp.txt", "r", stdin);

	freopen("out1.txt", "w", stdout);
#endif
	init(dp, -1);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int x = go(k, 0);

	if (x == 0)
		cout << "First";
	else {
		cout << "Second";
	}







}


Measured memory_bytes: 11448
// include
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
// prototype
int SortAscendNum(const void *num1, const void *num2);
int SortDescendNum(const void *num1, const void *num2);
 
// main
int main(void)
{
    int N;
  	int i;
    int flag=1;
    
  	scanf("%d\n",&N);
  	int A[N];
  	for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    }
     
     
    // 文字列を昇順でソート
    qsort(A,N, sizeof(*A), SortAscendNum);
  	for(i=0;i<N-1;i++){
    	if(A[i]==A[i+1]){
    		flag=0;
    	}
    }
	if(flag==1)
  		printf("YES\n");
  	else if(flag==0)
      	printf("NO\n");
    // 文字列を降順でソート
    //qsort(str, cnt, sizeof(*str), SortDescendStr);
    return 0;
}
 
int SortAscendNum(const void *num1, const void *num2)
{
    return *(int *)num1 - *(int *)num2;
}
 
// =======================================
// @brief  数値を降順でソートする
// @param  num1 [in],比較対象1
// @param  num2 [in],比較対象2
// @return 負 比較対象2の方が小さい
// @return 0  比較対象1と比較対象2が等しい
// @return 正 比較対象2の方が大きい
// @note   無し
// =======================================
int SortDescendNum(const void *num1, const void *num2)
{
    return *(int *)num2 - *(int *)num1;
}

Measured memory_bytes: 1788
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n;
    cin >> n;
    int  h[n];
    inrep(n,h);

    ll ans = 1,m = h[0];
    rep(i,1,n){
	if(m <= h[i]){
	    ans ++;
	    m = h[i];
	}
    }
    P(ans);
    
	   
    return  0;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
 const dataStrings = input.split(' ');
 const a = Number(dataStrings[0])
 const b = Number(dataStrings[1])
 const c = Number(dataStrings[2]);
 let countDivisor = 0;
 
 for (var i = a; i <= b; i++) {
   if ( c % i === 0) {
     countDivisor += 1;
   }
 }
 
 console.log(countDivisor);


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

int main(){
    string S;
    cin >> S;
    int day;
    if(S=="SUN") day = 7;
    if(S=="MON") day = 6;
    if(S=="TUE") day = 5;
    if(S=="WED") day = 4;
    if(S=="THU") day = 3;
    if(S=="FRI") day = 2;
    if(S=="SAT") day = 1;

    cout << day << endl;
}

Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  cin>>n;
  vector<vector<ll> >v(n,vector<ll>(n,0));
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      cin>>v[i][j];
    }
  }
  vector<vector<ll> >dp(n+1,vector<ll>((ll)1<<n,0));
  dp[0][0]=1;
    for(ll j=0;j<(ll)1<<n;j++){
      ll i=1;
      for(ll a=0;a<n;a++){
        if(j&((ll)1<<a))i++;
      }
      for(ll l=0;l<n;l++){
        if((j&((ll)1<<l))==0&&v[i-1][l]>0){
          dp[i][(j|((ll)1<<l))]=(dp[i][(j|((ll)1<<l))]+dp[i-1][j])%MOD;
        }
      }
  }
  ans=dp[n][((ll)1<<n)-1];
  cout<<ans<<endl;
}


Measured memory_bytes: 377216
N,M = map(int,input().split())
flag = True
answer = [0]*N
if len(answer) != 1:
    answer[0] = 1
change_list = [0]*N
answer_num = 0
for i in range(M):
    num_list = list(map(int,input().split()))
    if change_list[num_list[0]-1] == 0:
        answer[num_list[0]-1] = num_list[1]
        change_list[num_list[0]-1] = 1
    else:
        if answer[num_list[0]-1] == num_list[1]:
            continue
        else:
            flag = False

if flag == False:
    print(-1)

elif (answer[0] == 0)&(len(answer) != 1):
    print(-1)
else:
    for i in range(len(answer)):
        answer_num += 10**(len(answer) - (i+1))*answer[i]
    print(answer_num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  int a,b;
  cin >> a >> b;
  cout << max({2*a-1,a+b,2*b-1}) << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];

  ll cur = 1000;
  ll mi = 999;
  rep(i,n){
    if(a[i] < mi) mi = a[i];
    else {
      cur = a[i] * (cur/mi) + cur%mi;
      mi = a[i];
    }
  }

  cout << cur << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
    int N, q;
    cin >> N >> q;
    pair<string, int> p;
    queue<pair<string, int> > que;
    for (int i = 0; i < N; i++) {
        cin >> p.first >> p.second;
        que.push(p);
    }
    int time = 0;
    while (que.size() > 0) {
        pair<string, int> pp;
        pp = que.front();
        que.pop();
        if (pp.second <= q) {
            time += pp.second;
            cout << pp.first << " " <<  time << endl;
        } else {
            time += q;
            pp.second -= q;
            que.push(pp);
        }
    }
}


Measured memory_bytes: 6324
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def i(n: Int): Int = ints(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    val Seq(w, h, x, y, r) = readLine.ints
    println(yesNo(x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h))
  }
}

Measured memory_bytes: 43876
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))

n = I()
p = LI()
p_min = p[0]
c = 0
for pi in p:
    if pi <= p_min:
        p_min = pi
        c += 1
print(c)

Measured memory_bytes: 25696
#include<stdio.h>
#include<iostream>

using namespace std;


int main(){
    int d,i;
    cin>>d;
    int k=d;

    for(i=1;i<=d;i++)
    {
        k=k/10;
        if(k==0)
        {
            break;
        }
    }
    int j=i;
    k=d;
    int l[i];

    for(i=0;i<j;i++)
    {
        l[i]=k%10;
        k=k/10;
    }

    for(i=j-1;i>=0;i--)
    {

        if(l[i]==1)
        {
            l[i]=9;
        }
        else if(l[i]==9){
            l[i]=1;
        }

    }

    k=l[j-1];


    for(i=j-1;i>0;i--)
    {
        k=k*10+l[i-1];
    }

    cout<<k;


    return 0;

}


Measured memory_bytes: 256
import java.text.Format;

import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	

	void run() {

		/*

		 * @ meiji 1868. 9. 8 ツ〜 1912. 7.29

		 * 

		 * @ taisho 1912. 7.30 ツ〜 1926.12.24

		 * 

		 * @ showa 1926.12.25 ツ〜 1989. 1. 7

		 * 

		 * @ heisei 1989. 1. 8 ツ〜

		 */

		String meiji = "1868.09.08";

		String taisho = "1912.07.30";

		String showa = "1926.12.25";

		String heisei = "1989.01.08";

		for(;sc.hasNextInt();){

			int y = sc.nextInt();

			int m = sc.nextInt();

			int d = sc.nextInt();

			if(y<1000){

				System.out.println("pre-meiji");

				continue;

			}

			String f = y+"."+(m<10?"0":"")+m+"."+(d<10?"0":"")+d;

//			System.out.println(f);

			String nengo = "";

			int year = 0;

			if(y>=10000 || f.compareTo(heisei) >= 0){

				nengo = "heisei";

				year =1+ y - Integer.valueOf(heisei.substring(0,4));

			}else if(f.compareTo(showa)>=0){

				nengo = "showa";				

				year =1+ y - Integer.valueOf(showa.substring(0,4));

			}else if(f.compareTo(taisho)>=0){

				nengo = "taisho";

				year =1+ y - Integer.valueOf(taisho.substring(0,4));

			}else if(f.compareTo(meiji)>=0){

				nengo = "meiji";

				year =1+ y - Integer.valueOf(meiji.substring(0,4));

			}else{

				System.out.println("pre-meiji");

				continue;

			}

			System.out.println(nengo + " " + year + " " + m+ " "+d);

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 11000
import java.util.*;

public class Main {

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int st[][]=new int[n][2];
		int flag[][]=new int[m][2];
		int ans[]=new int[m];
		
		for(int i=0;i<n;i++)
		{
			st[i][0]=sc.nextInt();
			st[i][1]=sc.nextInt();
		}
		for(int i=0;i<m;i++)
		{
			flag[i][0]=sc.nextInt();
			flag[i][1]=sc.nextInt();
		}
		int min;
		for(int i=0;i<n;i++)
		{
			min=1000000000;
			for(int j=0;j<m;j++)
			{
				ans[j]=Math.abs(st[i][0]-flag[j][0])+Math.abs(st[i][1]-flag[j][1]);
				min=Math.min(ans[j], min);
			}
			//System.out.println(Arrays.toString(ans));
			for(int j=0;j<m;j++)
			{
				if(ans[j]==min) 
					{
						System.out.println(j+1);
						break;
					
					}
			}
			
		}
		
		
		
		System.out.println();
	}
}


Measured memory_bytes: 36044
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int N = sc.nextInt();
        int W = sc.nextInt();
        long[] dp = new long[1000 * N + 1];
        Arrays.fill(dp, 10000000000l);
        dp[0] = 0;
        for (int i = 0; i < N; i++) {
            int w = sc.nextInt();
            int v = sc.nextInt();
            for (int j = 1000 * N; j >= v; j--) {
                dp[j] = Math.min(dp[j], dp[j - v] + w);
            }
        }

        for (int i = 1000 * N; i >= 0; i--) {
            if (dp[i] <= W) {
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,m,ans=0;
	cin>>n>>m;
	int a[n+5];
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n;i>n-m;i--)ans+=a[i];
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main(){

   int n;
   cin>>n;
   cout<<(n+1)/2<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int a[3];
int main() {
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	sort(a, a+3);
	printf("%d\n", 10*a[2] + a[0] + a[1]);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();

            Array.Sort(input);
            for (int i = 0; i < N - 1; i++)
            {
                input[i + 1] = (input[i] + input[i + 1]) / 2;
            }

            Console.WriteLine(input[N - 1]);
        }
    }
}



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

int main(){
    long long n;
    cin>>n;
    long long a[n][3] , dp[n][3];
    for(int i = 0; i < n; i++){
        cin>>a[i][0] >> a[i][1] >> a[i][2];
    }
    dp[0][0] = a[0][0] , dp[0][1] = a[0][1] , dp[0][2] = a[0][2];
    for(int i = 1; i < n; i++){
        dp[i][0] = max(dp[i - 1][1] , dp[i - 1][2]) + a[i][0];
        dp[i][1] = max(dp[i - 1][0] , dp[i - 1][2]) + a[i][1];
        dp[i][2] = max(dp[i - 1][1] , dp[i - 1][0]) + a[i][2];
    }
    long long ans = max(dp[n - 1][0] , max(dp[n - 1][1] , dp[n - 1][2]));
    cout<<ans;
}

Measured memory_bytes: 8220
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    if(a < 10 && b < 10) {
      System.out.println(a * b);
    } else {
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 23636
W,H,N=map(int, input().split())
xmin=0
xmax=W
ymin=0
ymax=H
for i in range(N):
  x,y,a=map(int, input().split())
  if a==1 and xmin < x:
    xmin=x
  elif a==2 and xmax > x:
    xmax=x
  elif a==3 and ymin < y:
    ymin=y
  elif a==4 and ymax > y:
    ymax=y
x = max([0, xmax-xmin])
y = max([0, ymax-ymin])
print(x*y)

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    vector<int> v(3);
    for (int i = 0; i < 3; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    printv(v);
}



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

using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> S(h);
	for (int i = 0; i < h; ++i) {
		cin >> S[i];
	}
	cout << string(w + 2, '#') << endl;
	for (int i = 0; i < h; ++i) {
		cout << "#" << S[i] << "#" << endl;
	}
	cout << string(w + 2, '#') << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

mans = [0]*n
for i in range(k):
    d = input()
    a = list(map(int, input().split()))
    for aa in a:
        mans[aa-1] += 1

cnt = 0
for m in range(len(mans)):
    if mans[m] == 0:
        cnt += 1

print(cnt)

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e13;
int main() {
    ll A, B;
    cin >> A >> B;
    ll i, j, k;
    for(i = B + 1; i < B + A;i++){
        ll d = (i / B) + (i % B) / A + ((i % B) % A);
        ll c = i / A + i % A;
        if(c<d){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


a, b, x = readnums()

s = a + x - a % x if a % x else a
if s > b:
    ans = 0
else:
    ans = b // x - s // x + 1

print(ans)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] count = new int[n + 1];
    Arrays.fill(count, 1);
    for (int i = 2; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        if (j % i == 0) count[j]++;
      }
    }
    int result = 0;
    for (int i = 1; i <= n; i += 2) {
      if (count[i] == 8) result++;
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 22100
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
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 int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

char s[10];
int main(void){
	const char* a = "No";
	scanf("%s",s);
	rep(i,5){
		if(s[i]=='A' && s[i+1]=='C')a="Yes";
	}
	puts(a);
	return 0;
}






Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}


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

	int n,in[3];
	cin>>n>>in[0]>>in[1]>>in[2];
	vi w(n);
	rep(i,n){
		string s;
		cin>>s;
		if(s=="AB")w[i]=0;
		if(s=="AC")w[i]=1;
		if(s=="BC")w[i]=2;
	}
	vs out(n);
	rep(i,n){
		int a,b;
		if(w[i]==0)a=0,b=1;
		if(w[i]==1)a=0,b=2;
		if(w[i]==2)a=1,b=2;
		if(in[a]==0&&in[b]==0){
			cout<<"No"<<endl;
			return 0;
		}
		int t=-1;
		if(in[a]==0){
			in[a]++;
			in[b]--;
			t=a;
		}else if(in[b]==0){
			in[a]--;
			in[b]++;
			t=b;
		}else if(in[a]==1&&in[b]==1){
			if(i==n-1)t=a;
			else{
				in[a]++;in[b]--;
				if(w[i+1]==0&&in[0]==0&&in[1]==0||
				w[i+1]==1&&in[0]==0&&in[2]==0||
				w[i+1]==2&&in[1]==0&&in[2]==0){
					in[a]-=2;
					in[b]+=2;
					t=b;
				}else{
					t=a;
				}
			}
		}else{
			if(in[a]<in[b]){
				in[a]++;
				in[b]--;
				t=a;
			}else{
				in[a]--;
				in[b]++;
				t=b;
			}

		}
		out[i]=(char)(t+'A');
	}
	yes;
	rep(i,n)cout<<out[i]<<endl;
}


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

int main(){
	string s;
	cin >> s;

	int l, r;
	rep(i,s.size()) {
		if (s[i] == 'A') {
			l = i;
			break;
		}
	}
	for (int i = s.size()-1; i >= 0; i--) {
		if (s[i] == 'Z') {
			r = i;
			break;
		}	
	}

	cout << r-l+1 << endl;

	return 0;
}


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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
typedef vector<int> vi;
typedef vector<ll> vll;
ll mod=1e9+7;


int main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int test=1;
//cin>>test;
while(test--)
{

	int n;
	cin>>n;
	int a[n+1]={0};
	int x;
	for(int i=1;i<n;i++)
	{
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;
	
}
return 0;
}









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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    k, n = rli()
    la = rli()
    la.sort()
    m = 0
    for i in range(n):
        l = la[i]
        r = la[(i+1)%n]
        if l > r:
            r += k
        m = max(m, r-l)
    print(k-m)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{

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

	/*const double phi = 3.14;
	int r;
	cin >> r;
	cout << (phi * r * r) / (phi * 1 * 1) << "\n";*/

	int n;
	cin >> n;
	string s;
	cin >> s;
	if(n % 2 != 0)
	{
		cout << "No\n";
		return 0;
	}

	bool cek = true;
	int j = s.size() /2;
	for(int i=0; i<s.size()/2; i++){
		if(s[i] != s[j])
			cek = false;
		j++;
	}

	if(cek)
		cout << "Yes\n";
	else
		cout << "No\n";


	return 0;
}


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

int main(){
    ll n;
    string s="";
    cin>>n;
    for(int i=0;i<=99999;i++){
        if(abs(n)%(ll)pow(2,i+1)!=0){
            s="1"+s;
            n -=pow(-2,i);
        }else s="0"+s;
        if(n==0) break;
    }
    cout<<s<<endl;
}


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

typedef long long ll;

int main(){
    ll N;
    cin>>N;

    vector<ll> A(N+1);
    vector<ll> B(N);

    for(ll i=0;i<N+1;i++){
        cin>>A.at(i);
    }

    ll memory=0;
    memory=accumulate(A.begin(),A.end(),0LL);

    for(ll i=0;i<N;i++){
        cin>>B.at(i);
    }

    for(ll i=0;i<N;i++){
        if(A.at(i)>=B.at(i)){
            A.at(i)-=B.at(i);
        }
        else if(A.at(i+1)>=B.at(i)-A.at(i)){
            A.at(i+1)=A.at(i+1)-B.at(i)+A.at(i);
            A.at(i)=0;
        }
        else{
            A.at(i+1)=0;
            A.at(i)=0;
        }
    }

    cout<<memory-accumulate(A.begin(),A.end(),0LL)<<endl;
}

Measured memory_bytes: 1792
def resolve():
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    dist = []
    for i in range(n-1):
        dist.append(a[i+1]-a[i])
    dist.append(k-(a[n-1]-a[0]))
    total = sum(dist)
    print(total-max(dist))
resolve()

Measured memory_bytes: 87244
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

vector<int> to[205];
vector<int> dist;
int n;

int bfs(int i){
    queue<int> q;
    vector<int> pre(n,-1);
    int ans = -1;
    dist[i] = 1;
    q.push(i);
    while(!q.empty()){
        int v = q.front();q.pop();
        for(int u: to[v]){
 //           cout << v << endl;
            //rep(i,0,n-1)cout << dist[i] << " ";
 //           for(int uu : to[v])cout << uu << " ";
 //           cout << endl;
            if(dist[u] != -1){
                if(dist[u] != dist[v]+1 && dist[u] != dist[v] -1){
                    return -1;
                }
                continue;
            }
            pre[u] = v;
            dist[u] = dist[v]+1;
            q.push(u);
        }
    }
    rep(i,0,n-1) ans = max(ans,dist[i]);
    return ans;

}

int main(){
    int cls_num,ans=-1;
    string s;
    cin >> n;
    dist.resize(n);
//    int s[n][n];
    rep(i,0,n-1){
        cin >> s;
        rep(j,0,n-1){
            if(s[j] == '1'){
                to[j].push_back(i);
            }
        }
    }
    rep(i,0,n-1){
      //  int i = 0;
        rep(j,0,n-1)dist[j] = -1;
        cls_num = bfs(i);
        ans = max(ans,cls_num);
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 512
w, h, x, y, r = gets.chomp.split(" ").map(&:to_i)
flag_x = 0 + r <= x && w - r >= x
flag_y = 0 + r <= y && h - r >= y
if flag_x == true && flag_y == true
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8680
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;
    cin >> n;
    ll i = 0;
    ll x = 0;
    while(x < n){
        x = (1LL << i);
        i++;
    }
    if(x == n){
        cout << x * 2 - 1;
    }else{
        cout << (x >> 1LL) * 2LL - 1;
    }
    return 0;
}


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

int main(){
  int i,N;
  cin >> N;
  vector<int> A(N-1);
  vector<int> ans(N,0);
  for(i=0; i<N-1; i++){
    cin >> A.at(i);
  }
  for(i=0; i<N-1; i++){
    ans.at(A.at(i)-1)++;
  }
  for(i=0; i<N; i++){
    cout << ans.at(i) << endl;
  }
  return 0;
}

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

int main(void)
{
  int h1,h2,m1,m2,k;

  scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);

  int start = 60*h1+m1;
  int end = 60*h2+m2;

  printf("%d\n",end-start-k);

  return 0;
}

Measured memory_bytes: 1728
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;

int n,a[210000];
long long s[210000],ans=1ll<<60;
long long Fabs(long long x){
    return x>0?x:-x;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s[i]=s[i-1]+a[i];
    }for(int i=1;i<=n-1;i++){
        ans=min(ans,Fabs(s[i]-(s[n]-s[i])));
    }printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll maxi = 0;
    ll N;
    cin >> N;
    ll ans = 0;
    while(N--) {
        ll a, b;
        cin >> a >> b;
        if(maxi < a) {
            maxi = a;
            ans = a + b;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256