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

template <typename T, typename _ = void>
struct is_container : std::false_type {};
template <typename T>
struct is_container<T, std::void_t<decltype(std::declval<T>().begin()),
                                   decltype(std::declval<T>().end())>>
    : std::true_type {};
template <typename T, typename _ = void>
struct is_pair : std::false_type {};
template <typename T>
struct is_pair<T, std::void_t<decltype(std::declval<T>().first),
                              decltype(std::declval<T>().second)>>
    : std::true_type {};
template <typename T>
void debug(const T& v) {
  if constexpr (is_pair<T>::value) {
    std::cerr << "{";
    debug(v.first);
    std::cerr << ", ";
    debug(v.second);
    std::cerr << "}";
  } else if constexpr (is_container<T>::value) {
    std::cerr << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
      if (it != v.begin()) std::cerr << ", ";
      debug(*it);
    }
    std::cerr << "}";
  } else {
    std::cerr << v;
  }
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  debug(value);
  std::cerr << ", ";
  debug(args...);
}
#if DEBUG
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  if constexpr (std::is_same<T, bool>::value) {
    std::cout << (value ? "Yes" : "No");
  } else {
    std::cout << value;
  }
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  write_to_cout(value);
  std::cout << ' ';
  write_to_cout(args...);
}
#define wt(...)                 \
  do {                          \
    write_to_cout(__VA_ARGS__); \
    cout << '\n';               \
  } while (0)

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
  for (T& vi : v) is >> vi;
  return is;
}

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

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

#include <boost/hana/functional/fix.hpp>
auto Fix = boost::hana::fix;

using ll = long long;

template <typename T>
using low_priority_queue =
    std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, n, d, x);
  V<int> a(n);
  cin >> a;
  int ans = x;
  rep(i, n) for (int j = 1; j <= d; j += a[i])++ ans;
  wt(ans);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[100005];
map<int,int> mp;

int main(void){
	scanf("%d",&n);
	bool flag0=true;
	int zo=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]!=0)flag0=false;
		else{
			zo++;
		}
		mp[a[i]]++;
	}
	if(flag0){
		printf("Yes\n");
		return 0;
	}
	if(n%3!=0){
		printf("No\n");
		return 0;
	}
	if(zo*3==n && mp.size()==2){
		printf("Yes\n");
		return 0;
	}
	if(mp.size()!=3){
		printf("No\n");
		return 0;
	}
	int sum=0;
	bool ok=true;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		if(n/3!=(*it).second)ok=false;
		sum^=(*it).first;
	}
	if(sum!=0)ok=false;
	printf("%s\n",ok?"Yes":"No");
	return 0;
} 

Measured memory_bytes: 4224
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <string>
using namespace std;
typedef long long ll;



int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n);
    vector<pair<int, int>> x(n);
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x[i] = make_pair(a[i], i);
    }
    
    sort(x.begin(), x.end());
    
    int ans = 0;
    for (int i = 0; i < n; i+=2) {
        if (i % 2 != x[i].second % 2) ans++;
    }
    
    cout << ans << endl;
    
}


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

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

vector<string> split(string s, const string &b){
  vector<string> res;
  while(1){
    int pos = s.find(b);
    if(pos == -1) break;
    res.push_back(s.substr(0,pos));
    s = s.substr(pos+1,s.size());
  }
  if(s != "") res.push_back(s);
  return res;
}

