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

///for ordered set///
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/trie_policy.hpp>
///for ordered set///

using namespace std;

///for ordered set///
//using namespace __gnu_pbds;
//typedef tree< long long int , null_type, less_equal<long long int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
///for ordered set///

///Compiler Optimizer///
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
///Compiler Optimizer///

typedef long long           ll;
typedef unsigned long long  ull;

#define sf                  scanf
#define pf                  printf
#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define PF                  first
#define PS                  second
#define si(n)               scanf("%d",&n)
#define sii(x,y)            scanf("%d %d",&x,&y)
#define siii(x,y,z)         scanf("%d %d %d",&x,&y,&z)
#define sl(n)               scanf("%lld",&n)
#define sll(x,y)            scanf("%lld %lld",&x,&y)
#define slll(x,y,z)         scanf("%lld %lld %lld",&x,&y,&z)
#define FOR(i,x,y)          for(int i=x;i<y;i++)
#define RFOR(i,x,y)         for(int i=x;i>=y;i--)
#define CLR(arr,val)        memset(arr,val,sizeof arr);
#define vout(v)             for(int ind=0;ind<v.size();ind++){ cout<<v[ind]; if(ind<v.size()-1) cout<<' '; else cout<<endl;}
#define TCL(test,t)         for(test=1;test<=t;test++)
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define fastIO()            {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define MAXN                1000006
#define MAXP                1000006
#define MOD                 1000000007
#define PI                  acos(-1)

int arr[MAXN];

int main(){
    #ifdef ELDUIVEL
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n,k,ans;
    cin>>k>>n;
    ans=k;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(i){
            ans=min(ans,k-abs(arr[i]-arr[i-1]));
        }
    }
    ans=min(ans,k-((k-arr[n-1])+arr[0]));
    cout<<ans<<endl;
    #ifdef ELDUIVEL
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef bitset<50001> bits;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

namespace{
	const int mod=998244353;
	int mul(int x,int y){
		return (ll)x*y%mod;
	}
	int fix(int x){
		return x>=mod?x-mod:x;
	}
	void add(int &x,int y){
		x=(x+y>=mod?x+y-mod:x+y);
	}
}

const int N=405;
int h[N],pw[N*N],n,ans;

vector<pii> solve(int l,int r,int H){
	if(l>r) return {mp(1,0)};
	int m=min_element(h+l,h+r+1)-h;
	auto L=solve(l,m-1,h[m]);
	auto R=solve(m+1,r,h[m]);
	vector<pii> res(r-l+2);
	REP(i,L.size()) REP(j,R.size()){
		int a=mul(L[i].fi,R[j].fi);
		int b=fix(mul(L[i].se,fix(R[j].fi+R[j].se))+mul(L[i].fi,R[j].se));
		add(res[i+j].fi,a);
		add(res[i+j].se,b);
		add(res[i+j+1].fi,mod-a);
		add(res[i+j+1].se,a);
	}
	rep(i,0,r-l+1) REP(j,h[m]-H){
		res[i].fi=mul(res[i].fi,pw[r-l+1-i]);
		res[i].se=mul(res[i].se,pw[r-l+1-i]-1);
	}
	return res;
}

int main(){
	read(n);
	rep(i,1,n) read(h[i]);
	pw[0]=1;
	rep(i,1,n*n) pw[i]=fix(pw[i-1]+pw[i-1]);
	auto res=solve(1,n,0);
	for(auto x:res) add(ans,fix(x.fi+x.se));
	cout<<(ans+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=1e6+1;
int n,m,q;
int a[11];
int b[21];
ll w[51],x[51],y[51],z[51];
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m >> q;
	for(int i=1; i<=q ;i++){
		cin >> w[i] >> x[i] >> y[i] >> z[i];
	}
	for(int i=1; i<=m-1 ;i++){
		b[i]=0;
	}
	for(int i=m; i<=m+n-1 ;i++) b[i]=1;
	ll ans=0;
	do{
		{
			int x=1,y=1;
		for(int i=1; i<=m+n-1 ;i++){
			if(b[i]==0) x++;
			else{
				a[y++]=x;
			}
		}
		}
		ll res=0;
		for(int i=1; i<=q ;i++){
			if(a[x[i]]-a[w[i]]==y[i]) res+=z[i];
		}
		ans=max(ans,res);
	}while(next_permutation(b+1,b+m+n));
	cout << ans << '\n';
}

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

int main() {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(abs(c - a) <= d){
		cout << "Yes" << endl;
	} else if(abs(c - b) <= d && abs(b - a) <= d){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int h,w;
char s[500][500];
bool used[500][500];
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

void dfs(int x,int y,bool flag,ll &b,ll &wh){
  //cout<<' '<<cnt<<' '<<x<<' '<<y<<endl;
  used[x][y]=true;
  if(flag) b++;
  else wh++;
  rep(i,4){
    int nx=x+dx[i],ny=y+dy[i];
    if(1<=nx && nx<=h && 1<=ny && ny<=w && !used[nx][ny]){
      if(flag){
        if(s[nx][ny]=='.') dfs(nx,ny,!flag,b,wh);
      }else{
        if(s[nx][ny]=='#') dfs(nx,ny,!flag,b,wh);
      }
    }
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    FOR(i,1,h+1)FOR(j,1,w+1){
      cin>>s[i][j];
      used[i][j]=false;
    }
    ll ans=0;
    FOR(i,1,h+1)FOR(j,1,w+1){
      if(!used[i][j] && s[i][j]=='#'){
        ll b=0,wh=0;
        dfs(i,j,true,b,wh);
        ans+=b*wh;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10624
a = input()
b = len(a)
k = 0
str = []
str = list(a)
for i in range(1,b):
    if str[i-1] == "0" and str[i] == "0":
        str[i] = "1"

        k = k + 1
    
    if str[i-1] == "1" and str[i] == "1":
        str[i] = "0"
        k = k + 1

print(k)

Measured memory_bytes: 3956
#include <stdio.h>
#include <string.h>

int main(void)
{
    //debug
    FILE *fin,*fout;
//#define DEBUG
#ifdef DEBUG
    fin=fopen("input.txt","r");
    fout=fopen("output.txt","w");
#else
    fin=stdin; fout=stdout;
#endif

    char buf[25];
    fscanf(fin,"%s",buf);
    int len=strlen(buf);
    int i;
    for(i=len-1;i>=0;i--){
        fprintf(fout,"%c",buf[i]);
    }
    fprintf(fout, "\n");
    
    
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define ld long double
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    for (int i = -1e3; i<=1e3; i++) {
        for (int j = -1e3; j<=1e3; j++) {
            ll teci = pow(i, 5), tecj = pow(j, 5);
            if (teci - tecj == x) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4084
<?php
function nthRoot($x){
    return pow($x, 1 / 2);
}

function nthPow($x){
    return pow($x,2);
}

$inputs = trim(fgets(STDIN));
$inputs = explode(' ',$inputs);


$result = 0;
for ($i = 1; $i <= $inputs[0]; $i++) {
    $tmpInts = explode(' ',trim(fgets(STDIN)));
    $root = nthPow($tmpInts[0]) + nthPow($tmpInts[1]);
    $nthroot = nthRoot($root);
    if($inputs[1] >= $nthroot){
        $result += 1;
    }
}

echo $result;

?>


Measured memory_bytes: 16756
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int a[4];

int main() {
  string s;
  cin>>s;
  rep(i,4) a[i]=s[i]-'0';
  for(int x=0;x<8;x++){
    int sum=a[0];
    string s;
    s+=(char)('0'+a[0]);
    rep(i,3){
      if(x&(1<<i)){
        sum+=a[i+1];
        s+='+';
        s+=(char)('0'+a[i+1]);
      }else{
        sum-=a[i+1];
        s+='-';
        s+=(char)('0'+a[i+1]);
      }
    }
    if(sum==7){
      cout<<s<<"=7"<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int p = sc.nextInt();
    int q = sc.nextInt();
    int r = sc.nextInt();
    int ans = 0;
    ans = Math.min((p + q), Math.min(q + r, r + p));
    System.out.println(ans);
  }
}

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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair				
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;
 
#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type
{int o = 0; p << "{"; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if (p > y) p = y;}
sim, class s> void maxi(n &p, s y) {if (p < y) p = y;}

#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "

#ifndef LOCAL
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template <typename T>
using ordered_set =
	tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#else
#include</Users/dawid/algo/mac/ordered_set>
#endif

#define int ll

int ans, sum, n;

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

	cin >> n;

	for(int i = 1; i <= n; ++i)
	{
		int d, c;
		cin >> d >> c;
		sum += d*c;
		ans += c;
	}

	--ans;

	while(sum/10)
	{
		int ile = sum/10;
		ans += ile;
		sum -= ile*10;
		sum += ile;
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if ((W - x >= r ) && (H - y >= r) && (x >= r) && (y >= r)){
		cout << "Yes" << endl;
	} else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=500001;
using namespace std;


ll fact[NMAX+1];
ll invfact[NMAX+1];

ll pow(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    ll d = pow(a, b / 2);
    return (d * d) % MOD;
  } else {
    ll d = pow(a, b - 1);
    return (a * d) % MOD;
  }
}

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

    fact[0] = 1;
    for(int i = 1; i <= NMAX; i++){
        fact[i] = fact[i-1]*i%MOD;
    }
    invfact[NMAX] = pow(fact[NMAX], MOD-2);
    invfact[0] = 1;
    for(int i = NMAX-1; i > 0; i--){
        invfact[i] = invfact[i+1]*(i+1)%MOD;
    }

    ll ans = 0;
    for(int i = 0; i <= n; i++){
        ll tmp = fact[n]*invfact[n-i]%MOD;
        tmp = tmp*invfact[i]%MOD;

        tmp = tmp*fact[m-i]%MOD;
        tmp = tmp*invfact[m-n]%MOD;
        
        if(i%2 == 1) tmp *= -1;
        ans += tmp;
        if(ans < 0) ans += MOD;
        ans %= MOD;
    }
    ans = ans * fact[m] % MOD;
    ans = ans * invfact[m-n] % MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11412
S = input()
ACGT = ["A", "C", "G", "T"]
K = []
for i in range(len(S)):
    if S[i] in ACGT:
        K.append(i)
if len(K) == 0:
    ans = 0
elif len(K) == 1:
    ans = 1
else:
    count = 0
    mx = 0
    for j in range(len(K)-1):
        if K[j+1]-K[j] == 1:
            count += 2
        else:
            ans = max(count, mx)
            count = 0
            mx = ans
    ans = max(count, mx)
    ans = ans/2 + 1
print(int(ans))

Measured memory_bytes: 3064
// May this submission get accepted
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    vector<ll> p = inp(n);

    ll pmin = INF, ans = 0;
    REP(i, n) {
        chmin(pmin, p[i]);
        if (pmin >= p[i]) ans++;
    }
    say(ans);
    
}

Measured memory_bytes: 1792
n=int(input())
rel=[{'good':set(),'bad':set()} for _ in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    if y==1:
      rel[i]['good'].add(x-1)
    else:
      rel[i]['bad'].add(x-1)
ans=0
for i in range(2**n):
  true=set()
  c=0
  for j in range(n):
    if (i>>j) & 1==1:
      true.add(j)
  for j in true:
    if len(rel[j]['bad']&true)>0 or not rel[j]['good']<=true:
      break
    c+=1
  if c==len(true):
    ans=max(ans,c)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;

const int N = 1e8;
const int maxn = 300005;
const int maxm = maxn*30;
const int inf = 1<<28;
#define clr(_) memset(_,0,sizeof _)

struct node {int x,y;} p[maxn];
bool comp(node a,node b) {return a.x<b.x;}
int stk1[maxn],ref1[maxn],top1;
int stk2[maxn],ref2[maxn],top2;
int W,H,n,ans,rt;

int _o_,o_o;
namespace ST {
	int tag[maxm],w[maxm],c[maxm][2],tot;
	#define ls c[rt][0]
	#define rs c[rt][1]
	void inc(int rt,int v)
	{
		rt?(w[rt]+=v,tag[rt]+=v):0;
	}
	void pushdown(int rt)
	{
		if (int v=tag[rt]) {
			inc(ls,v);inc(rs,v);tag[rt]=0;
		}
	}
	void insert(int &rt,int L,int R,int p,int v)
	{
		if (!rt) rt=++tot;
		if (L>=R) {w[rt]=v;return ;}
		int mid=L+R>>1;pushdown(rt);
		if (p<=mid) insert(ls,L,mid,p,v);
		else insert(rs,mid+1,R,p,v);
		w[rt]=max(w[ls],w[rs]);
	}
	void modify(int rt,int L,int R,int l,int r,int v)
	{
		if (!rt||l>r) return ;
		if (L>=l&&R<=r) {inc(rt,v);return ;}
		int mid=L+R>>1;pushdown(rt);
		if (l<=mid) modify(ls,L,mid,l,r,v);
		if (r>mid) modify(rs,mid+1,R,l,r,v); 
		w[rt]=max(w[ls],w[rs]);
	}
}
using namespace ST;

void solve()
{
	sort(p+1,p+n+1,comp);
	_o_=W>>1;o_o=W+1>>1;
	insert(rt,0,N,0,W);
	
	stk1[top1=1]=_o_;ref1[top1]=0;
	stk2[top2=1]=o_o;ref2[top2]=0;
	for (int i=1;i<=n;i++)
	if (p[i].x) {
		ans=max(ans,p[i].x+w[rt]);
		if (p[i].y<=_o_)
		{
			int las=p[i].x,cur=0;
			while (top1&&stk1[top1]<p[i].y)
				modify(rt,0,N,ref1[top1],las-1,-p[i].y+cur),
				las=ref1[top1],cur=stk1[top1],top1--;
			modify(rt,0,N,ref1[top1],las-1,-p[i].y+cur);
			stk1[++top1]=p[i].y;ref1[top1]=p[i].x;
		}
		if (p[i].y>=o_o)
		{
			int las=p[i].x,cur=W;
			while (top2&&stk2[top2]>p[i].y)
				modify(rt,0,N,ref2[top2],las-1,p[i].y-cur),
				las=ref2[top2],cur=stk2[top2],top2--;
			modify(rt,0,N,ref2[top2],las-1,p[i].y-cur);
			stk2[++top2]=p[i].y;ref2[top2]=p[i].x;
		}
		insert(rt,0,N,p[i].x,W-p[i].x);
	}
	
	ans=max(ans,H+w[rt]);
}
int main()
{
	#ifdef Amberframe
		freopen("arc063f.in","r",stdin);
		freopen("arc063f.out","w",stdout);
	#endif
	scanf("%d %d %d",&W,&H,&n);w[0]=-inf;
	for (int i=1;i<=n;i++)	
		scanf("%d %d",&p[i].x,&p[i].y);
	
	swap(W,H);solve();
	tot=rt=0;clr(tag);clr(c);clr(w);
	for (int i=1;i<=n;i++)
		swap(p[i].x,p[i].y);
	swap(W,H);solve();
	printf("%d",ans<<1);
	return 0;
}

Measured memory_bytes: 147968
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint N;
  cin>>N;
  cout<<(N*(N-1))/2<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    writeln!(o, "{}", solve(n)).unwrap();
}
fn solve(n: usize) -> usize {
    let mut ans = 0;
    divisors(n, |x| {
        let m_1 = n / x;
        let m = m_1 - 1;
        if x < m {
            ans += m;
        }
    });
    ans
}
fn divisors<F: FnMut(usize)>(n: usize, mut f: F) {
    fn divisors_by<F: FnMut(usize)>(fs: &[(usize, usize)], mut n: usize, f: &mut F) {
        if fs.is_empty() {
            f(n);
            return;
        }
        let (p, c) = fs[0];
        for _ in 0..c + 1 {
            divisors_by(&fs[1..], n, f);
            n *= p;
        }
    }
    divisors_by(&factorize(n), 1, &mut f)
}
fn factorize(mut n: usize) -> Vec<(usize, usize)> {
    let mut fs = Vec::new();

    for p in primes((n as f64).sqrt() as usize) {
        let mut c = 0;
        while n % p == 0 {
            n = n / p;
            c += 1;
        }
        if c != 0 {
            fs.push((p, c));
            if n == 1 {
                break;
            }
        }
    }
    fs
}
fn primes(max: usize) -> Vec<usize> {
    let end = max + 1;
    let mut m = vec![false; end];
    let mut ps = Vec::new();

    for i in 2..end {
        if m[i] {
            continue;
        }
        let mut j = i;
        while j < end {
            m[i] = true;
            j += i;
        }
        ps.push(i);
    }
    ps
}


mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

using namespace std;

int main(){
    int n;
    cin >> n;

    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int k = 0;
    for(int i = 0; i <  n; i++){
        if(p[i] != i + 1){
            k++;
        }
    }
    if(k <= 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, z[11], i;
    string s;
    getline(cin, s);
    a=0;
    c=1001;
    for (i=0; i<10; i++)
    {
        z[i]=s[i]-48;
        if ('1'<=s[i] && s[i]<='9')
        {
            a++;
        }
    }
    for (i=0; i<a-2; i++)
    {
        b=z[i]*100+z[i+1]*10+z[i+2]-753;
        if (b<0)
        {
            b=-b;
        }
        if (b<c)
        {
            c=b;
        }
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final Map<Integer, List<Integer>> graph = new HashMap<>();
        for (int i = 0; i < m; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();
            graph.computeIfAbsent(a, v -> new ArrayList<>()).add(b);
            graph.computeIfAbsent(b, v -> new ArrayList<>()).add(a);
        }

        int begin = 1;
        int end = graph.get(1).get(0);
        final boolean[] isIncluded = new boolean[n + 1];
        isIncluded[begin] = true;
        isIncluded[end] = true;
        final Deque<Integer> path = new ArrayDeque<>();
        path.add(begin);
        path.add(end);

        while (true) {
            final Optional<Integer> beginCandidate = graph.get(begin).stream()
                .filter(i -> !isIncluded[i])
                .findFirst();
            if (beginCandidate.isPresent()) {
                begin = beginCandidate.get();
                isIncluded[begin] = true;
                path.addFirst(begin);
                continue;
            }

            final Optional<Integer> endCandidate = graph.get(end).stream()
                .filter(i -> !isIncluded[i])
                .findFirst();
            if (endCandidate.isPresent()) {
                end = endCandidate.get();
                isIncluded[end] = true;
                path.addLast(end);
                continue;
            }

            break;
        }

        System.out.println(path.size());
        final String answer = path.stream()
            .map(i -> Integer.toString(i))
            .collect(Collectors.joining(" "));
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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


Measured memory_bytes: 77412
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int c=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i) == '1'){
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long time = in.nextLong();
            long[] t = new long[n];
            long ans = time;
            for (int i = 0; i < n; ++i)
                t[i] = in.nextLong();
            for (int i = 1; i < n; ++i) {
                if (t[i] - t[i - 1] > time)
                    ans += time;
                else
                    ans += t[i] - t[i - 1];
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 67320
import collections
import bisect
n = int(input())

primes = []
a = 2
while n > a*a:
    while n % a == 0:
        primes.append(a)
        n //= a
    a += 1
if n != 1:
    primes.append(n)

ctr = collections.Counter(primes)
ans = 0
for k,v in ctr.items():
    for i in range(1,100):
        if v >= i*(i+1)//2:
            ans += 1
print(ans)

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

int main() {
  string S;
  cin >> S;
  
  int count =0;
  for(int i=0; i<3; i++)if(S.at(i)=='R')count ++;
  if(S.at(1)=='S' && count ==2)count--;
  
  cout << count << endl;
}

Measured memory_bytes: 3620
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 2e5 + 300, N2 = 2e3, inf = 1e18 + 200;

int t[4*N], c[4*N];
int d[N];

vector <int> L[N], R[N];

void push(int v, int l, int r){
	t[v] += c[v];
	if (l != r){
		c[v+v] += c[v];
		c[v+v+1] += c[v];
	}
	c[v] = 0;
}

void update (int v, int ll, int rr, int l, int r, int res){
	push(v, ll, rr);
	if (ll > r || rr < l) return;
	if (ll >= l && rr <= r){
		c[v] += res;
		push(v, ll, rr);
	}
	else{
		int mid = (ll + rr) / 2;
		update(v+v, ll, mid, l, r, res);
		update(v+v+1, mid + 1, rr, l, r, res);
		t[v] = max(t[v+v], t[v+v+1]);
	}
}

int maxi(int v, int ll, int rr, int l, int r){
	push(v, ll, rr);
	if (ll > r || rr < l){
		return -inf;
	}
	if (ll >= l && rr <= r){
		return t[v];
	}
	int mid = (ll + rr) / 2;
	return max(maxi(v+v, ll, mid, l, r), maxi(v+v+1, mid + 1, rr, l, r));
}
/*
void propagate(int pos,int left,int right){

	if(c[pos] == 0) return;

	if(left != right){
		c[2*pos] += c[pos];
		c[2*pos+1] += c[pos];
	}

	t[pos] += c[pos];
	c[pos] = 0;

}

void update(int pos,int left, int right,int i,int j, int delta){

	propagate(pos,left,right);
	if(left > right || left > j || right < i) return;

	if(left >= i && right <= j){
		c[pos] += delta;
		propagate(pos,left,right);
		return;
	}

	int mid = (left+right)/2;
	update(2*pos,left,mid,i,j,delta);
	update(2*pos+1,mid+1,right,i,j,delta);

	t[pos] = max(t[2*pos],t[2*pos+1]);

}

int maxi(int pos,int left,int right,int i,int j){

	propagate(pos,left,right);

	if(left >= i && right <= j) return t[pos];

	int mid = (left+right)/2;
	if(j <= mid) return maxi(2*pos,left,mid,i,j);
	else if(i >= mid + 1) return maxi(2*pos+1,mid+1,right,i,j);
	else return max(maxi(2*pos,left,mid,i,j), maxi(2*pos+1,mid+1,right,i,j));

}
*/
int l[N], r[N], x[N];

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		cin >> l[i] >> r[i] >> x[i];
		L[l[i]].pb(i);
		R[r[i]].pb(i);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++){
		for(int j : L[i]){
			update(1, 0, n, 0, l[j] - 1, x[j]);
		}
		d[i] = maxi(1, 0, n, 0, i - 1); 
		ans = max(ans, d[i]);
		update(1, 0, n, i, i, d[i]);
		for(int j : R[i]){
			update(1, 0, n, 0, l[j] - 1, -x[j]);
		}
	}
	cout << ans;
	
	return 0;
}

/*
for(int i = 1;i<=N;i++){
		for(int j : adiciona[i]){
			update(1,0,N,0,ini[j] - 1,valor[j]);
		}
		dp[i] = query(1,0,N,0,i-1);
		update(1,0,N,i,i,dp[i]);
		for(int j : retira[i]){
			update(1,0,N,0,ini[j] - 1,-valor[j]);
		}
	}*/









Measured memory_bytes: 39424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){

  char C;
  cin >> C;
  cout << (char)((int)C + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        string s;
        cin >> s;
        ll sum = 0;
        for(auto u : s){
            sum += u - '0';
        }
        if(sum % 9 == 0){
            cout << "Yes";
        }
        else{
            cout << "No";
        }
    }
    return 0;
}

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


using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<int, int> P;

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll A, B, C, X, Y, N, M, K;
string S;

int searchNum(int start, int Num) {
    Num += '0';
    for (int i = start; i < S.length(); i++) {
        if (S[i] == Num) {
            return i;
        }
    }
    return -1;
}

signed main() {

    cin >> N;
    cin >> S;

    int count = 0;
    rep(i, 10) {
        int ret_i = searchNum(0, i);
        if (ret_i != -1) {
            rep(j, 10) {
                int ret_j = searchNum(ret_i+1, j);
                if (ret_j != -1) {
                    rep(k, 10) {
                        if (searchNum(ret_j+1, k) != -1) {
                            PRINT(i)
                            PRINT(j)
                            PRINT(k)
                            PRINT(ret_i)
                            PRINT(ret_j)
                            count++;
                        }
                    }
                }
            }
        }
    }
cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+10;
int n,k,a[N];
int check(int x){
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=(a[i]+x-1)/x-1;
	return ans<=k;
}
signed main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	int l=1,r=2e9;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
	return 0;
}

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

int n;
long long wt;
int v[100];
long long w[100];
long long dp[100][10001];

int main()
{
	cin >> n >> wt;

	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i];

	memset(dp, 0, sizeof(dp));

	int vt = v[0];
	dp[0][v[0]] = w[0];

	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= vt; j++)
			dp[i][j] = dp[i - 1][j];

		if (dp[i - 1][v[i]] > 0)
			dp[i][v[i]] = min(dp[i - 1][v[i]], w[i]);
		else
			dp[i][v[i]] = w[i];

		for (int j = 1; j <= vt; j++) {
			if (dp[i - 1][j] > 0) {
				if (dp[i - 1][j + v[i]] > 0)
					dp[i][j + v[i]] = min(dp[i - 1][j + v[i]], dp[i - 1][j] + w[i]);
				else
					dp[i][j + v[i]] = dp[i - 1][j] + w[i];
			}
		}
		vt += v[i];
	}

	int vm = 0;

	for (int j = 0; j <= vt; j++) {
		if (dp[n - 1][j] <= wt && dp[n - 1][j] > 0)
			vm = j;
	}

	cout << vm << endl;

	return 0;
}


Measured memory_bytes: 10932
import sys
input = sys.stdin.readline
#from numpy import matrix, eye, dot
def productMatrix(N, A, B):
    Ret = [[0]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            for k in range(N):
                Ret[i][j] += A[i][k]*B[k][j]
    return Ret
def modMatrix(N, A, Q): #N×N行列のmod
    for i in range(N):
        for j in range(N):
            A[i][j] %= Q
    return

def powOfMatrix(N, X, n, Q): #N×N行列のn乗
    Ret = [[1,0,0],[0,1,0],[0,0,1]]
    power = '{:060b}'.format(n)[::-1] #log2(pow(10,18)) < 60
    for p in power:
        if p == "1":
            Ret = productMatrix(N,Ret, X)
            modMatrix(N, Ret, Q)
        X = productMatrix(N,X,X)
        modMatrix(N, X, Q)
    return Ret

def main():
    L, A, B, M = map( int, input().split())
    s = A
    ANS = [[1,0,0],[0,1,0],[0,0,1]]
    for i in range(1, 37):
        if s >= pow(10,i):
            continue
        P = [[pow(10, i, M), 0, 0], [1,1,0], [0,B,1]]
        step = (pow(10,i)-s+B-1)//B
        if L <= step:
            ANS = productMatrix(3,ANS,powOfMatrix(3,P,L,M))
            modMatrix(3,ANS,M)
            break
        ANS = productMatrix(3,ANS, powOfMatrix(3,P, step,M))
        modMatrix(3,ANS, M)
        L -= step
        s += step*B
    print( (ANS[1][0]*A + ANS[2][0])%M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
N,M,C = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
As = [[int(s) for s in input().split()] for i in range(N)]
print(len(list(filter(lambda A: sum([a*b for a, b in zip(A, B)])+C > 0, As))))

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

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

int i;

int main(void){
    
    string s;
    cin >> s;
    
    int slen = s.length();
    
    int ans=0;
    
    FOR(i,slen){
        s.pop_back();
        int stlen = s.length();
        string st1 = s.substr(0,stlen/2);
        string st2 = s.substr( stlen/2,stlen/2 );
        //cout << st1 << " " << st2 << endl;
        if(st1==st2){
            ans=st1.length()*2;
            break;
        }
    }
    
    cout<<ans;
    
    return 0;
    
}


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

int main() {
	int n;string s;cin>>n>>s;
	vector<int> ans(n+1);
	for(int i=0;i<n;i++)if(s[i]=='.')ans[0]++;
	for(int i=0;i<n;i++){
		if(s[i]=='#')ans[i+1]=ans[i]+1;
		if(s[i]=='.')ans[i+1]=ans[i]-1;
	}

	//for(int i=0;i<n+1;i++)cout<<ans[i]<<endl;
	
	sort(ans.begin(), ans.end());
	cout<<ans[0]<<endl;
	
	return 0;
}



Measured memory_bytes: 1412
s=input()
s1=[i for i in s[::2] if i=='R' or i=='U' or i=='D']
s2=[i for i in s[1::2] if i=='L' or i=='U' or i=='D']
if len(s1)==len(s[::2]) and len(s2)==len(s[1::2]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main(){
  int a,b,c,d;
  int x,y;
  cin >>a>>b>>c>>d;
  x = c/b;
  y = a/d;
  if(c%b!=0) x+=1;
  if(a%d!=0) y+=1;
  if(x<=y) cout<<"Yes"<<endl;
  else cout <<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const int N=200005;
int n,sum[N],b[N],ans=1e9;
char s[N];

inline void read(int &i){
	i=0;char c=getchar();bool j=0;
	for(;!isdigit(c);c=getchar())if(c=='-')j=1;
	for(;isdigit(c);c=getchar())i=(i<<1)+(i<<3)+c-'0';i=j?-i:i;
}

int main(){
	read(n);
	scanf("%s",s+1);
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+(s[i]=='.');
	for(int i=n;i>=1;--i)b[i]=b[i+1]+(s[i]=='#');
	for(int i=0;i<=n;++i){
		ans=min(ans,(i-sum[i])+(n-i-b[i+1]));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[300010];
int main(){
	int k,n;
	cin>>k>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	int tp=a[1]+k-a[n];
	int num=tp;
	for(int i=2;i<=n;i++){
		int tp1=a[i]-a[i-1];
		if(tp1>tp) tp=tp1;
		num+=tp1;
	}
	cout<<num-tp;
}
	

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri(), a = ri(), b = ri();
	int p[n]; INPUT(p);
	
	int r0 = 0, r1 = 0, r2 = 0;
	FOR(i,n) {
		if (p[i] <= a) r0++;
		else if (p[i] <= b) r1++;
		else r2++;
	}
	
	cout << min(r0,min(r1,r2)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define xx first
#define yy second
#define dob double
#define int long long int
#define ss size()
using namespace std;
const int M=1e9+7,maxn=3005;
std::vector<int> adj[30];
std::vector<int> v1;
std::vector<int> v;
int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn][maxn];
bool mark[maxn];
int32_t main(){
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[i][1]=a[i];
    }
    for(int j=2;j<=n;j++){
        for(int i=0;i<=n-j;i++){
            dp[i][j]=max(a[i]-dp[i+1][j-1],a[i+j-1]-dp[i][j-1]);
        }
    }
    cout<<dp[0][n];
    return 0;
}


Measured memory_bytes: 70016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <deque>
#define MAX_N 100000
#define INF 1000000000000
typedef long long ll;
using namespace std;

int main(){
  int n,k;
  int ans=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(ans<k) ans*=2;
    else ans+=k;
  }
  cout<<ans<<endl;

  return 0;
}


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

#define MAX_N 12
#define MAX_T 10000

int x[MAX_N][MAX_N];
int z[8],y[8];
char c,T[4]=".ox";

int main(){
	for(int i=1;i<=8;i++){
		for(int j=1;j<=8;j++){
			cin>>c;
			if(c=='o'){
				x[i][j]=1;
			}
			if(c=='x'){
				x[i][j]=2;
			}
			if(c=='.'){
				x[i][j]=0;
			}
		}
	}
	for(int i=0;i<MAX_T;i++){
		int dx[8]={0,1,1,1,0,-1,-1,-1};
		int dy[8]={-1,-1,0,1,1,1,0,-1};
		for(int h=2;h>0;h--){
			int score=0,maxn=0,cnt=0,X=0,Y=0,cx=0,cy=0;
			for(int j=1;j<=8;j++){
				for(int k=1;k<=8;k++){
					if(x[j][k]==0){
						score=0;
						for(int l=0;l<8;l++){
							z[l]=0;
							cnt=0;
							cx=j+dx[l];cy=k+dy[l];
							while(cx>=1 && cx<=8 && cy>=1 && cy<=8){
								if(x[cx][cy]==0){
									goto E;
								}
								if(x[cx][cy]!=h){
									goto F;
								}
								cnt++;
								cx+=dx[l];cy+=dy[l];
							}
							goto E;
F:;
							score+=cnt;
							z[l]=1;
E:;
						}
						if(score>maxn || (score==maxn && h==1)){
							maxn=score;X=j;Y=k;
							for(int l=0;l<8;l++){y[l]=z[l];}
						}
					}
				}
			}
			if(maxn>=1){
				x[X][Y]=(3-h);
				for(int l=0;l<8;l++){
					if(y[l]==1){
						cx=X+dx[l];cy=Y+dy[l];
						while(cx>=1 && cx<=8 && cy>=1 && cy<=8){
							if(x[cx][cy]!=h){
								break;
							}
							x[cx][cy]=(3-h);
							cx+=dx[l];cy+=dy[l];
						}
					}
				}
			}
		}
	}
	for(int i=1;i<=8;i++){
		for(int j=1;j<=8;j++){
			cout<<T[x[i][j]];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1136
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int r;
    cin >> r;
    cout << 2 * 3.141592 * r << endl;
    
    return 0;
}

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

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

int main() {
    int a, b;
    while (cin >> a >> b) {
        cout << gcd(a, b) << ' ' << lcm(a, b) << endl;
    }
}



Measured memory_bytes: 3080
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}



int main(void){
   
long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,k,q,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a[1000000]={0},b,count1=0,a2,b2;
scanf("%lld%lld%lld",&n,&k,&q);

for(i=0;i<q;i++){
    scanf("%lld",&m);
   a[m-1]++;
}
for(i=0;i<n;i++){
    c=q-a[i];
    if(k-c>=1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}
return 0;
}


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

int main(){
  int n;
  cin >> n;

  int a[100010];
  int memo[100010] = {};
  int cnt = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    memo[a[i]]++;
    if(memo[a[i]] > 1){
      cnt++;
    }
  }

  if(cnt == 0){
    cout << n << endl;
  }else{
    if(cnt % 2 == 0){
      cout << n-cnt << endl;
    }else{
      cout << n-cnt-1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>

int main(){
	unsigned M, K;
	scanf("%u %u", &M, &K);
	if(M == 1){
		if(K == 0) printf("0 0 1 1\n");
		else printf("-1\n");
	}else if(K >= 1 << M){
		printf("-1\n");
	}else{
		printf("%u", K);
		for (int i = 0; i < 1 << M; ++i){
			if(i != K) printf(" %d", i);
		}
		printf(" %u", K);
		for (int i = (1 << M) - 1; i >= 0; --i){
			if(i != K) printf(" %d", i);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1792
f=lambda:map(int,input().split())
n,l,t=f()
X=[0]*n
b=0
for i in range(n):x,w=f();x+=t*(3-2*w);b+=x//l;X[i]=x%l
X.sort()
for i in range(n):print(X[(i+b)%n])

Measured memory_bytes: 8136
s=input()
n=len(s)
a=[]
t=1
mod=10**9+7
for i in range(6):
    a.append(t)
    t*=10
    t%=13
dp=[[0 for i in range(13)] for i in range(n+1)]
dp[0][0]=1
for i,S in enumerate(s[::-1],1):
    if S=="?":
        t=a[(i-1)%6]
        for j in range(13):
            for k in range(10):
                dp[i][j]+=dp[i-1][j-t*k%13]
            dp[i][j]%=mod
    else:
        S=int(S)
        t=S*a[(i-1)%6]%13
        for j in range(13):
            dp[i][j]=dp[i-1][j-t]
print(dp[-1][5]%mod)

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

signed main(){
  int N,M,X;
  cin>>N>>M>>X;
  vector<int> charge(M);
  rep(i,M)cin>>charge[i];
  int toZ=0,toN=0;
  rep(i,M){
    if(charge[i]<X)toZ+=1;
    if(charge[i]>X)toN+=1;
  }
  cout<<min(toZ,toN)<<endl;
  return 0;
}

Measured memory_bytes: 3636