akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int x;  cin>>x;
  cout<<1-x<<endl;
  return 0;
}


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

function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	b = zeros(Int,n+1)
	for i in 1:n
		b[i+1] = b[i]+a[i]
	end
	c = Int[]
	for i in 1:n
		for j in i:n
			push!(c,b[j+1]-b[i])
		end
	end
	ans = 0
	ma = sum(a)
	r = 0
	while 2^r<ma
		r += 1
	end
	f = zeros(Int,n*(n+1)>>1)
	lf = 0
	for t in r:-1:0
		chg = Int[]
		if lf==0
			for i in 1:n*(n+1)>>1
				if c[i]&2^t==2^t
					push!(chg,i)
				end
			end
			if length(chg)>=k
				lf = 1
				ans += 2^t
				for i in 1:length(chg)
					f[chg[i]] = 1
				end
			end
		else
			z = 0
			for i in 1:n*(n+1)>>1
				if f[i]==1
					z += 1
					if c[i]&2^t!=2^t
						push!(chg,i)
					end
				end
			end
			if z-length(chg)>=k
				ans += 2^t
				for i in 1:length(chg)
					f[chg[i]] = 0
				end
			end
		end
	end
	println(ans)
end

main()

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

int main(){
  int a,b,c;
  int stan = 2*60*60;
  while(1){
    cin >> a >> b >> c;
    if(a == -1 && b == -1 && c == -1) break;
    int minute = a*60*60 + b*60 + c;
    int s = stan - minute;
    if(s > 0){
      int tmp = s;
      int ho,mi,se;
      ho = tmp / (60*60);
      tmp %= (60*60);
      mi = tmp / 60;
      tmp %= 60;
      se = tmp;
      if(ho < 10) cout << "0" << ho << ":";
      else cout << ho << ":";
      if(mi < 10) cout << "0" << mi << ":";
      else cout << mi << ":";
      if(se < 10) cout << "0" << se << endl;
      else cout << se << endl;
      tmp = s*3;
      ho = tmp / (60*60);
      tmp %= (60*60);
      mi = tmp / 60;
      tmp %= 60;
      se = tmp;
      if(ho < 10) cout << "0" << ho << ":";
      else cout << ho << ":";
      if(mi < 10) cout << "0" << mi << ":";
      else cout << mi << ":";
      if(se < 10) cout << "0" << se << endl;
      else cout << se << endl;
    } else {
      cout << "00:00:00" << endl;
      cout << "00:00:00" << endl;
    }
  }
}

Measured memory_bytes: 1160
n, m = map(int,input().split())
n += 1
s = input()
Z = []
for i in range(n):
    if s[i] == "0":
        Z.append(i)
D = [-1] * n
i = len(Z)-1

import sys
for j in range(n-1, -1, -1):
    if s[j] == "0":
        while i >= 0 and j - Z[i] <= m:
            i -= 1
        D[j] = Z[i+1]
        # print(D)
        if j != 0 and j <= Z[i+1]:
            print(-1)
            sys.exit()
# print(D)

a = n-1
ANS = []
while a != 0:
    b = D[a]
    ANS.append(a-b)
    a = b

print(" ".join([str(i) for i in ANS[::-1]]))

Measured memory_bytes: 50864
// AtCoder Beginner Contest 129 - Problem E: Sum Equals Xor (https://atcoder.jp/contests/abc129/tasks/abc129_e) 
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll MOD { 1000000007 };

const int MAX { 100010 };

ll dp[MAX][2];

ll fast_exp(ll a, ll n)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = (res * base) % MOD;

        base = (base * base) % MOD;
        n >>= 1;
    }

    return res;
}