int main(){
  string s, t;
  while(cin >> s, s != "."){
    cin >> t;
    vector<string> as = split(s,"\""), bs = split(t,"\"");
    if(as.size() != bs.size()){
      cout << "DIFFERENT" << endl;
      continue;
    }
    int even = 0, odd = 0;
    rep(i, as.size()){
      if(i % 2 == 0) even += as[i] != bs[i];
      else odd += as[i] != bs[i];
    }
    if(even != 0 or odd > 1) cout << "DIFFERENT" << endl;
    else if(odd == 1) cout << "CLOSE" << endl;
    else cout << "IDENTICAL" << endl;
  }
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

bool is_prime(int n) {
	for (int i = 2; i*i <= n; ++i) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}
int main() {
	int x; cin >> x;
	while (true) {
		if (is_prime(x)) {
			cout << x << endl;
			return 0;
		}
		x++;
	}
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int abcnt = 0;
    int bcnt = 0;
    REP(i,n){
        if(s[i]=='a'){
            if(abcnt<a+b){
                abcnt++;
                puts("Yes");
                continue;
            }
        }else if(s[i]=='b'){
            if(abcnt<a+b&&bcnt<b){
                abcnt++;
                bcnt++;
                puts("Yes");
                continue;
            }
        }
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 848
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int a, b, c, d;
int flag[150];
int main()
{
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int ans = 0;
	for(int i = a; i <= b; i++) flag[i]++;
	for(int i = c; i <= d; i++) flag[i]++;
	for(int i = 0; i <= 100; i++) if(flag[i] == 2) ans++;
	if(ans != 0) ans--;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

template<typename type> vector<type> divisor(type n)
{
    vector<type> res;
    for(type i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            res.push_back(i);
            if(i * i != n) res.push_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

void solve()
{
    ll x; cin >> x;
    vector<ll> divisors = divisor(x); 
    ll a = 1;
    while(true)
    {
        for(auto& num : divisors)
        {
            ll b = a - x / num;
            if((ll)pow(a, 5) - (ll)pow(b, 5) == x)
            {
                cout << a << " " << b << endl;
                return;
            }
        }
        a++;
    }
}

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

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

int main() {
	long long int l[86] = {};
	int n;
	cin >> n;
	l[0] = 2;
	l[1] = 1;
	for (int i = 2; i < n+1; i++)l[i] = l[i - 1] + l[i - 2];
	cout << l[n] << endl;

	return 0;
}

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

int main() {
  
  int x ;
  cin >> x ;
  
  int s1 , s2 , s3 ;
  s1 = x / 100 ;
  s2 = (x - s1 * 100 ) / 10 ;  
  s3 = x - s1 * 100 - s2 * 10 ;

  cout << s1 + s2 + s3 << endl;
  
  
  
  
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

int main() {
  ll k, s;
  cin >> k >> s;

  ll ans = 0;
  rep(x, k + 1) rep(y, k + 1) {
    ll z = s - x - y;
    if (z >= 0 && z <= k) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 3011

using namespace std;

const int MOD = (int)1e9 + 7;

int n, dp[N][N], pre[N];
string s;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> s;
	for(int i=0; i<n; i++) {
		for(int j=0; j<i+1; j++) {
			if(i == 0) dp[i][j] = 1;
			else {
				dp[i][j] = 0;
				if(s[i-1] == '>') dp[i][j] = (i > 0) ? (pre[i-1] + MOD - (j > 0 ? pre[j-1] : 0)) % MOD : 0;
				else dp[i][j] = (j > 0) ? pre[j-1] : 0;
			}
		}
		for(int j=0; j<i+1; j++) {
			pre[j] = dp[i][j];
			if(j > 0) pre[j] = (pre[j] + pre[j-1]) % MOD;
		}
	}
	int ans = 0;
	for(int i=0; i<n; i++)
		ans = (ans + dp[n-1][i]) % MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 69248
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
#define All(v) (v).begin(),(v).end()
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define REPS(i,n) for(int i = 1; i <= (int)n; i++)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define FORS(i,m,n) for(int i = m; i <= n; i++)
#define INF 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

int main (){
    string s;
    ll k;
    cin >> s >> k;
    if(k <= s.size()){
        REP(i,k){
            if(s[i] != '1'){
                cout << s[i] << "\n";
                return 0;
            }
        }
        cout << 1 << "\n";
    }else{
        REP(i,s.size()){
            if(s[i] != '1'){
                cout << s[i] << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
N = int(input())
#N,A,B = map(int,input().split())
B_list = list(map(int,input().split()))
#X1_list = [int(input()) for i in range(N)]
#X2_list = [list(map(int,input().split())) for i in range(N)]
target =  [0] * N
target[0] = B_list[0]
target[1] = B_list[0]
for i in range(1,N-1):
    #print(target)
    if B_list[i-1] > B_list[i]:
        target[i] = B_list[i]
        target[i+1] = B_list[i]
    else:
        target[i+1] = max(B_list[i-1],B_list[i])
#print(target)
print(sum(target))

Measured memory_bytes: 3064
#include <iostream>
#include<stdio.h>
using namespace std;

int main() {
	int a,b,d,r;
	double  f;
	cin>>a>>b;
	d = a/b;
	r = a%b;
	f = (double)a/b;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}


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

const double PI = 3.141592653589;

int main() {
	int a, b, i = 0;
	char op;
	int answer[20000];

	while(1){
		cin >> a >> op >> b;

		if(op == '+') { answer[i] = a + b; }
		else if(op == '-') { answer[i] = a - b; }
		else if(op == '*') { answer[i] = a * b; }
		else if(op == '/') { answer[i] = a / b; }
		else if(op == '?') { break; }
		i++;
	}

	for (int j = 0; j < i; j++) {
		cout << answer[j] << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    vector<int> a(3);
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int sum=0;
    for(int i=0;i<3;i++){
        sum+=a[i];
    }
    if(0==(3*a[2]-sum)%2){
        cout<<(3*a[2]-sum)/2<<endl;
    }else{
        cout<<(3*(a[2]+1)-sum)/2<<endl;
    }
    return 0;
}

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

A = []
B = []

for i in range(n):
   a, b = map(int, input().split())
   A.append(a)
   B.append(b)

A.sort()
B.sort()

ans = 0

if n % 2 == 1:
    l1 = A[int(n/2)]
    r1 = B[int(n/2)]
    ans = r1 - l1 + 1
else:
    l2 = A[int(n/2)-1] + A[int((n/2))]
    r2 = B[int(n/2)-1] + B[int((n/2))]
    ans = r2 - l2 + 1

print(ans)




Measured memory_bytes: 25368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    int k = 1;
    int d[100];
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> d[i];
    }
    sort(d,d + N);
    for(int i = N - 1;i >= 1;i--){
        //printf("%d\n",d[i]);
        if(d[i] > d[i - 1]){
            k++;
        }
    }
    cout << k << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(100010);
    rep(i, N){
        int a;
        cin >> a;
        A[a]++;
    }
    
    int ans = 0;
    rep(i, 100000){
        ans = max(ans, A[i] + A[i + 1] + A[i + 2]);
    }
    
    output(ans);
    
    return 0;
}

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

static const auto fast_io = [] {
 ios_base::sync_with_stdio(false); 
 cin.tie(nullptr); cout.tie(nullptr); 
 return nullptr;
}();

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int rnd() {
 return uniform_int_distribution<int> (1, (int) 1e9) (rng);
}

template<class A> 
A rnd(A x, A y) {
 return uniform_int_distribution<A> (x, y) (rng);
}

string to_string(string s) {
 return '"' + s + '"';
}

string to_string(const char* ch) {
 return to_string((string)ch);
}

string to_string(char ch) {
 return (string)"'" + ch + (string)"'";
}

string to_string(bool b) {
 return (b ? "true" : "false");
}

template<class A, class B>
string to_string(pair<A, B> p) {
 return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<class A>
string to_string(A a) {
 string res = "{";
 bool first = true;
 for(const auto& x: a) {
  if(first == false) res += ", ";
  first = false;
  res += to_string(x);
 }
 res += "}";
 return res;
}

template<class A, class B, class C>
string to_string(priority_queue<A, B, C> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(priority_queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(stack<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 return to_string(res);
}

template<class A>
string to_string(queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.front());
  a.pop();
 }
 return to_string(res);
}

vector<string> __vector_tuple;
template<int index, class... A>
struct print_tuple {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<index>(a)));
  print_tuple<index-1, A...>{}(a);
 }
};

template<class... A>
struct print_tuple<0, A...> {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<0>(a)));
 }
};

template<class... T>
string to_string(tuple<T...> a) {
 const int ttsz = tuple_size<decltype(a)>::value;
 print_tuple<ttsz-1, T...>{}(a);
 string __ss = to_string(__vector_tuple);
 __vector_tuple.clear();
 return __ss;
}

void debug() {cerr << "]\n";}

template<class H, class... T>
void debug(H head, T... tail) {
 cerr << to_string(head) << " ";
 debug(tail...);
}

#ifdef LOCAL
 #define debug(...) cerr << "[" << #__VA_ARGS__ << " ] = ["; debug(__VA_ARGS__);
#else 
 #define debug(...) 
#endif

typedef long long int ll;

int main()
{
 int n, k;
 cin >> n >> k;
 vector<int> a(n);
 for(auto& i: a) cin >> i;
 for(int i = k; i < n; i++) {
  cout << (a[i] > a[i-k] ? "Yes" : "No") << '\n'; 
 }
 return 0;
}


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

int main(){
	int a[3][3],b[10];
	int n;
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++) cin >> a[i][j];
	cin >> n;
	for(int i=0; i < n; i++) cin >> b[i];

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < n; k++){
				if(a[i][j] == b[k]) a[i][j] = 0;
			}
		}
	}
	int judge;
	bool flag=false;
	for(int i = 0; i< 3; i++){
		int buf1=0,buf2=0;
		for(int j= 0; j < 3; j++){
			buf1 += a[i][j];
			buf2 += a[j][i];
		}
		if(buf1 == 0 || buf2 == 0) flag = true;
	}
	if(a[0][0] + a[1][1] + a[2][2] == 0 || a[0][2] + a[1][1] + a[2][0] == 0){
		flag = true;
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
    char suit;//絵柄
    int value;//数字
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card Merge[], int n, int left, int mid, int right){
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for(i=0; i<n1; i++){
        L[i] = Merge[left+i];
    }
    for(i=0; i<n2; i++){
        R[i] = Merge[mid+i];
    }
    L[n1].value = R[n2].value = SENTINEL;
    i=j=0;
    for(k = left; k< right; k++){
        if (L[i].value <= R[j].value){
            Merge[k] = L[i++];
        } else{
            Merge[k] = R[j++];
        }
    }
}

void mergeSort(struct Card Merge[], int n, int left, int right){
    int middle;
    if(left + 1 < right){
        middle = (left + right) / 2;
        mergeSort(Merge, n, left, middle);
        mergeSort(Merge, n, middle, right);
        merge(Merge, n, left, middle, right);
    }
}

int partition(struct Card Quick[], int n, int p,int r){
    int i,j;
    struct Card t, x;
    x = Quick[r];
    i = p-1;
    for(j=p; j<r; j++){
        if(Quick[j].value <= x.value){//基準の値より小さい場合は大きいと分類された先頭の値を入れ替える
            i++;
            t = Quick[i];
            Quick[i] = Quick[j];
            Quick[j] = t;
        }
    }
    //基準の値と大きいと分類された先頭の値を入れ替える
    t = Quick[i+1];
    Quick[i+1] = Quick[r];
    Quick[r] = t;
    return i+1;
}

void quickSort(struct Card Quick[], int n, int p, int r){//パーティションを繰り返してソートを行う
    int q;
    if(p < r){
        q = partition(Quick, n, p, r);
        quickSort(Quick, n, p, q-1);
        quickSort(Quick, n, q+1, r);
    }
}

int main(){
    int num,i,v;
    struct Card Merge[MAX], Quick[MAX];
    char design[10];
    int stable = 1;
    scanf("%d", &num);

    for(i=0; i<num; i++){
        scanf("%s %d", design, &v);//入力された絵柄と数字を入れていく
        Merge[i].suit = Quick[i].suit = design[0];
        Merge[i].value = Quick[i].value = v;
    }

    mergeSort(Merge, num, 0, num);
    quickSort(Quick, num, 0, num-1);

    for(i=0; i<num; i++){
        //マージソートは同じ数字の場合,絵柄は入力された順序で並ぶためマージソートと一致するときは,安定な出力となる
        if(Merge[i].suit != Quick[i].suit){
            stable = 0;
        }
    }
    if(stable ==1){
        printf("Stable\n");
    }
    else{
        printf("Not stable\n");
    }
    for(i=0; i<num; i++){
        printf("%c %d\n", Quick[i].suit, Quick[i].value);
    }
    return 0;
}


Measured memory_bytes: 5032
n,y = gets.chomp.split(' ').map(&:to_i)
yukichi = 0
while (yukichi <= n) && (yukichi * 10000 <= y)
  ichiyo = 0
  while (ichiyo <= (n - yukichi)) && (yukichi * 10000 + ichiyo * 5000 <= y)
    hideyo = n - yukichi - ichiyo
    if (yukichi * 10000 + ichiyo * 5000 + hideyo * 1000 == y)
      puts [yukichi,ichiyo,hideyo].join(' ')
      exit
    end
    ichiyo += 1
  end
  yukichi += 1
end
puts "-1 -1 -1"

Measured memory_bytes: 14360
#include <iostream>

using namespace std;

int main(void){
  int A, B;
  cin >> A >> B;

  if(A%3==0 || B%3==0 || (A+B)%3==0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int su[1000005] = {};
int ans = 0;

bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;  // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }
  // 素数である
  return true;
}

void calc(ll n) {
  ll tmp = n;
  for (ll i = 2; i * i <= tmp; i++) {
    if (IsPrime(i)) {
      while (n % i == 0) {
        n /= i;
        su[i]++;
      }
    }
  }
  if (n > sqrt(tmp)) ans++;
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  ll n;
  cin >> n;
  /* if (n == 1) {
    cout << 0 << endl;
    return 0;
  } */
  calc(n);
  // rep(i, 30) cout << su[i] << endl;
  rep(i, 1000005) {
    if (su[i] > 0) {
      ans++;
      su[i] -= 1;
      int cnt = 2;
      while (su[i] - cnt >= 0) {
        ans++;
        su[i] -= cnt;
        cnt += 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  std::cin >> N;
  
  std::vector<int> vec(N);
  for (auto& v : vec) {
    std::cin >> v;
  }
  
  int result = 0;
  for (int i = 0; i < N - 1; ++i) {
	for (int j = i + 1; j < N; ++j) {
      result += vec[i] * vec[j];
    }
  }
  
  std::cout << result;
  return 0;
}


Measured memory_bytes: 256
import math
X = int(input())
 
if X == 2:
  print(2)
  exit()
  
hajime = X
 
if hajime % 2 == 0:
  hajime += 1
checkMax = math.ceil(math.sqrt(hajime))
for i in range(hajime, 1000000, 2):
  goseisu = False
  for j in range(2, checkMax + 1):
    if i % j == 0:
      goseisu = True
      break
  if not goseisu:
    print(i)
    exit()

Measured memory_bytes: 3064
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



#bfs内で処理すると使い回しが効かないのでsearch_color とか幅探索後の具体的な処理は別個にしたほうがいい
def bfs(s,n,node,c):
    
    side_num_arr=list(map(lambda x :len(x),node))
    l=max(side_num_arr)
    #print(l)
    queue=[-1 for _ in range(n)]
    now=0
    queue[now]=s
    ans=[-1 for _ in range(n)]
    ans[0]=[0]
    last_ind=1
    while last_ind<n:
        
        if now>=n:
            return []
        c[queue[now]]=True
        if side_num_arr[queue[now]]<=0:
            now+=1
            continue
        for i in node[queue[now]]:
            edge=i[0]
            
            ind=i[1]
            if side_num_arr[edge]<=0 or c[edge]==True:
                continue
            side_num_arr[edge]-=1
            side_num_arr[queue[now]]-=1
            queue[last_ind]=edge
            last_ind+=1
            c[edge]=True
            
            ans[edge]=queue[now]
        now+=1
    return ans



n,m=input_list()
node=[[] for _ in range(n)]
for i in range(m):
    u,v=input_list()
    u-=1
    v-=1
    node[u].append([v,i])
    node[v].append([u,i])

#print(np.array(node))
c=[-1 for _ in range(n)]
c[0]=0
ans=bfs(0,n,node,c)
if len(ans)==0:
    print("No")
    exit()

print("Yes")
for each in ans[1:]:
    print(each+1)








Measured memory_bytes: 91848
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

ll n, a, b;

int main() {
	cin >> n >> a >> b;
	if (a > b) cout << 0 << endl;
	else if (n == 1 && a != b) cout << 0 << endl;
	else cout << (n - 2)*(b - a) + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int ac = 0;
          int wa =0;
          int tle =0;
          int re=0;
      while(n-->0)
      {
          String s = sc.next();
          
          if(s.equals("AC"))
            ac++;
          else if(s.equals("TLE"))
            tle++;
          else if(s.equals("RE"))
            re++;
          else if(s.equals("WA"))
            wa++;
      }
            System.out.println("AC x " + ac);
            System.out.println("WA x " + wa);
            System.out.println("TLE x " + tle);
            System.out.println("RE x " + re);
    }
}

Measured memory_bytes: 58076
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;
#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<" "
#define pr2(a,b)    cout<<a<<" "<<b<<" "
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()						
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
void inline minize(ll& a,ll b){a=(a>b?b:a);};
void inline maxize(ll& a,ll b){a=(a<b?b:a);};
string inline toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll add[MAXN+5];
triple arr[MAXN+5];
bool cmp_se(triple a,triple b){
	re a.se.fi<b.se.fi;
}
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,a,b,prevcnt,cnt2=0;
	// PROCESSING IN HERE
	sc(n);
	fu(i,0,n-1)sc(arr[i].fi),arr[i].se.fi=arr[i].fi;
	
	sort(arr,arr+n,cmp_se);
	while(arr[n-1].se.fi>=n){
		cnt2=0;
		fd(i,n-1,0){
			arr[i].se.se+=(arr[i].se.fi+cnt2)/n;
			cnt2+=(arr[i].se.fi+cnt2)/n;
		}
		cnt+=cnt2;
		fu(i,0,n-1)arr[i].se.fi=arr[i].fi-arr[i].se.se*n+cnt-arr[i].se.se;
		sort(arr,arr+n,cmp_se);
	}
	
	pr(cnt);
	re 0;
	// Hack it if you can :)
}

int main(){
//	INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	Solves();
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

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

int main() {
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if (S == "Y"){
      cout << "Four";
      break;
    }
    else if (i == N-1){
      cout << "Three";
    }
  }
} 

Measured memory_bytes: 384
N, A, B = map(int, input().split())
ans = 0
def sumsum(x):
    k = 0
    while(x != 0):
        t, x = x%10, x//10
        k += t
    return k
for i in range(1,N+1):
    if A <= sumsum(i) <= B:
        ans += i
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int w_right=0,e_right=0;
  rep(i,n)if (s[i]=='W') w_right++;else e_right++;
  int ans=n;
  int w_left=0,e_left=0;
  rep(i,n){
    ans=(s[i]=='W')?min(ans,w_left+e_right):min(ans,w_left+e_right-1);
    if (s[i]=='W') {w_right--;w_left++;}
    else{e_right--;e_left++;}
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 900
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    string s = "";
    if (a > b) {
        for (int i=0; i<a; i++) {
            s += to_string(b);
        }
    } else {
        for (int i=0; i<b; i++) {
            s += to_string(a);
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
N,P = map(int,input().split())
S = input()

if P%2 == 0 or P%5 == 0:
    ans = 0
    ##S = S[::-1]
    for i,j in enumerate(S):
        if int(j)%P == 0:
            ans += i+1
    print(ans)
else:
    tmp = 0
    mod = [0]*P
    mod[0] = 1
    S = S[::-1]
    for i,j in enumerate(S):
        tmp = (tmp + int(j)*pow(10,i,P))%P
        mod[tmp] += 1    
    print(sum([i*(i-1)//2 for i in mod]))

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

int bit[200005];
inline void add(int i, int x){
  i++;
  while(i<200005){
    bit[i]+=x;
    i+=i&-i;
  }
}
inline int sum(int i){
  i++;
  int ret=0;
  while(i){
    ret+=bit[i];
    i-=i&-i;
  }
  return ret;
}

int n, k;
string str;
int nxt[26];
void gonext(int i){
  while(nxt[i]<n && str[nxt[i]]!='a'+i) nxt[i]++;
}
int main(){
  cin >> str >> k;
  n=str.length();
  fill(bit, bit+200005, 0);
  for(int i=0; i<n; i++) add(i, 1);
  fill(nxt, nxt+26, 0);
  for(int i=0; i<26; i++) gonext(i);
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      if(nxt[j]==n) continue;
      int cnt=sum(nxt[j]-1);
      if(cnt<=k){
        k-=cnt;
        add(nxt[j], -1);
        cout << (char)('a'+j);
        nxt[j]++;
        gonext(j);
        break;
      }
    }
  }
  cout << endl;
}

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

int main(){
    long long a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;

    long long x = abs(a-b);

    long long y = (v-w)*t;

    if(x<=y){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 3576
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		while (true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if (op.equals("+")) {
				System.out.println(a+b);
			} else if (op.equals("-")) {
				System.out.println(a-b);
			} else if (op.equals("*")) {
				System.out.println(a*b);
			} else if (op.equals("/")) {
				System.out.println(a/b);
			} else if (op.equals("?")) {
				break;
			}
		}

	}

}

Measured memory_bytes: 26260
#include<bits/stdc++.h>
#define ll long long int
#define fin for(i=0;i<n;i++)
#define vec vector<ll>
#define pb push_back
#define vecit vector<ll>::iterator
#define vecp vector<pair<ll,ll> >
#define vecpit vector<pair<ll,ll> >::iterator
#define mapp map<ll,ll>
#define mapr map<ll,pair<ll,ll> >
#define maprit map<ll,pair<ll,ll> >::iterator
#define mapit map<ll,ll>::iterator
#define mod1 1000000007
#define INF 10000000000
using namespace std;
int main()
{
   ll n,k;
   cin>>n>>k;
   vec v;
   ll i,j,p,q,l;
   fin
   {
       cin>>j;
       v.pb(j);
   }
   sort(v.begin(),v.end());
   vec dp(k+1);
   dp[0]=0;
   for(i=1;i<v[0];i++)
    dp[i]=2;
    p=v[0];
    ll f;
   for(i=p;i<=k;i++)
   {
       f=0;
       for(j=0;j<n;j++)
       {
           q=v[j];
           if(q>i)
            break;
           if(dp[i-q]==0)
            f=1;
           else if(dp[i-q]==2)
            f=1;
       }
       if(f==0)
        dp[i]=2;
       else
        dp[i]=1;
   }
   if(dp[k]==1)
    cout<<"First";
   else
    cout<<"Second";


}


Measured memory_bytes: 4040
#include<stdio.h>
int main (void)
{
    int d,K,i,ans;
    while(scanf("%d",&d)!=EOF){
        ans=0,K=d;
        for(i=1;i<600/K;i++){
            ans+=d*d*K;
            d+=K;
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    int n, k;
    cin >> n >> k;
    cout << ((n % k == 0) ? 0 : 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

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

    vector<tuple<int, int, int>> data(M);

    for (int i = 0; i < M; i++)
    {
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }

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

    vector<int> cnt(N + 1);
    fill(cnt.begin(), cnt.end(), 0);

    vector<pair<int, int>> id(M);

    for (int i = 0; i < M; ++i)
    {
        int y, p, idx;
        tie(y, p, idx) = data[i];
        ++cnt[p];
        id[idx] = make_pair(p, cnt[p]);
    }

    for (int i = 0; i < M; ++i)
    {
        cout << setw(6) << setfill('0') << id[i].first;
        cout << setw(6) << setfill('0') << id[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <complex.h>
using namespace std;


struct point{
    int x, y;
};


int dist(point p, point q){
    return abs(p.x-q.x)+abs(p.y-q.y);
}



int main(){
	int h, w, d, a;
    int q, l, r;
    point M[90001];
    int di[90001]={0};
    int MP[100001]={0};
    scanf("%d %d %d", &h, &w, &d);

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            scanf("%d", &a);
            M[a].x = j;
            M[a].y = i;
        }
    }

    for(int i=1;i+d<=h*w;i++){
        di[i+d] = dist(M[i], M[i+d]) + di[i];
    }

    scanf("%d", &q);

    for(int i=0;i<q;i++){
        scanf("%d %d", &l, &r);
        MP[i] = di[r] - di[l];
    }

    for(int i=0;i<q;i++){
        printf("%d\n", MP[i]);
    }

	return 0;
}


Measured memory_bytes: 2432
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
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;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

const int B = 60;
ll cnt[B];
int main() {
    int N; cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        for(int j=0; j<B; j++) {
            cnt[j] += (A[i] >> j & 1);
        }
    }

    ll ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<B; j++) {
            ll D = (1LL << j) % MOD;
            ll cnt1 = cnt[j] % MOD, cnt0 = (N - cnt1) % MOD;
            if(A[i] >> j & 1) (ans += cnt0 * D % MOD) %= MOD;
            else (ans += cnt1 * D % MOD) %= MOD;
        }
    }
    (ans *= 500000004LL) %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define MAXN 10010
#define MAXY 2010
#define INF 0x3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int n,s=1;
int main(){
//	freopen("1.out","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x==s){
			s++;
		}
	}
	s--;
	if(s)
	cout<<n-s;
	else
	cout<<-1;
	return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  
  int Slen = (int)(S.length()), Tlen = (int)(T.length());
  int ans = Tlen;
  
  for (int i = 0; i <= Slen - Tlen; i++){
    int che = 0;
    
    for (int j = 0; j < Tlen; j++){
      if (S.at(i + j) != T.at(j)){
        che++;
      }
    }
    
    ans = min(ans, che);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

!function () {
  function splitNum(line) {
    return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
      return parseInt(n);
    });
  }

  !function (input) {
    var lines = input.split("\n");

    var _splitNum = splitNum(lines[0]),
        _splitNum2 = _slicedToArray(_splitNum, 2),
        N = _splitNum2[0],
        K = _splitNum2[1];

    var S = lines[1].slice(0, N);
    console.log(S.slice(0, K - 1) + S[K - 1].toLowerCase() + S.slice(K));
  }(require("fs").readFileSync("/dev/stdin", "utf8"));
}();


Measured memory_bytes: 22076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define LINF  0x3f3f3f3f3f3f3f3fll
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 

const ll mod = 999983;
#define mx 200005
const ll mxi = 10005;

int main()
{
	fast_as_levi;
	string str;
	cin>>str;
	ll n = str.length();
	ll d = 10;
	ll suf[n],cnt[2019];
	for(int i=0;i<2019;i++)
	{
		cnt[i] = 0;
	}
	suf[n-1] = str[n-1] - '0';
	for(int i=n-2;i>=0;i--)
	{
		suf[i] = (suf[i+1] + ((int)(str[i] - '0'))*d)%2019;
		d*=10;
		d%=2019; 
	}
	for(int i=0;i<n;i++)
	{
		cnt[suf[i]]++;
	}
	cnt[0]++;
	ll ans = 0;
	for(int i=0;i<2019;i++)
	{
		ans += cnt[i]*(cnt[i]-1)/2;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 5352
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,m,ans=1000000000000000;
  cin >> n >> m;
  vector<ll> spo_c(m,0);
  ll a[n][m];
  set<ll> st;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  for(int i=0;i<m;i++){
    st.insert(i);
  }
  for(int i=0;i<m;i++){
    ll rm=0;
    fill(spo_c.begin(),spo_c.end(),0);
    for(int j=0;j<n;j++){
      for(int k=0;k<m;k++){
        if(st.find(a[j][k])!=st.end()){
          spo_c[a[j][k]]++;
          break;
        }
      }
    }
    for(int j=0;j<m;j++){
      if(spo_c[rm]<spo_c[j]){
        rm = j;
      }
    }
    ans = min(ans,spo_c[rm]);
    st.erase(rm);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


n=l()[0]
X=l()
A=sorted(X)
d={}
z=n//2
for i in range(n):
    if(A[i] in d):
        continue
    if(i<z):
        d[A[i]]=A[z]
    else:
        d[A[i]]=A[z-1]
for i in range(n):
    print(d[X[i]])
    

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

int main() {
  int N, ans; ans = 0;
  cin >> N;

  rep(i, N+1) {
    int c = 0;
    rep(j, i+1) {
      if (i % j == 0 && j%2 != 0)
        c++;
    }
    if (c == 8)
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MOD=1000000007;

int n;
int a[MAXN+1];
int cnt[MAXN];

int inv[MAXN+2];
int fac[MAXN+2];
int ifac[MAXN+2];
int C(int n,int k) { if(k<0||k>n) return 0; return (ll)fac[n]*ifac[k]%MOD*ifac[n-k]%MOD; }


void run() {
	scanf("%d",&n); REP(i,n+1) scanf("%d",&a[i]),--a[i];
	REP(i,n) cnt[i]=0; REP(i,n+1) ++cnt[a[i]];
	int dup=-1; REP(i,n) if(cnt[i]>=2) dup=i;
	int l=-1,r=-1; REP(i,n+1) if(a[i]==dup) { if(l==-1) l=i; else r=i; } assert(l!=-1&&r!=-1);
	
	inv[1]=1; FORE(i,2,n+1) inv[i]=(ll)(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1; FORE(i,1,n+1) fac[i]=(ll)fac[i-1]*i%MOD;
	ifac[0]=1; FORE(i,1,n+1) ifac[i]=(ll)ifac[i-1]*inv[i]%MOD;

	FORE(i,1,n+1) {
		int ret=C(n+1,i);
		int rem=n+1-(r-l+1);
		int sub=C(rem,i-1);
		if((ret-=sub)<0) ret+=MOD;
		printf("%d\n",ret);
	}
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    ll N;cin>>N;
    cout<<(1+N-1)*(N-1)/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
int a[100001],b[100001],c[100001];
int main()
{
    int n,m;long long gg=0;
    std::cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        std::cin>>a[i];
        a[i]=(a[i]+a[i-1])%m;
        b[i]=a[i];
    }
    std::sort(b+1,b+1+n);
    int t=1;
    for(int i=2;i<=n;i++)if(b[i]!=b[i-1])b[++t]=b[i];

    for(int i=1;i<=n;i++)
    {
        int k=std::lower_bound(b+1,b+1+t,a[i])-b;
        c[k]++;
    }

    if(b[1]==0)gg+=c[1];

    for(int i=1;i<=n;i++)
    {
        int k=std::lower_bound(b+1,b+1+t,a[i])-b;
        c[k]--;
        gg+=c[k];
    }
    std::cout<<gg<<std::endl;
}


Measured memory_bytes: 1280