akhauriyash/Code-Regression huggingface dataset:
import collections
import itertools

prime = [2]
for i in range(3,100):
    check = True
    for k in range(2,i):
        if i%k == 0:
            check = False
    if check:
        prime.append(i)

def factorial(n):
    ans = []
    start = 0
    while n != 1:
        if n%prime[start] == 0:
            n = n//prime[start]
            ans.append(prime[start])
        else:
            start += 1
    return ans

n = int(input())
factor = [i for i in range(1,n+1)]
a = collections.Counter(factor)

for i in a:
    if i not in prime:
        temp = factorial(i)
        for k in range(len(temp)):
            a[temp[k]] += 1
        a[i] = 0

test = []
for i in a:
    if a[i] >= 2:
        test.append(i)
counter = 0
look2 = list(itertools.permutations(test,2))
look3 = list(itertools.permutations(test,3))

for i in range(len(test)):
    if a[test[i]] >= 74:
        counter += 1

for i in range(len(look2)):
    if a[look2[i][0]] >= 2 and a[look2[i][1]] >= 24:
        counter += 1
    if a[look2[i][0]] >= 4 and a[look2[i][1]] >= 14:
        counter += 1

for i in range(len(look3)):
    if a[look3[i][0]] >= 2 and a[look3[i][1]] >= 4 and a[look3[i][2]] >= 4 and look3[i][1] < look3[i][2]:
        counter += 1

print(counter)

Measured memory_bytes: 3564
#include <iostream>
using namespace std;
using ll = long long;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>=(0);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

int main(){
    ll X;
    cin >> X;
    ll ans = (X/11)*2;
    if(X%11 != 0){
        if(X%11 > 6) ans += 2;
        else ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# ABC154 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
s,t=nm()
a,b=map(int, input().split())
u=input()

if u==s:
    print(a-1,b)
else:
    print(a,b-1)



Measured memory_bytes: 3060
w,h = 0,0                       
W,H,N = map(int,input().split())

for _ in range(N):
    x,y,a = map(int,input().split())
    if a==1:
        w = max(x,w)
    elif a==2:
        W = min(x,W)
    elif a==3:
        h = max(y,h)
    else:
        H = min(y,H)
        
if h<H and w<W:
    print((W-w)*(H-h))
else:
    print(0)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n , k ;
cin>>n>>k;
vector<int>v(n);
for(int i = 0 ; i < n ; i++)cin>>v[i];
sort(v.begin(),v.end());
vector<int>dp(k+1,1);
for(int i = 0 ; i < v.front();i++){
dp[i]=-1;
}
for(int i = v.front() ; i <= k ; i++ ){
for(int j = 0 ; j < v.size() ; j++){
if(i-v[j]>=0){
dp[i]=min(dp[i],dp[i-v[j]]);
}
}
dp[i]*=(-1);
}
if(dp[k]==1)cout<<"First";
else cout<<"Second";

}


Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        char[] s = S.toCharArray();

        long ret=0;
        long b = 0;

        for(int i=0;i<s.length;i++) {
            if(s[i]=='B') {
                b++;
            } else {
                ret+=b;
            }
        }
        
        System.out.println(ret);
    }
}

Measured memory_bytes: 26544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

ll GCD(ll a, ll b){
    if (b) return GCD(b,a%b);
    else return a; 
}