ll solve(const string& L)
{
    int N = (int) L.size();
    dp[1][0] = 1;       // A + B < L
    dp[1][1] = 2;       // A + B == L

    for (int i = 2; i <= N; ++i)
    {
        // Duas possíbilidades para o último dígito ser 1 (concatenar (1, 0) ou (1, 0) em cada
        // termo, só uma (concatenar (0, 0)) se o último dígito é zero
        dp[i][1] = (dp[i - 1][1] * (L[i - 1] == '1' ? 2 : 1)) % MOD;

        // Transição:
        //      1. Manter o que já estava funcionado
        //      2. Concatenar (1, 0) ou (1, 0) ao final de cada que já funcionava
        //      3. Se o próximo dígito é '1', os prefixos p iguais ao anterior geram novas válidas
        //         menores que L quando acrescidos de um zero no final
        //         e (0, p | 0)           
        dp[i][0] = (3*dp[i - 1][0] + (L[i - 1] == '1' ?  dp[i - 1][1] : 0)) % MOD;
    }

#ifdef DEBUG
    for (int i = 1; i <= N; ++i)
    {
        cout << "dp[" << i << "][" << 0 << "] = " << dp[i][0] << endl;
        cout << "dp[" << i << "][" << 1 << "] = " << dp[i][1] << endl;
    }
#endif
/*    
    int N = (int) L.size();
    ll ans = 2;

    for (auto c : L)
    {
        N--;

        if (c == '1')
            ans = (ans + fast_exp(3, N)) % MOD;
    }
*/

    ll ans = (dp[N][0] + dp[N][1]) % MOD;

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    string L;
    cin >> L;

    auto ans = solve(L);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 5280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		char[] str = s.next().toCharArray();
		for(int i = str.length - 1; 0 <= i; --i) {
			System.out.print(str[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 17124
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  cin>>N;

  string S;
  cin>>S;

  int lb,rb,l,r;
  lb=rb=l=r=0;

  rep(i,N){
    if(S[i]=='('){
      lb++;
    }
    else if(lb){
      lb--;
    }
    else l++;
  }

  repr(i,N-1,0){
    if(S[i]==')'){
      rb++;
    }
    else if(rb){
      rb--;
    }
    else r++;
  }

  rep(i,l){
    cout<< '(';
  }

  cout<< S;

  rep(i,r){
    cout<< ')';
  }

  cout<<"\n";

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


Measured memory_bytes: 256
A_ini, B, C_ini, D = map(int, input().split())
# print(A_ini)
# print(B)
# print(C_ini)
# print(D)
# print()

# print('main')
# print()

C_rem = C_ini - B
A_rem = A_ini - D
# print(C_rem)
# print(A_rem)

if C_rem <= 0 and A_rem > 0:
  print('Yes')
elif C_rem <= 0 and A_rem <= 0:
  print('Yes')
elif C_rem > 0 and A_rem <= 0:
  print('No')
else:
  while C_rem > 0 and A_rem > 0 :
    C_rem = C_rem - B
    # print(C_rem)
    if C_rem <= 0:
      print('Yes')
      break
    A_rem = A_rem - D
    if A_rem <= 0:
      print('No')
      break

Measured memory_bytes: 9204
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
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 ,c;
	cin >> a >> b >> c ;

	cout << a * b /2 << endl;




	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin>>n;
  int ac=0,wa=0,tle=0,re=0;

  rep(i,0,n){
    string s;
    cin>>s;
    if(s == "AC") ++ac;
    else if(s == "WA") ++wa;
    else if(s == "TLE") ++tle;
    else ++re;
  }

  cout<<"AC x "<<ac<<'\n';
  cout<<"WA x "<<wa<<'\n';
  cout<<"TLE x "<<tle<<'\n';
  cout<<"RE x "<<re<<'\n';
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,A,B,x,y,c,d;
cin>>N;
A=0;
B=0;
x=0;
y=0;
vector<int>card(N);
for(int i=0;i<N;i++){
    cin>>card.at(i);
}
for(int p=0;p<1+N/2;p++)  {
x=0;
y=0;
c=0;
d=0;
  for(int j=0;j<card.size();j++){  

    if(x<=card.at(j)){
        x=card.at(j);
        c=j;}
  }
    A+=x;
    card.at(c)=0;

  for(int k=0;k<card.size();k++){

    if(y<=card.at(k)){
        y=card.at(k);
        d=k;}
  }
    B+=y;
    card.at(d)=0;

}  

cout<< A-B<<endl;    
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  string a,b;
  cin >> a >> b;
  int64_t d = stoi(a+b);
  cout << ((pow((int64_t)sqrt(d),2) == d) ? "Yes" : "No" ) << endl;
  return 0;
}


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

int main(){
	LL k;
	cin >> k;
	LL n = 50;
	LL c = k/n;
	LL a[50];
	for(int i = 0; i < n; i++){
		a[i] = c*(n+1) - k + n-1;
	}
	for(int i = 0; i < (k % n); i++){
		a[i] += (n+1);
	}
	cout << n << endl;
	for(int i = 0; i < n; i++){
		cout << a[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 256
def resolve():
    input()
    s=[i for i in input()]

    mx=0
    for i in range(len(s)):
        A=set(s[:i])
        B=set(s[i:])
        AB=list(A & B)

        mx=max(mx,len(AB))
    print(mx)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 38536
#include <stdio.h>
#include <math.h>

typedef struct {
  double x;
  double y;

}data;
void kock(int,data,data);

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

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;
    printf("%.8f %.8f\n",a.x,a.y);
    
    kock(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0;
}

void kock(int n,data p1,data p2){
  data s,t,u;
  double x=M_PI_2*2/3;
  
  if(n==0) return;
  s.x=(2.0*p1.x+1.0*p2.x)/3.0;
  s.y=(2.0*p1.y+1.0*p2.y)/3.0;
  t.x=(1.0*p1.x+2.0*p2.x)/3.0;
  t.y=(1.0*p1.y+2.0*p2.y)/3.0;
  u.x=(t.x-s.x)*cos(x)-(t.y-s.y)*sin(x)+s.x;
  u.y=(t.x-s.x)*sin(x)+(t.y-s.y)*cos(x)+s.y;


  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1, t, p2);
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String v = sc.nextLine();
		String s = sc.nextLine();
		String o = s.substring(0,n/2);
		String t = s.substring(n/2,n);
		if(o.equals(t)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21204
#include "bits/stdc++.h"
#define pb push_back
#define mt make_tuple
#define all(a) (a).begin(),(a).end()
#define frep(i,a,n) for(int i=(a);i<(n);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define rrep(i, n) for(int i=n-1;i>=0;--i)
#define debug(x) cout << #x << " : " << x << " ------------ " << endl;
using namespace std;
int main()
{
    int q;
    cin >> q;
    while (q--) {
        int n, count = 0;
        cin >> n;
        map<int, bool> h;
        while (1) {
            if (floor(n/10) == 0) break;
            string s = to_string(n);
            vector<int> p;
            frep(i, 1, s.length()) {
                int tmp = stoi(s.substr(0, i)) * stoi(s.substr(i));
                p.pb(tmp);
                if (tmp == 0) break;
            }
            int m = *max_element(all(p));
            if (h[m]) {
                count = -1;
                break;
            }
            n = m;
            h[m] = true;
            ++count;
        }
        
        cout << count << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3288
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(size_t[]), h = rd[0], w = rd[1];

  writeln('#'.repeat.take(w+2));
  foreach (_; 0..h) {
    write("#");
    write(readln.chomp);
    writeln("#");
  }
  writeln('#'.repeat.take(w+2));
}


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

int main(){
	int r,c;
	while(1){
		cin>>r>>c;
		if(r==0 && c==0)break;
		if(r%2==0)cout<<"yes"<<endl;
		else{
			if(c%2==0){
				cout<<"yes"<<endl;
			}else{
				cout<<"no"<<endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

struct drink_info {
		ll a;
		ll b;
};

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

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

		sort(v.begin(), v.end(), 
			[](const drink_info& l, const drink_info& r) { return l.a < r.a; } );

		int bought_count = 0;
		ll total_amount = 0;
		for ( int i = 0; bought_count < M; i++) {
				int t = M - bought_count;	
				if ( t > v[i].b ) {
						bought_count += v[i].b;
						total_amount += v[i].a * v[i].b;
				} else {
						bought_count += t;
						total_amount += v[i].a * t;
				}
		}

		cout << total_amount << endl;

		return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,K,i;
    cin >> N >> K;
    ll A[N],p[N];
    for(i=0;i<N;i++){
        cin >> A[i];
        p[i]=0;
    }
    ll now=1;
    ll cnt=1;
    while(p[now-1]==0){
        p[now-1]=cnt;
        now=A[now-1];
        cnt++;
    }
    if(K>p[now-1]){
        K=p[now-1]+(K-p[now-1])%(cnt-p[now-1]);
    }
    cnt=1;
    now=1;
    while(cnt<=K){
        cnt++;
        now=A[now-1];
    }
    cout << now;
    return 0;
}


Measured memory_bytes: 6764
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
#include <iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<string,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
const ll MODatc = 1000000007;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
bool pairCompare2(P firstElof,P secondElof){
    return (firstElof.second)%1000>(secondElof.second)%1000;
}
bool less_mod1000(int lhs, int rhs) {
  if ((lhs - rhs) % 1000 != 0)
    return lhs % 1000 < rhs % 1000;
  else // 5で割った余りが等しいなら普通に大小比較する
    return lhs < rhs;
}
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string a="abcdefghijklmnopqrstuvwxyz";
ll dp[107000];
ll jump(ll start,ll goal){
  if(dp[start]>=0)return dp[start];
  if(start==goal){
    return 1;
  }elif(start>goal){
    return 0;
  }
  return dp[start]=(jump(start+1,goal)+jump(start+2,goal))%MODatc;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;cin>>n;
    ll p[n];
    ll ans=0;
    rep(i,0,n)cin>>p[i];
    rep(i,1,n-1){
      if(p[i]>=p[i-1]||p[i]>=p[i+1]){
        if(p[i]<=p[i-1]||p[i]<=p[i+1])ans++;
      }
    }
    cout<<ans<<endl;
}


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

const int N = 10;

int col[N][N];

int h, w, k;

int solve (int x, int y) {
	int ret = 0;
	for (int i = 0; i < h; i ++) if (x >> i & 1)
		for (int j = 0; j < w; j ++) if (y >> j & 1)
			ret += (col[i][j] == 0);
	return ret;
}

int main (void) {
	scanf("%d%d%d", &h, &w, &k);
	char ch;
	for (int i = 0; i < h; i ++) {
		for (int j = 0; j < w; j ++) {
			scanf(" %c", &ch);
			col[i][j] = (ch == '.');
		}
	}

	int ans = 0;
	for (int i = 0; i < (1 << h); i ++) {
		for (int j = 0; j < (1 << w); j ++) {
			if (solve(i, j) == k)
				ans ++;
		}
	}
	printf("%d\n", ans);
}

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

int main(){
	string s; 
	cin>>s;
	bool flag=true; 
	
	const int LENGTH=s.length();
	for(int i=1;i<=LENGTH;i++){
		if(i%2==1 && s[i-1]=='L'  || i%2==0 && s[i-1]=='R')
		{
			flag=false;
			break;
		}
	}
	
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
	
	
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int temp, result = 0;
  int i;
  for (i = 0; result < n; i++) {
    temp = i * i;
    if (temp > n) {
      break;
    }
    result = temp;
  }
  cout << result << endl;
  return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] d = new int[n+2];
        d[0] = 0;
        for (int i = 1; i <= n; i++) {
            d[i] = sc.nextInt();
            d[i] += d[i-1];
        }
        d[n+1] = Integer.MAX_VALUE;
        for(int i = 0; i < n+2; i++) {
          if(x < d[i]) {
        	System.out.println(i);
            return;
          }
        }
    }
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int abcd = sc.nextInt();
        int tmp = abcd;
        int a = tmp / 1000;
        int b = (tmp / 100) % 10;
        int c = (tmp / 10) % 10;
        int d = (tmp) % 10;
        boolean finish;
        String ans = "aa";

        if (7 == a + b + c + d) {
            ans = a + "+" + b + "+" + c + "+" + d;
        }
        if (7 == a + b + c - d) {
            ans = a + "+" + b + "+" + c + "-" + d;
        }
        if (7 == a + b - c - d) {
            ans = a + "+" + b + "-" + c + "-" + d;
        }
        if (7 == a + b - c + d) {
            ans = a + "+" + b + "-" + c + "+" + d;
        }
        if (7 == a - b + c - d) {
            ans = a + "-" + b + "+" + c + "-" + d;
        }
        if (7 == a - b + c + d) {
            ans = a + "-" + b + "+" + c + "+" + d;
        }
        if (7 == a - b - c - d) {
            ans = a + "-" + b + "-" + c + "-" + d;
        }
        if (7 == a - b - c + d) {
            ans = a + "-" + b + "-" + c + "+" + d;
        }

        System.out.println(ans + "=7");
    }
}

Measured memory_bytes: 23764
'use strict';

function main(input) {
  const args = input.split(' ');
  const N = parseInt(args[0]),
        Y = parseInt(args[1]);
  
  var result = '-1 -1 -1';
  var sum = 0;
  
  for (let i = 0; i <= N; ++i) {
    for (let j = 0; j <= N; ++j) {
      if (i+j > N) {
        continue;
      }
      sum = 10000*i + 5000*j + 1000*(N-i-j);
      if (sum === Y) {
        result = `${i} ${j} ${N-i-j}`;
        break;
      }
    }
  }
  
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7628
import sys

N = int(sys.stdin.readline())
h = list(map(int, sys.stdin.readline().split()))

max_h = max(h)

shakutori_list = []
shikiri = []
#0
phase = 0

total = 0

for i in range(max_h):
    current_height = i + 1
    phase = 0
    for j in range(N):
        if h[j] >= (current_height) and phase == 0:
            total += 1
            phase = 1
        if h[j] < current_height and phase == 1:
            phase = 0

print(total)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<utility>
#include<cstdio>

int main(void){
    int w,n;
    std::cin>>w;
    std::vector<int> state(w+1);
    for(int i=1;i<=w;i++) state[i]=i;
    std::cin>>n;
    int a,b;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        std::swap(state[a],state[b]);
    }
    for(int i=1;i<=w;i++) std::cout<<state[i]<<std::endl;
    return 0;
}


Measured memory_bytes: 3032
def contains(a, b):
  for i in range(N-M+1):
    for j in range(N-M+1):
      for k in range(M):
        if a[i+k][j:j+M] != b[k]:
          break
      else:
        return True
  return False

N,M = map(int, raw_input().split())

imga = [raw_input() for i in range(N)]
imgb = [raw_input() for i in range(M)]
print 'Yes' if contains(imga, imgb) else 'No'

Measured memory_bytes: 2568
#include <iostream>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long r){
    cout << 3 * pow(r, 2) << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef unsigned long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}


int main(void) {
	ll n, m;
	cin >> n >> m;
	vector<ll>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	ll a, b;
	vector<vector<ll>>L(n);
	rep(i, m) {
		cin >> a >> b;
		L[a - 1].push_back(b - 1);
		L[b - 1].push_back(a - 1);
	}
	ll ans = 0;
	rep(i, n) {
		bool good = true;
		rep(j, L[i].size()) {
			if (h[i] <= h[L[i][j]]) {
				good = false;
				break;
			}
		}
		if (good) {
			++ans;
		}
	}
	cout << ans;
}

/*

*/


Measured memory_bytes: 9860
A = int(input())
B = int(input())
if(A==1 and B==2):
  ans=3
if(A==1 and B==3):
  ans=2
if(A==2 and B==1):
  ans=3
if(A==2 and B==3):
  ans=1
if(A==3 and B==1):
  ans=2
if(A==3 and B==2):
  ans=1
print(ans)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    flag = True
    for h in range(H):
        for w in range(W):
            if s[h][w] == '#':
                if h == H-1: U = True
                else: U = s[h+1][w] != '#'
                if h == 0: D = True
                else: D = s[h-1][w] != '#'
                if w == 0: L = True
                else: L = s[h][w-1] != '#'
                if w == W-1: R = True
                else: R = s[h][w+1] != '#'
                if all([U, D, L, R]):
                    flag = False
    if flag:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
//
//  abc149_b.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

std::vector<int> permutations;

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

int main() {
  ll a, b, k;
  std::cin >> a >> b >> k;

  if (a >= k) {
    a -= k;
  }
  else {
    k -= a;
    a = 0;
    if (b >= k) {
      b -= k;
    }
    else {
      k -= b;
      b = 0;
    }
  }

  std::cout << a << " " << b << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 100011
#define MOD 1000000007ll
using namespace std;
int n;
LL dp[MAXN],cnt[MAXN],a[MAXN],num[MAXN][3];
LL ANS(int x,int y,int z)
{
    //cout<<x<<" "<<y<<" "<<z<<endl;
    if(x==1&&y==2&&z==3)return 1;
    if(x==1&&y==3&&z==3)return 2;
    if(x==2&&y==2&&z==3)return 2;
    if(x==2&&y==3&&z==3)return 4;
    if(x==3&&y==3&&z==3)return 6;
    if(x==1&&y==2&&z==0)return 1;
    if(x==1&&y==3&&z==0)return 2;
    if(x==2&&y==2&&z==0)return 2;
    if(x==2&&y==3&&z==0)return 4;
    if(x==3&&y==3&&z==0)return 6;
    if(y==0&&z==0)return x;
    return 0;
}
int main()
{
    scanf("%d",&n);
    LL maxx=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        maxx=max(maxx,a[i]);
    }
    
    cnt[0]=3;
    LL ans=1;
    for(int i=1;i<=n;i++)
    {
        num[a[i]+1][cnt[a[i]+1]++]=cnt[a[i]];
    }
    for(int i=0;i<=maxx;i++)
    {
        dp[i+1]=ANS(num[i+1][0],num[i+1][1],num[i+1][2]);
        ans*=dp[i+1];
        ans%=MOD;
    }
    for(int i=1;i<=maxx+1;i++)
    {
        if(cnt[i]>cnt[i-1])ans=0;
    }
    
    cout<<ans<<endl;
    return 0;
}



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

int main()
{
    long long n, i, sum=0;
    cin>>n;

    for(i=1; i<=n; i++){
        if((i%3 != 0) && (i%5 != 0)){
            sum = sum + i;
        }
    }
    cout<<sum;

}


Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
using namespace std;
int main () {
    int x,y,r,w,h;
    scanf("%d",&w);
    scanf("%d",&h);
    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&r);
    if(r > x || r > y)
    {
        cout << "No" << endl;
        return 0;
    }
     if(w-r < x || h-r<y)
    {
         cout << "No" << endl;
         return 0;
     }
      cout << "Yes" << endl;
      return 0;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int i = 0; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int N;
    cin >> N;
    Cout(Yes(N%10 == 7 || (N/10)%10 == 7 || N / 100 == 7));
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int dp[500][500] = {0};
int main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  for(int i(0);i<M;i++){
    int l,r;
    cin>>l>>r;
    l--;
    r--;
    dp[l][r]++;
  }
  // cout << endl;
  // for(int i(0);i<N;i++){
  //   for(int j(0);j<N;j++){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  for(int i = 1; i < N; i++) {
    for(int j = 0; j < N - i; j++) {
      int w = i + j;
      int h = j;
      dp[h][w] += dp[h+1][w] + dp[h][w-1] - dp[h+1][w-1];
    }
  }
  // for(int i(0);i<N;i++){
  //   for(int j(0);j<N;j++){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  for(int i(0);i<Q;i++){
    int p,q;
    cin>>p>>q;
    p--;q--;
    cout << dp[p][q] << endl;
  }
  return 0;
}



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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> ans(n, -1);
    for(int i = 0; i < m; i++){
        int s, c;
        cin >> s >> c;
        s--;
        if(s == 0 && c == 0 && n != 1){
            cout << -1 << endl;
            return 0;
        }else if(ans[s] == -1){
            ans[s] = c;
        }else if(ans[s] != c){
            cout << -1 << endl;
            return 0;
        }
    }
    if(ans[0] == -1){
        if(n == 1){
            ans[0] = 0;
        }else{
            ans[0] = 1;
        }
    }
    for(int i = 1; i < n; i++){
        if(ans[i] == -1){
            ans[i] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
using P = pair<ll, ll>;
int main(){
    ll x;
    cin >> x;
    ll base = 7;
    ll num = 0;
    for(int i = 1; i <= x; i++){
        num = (num + base) % x;
        base = (base * 10) % x;
        if(num == 0) {cout << i << "\n"; return 0;}
    }
    cout << -1 << "\n";
}

Measured memory_bytes: 3632
n = int(input())
L = []
for i in range(n):
    s= ""
    l = sorted(list(input()))
    for j in range(len(l)):
        s += l[j]
    L.append(s)

dic = {}
for i in range(n):
    if L[i] not in dic:
        dic[L[i]] = 1
    else:
        dic[L[i]] += 1

ans = 0
for v in dic.values():
    ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 19512
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;

int main() {
//	cout << fixed << setprecision(15);
    int n;
    cin >> n;
    vvi a(n, vi(n));
    rep(i, n) rep(j, n) cin >> a[i][j];

    vll sc(1 << n);
    rep(i, 1 << n) {
        rep(j, n) for(int k = j; k < n; k++) {
            if(!((1 << j) & i && (1 << k) & i)) continue;
            sc[i] += a[j][k];
        }
    }

    vll dp(1 << n, -INFL);
    dp[0] = 0;
    rep(use, 1 << n) {
        int unuse = ((1 << n) - 1) & (~use);
        for(int i = unuse; i > 0; i = (i - 1) & unuse) {
            if(i <= use) continue;
            chmax(dp[use | i], dp[use] + sc[i]);
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}


Measured memory_bytes: 1280
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
int dp[M][4];
int a[M];
 main()

{
    fast
    dp[0][0]=1;
    string s;
    cin>>s;
    int n=s.size();
    f(i,0,n-1)
    {
        if(s[i]=='?')a[i+1]=3;
        else a[i+1]=s[i]-'A';
    }
    f(i,1,n)
    {
        if(a[i]==3)
        {
            f(j,0,3)
            {
                dp[i][j]=ad(dp[i][j],gun(3,dp[i-1][j]));
            }
        }
        else
        {
             f(j,0,3)
             {
                 dp[i][j]=ad(dp[i][j],dp[i-1][j]);
             }
        }
        if(a[i]==0 || a[i]==3)dp[i][1]=ad(dp[i][1],dp[i-1][0]);
        if(a[i]==1 || a[i]==3)dp[i][2]=ad(dp[i][2],dp[i-1][1]);
        if(a[i]==2 || a[i]==3)dp[i][3]=ad(dp[i][3],dp[i-1][2]);

    }
    cout<<dp[n][3]<<endl;
    return 0;

}





































Measured memory_bytes: 7688
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main(){
  int n,m,sum;
  cin >> n >> m;
  vvi a(n,vi(m));
  vi b(m);
  for(int i = 0;i<n;i++){
    for(int j = 0;j<m;j++){
      cin >> a.at(i).at(j);
    }
  }
  rep(j,m){
    cin >> b.at(j);
  }
  rep(i,n){
    sum = 0;
    rep(j,m){
      sum += a[i][j]*b[j];
    }
      cout << sum << endl;
  }
  return 0;
}



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

using namespace std;

#define N 100000
#define ll long long

int n, a[N + 5];
ll ans;

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

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

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    set<string> s;
    for(int i=0;i<n;++i){
        string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << "\n";

    

    return 0;
}

Measured memory_bytes: 19248
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

int n,m,k,d;
string s,t;
int a[200005];

int main() {
  cin >> k >> n;
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  d=a[0]+(k-a[n-1]);
  rep(i,n-1) chmax(d,a[i+1]-a[i]);
  cout << k-d << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<int>adj[100];
int visited[100];
void bfs(int s,int n)
{
    for(int i=0; i<n; i++)
    {
        visited[i]=0;
        queue<int>Q;
        Q.push(s);
        visited[s]=1;
        while(!Q.empty())
        {
            int u=Q.front();
            Q.pop();
            for(int i=0; i<adj[u].size(); i++)
            {
                if(visited[adj[u][i]]==0)
                {
                    int v=adj[u][i];
                    visited[v]=1;
                    Q.push(v);
                }
            }
        }
    }
}
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}

int main()
{

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a==1 && b==31)
    {
        cout<<1<<endl;
    }
    else  if(a==2 && b==28)
    {
        cout<<1<<endl;
    }
    else  if(a==3 && b==31)
    {
        cout<<1<<endl;
    }
     else  if(a==4 && b==30)
    {
        cout<<1<<endl;
    }
 else  if(a==5 && b==31)
    {
        cout<<1<<endl;
    }
     else  if(a==6 && b==30)
    {
        cout<<1<<endl;
    }
     else  if(a==7 && b==31)
    {
        cout<<1<<endl;
    }
     else  if(a==8 && b==30)
    {
        cout<<1<<endl;
    }
     else  if(a==9 && b==30)
    {
        cout<<1<<endl;
    }
     else  if(a==10 && b==31)
    {
        cout<<1<<endl;
    }
     else  if(a==11 && b==30)
    {
        cout<<1<<endl;
    }
     else  if(a==12 && b==31)
    {
        cout<<1<<endl;
    }
    else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int MAXN = 52;
char s[MAXN][MAXN];

int getType(int i) {
  if (s[0][i] == s[1][i]) return 1;
  return 2;
}

int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s[0]);
  scanf("%s", s[1]);

  int t = getType(0);
  ll ans = t == 1? 3: 6;
  int cur = t == 1? 1: 2;
  while (cur < n) {
    int t2 = getType(cur);
    if (t2 == 1) cur++;
    else cur += 2;

    if (t2 == 1 && t == 1) ans *= 2;
    else if (t2 == 2 && t == 1) ans *= 2;
    else if (t2 == 2 && t == 2) ans *= 3;
    ans %= MOD;
    t = t2;
  }

  
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
from collections import deque


def input_int_list():
    return [int(thing) for thing in input().split(" ")]


S=input()
Q=int(input())
Q_list=[input().split(" ") for i in range(Q)]
hantenness=1
left=[]
right=[]
ans=deque()
ans.extend(list(S))

for Query in Q_list:
    if Query[0]==str(1):
        hantenness*=-1
    else:
        C=Query[2]
        F=int(Query[1])
        if hantenness==1:
            if F==1:
                ans.appendleft(C)
            else:
                ans.append(C)
        else:
            if F==1:
                ans.append(C)
            else:
                ans.appendleft(C)

print("".join(ans) if hantenness==1 else "".join(ans)[::-1])


Measured memory_bytes: 44636
n = int(input())

uvws = [tuple(map(int, input().split())) for _ in range(n-1)]

colors = [None for _ in range(n+1)]
colors[1] = 0

edges = [dict() for _ in range(n+1)]

for u, v, w in uvws:
    edges[u][v] = w
    edges[v][u] = w

plan = set((1,))

while len(plan) > 0:
    g = plan.pop()
    for n, w in edges[g].items():
        if colors[n] is None:
            colors[n] = (colors[g] + w) % 2
            plan.add(n)

print("\n".join(map(str, colors[1:])))


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

using namespace std;

const int max_n = 200222, inf = 1000111222;
const int max_c = 26;

int n, q, ans;
char s[max_n], c[max_n], dir[max_n];
vector<int> all[max_c];

int go(int x) {
    for (int i = 0; i < q; ++i) {
        if (s[x] == c[i]) {
            if (dir[i] == 'L') {
                --x;
            } else {
                ++x;
            }
        }
        if (x < 0 || x == n) {
            return x;
        }
    }
    return x;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d%s", &n, &q, &s);
    for (int i = 0; i < n; ++i) {
        all[s[i] - 'A'].push_back(i);
    }
    for (int i = 0; i < q; ++i) {
        scanf("\n%c %c", &c[i], &dir[i]);
    }
    int ans = 0;
    for (int c = 0; c < max_c; ++c) {
        int l = -1, r = all[c].size();
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (go(all[c][mid]) == -1) {
                l = mid;
            } else {
                r = mid;
            }
        }
        int to = l;

        l = -1;
        r = all[c].size();
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (go(all[c][mid]) == n) {
                r = mid;
            } else {
                l = mid;
            }
        }
        ans += r - to - 1;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1904
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    println(ifelse(a*b%2==0,"Even","Odd"))
end
main()

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

int main() {
  char c;
  cin >> c;
  for (auto a : {'a', 'i', 'u', 'e', 'o'}) {
    if (c == a) return cout << "vowel" << "\n", 0;
  }
  cout << "consonant" << "\n";
}

Measured memory_bytes: 3548
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
a=a%b;
c=c%b;
for(int i=1;i<=b;i++){
if((a*i)%b==c){
	cout<<"YES"<<endl;
return 0;
}
}
cout<<"NO"<<endl;
return 0;
}

Measured memory_bytes: 256
<?php
list($N, $H) = array_map('intval', explode(' ', fgets(STDIN)));
for ($i = 0; $i < $N; $i++) {
   list($a[], $b[]) = array_map('intval', explode(' ', fgets(STDIN)));
}
$a_max = max($a);
rsort($b);
$cnt = 0;
for ($i = 0; $i < $N && $b[$i] > $a_max; $i++) {
    $H -= $b[$i]; $cnt++;
    if ($H <= 0) {
        print "{$cnt}\n";
        exit;
    }
}
print $cnt + ceil($H / $a_max) . "\n";

Measured memory_bytes: 14840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 string s;
 cin >> s;
 int num1=(s[0]-'0')*10+(s[1]-'0');
 int num2=(s[2]-'0')*10+(s[3]-'0');
 if(num1>0&&num1<=12&&num2>0&&num2<=12){
  cout<<"AMBIGUOUS"<<endl;
 }
 else if(num1&&num1<=12){
  cout<<"MMYY"<<endl;
 }
 else if(num2&&num2<=12){
  cout<<"YYMM"<<endl;
 }
 else cout<<"NA"<<endl;
 return 0;
}

Measured memory_bytes: 256