akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define cont continue
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 987654321;

bool isprime[1000001] = {};
vector<int> prime;
set<int> st;

int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  memset(isprime, true, sizeof(isprime));
  isprime[1] = false;
  for(ll i = 2 ; i < 1000000 ; i++) {
    if(isprime[i]) prime.pb(i);
    for(ll j = i * i ; j <= 1000000 ; j+=i) {
      isprime[j] = false;
    }
  }
  int X;
  cin >> X;
  vector<int> arr;
  int ans = 0;
  int onecnt = 0;
  bool visit[1000001] = {};

  for(int i = 0 ; i < X ; i++) {
    int x;
    cin >> x;
    arr.pb(x);
    if(!visit[x]) visit[x] = true;
    else st.insert(x);
    if(x == 1) onecnt++;
  }
  sort(arr.begin(), arr.end());

  if(onecnt != 0) {
    if(onecnt == 1) {
      cout << "1" << endl;
      return 0;
    }
    else {
      cout << "0" << endl;
      return 0;
    }
  }

  for(int i = 0 ; i < arr.size() ; i++) {
    int cur = arr[i];
    bool flag = true;
    if(st.find(cur) != st.end()) flag = false;
    for(int j = 2 ; j <= sqrt(cur) ; j++) {
      if(cur % j == 0) {
        if(st.find(j) != st.end()) flag = false;
        if(st.find(cur / j) != st.end()) flag = false;
      }
    }
    st.insert(cur);
    if(flag) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 15716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

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

    if(N%2) { cout << 0 << endl; return 0; }

    ll cur = 10;
    ll res = 0;
    while(N/cur > 0) res += N/cur, cur *= 5;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 764
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,q := input.NextInts()
  s := input.NextLine()
  x := make([]int,n+2)
  t := make([]int,q)
  d := make([]int,q)
  for i:=1;i<n+1;i++ { x[i] = int([]rune(s[i-1:i])[0])-64 }
  for i:=0;i<q;i++ { t[i],d[i] = input.NextStrings() }
  l,sup := 0,n+1
  for sup-l > 1 {
    m := (sup+l)/2
    y := m
    for i:=0;i<q;i++ {
      if x[y] == t[i] { y += d[i] }
    }
    if y == 0 {
      l = m
    } else {
      sup = m
    }
  }
  inf,r := 0,n+1
  for r-inf > 1 {
    m := (r+inf)/2
    y := m
    for i:=0;i<q;i++ {
      if x[y] == t[i] { y += d[i] }
    }
    if y == n+1 {
      r = m
    } else {
      inf = m
    }
  }
  fmt.Println(r-l-1)
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextStrings() (int,int) {
  s := strings.Split(i.NextLine()," ")
  n := int([]rune(s[0])[0])-64
  m := 1
  if s[1] == "L" { m = -1 }
  return n,m
}
func(i *Input) NextInts() (int,int) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 10496
package main

import (
  "fmt"
)

func main() {
  var o, e string 
  fmt.Scan(&o, &e)
  res := make([]byte, len(o) + len(e))
  for i := 0; i < len(o); i++ {
    res[2*i] = o[i]
  }
  for i := 0; i < len(e); i++ {
    res[1+2*i] = e[i]
  }
  fmt.Println(string(res))
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    auto b(a);
    sort(ALL(b));
    if(a == b) {
        cout << "YES" << endl;
        return 0;
    }
    REP(i, n) FOR(j, i+1, n) {
        swap(a[i], a[j]);
        if(a == b) {
            cout << "YES" << endl;
            return 0;
        }
        swap(a[i], a[j]);
    }
    cout << "NO" << endl;

    return 0;
}


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

#define int long long

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

#define INF (3e9)

using namespace std;

int n;
int a[100003];

signed main()
{
    cin >> n;

    int maxa = 0;
    REP(i, n)
    {
        cin >> a[i];
        maxa = max(maxa, a[i]);
    }

    int maxr = 0;
    int rindex = 0;
    REP(i, n)
    {
        int r = min(maxa-a[i], a[i]);
        if (r >= maxr)
        {
            maxr = r;
            rindex = i;
        }
    }

    printf("%lld %lld\n", maxa, a[rindex]);

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	
	
	void run() {
		int n, m;
		List<Integer> hlist = new ArrayList<Integer>();
		while (true) {
			n = sc.nextInt(); m = sc.nextInt();
			if (n == 0 && m == 0) break;
			int[] h = new int[n+1];
			int[] w = new int[m+1];
			for (int i = 0; i < n; i++)
				h[i] = sc.nextInt();
			for (int i = 0; i < m; i++)
				w[i] = sc.nextInt();
			
			hlist.clear();
			int sum;
			for (int i = 1; i <= n; i++) {
				sum = 0;
				for (int j = 0; j < i; j++) sum += h[j];
				for (int j = 0; j <= n-i; j++) {
					hlist.add(sum);
					sum -= h[j];
					sum += h[j+i];
				}
			}
			Collections.sort(hlist);
			
			int ans = 0;
			
			for (int i = 1; i <= m; i++) {
				sum = 0;
				for (int j = 0; j < i; j++) sum += w[j];
				for (int j = 0; j <= m-i; j++) {
					int index = Collections.binarySearch(hlist, sum);
					int count = 0;
					if (index >= 0) {
						int k = index;
						while (k < hlist.size() && hlist.get(k) == sum) {
							count++;
							k++;
						}
						k = index-1;
						while (k >= 0 && hlist.get(k) == sum) {
							count++;
							k--;
						}
					}
					ans += count;
					
					sum -= w[j];
					sum += w[j+i];
				}
			}
			out.printf("%d\n",ans);
			
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    ll Q;
    cin >> Q;
    
    while(Q--){
        ll com;
        cin >> com;

        ll b, e;
        cin >> b >> e;

        if(com==0){
            // min
            ll mi = *min_element(A.begin()+b, A.begin()+e);
            p(mi);
        }
        else{
            // max
            ll ma = *max_element(A.begin()+b, A.begin()+e);
            p(ma);
        }
    }
    
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    rep(i, 100)rep(j, 100){
        if(4*i+7*j == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int par[100010];
int sub[100010];
vector <int> g[100010];

int root(int x) {
	if(par[x] == x) return x;
	return par[x] = root(par[x]);
}
void join(int x, int y) {
	x = root(x);
	y = root(y);
	if(sub[x] > sub[y]) swap(x, y);
	if(x == y) return ;
	par[x] = y;
	sub[y] += sub[x];
}

int main(int argc, char const *argv[])
{
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 0; i <= n; i++) {
		par[i] = i;
		sub[i] = 1;
	}
	for(int i = 1; i <= m; i++) {
		int p, q;
		scanf("%d %d", &p, &q);
		g[p].push_back(q);
		g[q].push_back(p);
		join(p, q);
	}
	long long ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += (sub[root(i)] - g[i].size() - 1);
	}
	ans >>= 1;
	for(int i = 1; i <= n; i++) {
		if(root(i) == root(1)) continue;
		if(root(i) == root(2)) continue;
		if(sub[root(1)] > sub[root(2)]) {
			ans += 1LL * sub[root(i)] * sub[root(1)];
			join(i, 1);
		} else {
			ans += 1LL * sub[root(i)] * sub[root(2)];
			join(i, 2);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string W;
	cin >> W;
	int Alpha[26] = { 0 };
	bool B = (true);

	for (char c : W) {
		Alpha[c - 97]++;
	}
	for (int i = 0; i < 26; i++) {
		if (Alpha[i] % 2)
			B = (false);
	}
	if (B)
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
set<int>x;
int c;
cin>>c;
for(int i=0;i<c;i++){
	int f;
	cin>>f;
	if(x.find(f)!=x.end())x.erase(f);
	else x.insert(f);
}
cout<<x.size()<<endl;
	
	return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>

int main(void)
{
	char a[100];
	char b[100];
	int n;
	
	scanf("%d",&n);
	int i;
	scanf("%s%s",a,b);

	for(i=0;i<n;i++)
		printf("%c%c",a[i],b[i]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll ans = 1;
    int up = 0, down = 0;
    for (ll i = 1; i < n; i++) {
        if (a[i] - a[i-1] > 0) {
            up = 1;
            if (down) {
                ans++;
                up = 0; down = 0;
            }
        } else if (a[i] - a[i-1] < 0) {
            down = 1;
            if (up) {
                ans++;
                up = 0; down = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define Sort(v) sort((v).begin(), (v).end())
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using G = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
ll lINF = LLONG_MAX; ll lmINF = LLONG_MIN;
int INF = INT_MAX; int mINF = INT_MIN;
int a[1000100];
int main(){
    int n; cin >> n;
    rep(i, n){
        cin >> a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);
    ll ans=0;
    ans += a[0];
    int count = 2;
    for(int i=1;count<n;count+=2, i++){
        ans +=a[i];
        if (count +1 <n) ans += a[i];
    }
    cout << ans << endl;
}

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

int n, m;
vector<int>ady[100001];
vector<int>topoSort;
vector<int>who[100001];
bool visitado[100001];
int memo[100001];

void dfs(int nodo){
    visitado[nodo] = true;
    for(int i : ady[nodo])
        if (!visitado[i])
            dfs(i);
    topoSort.push_back(nodo);
}

void topological_sort(){
    for(int i = 1; i <= n; i++)
        if(!visitado[i])
            dfs(i);
}

int dp(int nodo){
    if(who[nodo].size() == 0)//es nodo raiz
        return  1;
    if(memo[nodo])
        return memo[nodo];
    int Max = 0;
    for(auto i : who[nodo])
        memo[nodo] = max(memo[nodo], dp(i) + 1);
    return memo[nodo];
}

int maxPath(){
    topological_sort();
    //hacemos orden topologico
    // for(int i = 0; i < n; i++)
    //     cout<<topoSort[i]<<" ";
    // cout<<endl;
    // for(int i = 1; i <= n; i++){
    //     cout<<i<<": ";
    //     for(auto j : who[i])
    //         cout<<j<<" ";
    //     cout<<endl;
    // }
    // cout<<endl;
    // exit(0);
    int Max = -1;
    for(int i = 0; i < n; i++)        
        Max = max(Max, dp(topoSort[i]));
    return Max;
}

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin>>n>>m;

    while(m--){
        int a, b;
        cin>>a>>b;
        ady[a].push_back(b);
        who[b].push_back(a);
    }
    cout<<maxPath() - 1;
}

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

using namespace std;

#define PB push_back
#define MP make_pair
#define FOR( i , n ) for( int i = 0; i < (n); i++ )
#define FORR( i , n ) for( int i = ( n - 1 ); i >= 0 ; i-- )
#define DB( x ) cout << #x << " = " << x << endl;
#define OUT( a , n ) for( int J = 0; J < (n); J++ )cout<< (a)[J] << " \n"[J == (n) - 1 ]
#define WAIT cout << flush , system("PAUSE");
#define CONTAINS(a, x) ((a).find(x) != (a).end())
#define endl '\n'

typedef pair<int, int> pii;
typedef long long ll;

const int N = 1e6 + 100;

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

	ll q , h,   s , d;
	ll n;
	cin >> q >> h >> s >> d;
	q *= 4;
	h *= 2;

	ll f = min(q , min(h , s));
	cin >> n;

	ll res = min(f * n , (n / 2) * d + (n % 2 == 1) * f);
	cout << res << endl;



	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end() 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    ll m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    cout<<!(m1==m2)<<endl;
}

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

int main()
	{
		int n,m;
		cin>>n>>m;
		vector< vector<int> > vec(10,vector<int>(10,-1));
		for (int i=0;i<m;i++)
			{
				int k;
				cin>>k;
				//vec[i].reserve(k);
				for (int j=0;j<k;j++)
					{
						cin>>vec[i][j];
						vec[i][j]--;
					}
			}
		std::vector<int> p(m);
		for(int i=0;i<m;i++) cin>>p[i];
		int ans=0;
		/*for (int i = 0; i < m; ++i)
		{
			/* code 
			for (int j=0;j<vec[i].size();j++)
				cout<<vec[i][j]<<endl;
		}*/
		
		for (int i=0;i<(1<<n);i++)
			{
				int ok=1;
				for (int j=0;j<m;j++)
					{//cout<<2<<endl;
						int c=0;
						for (int id : vec[j])
						{
							if((i>>id)&1) c++;
							//cout<<1<<endl;
						}
						//cout<<c<<endl;
						c%=2;
						if(c!=p[j]) ok=0;
					}
				if(ok)
				{
					ans++;
				}
			}
		cout<<ans<<endl;
	}

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

ht = [[0 for i in range(10)] for j in range(10)]

for i in range(1,n+1):
    temp = str(i)
    head = int(temp[0])
    tail = int(temp[-1])
    ht[head][tail] += 1

ans = 0
for i in range(1,n+1):
    temp = str(i)
    head = int(temp[0])
    tail = int(temp[-1])
    ans += ht[tail][head]

# print(ht)


print(ans)


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

int main() {
	int n;
	cin >> n;
	multiset<int> d;
	rep(i, n) {
		int a;
		cin >> a;
		auto it = d.lower_bound(a);
		if (it == d.begin()) {
			d.insert(a);
		} else {
			it--;
			d.erase(it);
			d.insert(a);
		}
	}
	cout << d.size() << endl;
}


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

using namespace std;
using ll = long long;

class UnionFind {
public:
vector<ll> parent;
UnionFind(int n) {
    parent = vector<ll>(n, -1);
}
int root(int a) {
    if(parent[a] < 0) return a;
    return parent[a] = root(parent[a]);
}
int size(int a) {
    return -parent[root(a)];
}
bool same(int x, int y){
    return root(x) == root(y);
}
bool unite(int a, int b) {
    a = root(a);
    b = root(b);
    if(a == b) {
        return false;
    }
    if(size(a) < size(b)) swap(a, b);
    parent[a] += parent[b];
    parent[b] = a;
    return true;
}
};

int main(){

    int n, k, l;
    cin >> n >> k >> l;
    UnionFind road(n), rail(n);
    for(int i = 0; i < k; ++i) {
        int p, q;
        cin >> p >> q;
        --p, --q;
        road.unite(p, q);
    }
    for(int i = 0; i < l; ++i) {
        int p, q;
        cin >> p >> q;
        --p, --q;
        rail.unite(p, q);
    }

    map<pair<int, int>, int> mp;
    for(int i = 0; i < n; ++i) {
        ++mp[{road.root(i), rail.root(i)}];
    }

    for(int i = 0; i < n; ++i) {
        cout << mp[{road.root(i), rail.root(i)}] << ' ';
    }
    cout << endl;

}


Measured memory_bytes: 15104
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

int main() {
string s,t="";
cin>>s;
rep(i,s.size()){
  if(i%2==0){
    t+=s[i];
  }
}
cout<<t<<endl;
return 0;
}

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

m = ((n-1)*(n-2))//2
if k > m:
    print(-1)
    exit()

print(n-1+m-k)
for i in range(1, n):
    print(str(1) + ' ' + str(i+1))

s = 2
d = 3
for i in range(m-k):
    print(str(s) + ' ' + str(d))
    d += 1
    if d > n:
        s += 1
        d = s+1

Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
string query(string a,string b)
{
    if(a.size()+1!=b.size())
        return "No";
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            return "No";
    }
    return "Yes";
}
int main()
{
    string a;
    string b;
    cin>>a>>b;
    cout<<query(a,b)<<endl;
    return 0;
}


Measured memory_bytes: 3624
from collections import *

H, W = list(map(int, input().split()))
S = [input() for i in range(H)]

ans = 0
INF = float('inf')

for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue

        dist = [[INF for i in range(W)] for j in range(H)]
        visited = [[False for i in range(W)] for j in range(H)]

        q = deque()
        q.append((i, j, 0))
        
        while q:
            i, j, c = q.popleft()

            if visited[i][j]: continue
            visited[i][j] = True
            dist[i][j] = c
            ans = max(ans, c)
            for a, b in [(1,0), (-1,0), (0,1), (0,-1)]:
                x = i+a
                y = j+b

                if 0 <= x < H and 0 <= y < W and S[x][y] == '.' and not visited[x][y]:
                    q.append((x, y, c+1))

print(ans)


Measured memory_bytes: 3316
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0]*(N+1) # 残り
cnt = 0
C[0] = A[0]
for i in range(1, N+1):
  #i-1番目の勇者が攻撃した後、i番目の街に残っているモンスターはC[i-1]体。N+1番目の街ではC[N]
  #i番目の勇者B[i-1]はi番目の街A[i-1]を攻撃したあと余力があれば(i+1)番目A[i]まで攻撃できる。
  
  if C[i-1] > B[i-1]: #余力がない
    C[i] = A[i]
    cnt += A[i-1] + B[i-1] -C[i-1] #i番目の街で倒したモンスター
    
  elif C[i-1] <= B[i-1]:
    if A[i] -B[i-1] + C[i-1] >=0:
      C[i] = A[i] -B[i-1] + C[i-1]
      cnt += A[i-1]
      
    else: #余力が有り余っている場合
      C[i] = 0
      cnt += A[i-1]
      


if B[N-1]-C[N-1] > 0:
  ans = cnt + min(A[N], (B[N-1] - C[N-1]))
else:
  ans = cnt
print(ans)

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	long long v[210000];
	for(int i=0;i<n;i++)
	cin>>v[i];
	sort(v,v+n);
	multiset<long long> ssi;
	for(int i=0;i<n;i++)
	{
	    ssi.insert(v[i]);
	}
	int res=0;
	while(!ssi.empty())
	{
	    long long x=*ssi.rbegin();
	   
	   while (!ssi.empty()) {
		long long x = *ssi.rbegin();
		ssi.erase(ssi.find(x));
		long long now = 1;
		while (now <= x)
			now *= 2;
		auto it = ssi.find(now - x);
		if (it == ssi.end())
			continue;
		ssi.erase(it);
		++res;
	}
	}
	cout<<res<<'\n';
	return 0;
}


Measured memory_bytes: 11264
using System;

namespace D___Brick_Break
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var input = Console.ReadLine ().Split (' ');
            var a = new int[n];
            for (var i = 0; i < n; i++)
            {
                a[i] = int.Parse (input[i]);
            }
            var count = 0;
            var c = 0;
            var d = 1;
            for (var i = c; i < a.Length; i++)
            {
                if (a[i] != d)
                    count++;

                else
                {
                    d++;
                    c = i + 1;
                    continue;
                }
            }
            if (count == a.Length)
                Console.WriteLine (-1);

            else
                Console.WriteLine (count);
        }
    }
}

Measured memory_bytes: 32732
#include <iostream>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a, b;
while(cin >> a >> b && (a > 0 || b > 0))
if (a < b) cout << a << " " << b << "\n";
else cout << b << " " << a << "\n";
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll nums[200009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>nums[i];
    rep(i,N-1) nums[i+1]+=nums[i];
    
    ll mn=LLINF;
    rep(i,N-1){
        ll x=nums[i];
        ll y=nums[N-1]-x;
        chmin(mn,abs(x-y));
    }
    cout1(mn)
}

Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N;
    string S; cin >> S;
    ll ans = 0;
    for(int i=1;i<N-1;i++){
        string s_1, s_2;
        s_1 = S.substr(0, i);
        s_2 = S.substr(i);
        ll c = 0;
        rep(i, 26){
            if(count(all(s_1), 'a'+i) && count(all(s_2), 'a'+i)) c++;
        }
        chmax(ans, c);
    }
    cout << ans;
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int num = sc.nextInt();
		int[] arr = new int[num];
		for (int i = 0; i < num; i++) {
			arr[i] = sc.nextInt();
		}
		
		int countChange = 0;
		for (int i = 0; i < num; i++) {
			int minj = i;
			int j;
			for (j = i; j < num; j++) {
				if (arr[j] < arr[minj]) {
					minj = j;
				}
			}
			
			if (i != minj) {
				int temp = arr[i];
				arr[i] = arr[minj];
				arr[minj] = temp;
				countChange++;
			}
		}
		
		
		for (int i = 0; i < num; i++) {
			System.out.print(arr[i]);
			if (i != num - 1)
				System.out.print(" ");
		}
		System.out.println("");
		System.out.println(countChange);
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll h,w,k;
  cin>>h>>w>>k;
  vector<string> field(h);
  REP(i,h)cin>>field[i];

  ll ans=0;
  REP(bith,(1<<h)){
    REP(bitw,(1<<w)){

    ll cnt=0;
      REP(H,h){
        if(!(1&(bith>>H)))
          continue;

        REP(W,w){
          if(!(1&(bitw>>W)))
            continue;
          if(field[H][W]=='#')
            cnt++;
        }
      }

    if(cnt==k)
      ans++;

    }
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 3652
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mod = 10 ** 9 + 7

if len(a) != len(set(a)) or len(b) != len(set(b)):
    print(0)
    exit()

a_cnt = [0 for _ in range(n*m+1)]
a_flg = [False for _ in range(n*m+1)]
for x in a:
    a_cnt[x] = 1
    a_flg[x] = True
for i in range(n*m):
    a_cnt[i+1] += a_cnt[i]

b_cnt = [0 for _ in range(n*m+1)]
b_flg = [False for _ in range(n*m+1)]
for x in b:
    b_cnt[x] = 1
    b_flg[x] = True
for i in range(n*m):
    b_cnt[i+1] += b_cnt[i]

ans = 1
cnt = 0
for x in range(n*m, 0, -1):
    if a_flg[x]:
        if b_flg[x]:
            cnt += 1
            continue
        else:
            ans *= (m - b_cnt[x])
    else:
        if b_flg[x]:
            ans *= (n - a_cnt[x])
        else:
            ans *= (n - a_cnt[x]) * (m - b_cnt[x]) - cnt

    ans %= mod
    cnt += 1

print(ans)

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  vector<bool> remainders(110, false);
   
  for (int i = 1; i < 110; i++) {
    int num = (a * i) % b;
    if (remainders[num]) break;
    if (num == c) {
      cout << "YES" << endl;
      return 0;
    }
    remainders[num] = true;
  }
  
  cout << "NO" << endl;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int Mod;

int n;
int dp[512][256][256];
int L[512],R[512];
struct Rec{
	int id,u,v;
}rec[512]; int m;
bool operator<(Rec x,Rec y){return x.u<y.u||x.u==y.u&&x.v<y.v;}
inline void add(int &x,int y){x=(x+y)%Mod;}
inline void add(int &x,ll y){x=(x+y)%Mod;}
int main()
{
	//freopen("data.in","r",stdin);
	//freopen("A.out","w",stdout);

	scanf("%d%d",&n,&Mod);
	for (int i=0;i<n;i++) L[i]=ceil(sqrt(n*n-i*i)),R[i]=min(floor(sqrt(4*n*n-i*i)),2.0*n-1),rec[++m]=(Rec){i,L[i]-1,R[i]};
	for (int i=n;i<n+n;i++) L[i]=0,R[i]=min(floor(sqrt(4*n*n-i*i)),2.0*n-1),rec[++m]=(Rec){i,R[i],0};
	//for (int i=0;i<m;i++) printf("%d: L %d R %d\n",i,L[i],R[i]);
	sort(rec+1,rec+m+1);
	for (int i=0;i<=n;i++) dp[0][0][i]=1;
	for (int i=0;i<m;i++){
		for (int j=0;j<=i&&j<=n;j++)
			for (int k=0;k+j<=n;k++){
				if (!dp[i][j][k]) continue;
				int x=rec[i+1].id;
				if (x>=n){
					if (R[x]+1-i+j>0) add(dp[i+1][j][k],1LL*dp[i][j][k]*(R[x]+1-i+j));
					continue;
				}
				if (L[x]-i+j>0) add(dp[i+1][j][k],-1LL*dp[i][j][k]*(L[x]-i+j));
				if (k){
					if (R[x]+1-m+k>0) add(dp[i+1][j+1][k-1],1LL*dp[i][j][k]*(R[x]+1-m+k));
				}
			}
	}
	int ans=0;
	for (int i=0;i<=n;i++) add(ans,dp[m][i][0]);
	printf("%d\n",(ans+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 72572
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int bingo[3][3];
  bool result[3][3]={false};
  bool ans=false;
  rep(i,3){
    rep(j,3){
      cin >> bingo[i][j];
      result[i][j]=false;
    }
  }
  int n;
  cin >>n;
  rep(i,n){
    int a;
    cin >> a;
    rep(j,3){
      rep(k,3){
        if(bingo[j][k]==a){
          result[j][k]=true;
        }
        //cout << result[j][k]<<endl;
      }
    }
  }
  rep(i,3){
    if(result[i][0]&&result[i][1]&&result[i][2]){ans=true;}
    if(result[0][i]&&result[1][i]&&result[2][i]){ans=true;}
  }
  if(result[0][0]&&result[1][1]&&result[2][2]){ans=true;}
  if(result[0][2]&&result[1][1]&&result[2][0]){ans=true;}
  if(ans){
    cout << "Yes" <<endl;
  }
  else cout << "No" <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
 
int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   int cntg, cntk;
   cntg = cntk = 0;
   REP(i, N){
      cin >> A[i];
      if(A[i] % 2){
         cntk++;
      }
      else{
         cntg++;
      }
   }

   if(cntk % 2 == 0){
      cout << "YES" << endl;
   }
   else{
      cout << "NO" << endl;
   }



   return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

//50 
typedef long long ll;

int main() {
	ll l, r;
    cin >> l >> r;
    if (r / 2019 > l / 2019) {
		cout << 0;
	}else {
		ll minn = 1e18 + 10000;
		for (ll i = l; i < r; ++i) {
			for (ll j = i + 1; j <= r; ++j) {
				minn = min(minn,(i * j) % 2019);
			}
		} 
		cout << minn;
	}
}
	


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

    int n = s.length();

    int t = n;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) t = min(t, max(i, n - i));
    }

    cout << t << endl;

    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3

N, M, X = map(int, input().split())

C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])

result = -1
for i in range(1 << N):
    t = [0] * M
    c = 0
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        c += C[j]
        for k in range(M):
            t[k] += A[j][k]
    if all(x >= X for x in t):
        if result == -1:
            result = c
        else:
            result = min(result, c)
print(result)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,m,u[N],v[N],dp[N],ans[N];
vector<int> from[N];

int rec(int pos){
	int &ret = dp[pos];
	if (ret != -1){
		return ret;
	}
	ret = 0;
	for (int &x : from[pos]){
		ret = max(ret, rec(x) + 1);
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i=1;i<=n-1+m;i++){
		cin >> u[i] >> v[i];
		from[v[i]].push_back(u[i]);
	}
	memset(dp,-1,sizeof(dp));
	for (int i=1;i<=n;i++){
		dp[i] = rec(i);
	}
	for (int i=1;i<=n-1+m;i++){
		if (dp[v[i]] == dp[u[i]] + 1){
			ans[v[i]] = u[i];
		}
	}
	for (int i=1;i<=n;i++){
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 9856
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
 const ll mod = 1000000007;

 ll gdc(ll a, ll b) {
	 ll ta = a, tb = b;
	 if (a < b) {
		 ta = b;
		 tb = a;
	 }

	 ll r = ta % tb;
	 while (r != 0) {
		 ta = tb;
		 tb = r;
		 r = ta % tb;
	 }
	 return tb;
 }

ll a(ll n, ll c, ll d) {
	ll lcm = c * d / gdc(c, d);
	return n - n / c - n / d + n / lcm;
}

int main() {
	ll N;
	cin >> N;
	
	vector<pair<ll, ll>> BA;
	for (ll i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		BA.pb(mp(b, a));
	}

	sort(BA.begin(), BA.end());

	ll sum = 0;
	for (ll i = 0; i < N; i++) {
		sum += BA[i].second;
		if (BA[i].first < sum) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int a[5];
	int ans;
	rep(i,0,5){
		
	cin>>a[i];
	if(!a[i])
	ans=i;
}
cout<<ans+1;
		
}



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

int main(){
  int i = 0;
  char str[100000];
  
  fgets(str, 100000, stdin);

  while(str[i] != '\n'){
    if('a' <= str[i] && str[i] <= 'z'){
      str[i] = str[i] - 'a' + 65;
    }
    i++;
  }
  
  cout << str << flush;

  return 0;
} 

Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
int a[maxn][3];
vector<int> v[2];

struct Fw {
    int t[maxn];

    Fw() {
        memset(t, 0, sizeof(t));
    }

    void put(int pos, int delta) {
        for (int i = pos; i < maxn; i |= i + 1)
            t[i] += delta;
    }

    int get(int r) {
        int res = 0;
        for (int i = r - 1; i >= 0; i = (i & (i + 1)) - 1)
            res += t[i];
        return res;
    }
};

pair<int, int> countInv(vector<int> v) {
    Fw fw;
    int n = sz(v);
    vector<int> p(n, -1);
    forn (i, n)
        p[v[i]] = i;
    forn (i, n)
        assert(p[i] != -1);
    int r0 = 0, r1 = 0;
    forn (i, n) {
        int steps = p[i] - fw.get(p[i]);
        if (steps % 4 >= 2)
            r0 ^= 1, r1 ^= 1, steps -= 2;
        if (steps % 2 == 1) {
            if (i % 2 == 0)
                r0 ^= 1;
            else
                r1 ^= 1;
        }
        fw.put(p[i], 1);
    }
    return {r0, r1};
}

int main() {
    #ifdef LOCAL
    assert(freopen("e.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    forn (j, 3)
        forn (i, n) {
            cin >> a[i][j];
            --a[i][j];
        }
    int inv[4] = {0, 0, 0, 0};
    forn (i, n) {
        int id = -1;
        int *b = a[i];
        if (b[0] == b[1] - 1 && b[0] == b[2] - 2 && b[0] % 3 == 0) {
            id = b[0] / 3;
        }
        reverse(b, b + 3);
        if (b[0] == b[1] - 1 && b[0] == b[2] - 2 && b[0] % 3 == 0) {
            id = b[0] / 3;
            inv[i % 4] ^= 1;
        }
        reverse(b, b + 3);
        if (id == -1 || id % 2 != i % 2) {
            cout << "No\n";
            return 0;
        }
        v[i % 2].push_back(id / 2);
    }
    //for (int x: v[0])
        //cerr << x << ' ';
    //cerr << '\n';
    //for (int x: v[1])
        //cerr << x << ' ';
    //cerr << '\n';
    
    int inv2[4] = {0, 0, 0, 0};
    tie(inv2[3], inv2[1]) = countInv(v[0]);
    tie(inv2[0], inv2[2]) = countInv(v[1]);
    forn (i, 4)
        cerr << inv[i] << ' ';
    cerr << '\n';
    forn (i, 4)
        cerr << inv2[i] << ' ';
    cerr << '\n';
    if (inv[0]) {
        forn (j, 4)
            inv[j] ^= 1;
    }
    if (inv2[0]) {
        forn (j, 4)
            inv2[j] ^= 1;
    }
    forn (j, 4) {
        if ((inv[j] + inv[j ^ 2]) % 2 != (inv2[j] + inv2[j ^ 2]) % 2) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}


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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n)cin >> p[i];

	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p[i] != max(p[i - 1], max(p[i], p[i + 1])) && p[i] != min(p[i - 1], min(p[i], p[i + 1]))) {
			ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10,mod=1e9+7;
int a,b,f[maxn],k;
map<int,int,greater<int>> dp,dp2;
unordered_map<int,int> fre;
void plusle(int &a,int b){
    a+=b;if(a>=mod)a-=mod; return;
}
void minun(int &a,int b){
    a-=b; if(a<0)a+=mod; return;
}
int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int mul(int a,int b){
    return (int)(((long long)a*b)%mod);
}

int main(){
    int n;
    scanf("%d%d",&n,&k);
    fre.reserve(1<<17);
    fre.max_load_factor(0.25);
    int cc=n,pt=1;
    while(cc){
      //  cout<<cc<<'\n';
        int x=n/cc;
        dp[x]=(n/x-n/(x+1));
        fre[x]=dp[x];
        cc=(n/(x+1));
    }
    int sum=0;
  //  for(auto i:dp)
    //printf("%d %d\n",i.first,i.second);
    while(k--){
        //cout<<'g'<<'\n';
    int last=-1;
    //dp2.clear();
    for(auto &it:dp){
        dp2[it.first]=(last==-1)?it.second:add(last,it.second);
        last=dp2[it.first];
    }
    for(auto &it:dp){
        it.second =mul(fre[it.first],dp2[n/(it.first)]);
    }
    }
    printf("%d\n",dp[n]);
}


Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    for(ll i=0; i < k; i++){
        if(i % 2){
            if(b % 2){
                b -= 1;
            }
            b /= 2;
            a += b;
        }else{
            if(a % 2){
                a -= 1;
            }
            a /= 2;
            b += a;
        }
    }
    cout << a << " " << b << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


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

    ll a,b,c; cin >> a >> b >> c;
    cout<< max(ll(0),(c-(a-b)));

    return 0;
    
}



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

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	string input;
	cin>>input;

	vector<int> left;
	vector<int> right;

	for(int x=0;x<input.size();x++)
	{
		if(input[x]=='L')
		{
			left.push_back(x+1);
		}
	}

	for(int x=input.size()-1;x>=0;x--)
	{
		if(input[x]=='R')
		{
			right.push_back(x+1);
		}
	}

	int curr = 0;

	int answer[input.size()];
	memset(answer,0,sizeof(answer));

	for(int x=0;x<input.size();x++)
	{
		if(input[x]=='R')
		{
			int start = x+1;

			while(start >= left[curr])
			{
				curr+=1;
			}

			int end = left[curr];

			int moves = end - start;

			if(moves%2 == 0)
			{
				answer[end - 1] += 1;
			}
			else
			{
				answer[end - 2] += 1;
			}
		}
	}


	curr = 0;
	for(int x = input.size()-1;x>=0;x--)
	{
		if(input[x]=='L')
		{
			int end = x+1;

			while(end <= right[curr])
			{
				curr+=1;
			}

			int start = right[curr];

			int moves = end - start;

			if(moves%2==0)
			{
				answer[start-1] += 1;
			}
			else
			{
				answer[start] += 1;
			}
		}
	}

	for(int x=0;x<input.size();x++)
	{
		cout<<answer[x]<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 1484
/**
  *  Worg
  */
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>


int main() {
    std::string s; std::cin >> s;
    int ans = 0, prv = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        ans += 1;
        if (prv != 1 || s[i] != s[i - 1]) {
            prv = 1;
        } else if (i + 1 == (int)s.size()) {
            ans -= 1;
        } else {
            prv = 2;
            i += 1;
        }

    }

    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
import collections
n=int(input())
a=list(map(int,input().split()))

d=collections.Counter(a)
#print(d)
ans=0
for v in d.values():
    ans+=v*(v-1)//2
#print(ans)

for i in range(n):
    ans2=ans
    v=d[a[i]]
    ans2-=v*(v-1)//2
    v-=1
    ans2+=v*(v-1)//2
    print(ans2)

Measured memory_bytes: 26772
N = int(input())
A = list(map(int, input().split()))
 
def gcd(a,b):
  if b==0:
    return a
  else:
  	return gcd(b, a%b)

L=[]
R=[]
L.append(0)
R.append(0)

for i in range(N):
  L.append(gcd(L[i],A[i]))
  R.append(gcd(R[i],A[N-i-1]))

R.reverse()

#Res=[]
res=0
for i in range(N):
  #Res.append(gcd(L[i],R[i+1]))
  res=max(res,gcd(L[i],R[i+1]))
print(res)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "blist"

using namespace std;

const int maxn = 1e5 + 69;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if(fopen(task".in", "r")){
        freopen(task".in", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(b * d, max(b * c, max(a * c, a * d)));


}
/*
10 3
11 4
12 5
*/


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
using namespace std;
int _abs(int x){
    if(x < 0)
        x = -x;
    return x;
}
#define _min(a, b) (a > b ? b : a)
void init(vector<int> &v){
    for(int i = 0; i < v.size(); ++i){
        v[i] = 0;
    }
}
int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> re;
    re.resize(N);
    init(re);
    for(int i = 1; i < N; ++i){
        for(int j = i + 1; j <= N; ++j){
            if(i <= X){
                int l_1 = _abs(j - i);
                int l_2 = _abs(X - i) + 1 + _abs(Y - j);
                l_1 = _min(l_1, l_2);
                re[l_1]++;
            }
            else{
                int l_1 = _abs(j - i);
                int l_2 = _abs(X - i) + 1 + _abs(Y - j);
                l_1 = _min(l_1, l_2);
                re[l_1]++;
            }
        }
    }
    for(int i = 1; i < N; ++i){
        cout << re[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int A, B;
  scanf("%d %d",&A, &B);

  if(A==0 && B==0)
  {
      printf("0\n");
  }
  else if(A+B >= A-B && A+B> A*B)
  {
      printf("%d", A+B);

  }
  else if(A-B > A+B && A-B >A*B)
  {
      printf("%d", A-B);
  }
  else if(A*B >A+B && A*B> A-B)
  {
      printf("%d",A*B);
  }
}



Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void showStr(string str) { cout << str << endl; }
void showInt(int num) { cout << num << endl; }
void showAB(bool isA, string a, string b) {
    if (isA) {
        cout << a << endl;
    } else {
        cout << b << endl;
    }
}
void showYesNo(bool isYes) { showAB(isYes, "Yes", "No"); }
void showYES_NO(bool isYES) { showAB(isYES, "YES", "NO"); }
int getInputToInt() {
    int a;
    cin >> a;
    return a;
}
string getInputToStr() {
    string str;
    cin >> str;
    return str;
}

int main() {
    int n = getInputToInt();
    int max4 = n / 4 + 1;
    int max7 = n / 7 + 1;

    bool is = false;
    for (size_t i = 0; i < max4; i++) {
        for (size_t j = 0; j < max7; j++) {
            if(i * 4 + j * 7 == n) {
                is = true;
            }
        }
    }

    showYesNo(is);

    return 0;
}


Measured memory_bytes: 256