int main(){
    int n;
    cin >> n;
    ll ans;
    cin >> ans;
    rep(i,n-1){
        ll tmp;
        cin >> tmp;
        ans = tmp / GCD(ans,tmp)*ans;
    }
    cout << ans << endl;
    
    
    
    return 0;    
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 250000

int main(void){
	int i,j;
	int num[N];
	int n,count;

	num[0]=0;
	for(i=1;i<N;i++)
		num[i]=1;
	for(i=1;i<N;i++)
		if(num[i])
			for(j=i+i+1;j<=N;j+=i+1)
				num[j]=0;

  for(;;){
    scanf("%d",&n);
    if(!n)
      break;

		count=0;
		for(i=n; i<=2*n-1; i++)
			if(num[i]) count++;
  
    printf("%d\n",count);
	}

	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
	ll n;
	while(1){
	cin>>n;
	if(n==0)return 0;
	V<ll> a(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll ave=sum/=n;
	int ans=0;
	for(int i=0;i<n;i++)if(a[i]<=ave)ans++;
	cout<<ans<<endl;
	}
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define endl '\n'
#define N 200005
using namespace std;

struct kieu{long gt,vt;};
kieu st[N];
long  a[N], n,so,kq;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>n;
	st[0]={0,0}; so=0;
	for(long i=1;i<=n;++i) cin>>a[i];
	for(long i=1;i<=n+1;++i){
		while(a[i]<st[so].gt){
			kq+=st[so].gt*(i-st[so].vt)*(st[so].vt-st[so-1].vt);
			--so;
		}
		st[++so]={a[i],i};
	}
	cout<<kq;
}

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

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;

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

    vector<ll> aTime(n + 1);
    aTime[0] = 0;
    for(int i = 1; i < aTime.size(); i++)
    {
        aTime[i] = aTime[i - 1] + a[i - 1];
    }

    vector<ll> bTime(m + 1);
    bTime[0] = 0;
    for(int i = 1; i < bTime.size(); i++)
    {
        bTime[i] = bTime[i - 1] + b[i - 1];
    }

    ll count = 0;
    ll timeBest = 0;
    ll lastJ = bTime.size() - 1;
    for(int i = 0; i < aTime.size(); i++)
    {
        for(int j = lastJ; j >= 0; j--)
        {
            ll time = aTime[i] + bTime[j];
            if(time <= k)
            {
                ll c = i + j;
                if(count < c)
                {
                    count = c;
                }
                lastJ = j;
                break;
            }
        }
    }

    cout << count  << endl;

    return 0;
}


Measured memory_bytes: 9568
#include<bits/stdc++.h>
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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    ll x, y; cin >> x >> y;
    if(abs(x-y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <ios>
#include <sstream>
using namespace std;

int triple_max(int x, int y, int z){
    int ans = x;
    if (y > x && y > z) ans = y;
    else if (z > x && z > y) ans = z;

    return ans;
}


int main(){
    string s;
    int len, cnt = 0;
    cin >> s;
    len = s.length();
    for (int i = 0; i < len; i += 2) {
        if (s[i] != '0') ++cnt;
    }
    for (int i = 1; i < len; i += 2) {
        if (s[i] != '1') ++cnt;
    }
    cout << min(cnt, len - cnt) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int m,d,x=0;cin>>m>>d;
  for(int i=1;i<=m;i++)for(int j=1;j<=d;j++){
    if(j>20&&j%10>1&&(j%10)*(j/10)==i)x++;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned llu;
typedef pair<ll, ll> P;//change when necessary
typedef long double ld;
#define mp make_pair
#define N ll(2e5 + 5)//change it
#define M ll(0)
const ll OO = 1e18;
const ll md = 1e9 + 7;
ll X[] = { 0,0,1,-1 }, Y[] = { 1,-1,0,0 };
void fast()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

ll a[N], p[N][23], n, res = 0, low, high, mid, t;

bool f(int x, int y)
{
	for (int i = 0; i <= 20; i++)
		if (p[y][i] - p[x - 1][i] > 1)
			return false;
	return true;
}
int main()
{
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		for (ll j = 0; j <= 20; j++)
		{
			p[i][j] = p[i - 1][j];
			if ((1LL << j)&a[i])
				p[i][j]++;
		}
	}
	//cout << f(1, 2) << endl;
	for (int i = 1; i <= n; i++)
	{
		low = i;
		high = n;
		t = i;
		while (low <= high)
		{
			mid = (low + high) / 2;
			if (f(i, mid))
				t = mid, low = mid + 1;
			else
				high = mid - 1;
		}
		res += (t - i + 1);
	}
	printf("%lld\n", res);
	return 0;
}

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

using namespace std;

const int MAX_N = 100005;

int n,m,A[MAX_N];
long long x[MAX_N], add[MAX_N];

// x[a..b]++ und add[a..b] += c
void magic(int a, int b, int c)
{
	if (a > b)
		return;
	x[a]++;
	x[b+1]--;
	add[a] += c;
	add[b+1] -= c;
}

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<=n; i++)
		scanf("%d",A+i);
	long long cost = 0;
	for (int i=1; i<n; i++)
	{
		int a = A[i], b = A[i+1];
		cost += (b-a+m)%m;
		if (a <= b)
			magic(a+1, b, -a-1); // a < x <= b: x - a - 1
		else
		{
			magic(a+1, m, -a-1); // a < x <= m:  x - a - 1
			magic(1, b, m-a-1);  // 1 <= x <= b: m - a + x - 1
		}
	}
	partial_sum(x, x+m+1, x);
	partial_sum(add, add+m+1, add);
	for (int i=1; i<=m; i++)
		x[i] = x[i]*i + add[i];
	printf("%lld\n", cost - *max_element(x+1, x+1+m));
	return 0;
}

Measured memory_bytes: 2176
r, c = map(int, input().split())  
l = [[0 for i in range(c + 1)] for i in range(r + 1)]
for i in range(r) :
  l[i] = list(map(int, input().split()))
    
for i in range(r) :
  s = sum(l[i])   
  l[i].append(s)  
    
for j in range(c) :   
  s = 0
  for i in range(r) :  
    s += l[i][j]
  l[r][j] = s 
    
l[r][c] = sum(l[r])  
  
for i in range(r + 1) :  
  for j in range(c + 1) :
    if(j == c) :
      print(l[i][j])
    else :
      print(str(l[i][j]) + " ", end = "")



Measured memory_bytes: 6216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	cout<<lcm(a,b)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    rep(i, 3) {
        if(S[i] == S[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;

    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        foreach (var n in Enumerable.Range(0, int.MaxValue).Select(x => Console.ReadLine()).TakeWhile(x => !string.IsNullOrEmpty(x)).Select(int.Parse))
        {
            Console.WriteLine(Primes.TakeWhile(x => x <= n).Count());
        }
    }
    private static IEnumerable<int> Primes
    {
        get
        {
            foreach (var prime in cache)
            {
                yield return prime;
            }
            for (int n = cache.Last() + 2; true; n += 2)
            {
                if (cache.TakeWhile(x => x * x <= n).All(x => n % x != 0))
                {
                    cache.Add(n);
                    yield return n;
                }
            }
        }
    }
    private static readonly List<int> cache = new List<int> { 2, 3, 5, 7 };
}

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

int main(){
  char a[2][3];
  for(int i=0; i<2; ++i){
    for(int j=0; j<3; ++j){
      cin>>a[i][j];
    }
  }
  if(a[0][0]==a[1][2] && a[0][1]==a[1][1] && a[0][2]==a[1][0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll n;
	cin>>n;
	ll ans = n / 2;
	if(n % 2 == 0) ans--;
	cout<<ans<<endl;                             
}


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

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = 100000
d = 100000
for i in range(n):
    tem = t-h[i]*0.006
    if d >= abs(tem-a):
        d = min(d, abs(tem-a))
        ans = i+1
print(ans)



Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
ll a[22];
ll b[22];
signed main() {
	ll n, ans = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n) {
		if (a[i] > b[i])ans += a[i] - b[i];
	}
	cout << ans << endl;
	ggr
}




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

int main() {
  int N;
  cin >> N;
  string ans = "No";
  int A = 7;
  int B = 4;
  for(int i = 0; i <= 100/7; i++){
    for(int j = 0; j <= 100/4; j++){
      int total = j*B + i*A;
      if(total == N){
        ans = "Yes";
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int main() {
	int n, a, b,ans;
	cin >> n >> a >> b;
	ans = min(b, a * n);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int ans,n,m;
signed main()
{
	cin>>n;
	int l=0,r=100000; 
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(mid*(mid+1)/2>=n)ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<endl;	

}
/*
fij表示前i个数是否能凑到j。
对于i，可选择正着跳/反着跳/不跳
fij=fi-1,j-i|fi-1,j+i|fi-1,j
然后我们考虑打表 
打表可以知道，对于一个数x，如果存在n*(n-1)/2<x<=n*(n+1)/2，答案就是n 于是你二分就好。 
*/

Measured memory_bytes: 3608
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int diff = Math.abs(a-b);
		if(diff%2!=0) {
			System.out.println("IMPOSSIBLE");
		}
		else {
			System.out.println(Math.min(a, b)+diff/2);
		}
	}
}

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

int main(){
	ll x,y;
	cin >> x >> y;
	ll dis = abs(y)-abs(x);
	ll ans;
	if(y>=x){
		if(y>=0&&x>=0||x<0&&y<0)
			ans = y-x;
		else{
			if(abs(y)>abs(x))
				ans = min(1+y-abs(x),y-x);
			else
				ans = min(y-x,abs(x)-abs(y)+1);
		}
	}
	else{
		if(x<=0&&y<=0){
			ans = min(2+abs(y)-abs(x),abs(y)-x+1);
		}
		if(x>0&&y<0){
			if(abs(x)<=abs(y))
				ans = abs(y)-x+1;
			else
				ans = x-abs(y)+1;
		}
		if(x>=0&&y>=0)
			ans = min(1+y+x,1+x-y+1);

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
	int sum=0;
	char ch1[100];
	char ch2[100];
	cin>>ch1;
	cin>>ch2;
	for(int i=0;i<strlen(ch1);i++)
	{
		if(ch1[i]==ch2[i])
		sum++;
	}
	cout<<sum;
	
	
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
class Graph 
{ 
    int V;    
    list<int> *adj;    
public: 
    Graph(int V);  // Constructor 
  
    // function to add an edge to graph 
    void addEdge(int v, int w);  
  
    // prints BFS traversal from a given source s 
    void BFS(int s);   
}; 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<int>[V]; 
} 
  
void Graph::addEdge(int v, int w) //How to add edge
{ 
    adj[v].push_back(w); 
} 
  
void Graph::BFS(int s) //BFS 
{ 
   
    bool *visited = new bool[V]; 
    for(int i = 0; i < V; i++) 
        visited[i] = false; 
 
    list<int> queue; 
    visited[s] = true; 
    queue.push_back(s); 
    list<int>::iterator i; 
  
    while(!queue.empty()) 
    { 
        s = queue.front(); 
        cout << s << " "; 
        queue.pop_front(); 
  
        for (i = adj[s].begin(); i != adj[s].end(); ++i) 
        { 
            if (!visited[*i]) 
            { 
                visited[*i] = true; 
                queue.push_back(*i); 
            } 
        } 
    } 
} //To create a graph
//Graph g(4); 
    //g.addEdge(0, 1); 
    //g.addEdge(0, 2); 
int gcd(int x, int y) {
        if (x == 0) {
            return y;
        }
        
        return gcd(y % x, x);
    }
ll factorial(ll a)
{
  ll fact[a+1];
  fact[0]=1;
  fact[1]=1;
  for(int i=2;i<=a;i++)
  fact[i]=fact[i-1]*i;
  return fact[a];
  
}
bool isPali(string s)
{
    string copy=s;
    reverse(s.begin(),s.end());
    if(s.compare(copy)!=0)
    return false;
    return true;
    
}


int main()
{
 ll n;
 cin>>n;
 ll a[n];
 for(int i=0;i<n;i++)
 cin>>a[i];
 unordered_map<ll,ll> mp;
 for(ll i=0;i<n;i++)
 mp[a[i]]++;
 
 
 
 ll res=0;
     for(auto j:mp)
     {
         ll tmp=j.second;
         res+=(tmp*tmp-tmp)/2;
     }
 for(ll i=0;i<n;i++)
 {
     
     cout<<res-mp[a[i]]+1<<"\n";
     
 }
 
}


Measured memory_bytes: 9160
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        int[] dp = new int[3];
        for (int i = 0; i < n; i++)
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            dp = new int[]
            {
                abc[0] + Max(dp[1], dp[2]),
                abc[1] + Max(dp[0], dp[2]),
                abc[2] + Max(dp[0], dp[1])
            };
        }
        Console.WriteLine(dp.Max());
    }
}


Measured memory_bytes: 17444
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;

fn main() {
    input! {
        n: usize,
        k: usize,
        hx: [i64; n],
    }

    let mut hx = hx;
    hx.sort();

    let mut ans = std::i64::MAX;

    for i in 0..n + 1 - k {
        ans = min(ans, hx[i + k - 1] - hx[i])
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
N = int(input())

count = 0
for i in range(1, N+1):
    if i * i > N:
        break
    for j in range(i, N+1):
        if N > i * j:
            if i == j:
                count += 1
            else:
                count += 2
        else:
            break
print(count)


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

using namespace std;

constexpr int INF = numeric_limits<int>::max() / 2;

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

    int N;
    cin >> N;
    vector<int> a(N), gt(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        gt[i] = i + 1;
    }
    map<vector<int>, int> dist, rdist;
    queue<vector<int>> que;
    dist[a] = 0;
    que.push(a);
    while (!que.empty())
    {
        auto v = que.front();
        que.pop();
        if (dist[v] >= 4)
            continue;
        /*
        int sx = 0, gx = N - 1;
        while (v[sx] == sx + 1)
            sx++;
        while (v[gx] == gx + 1)
            gx--;
        */
        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                auto v2 = v;
                reverse(v2.begin() + i, v2.begin() + j + 1);
                if (dist.find(v2) != dist.end())
                    continue;
                dist[v2] = dist[v] + 1;
                que.push(v2);
            }
        }
    }
    rdist[gt] = 0;
    que.push(gt);
    while (!que.empty())
    {
        auto v = que.front();
        que.pop();
        if (rdist[v] >= 4)
            continue;
        /*
        int sx = 0, gx = N - 1;
        while (v[sx] == sx + 1)
            sx++;
        while (v[gx] == gx + 1)
            gx--;
        */
        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                auto v2 = v;
                reverse(v2.begin() + i, v2.begin() + j + 1);
                if (rdist.find(v2) != rdist.end())
                    continue;
                rdist[v2] = rdist[v] + 1;
                que.push(v2);
            }
        }
    }
    int ret = 9;
    for (const auto &v : dist)
    {
        if (rdist.find(v.first) != rdist.end())
            ret = min(ret, dist[v.first] + rdist[v.first]);
    }
    cout << ret << endl;
}



Measured memory_bytes: 83208
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var X = Sarray()[0];
            var A = Sarray()[0];
            var B = Sarray()[0];
            WriteLine((X - A) % B);
        }
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27920
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
	LL N, P;
	cin >> N >> P;
	
	VI primes, counts;   // 素因数とそれぞれの数
	LL p = P;   // 素因数分解しようとしている数
	LL max = (LL)(sqrt(P) + 1);
	//cout << "max=" << max << endl;
	FOR(i, 2, max) {
		//cout << "i=" << i << ", p=" << p << endl;
		if (p < i) break;
		LL count = 0;
		while (p % i == 0) {
			count++;
			p /= i;
		}
		if (count > 0) {
			primes.push_back(i);
			counts.push_back(count);
		}
	}

	if (p != 1) {   // remaining, or prime
		primes.push_back(p);
		counts.push_back(1);
	}

	/*REP(i, SZ(primes)) {
		cout << "prime " << primes[i] << "^" << counts[i] << endl;
		}*/

	LL ans = 1;
	REP(i, SZ(primes)) {
		LL x = (LL)(counts[i] / N);
		REP(j, x) {
			ans *= primes[i];
		}
	}

	cout << ans << endl;

	return 0;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL f(LL N){
  if(N <= 2) return 0;
  return 1 + f((N-1)/2);
}

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

  LL X; cin >> X;
  LL lb = 0, ub = 1e18;
  while(ub-lb > 1){
	LL m = (lb + ub) / 2;
	if(f(m) > X)
	  ub = m;
	else
	  lb = m;
  }
  cout << lb << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);



