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

int cmp(int a,int b){//jiang
   return a>b;
 }
 int cmp2(int a,int b){//
   return a<b;
 }
 int a[100],b[100];
int main(){
    int n,m,x,y;
    int flag=0;
    cin>>n>>m>>x>>y;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++)
        cin>>b[i];
    sort(a,a+n,cmp);
    sort(b,b+m,cmp2);
    for(int i=x+1;i<=y;i++){
        if(i>a[0]&&i<=b[0]){
                flag=1;
                break;
        }
    }
    if(flag)
        cout<<"No War";
    else
        cout<<"War";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> h(n);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	
	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < n - 1; ++i) {
		if( h[i + 1] > h[i] ) {
			ans = max(ans, cnt);
			cnt = 0;
		}			
		
		else cnt++;
	}
	
	if( cnt > 0 ) ans = max(ans, cnt);
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	string S;
    cin>>S;
    ll len=S.size();
    ll ans[len]={};
    int r=0;
    rep(i,len){
        if(S[i]=='R') r++;
        else{
            int l=0;
            int p=i;
            while(S[i]=='L' && i<len){
                i++;
                l++;
            }
            ans[p-1]=ceil((double)r/2)+l/2;
            ans[p]=r/2+ceil((double)l/2);
            r=0,l=0;
            i--;
        }
    }
    rep(i,len) cout<<ans[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
vector<string> vec;
struct Node {
    int y;
    int x;
    int depth;
};
queue<Node> que;
int H, W;
int sy, sx, gy, gx;
int y, x, depth;
vector<int> y_vec = {0, 0, -1, 1};
vector<int> x_vec = {-1, 1, 0, 0};

void debug(vector<string> vec) {
    for (int i = 0; i < vec.size(); ++i) {
        cout << vec[i] << endl;
    }
}

int bfs() {
    while (!que.empty()) {
        Node node = que.front(); que.pop();
        y = node.y;
        x = node.x;
        depth = node.depth;
        if (y == gy && x == gx) return depth;

        for (int i = 0; i < 4; ++i) {
            Node next = {y + y_vec[i], x + x_vec[i], depth + 1};

            if (0 <= next.y && next.y <= H-1 && 0 <= next.x && next.x <= W - 1 && vec[next.y][next.x] == '.') {
                vec[next.y][next.x] = 'x';
                que.push(next);
            }
        }
    }
    return 0;
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int count = 0;
    cin >> H >> W;
    sy = 0;
    sx = 0;
    gy = H - 1;
    gx = W - 1;
    vec.resize(H);
    for (int i = 0; i < H; ++i) {
        cin >> vec[i];
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (vec[i][j] == '.') ++count;
        }
    }

    Node start = {sy, sx, 0};
    que.push(start);
    int dep = bfs();
    if (dep != 0) {
        cout << (count - dep - 1) << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-12 20:34:24
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int k; cin >> k;

  int64 ans = 0;

  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) {
        ans += gcd(a, gcd(b, c));
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <utility>
#include <queue>
#include <string>
using namespace std;
int main()
{

    queue<pair<string, int> > P;
    int n, q;

    cin >> n >> q;

    for (int i = 0; i < n; i++)
    {

        string first;
        int second;
        cin >> first >> second;
        pair<string, int> p = make_pair(first, second);
        P.push(p);
    }
    int cnt = 0;
    while (P.size())
    {
        if (P.front().second <= q)
        {
            cnt += P.front().second;
            cout << P.front().first << ' ' << cnt << endl;
        }
        else
        {
            cnt += q;
            P.front().second = P.front().second - q;
            P.push(P.front());
        }
        P.pop();
    }
}
//構造体
//名前
//define


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

signed main() {
	vector<int>a;
	int b;
	while (cin >> b) {
		if (b)a.push_back(b);
		else { cout << a[a.size() - 1] << endl; a.pop_back(); }
	}
}

Measured memory_bytes: 3024
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll lg=22;
const ll N=1e6+5;
const ll M=16;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
 
inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
int main()
{
    ll n;
    string s;
    cin>>n>>s;
    if(n<3200){cout<<"red"<<endl;exit(0);}
    cout<<s<<endl;
}

Measured memory_bytes: 256
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

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



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	string s, t;
	cin >> s;
	cin >> t;

	vector<int> ch1(100, 0), ch2(100, 0);
	vector<vector<int>> iti(100,vector<int>());
	for (int i = 0; i < t.size(); i++)
	{
		ch2[t[i] - 'a']++;
	}
	for (int i = 0; i < s.size(); i++)
	{
		ch1[s[i] - 'a']++;
		iti[s[i] - 'a'].push_back(i + 1);
	}

	for (int i = 0; i < 100; i++)
	{
		iti[i].push_back(-1);
	}

	for (int i = 0; i < 100; i++)
	{
		if (ch2[i] != 0 && ch1[i] == 0)
		{
			cout << -1 << endl;
			return 0;
		}
	}

	long long ans = 0;
	long long poi;
	ans += iti[t[0]-'a'][0];
	poi = iti[t[0] - 'a'][0];
	vector<int> imadoko(100, 0);
	if (iti[t[0] - 'a'][1] != -1)
		imadoko[t[0] - 'a']++;
	for (int i = 1; i < t.size(); i++)
	{
		for (int j = imadoko[t[i]-'a']; j < iti[t[i] - 'a'].size(); j++)
		{
			if (poi < iti[t[i] - 'a'][j])
			{
				ans += iti[t[i] - 'a'][j] - poi;
				poi = iti[t[i] - 'a'][j];
				if (iti[t[0] - 'a'][j + 1] != -1)
					imadoko[t[i] - 'a']++;
				else
					imadoko[t[i] - 'a'] = 0;
				break;
			}
			if (j == iti[t[i] - 'a'].size() - 1)
			{
				ans += s.size() - poi + iti[t[i] - 'a'][0];
				poi = iti[t[i] - 'a'][0];
				for (int k = 0; k < 100; k++)
				{
					imadoko[k] = 0;
				}
			}

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

Measured memory_bytes: 1228
#include <stdio.h>
int main(){
  int x;
  int y;
  int d;
  for(x = 0, y = 0; ; x++, y++){
  scanf("%d %d", &x, &y);
  if(x > y){
    d = x;
    x = y;
    y = d;
  }
  if(x == 0 && y == 0){
    break;
  }
  printf("%d %d\n", x, y);
  }
  return 0;
}

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

using namespace std;

string reverse(string str) {
	string r_str;
	for(int i = 0; i < str.size(); i++) {
		r_str = str[i] + r_str;
	}
	return r_str;
}

void search(string tmp, vector<string>& patturn) {
	vector<string>::iterator cIter = find(patturn.begin(), patturn.end(), tmp);
	if(cIter == patturn.end()) {
		patturn.push_back(tmp);
	}
}

int count_patturn(string input, vector<string>& patturn) {
	for(int i = 0; i < input.size() - 1; i++) {
		string first, second, r_first, r_second, tmp;
		for(int j = 0; j < input.size(); j++) {
			if(j <= i){
				first = first + input[j];
			}else{
				second = second + input[j];
			}
		}
		r_first = reverse(first);
		r_second = reverse(second);

		tmp = first + second;
		search(tmp, patturn);
		tmp = first + r_second;
		search(tmp, patturn);
		tmp = r_first + second;
		search(tmp, patturn);
		tmp = r_first + r_second;
		search(tmp, patturn);
		tmp = second + first;
		search(tmp, patturn);
		tmp = r_second + first;
		search(tmp, patturn);
		tmp = second + r_first;
		search(tmp, patturn);
		tmp = r_second + r_first;
		search(tmp, patturn);
	}
	return patturn.size();
}

int main(void) {
	int m;
	cin >> m;
	for(int i = 0; i < m; i++) {
		string input;
		cin >> input;

		vector<string> patturn;
		int num = count_patturn(input, patturn);
		cout << num << endl;
	}
	return 0;
}

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

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

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

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

void solve() {
    char s;
    cin >> s;
    if (s >= 'a') {
        cout << 'a' << "\n";
    }
    else {
        cout << 'A' << "\n";
    }
}

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

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

Measured memory_bytes: 3616
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
#include<climits>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009
#define MAX_V 10000
struct edge{
	int to;
	long long cost;
	int rev;
};
vector<edge> e[MAX_V];
bool used[MAX_V];
int n, m;
int x, y;
long long z;
long long ans = 0;
long long dfs(int s, int t, long long f){

	if (s == t)return f;
	used[s] = true;
	for (int i = 0; i < e[s].size(); i++){
		if (!used[e[s][i].to] && e[s][i].cost){
			int re = dfs(e[s][i].to, t, min(f, e[s][i].cost));
			if (re > 0){
				e[s][i].cost -= re;
				e[e[s][i].to][e[s][i].rev].cost += re;
				return re;
			}
		}
	}
	used[s] = false;
	return 0;
}

int main(void){
	int s, t;
	scanf("%d", &n);
	f(i, n){
		scanf("%lld", &z);
		if (z < 0){
			e[0].push_back({ i + 1, -z, e[i + 1].size() });
			e[i + 1].push_back({ 0, 0, e[0].size() - 1 });
		}
		else{
			ans += z;
			e[i + 1].push_back({ n + 1, z, e[n + 1].size() });
			e[n + 1].push_back({ i + 1, 0, e[i + 1].size() - 1 });
		}
	}
	f(i, n){
		x = i + 1;
		for (int j = 2; x*j <= n; j++){
			e[x].push_back({ x*j, LLONG_MAX, e[x*j].size() });
			e[x*j].push_back({ x, 0, e[x].size() - 1 });
		}
	}

	for (;;){
		memset(used, 0, sizeof(used));
		long long res = dfs(0, n + 1, LLONG_MAX);
		if (res > 0)ans -= res;
		else break;
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int a = 1;
  while(a <= n) {
    if(a*2 <= n) {
      a = a*2;
    } else {
      break;
    }
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//A=65,a=97

int main() {
    int h,w,n;cin >> h >> w >> n;
    vector<int> a(n);for(int i=0;i<n;i++) cin >> a[i];
    vector<vector<int>> g(h, vector<int>(w, 0));

    queue<int> q;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < a[i]; j++) {
            q.push(i+1);
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int x=q.front();
            q.pop();
            g[i][j]=x;
        }
    }

    for(int i = 0; i < h; i++) {
        if(i%2==1){
            reverse(g[i].begin(),g[i].end());
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w-1; j++) {
            cout << g[i][j] << ' ';
        }
        cout << g[i][w-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n;
    cin >> n;
    int l=1,r=n;
    vector<int> a(n),b(0);
    rep(i,n) {
        cin >> a.at(i);
        if(i!=0){
            if (a.at(i)<=a.at(i-1)) b.push_back(a.at(i));
        }
    }
    while(l!=r){
        int mid=(l+r)/2;
        map<int,int> m;
        bool t=false;
        rep(i,b.size()){
        while(!m.empty() && m.rbegin()->first > b[i])
			m.erase(prev(m.end()));

		int x = b[i];
		m[x]++;
		if(mid == 1) t=true;
        if (t) break;
		while(m[x] == mid) {
			m.erase(m.find(x));
			x--;
			m[x]++;
			if(x <= 0) {t=true;break;}
		}
		if(x <= 0) t=true;
	}
        if (t) l=mid+1;
        else r=mid;
    }
    cout << l << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


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

    ll ans=0;
    rep(i,N){
        ll a;
        cin >> a;
        if((i+1) % 2 == 1){
            if(a % 2 == 1){
                ans++;
            }
        }
    }

    cout << ans << endl;
}




Measured memory_bytes: 3584
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class node_t {
public:
  int x;
  int y;
  long long d;

public:
  node_t(int xx = -1, int yy = -1, long long dd = INF) : x(xx), y(yy), d(dd) {};

public:
  bool operator<(const node_t& x) const {
    return ! (d < x.d);
  };
};


class union_find_t {
public:
  union_find_t(int T) : T_(T), parent_(new int[T]), rank_(new int[T]) {
    for (int i = 0; i < T_; i++) {
      parent_[i] = i;
      rank_  [i] = 0;
    }
  };

  ~union_find_t() {
    delete[] parent_;
    delete[] rank_;
  };

public:
  int find(int x) {
    if (parent_[x] == x) {
      return x;
    }
    else {
      return parent_[x] = find(parent_[x]);
    }
  };

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y)
      return;

    if (rank_[x] < rank_[y]) {
      parent_[x] = y;
    }
    else {
      parent_[y] = x;

      if (rank_[x] == rank_[y])
        rank_[x] ++;
    }
  };

  bool same(int x, int y) {
    return find(x) == find(y);
  };

public:
  int T_;

  int* parent_;
  int* rank_;
};


int N;

long long A[333][333], B[333][333], M[333][333];

std::vector<std::vector<bool>> G;

bool visit[333];


void dfs(int i, int d)
{
  for (const auto& k : G[i]) {
  }
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::cin >> N;

  union_find_t uf(N);

  std::priority_queue<node_t> pq;

  for (int i = 0; i < N; i ++)
    for (int j = 0; j < N; j ++) {
      std::cin >> A[i][j];

      if (j > i)
        pq.emplace(j, i, A[i][j]);
      
      B[i][j] = M[i][j] = i == j ? 0 : INF;
    }

  while (! pq.empty()) {
    node_t node = pq.top(); pq.pop();

    int x = node.x, y = node.y;
    
    long long d = node.d;

    if (M[y][x] < d) {
      std::cout << -1 << std::endl;

      return 0;
    }
    else if (d < M[y][x]) {
      B[y][x] = B[x][y] = d;

      int px = uf.find(x);
      int py = uf.find(y);

      for (int i = 0; i < N; i ++) {
        int pi = uf.find(i);

        if (pi != px)
          continue;

        for (int j = 0; j < N; j ++) {
          int pj = uf.find(j);

          if (pj != py)
            continue;

          long long dd = M[x][i] + B[x][y] + M[y][j];

          if (dd < M[i][j])
            M[i][j] = M[j][i] = dd;
        }
      }

      if (M[y][x] > d)
        M[y][x] = M[x][y] = d;

      uf.unite(x, y);
    }
  }

  long long S = 0;

  for (int i = 0; i < N; i ++)
    for (int j = i + 1; j < N; j ++)
      if (B[i][j] < INF)
        S += B[i][j];

  std::cout << S << std::endl;

  return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> xy(N);
    for(int i=0; i<N; i++)
        cin >> xy[i].first >> xy[i].second;

    int ans = 1<<30;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            int dx = xy[j].first - xy[i].first;
            int dy = xy[j].second - xy[i].second;

            set<pair<int, int>> st;
            for(int k=0; k<N; k++)
                st.insert(xy[k]);

            int cnt = 1;
            auto itr = st.begin();
            auto z = *itr;
            st.erase(itr);
            while(!st.empty()){
                int xx = z.first + dx;
                int yy = z.second + dy;
                auto zz = make_pair(xx, yy);
                auto itr = st.find(zz);
                if(itr != st.end()){
                    st.erase(itr);
                    z = zz;
                }else{
                    cnt++;
                    itr = st.begin();
                    z = *itr;
                    st.erase(itr);
                }
            }
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

void push(int);
int pop();

int stack[100]={0};
int i=0;

int main(){
  char c[200];
  int x,y,z,sum=0;

  while(scanf("%s",c)!=EOF){
    if(c[0]=='+'){
      z=pop()+pop();
      push(z);
    }
    else if(c[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }
    
    else if(c[0]=='*'){
      z=pop()*pop();
      push(z);
    }
    
    else push(atoi(c));
  }

  printf("%d\n",stack[i-1]);  
  return 0;
}

void push(int x){
  stack[i]=x;
  i++;
}

int pop(){
  i--;
  return stack[i];
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
vector<int> nex[114514];
int dis1[114514],dis2[114514];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nex[x].pb(y);
		nex[y].pb(x);
	}
	for(int i=1;i<=n;i++){
		dis1[i]=inf;
		dis2[i]=inf;
	}
	dis1[1] = 0;
	dis2[n] = 0;
	queue<int> que;
	que.push(1);
	while(!que.empty()){
		int cur = que.front(); que.pop();
		for(int i=0;i<nex[cur].size();i++){
			int nx = nex[cur][i];
			if( dis1[nx] == inf ){
				dis1[nx] = dis1[cur]+1;
				que.push(nx);
			}
		}
	}
	que.push(n);
	while(!que.empty()){
		int cur = que.front(); que.pop();
		for(int i=0;i<nex[cur].size();i++){
			int nx = nex[cur][i];
			if( dis2[nx] == inf ){
				dis2[nx] = dis2[cur]+1;
				que.push(nx);
			}
		}
	}
	int cnt1=0,cnt2 = 0;
	for(int i=1;i<=n;i++){
		if(dis1[i] <= dis2[i]){
			cnt1++;
		}
		else{
			cnt2++;
		}
	}
	if(cnt1 > cnt2){
		cout<<"Fennec"<<endl;
	}
	else{
		cout<<"Snuke"<<endl;
	}
	return 0;
}

Measured memory_bytes: 8320
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    # dp[i] - is True if i gram of sugar is obtainable
    A, B, C, D, E, F = read_ints()
    dp = [False]*(F+1)
    dp[0] = True
    for i in range(F+1):
        if i+C < F+1:
            dp[i+C] = dp[i+C] or dp[i]
        if i+D < F+1:
            dp[i+D] = dp[i+D] or dp[i]
    # dp2[i] - highest gram of sugars that is not greater than i
    dp2 = [0]*(F+1)
    highest_sugar = 0
    for i in range(F+1):
        if dp[i]:
            dp2[i] = highest_sugar = i
        else:
            dp2[i] = highest_sugar

    highest_ratio = [0, 100*A]

    for a in range(31):
        for b in range(31):
            water = 100*A*a+100*B*b
            if water < F:
                sugar_limit = min(E*water//100, F-water)
                sugar = dp2[sugar_limit]
                if sugar*highest_ratio[1] > water*highest_ratio[0]:
                    highest_ratio = [sugar, water]
    return sum(highest_ratio), highest_ratio[0]


if __name__ == '__main__':
    print(*solve())


Measured memory_bytes: 65876
s = input()

for i in range(len(s)):
    if s[i] != s[len(s)-i-1]:
        print('No')
        exit()

pos2 = (len(s)-1)//2

for i in range(pos2):
    if s[i] != s[pos2-i-1]:
        print('No')
        exit()

pos3 = (len(s)+3)//2

for i in range(len(s)-pos3):
    if s[pos3-1+i] != s[len(s)-i-1]:
        print('No')
        exit()
        
print('Yes')

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

using namespace std;

typedef long long lli;

const int N = 2000000 + 10;
const int MOD = 1000000007;

int f[N], fr[N], p[N];

int exp(int x, int n)
{
	int tmp;
	if (n == 0) return 1;
	tmp = exp(x, n / 2);
	tmp = 1LL * tmp * tmp % MOD;
	if (n % 2) tmp = 1LL * tmp * x % MOD;
	return tmp;
}

int calc(int n, int m)
{
	return 1LL * f[n] * fr[m] % MOD * fr[n-m] % MOD;
}

int main()
{
	int res, r1, c1, r2, c2, n, m, a, b, i, j;
	cin>>r1>>c1>>r2>>c2;
	n = r2 + c2 + 2;
	f[0] = fr[0] = p[0] = 1;
	for (i=1; i<=n; i++) 
	{
		f[i] = 1LL * f[i-1] * i % MOD;
		fr[i] = exp(f[i], MOD - 2);
		p[i] = p[i-1] * 2LL % MOD;
	}
	a = (calc(r2 + c2 + 2, r2 + 1) + calc(r1 + c1, r1)) % MOD;
	b = (calc(r1 + c2 + 1, r1) + calc(r2 + c1 + 1, c1)) % MOD;
	res = ((a - b) % MOD + MOD) % MOD;
	cout<<res<<endl;
	return 0;
}

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

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

	int sum = 0;
	for (auto &&c : s)
	{
		sum += (c - '0');
	}

	cout << ((sum % 9 == 0) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3728
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 3005;
const int mod = 998244353;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
int main()
{
    string s;
    ll i,f=0;
    cin>>s;
    for(i=0;i<3;i++)
    {
        if(s[i]=='7')
        {
            f=1;
            break;
        }

    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0044
"""

from math import sqrt, ceil, pow
import bisect
import sys


# https://github.com/mccricardo/sieve_of_atkin/blob/master/sieve_of_atkin.py
class SieveOfAtkin:
    def __init__(self, limit):
        self.limit = limit
        self.primes = []
        self.sieve = [False] * (self.limit + 1)

    def flip(self, prime):
        try:
            self.sieve[prime] = True if self.sieve[prime] == False else False
        except KeyError:
            pass

    def invalidate(self, prime):
        try:
            if self.sieve[prime] == True: self.sieve[prime] = False
        except KeyError:
            pass

    def isPrime(self, prime):
        try:
            return self.sieve[prime]
        except KeyError:
            return False

    def getPrimes(self):
        testingLimit = int(ceil(sqrt(self.limit)))

        for i in range(testingLimit):
            for j in range(testingLimit):
                # n = 4*i^2 + j^2
                n = 4 * int(pow(i, 2)) + int(pow(j, 2))
                if n <= self.limit and (n % 12 == 1 or n % 12 == 5):
                    self.flip(n)

                # n = 3*i^2 + j^2
                n = 3 * int(pow(i, 2)) + int(pow(j, 2))
                if n <= self.limit and n % 12 == 7:
                    self.flip(n)

                # n = 3*i^2 - j^2
                n = 3 * int(pow(i, 2)) - int(pow(j, 2))
                if n <= self.limit and i > j and n % 12 == 11:
                    self.flip(n)

        for i in range(5, testingLimit):
            if self.isPrime(i):
                k = int(pow(i, 2))
                for j in range(k, self.limit, k):
                    self.invalidate(j)

        self.primes = [2, 3] + [x for x in range(len(self.sieve)) if self.isPrime(x) and x >= 5]
        return self.primes




def solve1(num, primes):
    #
    i = bisect.bisect_left(primes, num)
    lt = primes[i-1]
    i = bisect.bisect_right(primes, num)
    gt = primes[i]
    return lt, gt


if __name__ == '__main__':
    A = SieveOfAtkin(55000)
    A.getPrimes()
    # ??????????????\?????¨???????????????
    for line in sys.stdin:
        num = int(line)
        lt, gt = solve1(num, A.primes)
        print('{} {}'.format(lt, gt))

Measured memory_bytes: 8256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    //let n = read::<usize>();
    //let n = read::<u32>();
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
long long int s[100009] = {0};
long long int f[100009] = {0};
string z;
long long int n, m, i, x;
int main()
{
    //freopen("test.inp","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    long long int dem1 = 0, dem2 = 0;
    for (i = 1; i <= m; i++)
    {
        cin >> x >> z;
        if (z == "WA")
        {
            if (s[x] == 0) f[x]++;
        }
        else s[x] = 1;
    }
    for (i = 1; i <= n; i++)
    {
        if (s[i] == 1) dem1 ++;
        if (s[i]==1) dem2 += f[i];
    }
    cout << dem1 << " " << dem2;
}


Measured memory_bytes: 1792
import heapq
N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)

for _ in range(M):
  X = heapq.heappop(a)
  heapq.heappush(a, X/2)

print(sum(int(-x) for x in a))

Measured memory_bytes: 20032
//円と円の関係
//参考(http://dac.gijodai.ac.jp/it-con/h16_sakuhin/ippan/ippan3/math/3grade/circle/circle4.htm)
#include<cstdio>
#include<cmath>

using namespace std;

int main(void){
	int n,i,ans;
	double xa,ya,ra,xb,yb,rb;
	double menA,menB,data,data2,kyori;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		//二つの中心点の距離を求める
		data=(xb-xa)*(xb-xa)+(yb-ya)*(yb-ya);
		kyori=sqrt(data);
		//交点の関係
		data=ra+rb;
		data2=fabs(ra-rb);
		if(kyori>data)
			ans=0;
		else if(kyori<data2){
			menA=ra*ra*3.14;	//pi＝円周率
			menB=rb*rb*3.14;
			if(menA>menB)
				ans=2;
			else if(menA<menB)
				ans=-2;
		}
		else
			ans=1;
		printf("%d\n",ans);
	}

	return 0;
}

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

int main()
{
  ll n;
  cin >> n;
  
  ll h[n];
  rep(i,n) cin >> h[i];
  
  ll max = 0;
  ll maxnum = 0;
  rep(i,n)
  {
    if(h[i] > max)
    {
      max = h[i];
      maxnum = i;
    }
  }
  
  for(int i = maxnum; i < n; i++)
  {
    if(h[i] + 1 < h[maxnum])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  
  for(int i = 0; i < n-1; i++)
  {
    if(h[i] - 1 > h[i+1])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 4404
#include<stdio.h>
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	while(h!=0||w!=0){
		int i,j;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d%d",&h,&w);
	}
	return 0;
}



Measured memory_bytes: 2040
from operator import itemgetter
from collections import deque
N = int(input())
L = [[0,0]]
for i in range(N):
    l,r = map(int,input().split())
    L.append([l,r])
Q = sorted(L)
R = sorted(L,key=itemgetter(1))
ans = 0
suma=0
for i in range(N//2+1):
    suma +=2*(Q[-i-1][0]-R[i][1])
    if suma>ans:
        ans = suma
print(ans)
        
        

Measured memory_bytes: 23432
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');

!function (k) {
  input.forEach(function (l){
    return l - 0 && console.log(
      (l - 0)
      .toString(8)
      .split('')
      .map(function (ch) { return k[ch - 0]; })
      .join('')
    );
  });
}([0, 1, 2, 3, 5, 7, 8, 9]);

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

int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  int A[M];
  int i, sum = 0;
  for (i = 0; i < M; i++) {
    A[i] = 0;
    scanf("%d", &A[i]);
    sum += A[i];
  }
  int res = N - sum;
  if (res >= 0){
    printf("%d", res);
  }else{
    printf("-1");
  }
  return 0;
}

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

using namespace std;

int main(){
    bool c[20010];
    int n, m;
    while(cin >> n >> m, n+m){
        fill(c, c+20010, false);
        c[1] = true;
        vector<pair<int, pair<int, int>>> p;
        for(int i=0; i < m; i++){
            int t, s, d;
            cin >> t >> s >> d;
            p.push_back(make_pair(t, make_pair(s, d)));
        }
        sort(p.begin(), p.end());
        for(int i=0; i < m; i++){
            if(c[p[i].second.first]){c[p[i].second.second] = true;}
        }
        int ret = 0;
        for(int i=0; i <= n; i++) if(c[i]) ret++;
        cout << ret << endl;
    }
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int ceil(int a, int b)
{
    return (a + b - 1) / b;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int h, w, n;
    cin >> h >> w >> n;

    cout << ceil(n, max(h, w)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll n,m; cin>>n>>m;
    multiset<ll, greater<ll> >s;
    for(ll i=0;i<n;i++){
        ll x; cin>>x;
        s.in(x);
        
    }
    ll k=0;
    for(ll i=0;i<m;i++){
        ll x=*s.begin();
        s.erase(s.begin());
        if(x==0)
            break;
        s.in(x/2);
        
    }
    ll sum=0;
    for(auto i=s.begin();i!=s.end();i++)
        sum+=*i;
    cout<<sum;
    
    return 0;
}


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

int main(void){
    char c;
    cin >> c;

    if (c == 'A') cout << 'T' << endl;
    if (c == 'C') cout << 'G' << endl;
    if (c == 'G') cout << 'C' << endl;
    if (c == 'T') cout << 'A' << endl;
    return 0;
}


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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846


    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    void solve(){
        int n;
        cin>>n;
        vector<ll>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        long long money=1000;
        int j=0;
        for(int i=0;i<n-1;i++){
            if(a[i+1]>a[i])
                continue;
            else{
                long long stocks=money/a[j];
                money=(money-(stocks*a[j]))+(stocks*a[i]);
                j=i+1;
            }
        }
        if(j!=n-1){
            long long stocks=money/a[j];
            money=(money-(stocks*a[j]))+(stocks*a[n-1]);
        }
        cout<<money;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("alchemy_input.txt", "r", stdin);
//        freopen("alchemy_output.txt", "w", stdout);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3660
//https://atcoder.jp/contests/abc160/tasks/abc160_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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 (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
  std::ifstream in("./test/sample-1.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  ll K,N; cin>>K>>N;
  vector<ll> an(N);
  for(auto&& a:an){
    cin>>a;
  }
  an.push_back(K+an.at(0));
  ll max_d=0;
  FOR(i,1,an.size()){
    ll d=an.at(i) - an.at(i-1);
    chmax(max_d,d);
  }
  ll ans=K-max_d;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	bool ok = ((a == b) && (b == c));
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main() {
    int n;
    cin>>n;
    vector<ll> v(n+2),c1(n+2),c2(n+2);
    rep(i, n) cin>>v[i+1];
    ll sum =0;
    v[n+1]=0;
    v[0]=0;
    rep(i, n+1) sum+=abs(v[i]-v[i+1]);
    rep(i, n+1) c1[i] = abs(v[i]-v[i+1]);
    rep(i, n) c2[i] = abs(v[i]-v[i+2]);
    rep(i, n-2){
        pr(sum - c1[i]- c1[i+1]+c2[i]);
    }
    pr(sum - c1[n-2]- c1[n-1]+c2[n-2]);
    pr(sum - c1[n-1]- c1[n]+abs(v[n-1]));
}


Measured memory_bytes: 4216
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i, a, n) for(LL i = (a), i##_max = (n); i < i##_max; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##min = (a); i >= i##min; --i)
#define ALL(arr) (arr).begin(), (arr).end()
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class T>
T Next() { T buf; cin >> buf; return buf; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "UnionFind.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "FlowSolver.h"
#include "Tree.h"
#include "SuffixArray.h"
#include "Geometry.h"
#include "Matrix.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "BIT.h"
#include "Rational.h"
#include "Position.h"
#include "Factorization.h"
#include "Math.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
// template <class T>
// auto Is(const T& value) { return [value](const auto& comparand) -> bool { return comparand == value; }; }
#endif


int main() {
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << endl;
}

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

//N個の数字(A,B,…)のうち2で割れる回数が最小の物について、その回数を出力せよ。
//入力は「N A B …」の形式で与えられる。
int main() {
  int N,num;
  cin >> N;
  num=1000000000; //numは求める回数。暫定的に十分大きな値(10^9)を与えている。
  
  for(int i=0 ; i<N ; i++){//各自然数について2で割れる回数tを求める。tがnumより小さければnum=tとして更新する。
    int A,t;
    t=0;
    cin >> A;
    for (int j=0 ; j<1000000000 ; j++){
      if(A % 2 == 0){
        t++;
        A/=2;
      }
      else
        break;
    }
    if (num > t)
      num = t;
  }

  cout << num << endl;
}


Measured memory_bytes: 256