int main(){
  faster();
  string s;
  cin >> s;
  int ans=0;
  int size = s.size();
  rep(i,(size/2)){
    if(s[i]!=s[size-1-i]) ans++;
  }
  cout << ans << endl;
}






























//以下、ライブラリ

//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
ll POW(auto x,auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2???????????????????????????????±???????
double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}

// 2???????????????????????????????±???????
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

P projection(P a1, P a2, P p) {
    return a1 + dot(a2-a1, p-a1) / norm(a2-a1) * (a2-a1);
}

int main() {
    P p1, p2; cin >> p1.X >> p1.Y >> p2.X >> p2.Y;
    int q; cin >> q;
    rep(i,0,q) {
        P b; cin >> b.X >> b.Y;
        P ans = projection(p1, p2, b);
        printf("%.10f %.10f\n", ans.X, ans.Y);
    }
    return 0;
}

Measured memory_bytes: 1268
#include<stdio.h>
main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}



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

int main() {
  int X;
  int A,B;
  cin >> X;
  for(int i=-200; i<=200; i++) {
    for(int j=-200; j<=i; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}




Measured memory_bytes: 4060
n=int(input())
x=sorted([tuple(map(int,input().split()))for i in range(n)],key=lambda x:x[1])[::-1]
y=sorted([tuple(map(int,input().split()))for i in range(n)])
#print(x)
#print(y)
ans=0
for j in x.copy():
    for i in y.copy():
        s,t=i
        p,q=j
        if p<s and q<t:
            y.remove((s,t))
            x.remove((p,q))
            #print(p,q,s,t)
            ans+=1
            break
    #print(x,y)
print(ans)

Measured memory_bytes: 3064
import math

n,k = map(int,input().split())

def combinations_count(a, b):
    return math.factorial(a)//(math.factorial(a-b)*math.factorial(b))


blue = k
#両端を除いた隙間の数
blue_sp = k-1
red = n-k
#両端を含む隙間の数
red_sp = red+1


#青をグループに分けて，赤の隙間に入れる組合せを考える
#1から
for i in range(1,blue+1):
    #print(blue_sp,i-1,":",red_sp,i)        

    #出力
    #青のグループ数が赤の隙間より多い場合
    if i > red_sp:
        print(0)
    else:       
        #青のグループ分けの組合せ(両端を除いた隙間，選択する数)
        b_num = combinations_count(blue_sp,i-1)
        #赤を並べて，そこに青のグループを置く組合せ
        a_num = combinations_count(red_sp,i)
        print((b_num*a_num)%(10**9+7))
            

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5;
int n,m,s1,e1,s2,e2,vis[N][N]={0},vis2[N][N]={0},c[N][N]={0},mo[4][2]={1,0,-1,0,0,1,0,-1};
char s[N][N];
struct node{
    int x,y;
};

int bfs(){
    queue<node>q1,q2;
    node a,b;
    a.x=s1,a.y=e1;
    vis[a.x][a.y]=1;
    q1.push(a);
    while(!q1.empty()||!q2.empty()){
        while(!q1.empty()){//先用第一种方法
            a=q1.front();
            q1.pop();
            if(a.x==s2&&a.y==e2){
                return c[a.x][a.y];
            }
            for(int i=0;i<4;i++){
                b.x=a.x+mo[i][0],b.y=a.y+mo[i][1];
                int flag=0;
                if(!vis[b.x][b.y]&&b.x>=0&&b.x<n&&b.y>=0&&b.y<m&&s[b.x][b.y]!='#'){
                    flag=1;
                    vis[b.x][b.y]=1;
                    c[b.x][b.y]=c[a.x][a.y];
                    q1.push(b);
                }
                if(!flag) q2.push(a);
            }
        }
        while(!q2.empty()){//第一种方法走不了再用第二种方法
            a=q2.front();
            q2.pop();
            for(int i=-2;i<=2;i++){
                for(int j=-2;j<=2;j++){
                    if(abs(i)+abs(j)>=2){
                        b.x=a.x+i,b.y=a.y+j;
                        if(!vis[b.x][b.y]&&b.x>=0&&b.x<n&&b.y>=0&&b.y<m&&s[b.x][b.y]!='#'){
                            vis[b.x][b.y]=1;
                            c[b.x][b.y]=c[a.x][a.y]+1;
                            q1.push(b);
                        }
                    }
                }
            }
        }
    }
    return -1;
}

int main(){
    cin>>n>>m>>s1>>e1>>s2>>e2;
    s1--,s2--,e1--,e2--;
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>s[i][j];
    cout<<bfs();
}


Measured memory_bytes: 12588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int s = Integer.parseInt(scan.next());
        int w = Integer.parseInt(scan.next());
        scan.close();

        if (w >= s) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }

    }
}

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


public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(true){
			int result = 0;
			int distance = Integer.parseInt(s.nextLine());
			if(distance==0)
				break;
			int shopCnt = Integer.parseInt(s.nextLine());
			int orderCnt = Integer.parseInt(s.nextLine());
			int[] load = new int[shopCnt];
			load[0] = 0;
			for(int i=1 ; i<shopCnt ; i++) {
				load[i] = Integer.parseInt(s.nextLine());
			}
			Arrays.sort(load);
			for(int i=0 ; i<orderCnt ; i++) {
				int p = Integer.parseInt(s.nextLine());
				int position = Arrays.binarySearch(load, p);
				position = position >= 0 ? position : ~position;
				if(position == load.length) {
					result += Math.min(distance - p, p - load[position-1]);
				}else if(position==0) {
					result += Math.min(load[position] - p, load[load.length-1] - p);
				}else {
					result += Math.min(load[position] - p, p - load[position-1]);
				}
			}
		System.out.println(result);
		}
	}
}

Measured memory_bytes: 161940
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int k,n,a[200001];
int main(){
	ios::sync_with_stdio(0);
	cin>>k>>n;
	rep(i,n)
	cin>>a[i];
	int ans=a[0]+(k-a[n-1]);
	rep(i,n-1)
	ans=max(ans,a[i+1]-a[i]);
	cout<<k-ans;
	re 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int p=a+b;
		int m=a-b;
		int k=a*b;
		int A=Math.max( p, m);
		int B=Math.max(A, k);
		System.out.println(B);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  UnionFind k(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    k.unionSet(a,b);
  }
  int ans=0;
  rep(i,n){
    ans=max(ans,k.size(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  for (ll x=1;x<=3500;x++){
    for (ll y=1;y<=3500;y++){
      ll den = 4*x*y - N*y - N*x;
      ll enu = N*x*y;
      if (den>0 && enu%den==0) {
        ll z = enu/den;
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<queue>
#define x first
#define y second
using namespace std;
const int mod=998244353;
int N;

int x[205],y[205],power[205];

int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d %d",&x[i],&y[i]);
	}
	int ans;
	power[0]=1;
	for(int i=0;i<N;i++)
	{
		power[i+1]=(power[i]<<1)%mod;
	}
	ans=power[N]-N-1;

	for(int i=0;i<N;i++)
	for(int j=0;j<i;j++)
	{
		int cnt=0;
		for(int k=0;k<j;k++)
		{
			if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))
			cnt++;
		}
		ans=(ans-power[cnt]+mod)%mod;
	}
		printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

typedef pair<pll,ll> ppll;

const ll N=1e5+10;
mat G(N);
ll n,m;
vec dp(N);

void dfs(ll cur, ll pre) {
  dp[cur]=1;
  for(ll nex:G[cur]) {
    if(nex==pre) continue;
    dfs(nex,cur);
    dp[cur]=dp[cur]*(dp[nex]+1)%m;
  }
}

int main() {
  cin >> n >> m;
  for(ll i=0;i<n-1;i++) {
    ll u,v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1,0);
  queue<ppll> q;
  q.push({{1,0},0});
  while(q.size()) {
    ll cur=q.front().first.first;
    ll pre=q.front().first.second;
    ll tmp=q.front().second;
    q.pop();
    ll cnt=G[cur].size();
    vec fh(cnt+1),fl(cnt+1);
    fh[cnt]=1,fl[0]=1;
    for(ll i=0;i<cnt;i++) {
      ll v=dp[G[cur][i]];
      if(G[cur][i]==pre) v=tmp;
      fl[i+1]=fl[i]*(v+1)%m;
    }
    for(ll i=cnt;i;i--) {
      ll v=dp[G[cur][i-1]];
      if(G[cur][i-1]==pre) v=tmp;
      fh[i-1]=fh[i]*(v+1)%m;
    }
    for(ll i=0;i<cnt;i++) {
      ll nex=G[cur][i];
      if(nex==pre) continue;
      ll v=fl[i]*fh[i+1]%m;
      q.push({{nex,cur},v});
    }
    dp[cur]=dp[cur]*(tmp+1)%m;
  }
  for(ll i=1;i<=n;i++) cout << dp[i] << endl;
}

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

int main() {
  int N,R;
  cin >> N >> R;
  
  if (N < 10) {
    cout << 100 * (10 - N) + R << endl;
  } else {
    cout << R << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl;
#define STOP assert(false);
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main(){
	int H, W;
	while(cin >> H >> W) {
		if(H == 0 && W == 0) break;
		vector<vi> d(H);
		rep(i, H) {
			d[i].resize(W);
			rep(j, W) cin >> d[i][j];
		}
		
		auto calc = [&](int x1, int x2, int y1, int y2) {
			int m = 1e9;
			REP(i, x1, x2) m = min({m, d[y1][i], d[y2-1][i]});
			REP(i, y1, y2) m = min({m, d[i][x1], d[i][x2-1]});
			int ret = 0;
			REP(i, y1+1, y2-1) REP(j, x1+1, x2-1) {
				if(d[i][j] >= m) return 0;
				ret += m - d[i][j];
			}
			return ret;
		};

		int ans = 0;
		rep(i, W) REP(j, i+1, W+1) rep(k, H) REP(l, k+1, H+1) {
			ans = max(ans, calc(i, j, k, l));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
   
int main() {
   int x;
   cin>>x;
   bool ans=false;
   for(long long a=0;a<1000000;a++){
       for(long long b=0;b<200;b++){
          if(a*a*a*a*a-b*b*b*b*b==x){
              cout<<a<<" "<<b;
              ans=true;
              break;
          }
          if(a*a*a*a*a+b*b*b*b*b==x){
              cout<<a<<" "<<(-1)*b;
              ans=true;
              break;
          }
       }
       if(ans) break;
   }
}

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

int main(){
  int a,b;cin>>a>>b;
  if((a == 1 && b == 13) || (a == 13 && b == 1)){
    if(a == 1) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
  }
  else{
    if(a > b) cout<<"Alice"<<endl;
    else if(a < b) cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
  }
}

Measured memory_bytes: 3496
n, k = map(int, input().split())
ans = list(range(1,n+1))
num_list = []
for i in range(2*k) :
    num_list.append(list(map(int, input().split())))

for i in range(0,k) :
    del num_list[i]

for value in num_list :
    for values in value :
        if values in ans :
            ans.remove(values)

print(len(ans))


Measured memory_bytes: 9184