akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    vector<pair<ll, P>> ab(n);
    ll sum = 0, sum2 = 0;
    rep(i, n) {
        cin >> ab[i].se.fi;
        sum += ab[i].se.fi;
    }
    rep(i, n) {
        cin >> ab[i].se.se;
        sum2 += ab[i].se.se;
        ab[i].fi = ab[i].se.fi - ab[i].se.se;  //足りない分
    }

    if (sum < sum2) {
        cout << "-1\n";
        return 0;
    }

    sort(ab.begin(), ab.end());
    ll ans = 0;
    ll want = 0;
    rep(i, n) {
        if (ab[i].fi < 0) {
            ans++;
            want += -1 * ab[i].fi;
        }
    }
    for (ll i = n - 1; i >= 0; i--) {
        if (want > 0) {
            ans++;
            want -= ab[i].fi;
        }
    }

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

Measured memory_bytes: 5616
// 0505 Questionnaire (??¢?????±??????)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0505
// by Equim on 17-02-08

'use strict';

var raw = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

while (true) {
    var size = raw.shift().split(' ').map(Number);
    if (size[0] === 0) {
        break;
    }

    var count = {};
    for (var i = 0; i < size[0]; i++) {
        var line = raw.shift().split(' ').map(Number);
        for (var j = 0; j < size[1]; j++) {
            count[j + 1] = ((j + 1) in count ? count[j + 1] : 0) + line[j];
        }
    }

    // Support Lambda pls QAQ
    console.log(Object.keys(count).sort(function(a, b) { return count[a] === count[b] ? a - b : count[b] - count[a]; }).join(' '));
}

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

int main()
{
    int N, x;
    cin >> N >> x;
    int a[100005] = {};
    for (int n = 1; n <= N; n++)
    {
        cin >> a[n];
    }

    long long ans = 0;
    for (int n = 1; n <= N; n++)
    {
        if (a[n - 1] + a[n] > x)
        {
            ans += a[n - 1] + a[n] - x;
            a[n] -= a[n - 1] + a[n] - x;
        }
    }

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

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;

ll calc(ll x, ll y)
{
    if (x < y)
    {
        return calc(y, x);
    }
    while (ll m = x % y)
    {
        x = y;
        y = m;
    }
    return y;
}

int main()
{
    const int C_MAX = 100000;
    ll a[C_MAX];
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll ret = a[0];
    for (ll i = 1; i < n; i++)
    {
        ret = calc(ret, a[i]);
    }
    cout << ret;
    return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int m;
	cin>>m;
	ll s=0;
	ll cs=0;
	for(int i=0; i<m; i++){
		int d; ll c;
		cin>>d>>c;
		s+=c*d;
		cs+=c;
	}
	ll a;
	if(s%9==0) a=(s-9)/9;
	else a=(s-s%9)/9;
	cout<<cs-1+a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;




ll power(ll x,ll k){
  ll ret=1;
  while(k>0){
    if(k&1) (ret*=x) %= M;
    (x*=x) %= M;
    k >>= 1;
  }
  return ret;
}

main(){
  int l;
  cin>>l;
  
  int r;
  rrep(i,30){
    if(l&(1<<i)){
      r=i;
      break;
    }
  }

  WG<int> es(r+1);
  int m=0;
  FOR(i,1,r+1){  
    es[i].PB(edge<int>(i+1,power(2,i-1)));
    es[i].PB(edge<int>(i+1,0));
    m+=2;
  }

  RFOR(t,r,1){
    if(l-power(2,t-1)>=power(2,r)){
      es[t].PB(edge<int>(r+1,l-power(2,t-1)));
      m++;
      l-=power(2,t-1);
    }
  }

  cout<<r+1<<' '<<m<<endl;

  FOR(i,1,r+1){
    for(auto e:es[i]){
      cout<<i<<' '<<e.to<<' '<<e.cost<<endl;
    }
  }



}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K,R,S,P; cin >> N >> K >> R >> S >> P;
    string T; cin >> T;
    
    vector<bool> A(N);
    ll ans = 0;
    rep(i,N) {
        if (i < K) {
            if (T[i] == 'r') ans += P;
            if (T[i] == 's') ans += R;
            if (T[i] == 'p') ans += S;
            A[i] = true;
        } else {
            if (T[i] == T[i-K] && A[i-K]) continue;
            else {
                if (T[i] == 'r') ans += P;
                if (T[i] == 's') ans += R;
                if (T[i] == 'p') ans += S;
                A[i] = true;    
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    ll n, a, b, c;
    cin >> n >> a >> b;
    c = a - b;
    VL h(n);
    REP(i,n) scanf("%lld", &h[i]);

    ll sm = 0, la = 1e9;
    while (la - sm > 1){
        ll mi = (sm + la) / 2;
        ll x = 0;
        REP(i,n){
            if (h[i] <= mi * b) continue;
            x += (h[i] - mi * b + c - 1) / c;
        }
        if (x <= mi) la = mi;
        else sm = mi;
    }

    cout << la << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
vector<int>star[200005];
vector<int>endd[200005];
int vis1[200005];
int vis2[200005];
int ans[505][505];
int main(){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	for (int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		star[a].push_back(i);
		endd[b].push_back(i);
	}
	for (int i=1;i<=n;i++){
		for (int j=0;j<m;j++){
			vis1[j]=0;
			vis2[j]=0;
		}
		for (int j=i;j<=n;j++){
			int tmp=0;
			for (int k=0;k<star[j].size();k++){
				vis1[star[j][k]]=1;
			}
			for (int k=0;k<endd[j].size();k++){
				vis2[endd[j][k]]=1;
				if (vis1[endd[j][k]]==1){
					tmp++;
				}
			}
			ans[i][j]=tmp;
			if (j>i){
				ans[i][j]+=ans[i][j-1];
			}
		}
	}
	for (int i=0;i<q;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		printf ("%d\n",ans[a][b]);
	}
}

Measured memory_bytes: 15360
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
 	int N;
 	cin >> N;
 	vector<pair<int,int>> vec(N);
 	for(int i = 0;i < N;i++) {
 		int A,B;
 		cin >> A >> B;
 		vec.at(i) = make_pair(B,A);
 	}
 	sort(vec.begin(),vec.end());
 	int M = 0;
 	bool A = true;
 	for(int i = 0;i < N;i++) {
 		M += vec[i].second;
 		if(vec[i].first < M) {
 			A = false;
 			break;
 		}
 	}
 	if(A == true) {
 		cout << "Yes" << endl;
 	}
 	else {
 		cout << "No" << endl;
 	}
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,m,c;
    cin>>n>>m;
    c=max(0ll,(n-2*m));
    cout<<c<<"\n";
    return 0;
}

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

int main() {

  string s;
  int flag = -1, ans = 0;
  int J = 0, O = 0, I = 0;
  cin >> s;

  for(int i=0; i<s.size(); i++) {
    if( flag <= 0 && s[i] == 'J' ) {
      flag = 0;
      J++;
    }
    else if( flag == 0 && s[i] == 'O' ) {
      flag = 1; O++;
    }
    else if( flag == 1 && s[i] == 'O' ) {
      O++;
    }
    else if( flag == 1 && s[i] == 'I' ) {
      flag = 2; 
      if( J >= O ) {
	I++;
	ans = max(1, ans);
      } 
      else {
	flag = -1;
	J = O = I = 0;
      }
    }
    else if( flag == 2 && s[i] == 'I' ) {
      I++; 
      if( I >= O ) {
	ans = max(ans, min(J, min(O, I)));
      }
    }
    else {
      if( s[i] == 'J' ) {
	flag = 0;
	J = 1; O = I = 0;
      }
      else {
	flag = -1;
	J = O = I = 0;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <sstream>
#include <queue>

using namespace std;

#define li long int

void showvec(vector<int> &vi){
  for(int i=0;i<vi.size();++i){
    std::cout<<i<<","<<vi[i]<<endl;
  }
}

// variables
int N;
vector<int> ls;
vector<int> cnts;
int main(){
  cin >> N;
  int maxL = -1;
  ls.resize(N);
  for(int i=0;i<N;++i){
    cin >> ls[i];
    if(ls[i]>maxL){
      maxL = ls[i];
    }
  }
  //showvec(ls); //debug  
  int minL = maxL/2 + maxL%2;
  //cout<<"maxL = " << maxL<< " minL = "<<minL<<endl; //debug
  cnts.resize(maxL);
  for(int i=0;i<N;++i){
    cnts[ls[i]-1] += 1;
  }
  // showvec(cnts); // debug

  for(int i=0;i<maxL;++i){
    if( i+1 < minL){
      if(cnts[i]>0 ){
	//cout<<"too small l "<<i+1<<","<<cnts[i]<<","<<minL<<endl; //debug
	cout<<"Impossible"<<endl;
	return 0;
      }
    }
    else if( i+1 == minL){
      if(maxL%2 == 0){
	if(cnts[i]!=1){
	  //cout<<"invalid hinge l even "<<i+1<<","<<cnts[i]<<","<<minL<<endl; //debug
	  cout<<"Impossible"<<endl;
	  return 0;
	}
      }else{
	if(cnts[i]!=2){
	  //cout<<"invalid hinge l odd "<<i+1<<","<<cnts[i]<<","<<minL<<endl; //debug
	  cout<<"Impossible"<<endl;
	  return 0;

	}
      }
    }else{
      if(cnts[i]<2){
	//cout<<"invalid load "<<i+1<<","<<cnts[i]<<","<<minL<<endl; //debug
	cout<<"Impossible"<<endl;
	return 0;
      }
    }
  }
  cout<<"Possible"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 200000;
LL a[maxn + 5];
LL res;
int n;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		a[i] -= (LL)(i);
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++) res += abs(a[i] - a[(n + 1) / 2]);
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 1664
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ans = 0

n.times do |i|
  x = (a[i] <= b[i]) ? a[i] : b[i] 
  ans += x
  a[i] -= x
  b[i] -= x

  x = (a[i + 1] <= b[i]) ? a[i + 1] : b[i] 
  
  ans += x
  a[i + 1] -= x
  b[i] -= x
end

puts ans


Measured memory_bytes: 17292
#include <stdio.h>
  int main(){ 
	  int a[5],b[5],i,j;
	  int hit=0,blow=0;
	  while(scanf("%d %d %d %d %d %d %d %d",&a[1],&a[2],&a[3],&a[4],&b[1],&b[2],&b[3],&b[4]) != EOF){
		  for(i=1;i<=4;i++){
			  if(a[i]==b[i]){
				  hit++;
			  }
		  }
		  for(i=1;i<=4;i++){
			  for(j=1;j<= 4;j++){
				  if(j != i){
				  if(a[i]==b[j]){
					  blow++;
				  }	  
			  }
			  }
		  }
		  printf("%d %d\n",hit,blow);
		  hit=0; blow=0;
	  }
	  return 0;
  }

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

long long dp[100111];
long long h[100111];

int main()
{
	int n, k;
	
	cin >> n >> k;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> h[i];
		dp[i] = 1e10;
	}
	
	dp[1] = 0;
	
	for(int i = 2; i <= n; i++)
	{
		for(int j = max(1, i - k); j <= i - 1; j++)
		{
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    string s;cin>>s;
    int res=0;
    REP(i,s.size()-1){
        if(s[i]!=s[i+1])res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back 
#define f first
#define s second
#define min3(a, b, c) min(min(a, b), c)
#define max3(a, b, c) max(max(a, b), c)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

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

const int INF = 1e9;
//const ll INF = 1e18;
const ll mod = 1000000007;
// const ll mod = 998244353;

vl fact;
void modfac(int n){
    fact.resize(n+1);
    fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (i*fact[i-1])%mod;
    }
    return;
}
ll mpow(ll a, ll b){
    ll x = 1;
    while(b > 0){
        if(b&1){
            x = (x*a)%mod;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return x;
}
ll madd(ll a, ll b){
    return (a+b)%mod;
}

ll msub(ll a, ll b){
    return (a - b + mod)%mod;
}
ll mmul(ll a, ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll modinv(ll b){
    ll x = mpow(b, mod-2);
    return x;
}
ll mdiv(ll a, ll b){
    return mmul(a, modinv(b));
}

ll nck(ll n, ll k){
    return mdiv(fact[n], mmul(fact[n-k], fact[k]));
}
void solve(int tc){
    modfac(2001);
    ll s;
    cin >> s;

    ll ans = 0;

    for(int i = 1; i <= s/3; i++){
        ans = madd(ans, nck((s-2*i-1), (i-1)));
    }

    cout << ans << "\n";

}

int main(){
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    
    int tc = 1;
    //cin >> tc;
    for (int t = 0; t < tc; t++) solve(t);

    return 0;
}

Measured memory_bytes: 3664
<?php
fscanf(STDIN, "%d%d", $s, $e);
$min = 10**10;
if($e > $s){
  $min = min($min, $e-$s);
}
if($e+$s > 0){
  $min = min($min, $e+$s+1);
}
if($s-$e > 0){
  $min = min($min, $s-$e+2);
}
if(-$s-$e >= 0){
  $min = min($min, -$s-$e+1);
}
echo $min;

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

const int N = 1e5 + 9, LG = 17;

int a[N], dp[LG][N];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int l, q; cin >> l >> q;
	for (int i = 1; i <= n; i++) {
		dp[0][i] = upper_bound(a + i, a + n + 1, a[i] + l) - a - 1;
	}
	for (int k = 1; k < LG; k++) {
		for (int i = 1; i <= n; i++) dp[k][i] = dp[k - 1][dp[k - 1][i]];
	}
	while (q--) {
		int x, y; cin >> x >> y;
		if (x > y) swap(x, y);
		int ans = 0;
		for (int k = LG - 1; k >= 0; k--) {
			if (dp[k][x] < y) {
				x = dp[k][x];
				ans += 1 << k;
			}
		}
		ans++;
		cout << ans << '\n';
	}
    return 0;
}

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

using namespace std;

int main() {
  int h, w; cin >> h >> w;
  char g[h + 2][w + 2];
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      cin >> g[i][j];
    }
  }
  for(int i = 0; i <= h + 1; i++) {
    for(int j = 0; j <= w + 1; j++) {
      if(i == 0 or i == h + 1 or j == 0 or j == w + 1) printf("#");
      else printf("%c", g[i][j]);
    }
    puts("");
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

const vector<int> primes = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 };
int memo[15][15];
int combi(int n, int k) {
    if (k == 0) return 1;
    else if (n == k) return 1;
    else if (memo[n][k]) return memo[n][k];
    return memo[n][k] = combi(n - 1, k) + combi(n - 1, k - 1);
}

int N;

int main() {
    cin >> N;

    if (N < 10) {
        write(0);
        return 0;
    }

    vi pcnt(primes.size(), 0);
    for (int n = 2; n <= N; ++n) {
        int _n = n;
        int i = 0;
        while (i < primes.size() && _n > 1) {
            if (_n % primes[i] == 0) {
                pcnt[i]++;
                _n /= primes[i];
            }
            else i++;
        }
    }

    int ge74 = 0, ge24 = 0, ge14 = 0, ge4 = 0, ge2 = 0;
    rep(i, primes.size()) {
        if (pcnt[i] >= 74) ge74++;
        if (pcnt[i] >= 24) ge24++;
        if (pcnt[i] >= 14) ge14++;
        if (pcnt[i] >= 4) ge4++;
        if (pcnt[i] >= 2) ge2++;
    }

    int ans = (ge4 >= 2 ? combi(ge4, 2) * combi(ge2 - 2, 1) : 0)
        + (ge14 >= 1 && ge4 >= 1 ? combi(ge14, 1) * combi(ge4 - 1, 1) : 0)
        + (ge24 >= 1 && ge2 >= 1 ? combi(ge24, 1) * combi(ge2 - 1, 1) : 0)
        + (ge74 >= 1 ? combi(ge74, 1) : 0);
    write(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main(){
    int N = in;
    vector<int> A(N);
    rep( i, N ) A[i] = in-1;

    vector<int> ans(N);
    while( !A.empty() ) {
        for( int i=A.size()-1; i>=0; i-- ) {
            if( A[i] == i ) {
                A.erase( A.begin() +i );
                ans[A.size()] = i;
                goto E;
            }
        }
        cout << "-1\n";
        return 0;
        E:;
    }

    rep( i, N ) cout << ans[i]+1 << "\n";
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

type Row []string

type Data []Row

func gcd2(a, b, c int) uint64 {
	return gcd(gcd(uint64(a), uint64(b)), uint64(c))
}
func gcd(m, n uint64) uint64 {
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	a := new(big.Int).SetUint64(m)
	b := new(big.Int).SetUint64(n)
	return z.GCD(x, y, a, b).Uint64()
}

func main() {
	nextReader = newScanner()
	A := nextInt()
	ret := uint64(0)
	// for a := 1; a <= A; a++ {
	// 	for b := 1; b <= A; b++ {
	// 		for c := 1; c <= A; c++ {
	// 			ret += gcd2(a, b, c)
	// 			fmt.Printf("%d,%d,%d = %d\n", a, b, c, gcd2(a, b, c))
	// 		}
	// 	}
	// }

	for a := 1; a <= A; a++ {
		for b := a; b <= A; b++ {
			for c := b; c <= A; c++ {
				if a == b && b == c {
					ret += gcd2(a, b, c)
				} else if a == b || b == c {
					ret += (gcd2(a, b, c) * 3)
				} else {
					ret += (gcd2(a, b, c) * 6)
				}
			}
		}
	}
	fmt.Print(ret)
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	// r.Split(bufio.ScanLines)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func CustomScan(data []byte, atEOF bool) (advance int, token []byte, err error) {
	for i := 0; i < len(data); i++ {
		if data[i] == ' ' {
			return i + 1, data[:i], nil
		}
	}
	fmt.Println(data)
	return 0, data, bufio.ErrFinalToken
}

func nextStrings() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	// r.Split(bufio.ScanWords)
	r.Split(CustomScan)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 6688
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
int a[100];
int main(void)
{
	int n,res,i;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",a+i);
	res=0;
	FOR(i,1,n){
		if(a[i-1]==a[i]){
			res++,i++;
		}
	}
	printf("%d\n",res);
	return 0;
}
    
    
    

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){

  int N; cin >> N;
  ll L[N], R[N];
  for (int i = 0; i < N; i++){
    cin >> L[i] >> R[i];
  }
  
  ll L_max = L[0], R_min = R[0];
  int L_index = 0, R_index = 0;
  for (int i = 0; i < N; i++){
    if (L_max < L[i]){
      L_max = L[i];
      L_index = i;
    }
    if (R[i] < R_min){
      R_min = R[i];
      R_index = i;
    }
  }

  ll Max_Dist = max(0ll, R_min - L_max + 1), ans = 0;
  for (int i = 0; i < N; i++){
    ans = max(ans, Max_Dist + R[i] - L[i] + 1);
  }

  Pll AB[N];
  for (int i = 0; i < N; i++){
    ll A = max(0ll, R[i] - L_max + 1);
    ll B = -1 * max(0ll, R_min - L[i] + 1);
    AB[i] = make_pair(A, B);
  }
  sort(AB, AB + N);

  ll B = -1 * AB[0].second;
  for (int i = 0; i + 1 < N; i++){
    B = min(B, -1 * AB[i].second);
    ans = max(ans, AB[i + 1].first + B);
  }
  cout << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>

#define MAX_N 50000

using namespace std;

bool isprime(int n) {
	for (int i = 2; i * i <= n; i++)
		if (n % i == 0)
			return false;
	return n != 1;
}

int main() {
	int n;
	int g, l;
	vector<int> prime;
	for (int i = 2; i < MAX_N * 2; i++)
		if (isprime(i) == true)
			prime.push_back(i);
	while (cin >> n) {
		g = l;
		vector<int>::iterator it = prime.begin();
		while (it != prime.end()) {
			if (*it < n)
				g = *it;
			if (*it > n) {
				l = *it;
				break;
			}
			it++;
		}
		cout << g << " " << l << endl;
	}
	return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int nCr(ll N, ll M) {
    if (N == 3 && M != 0) {
        return 1;
    } else if (N < 3) {
        return 0;
    } else if (M == 0) {
        return 0;
    } else if (M == 1) {
        return 1;
    } else {
        ll q = 1;
        for (ll i = 0; i < M - 1; i++) {
            q *= N + M - 4 - i;
            q %= 1000000007;
        }
        for (int i = 0; i < M - 1; i++) {
            q /= 1 + i;
            q %= 1000000007;
        }
        return q;
    }
}
int main() {
    ll N;
    cin>>N;
    vector<ll>A(N);
    ll ans=0;
    for(int i=0; i<N; i++){
        cin>>A[i];
        if(i!=0){
            if(A[i]<A[i-1]){
                ans+=A[i-1]-A[i];
                A[i]=A[i-1];
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4832
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = (int) 2e5 + 100;
int a[N];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, x;
    scanf("%d%d", &n, &x);

    if (x == 1 || x == 2 * n - 1)
    {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");

    a[n - 1] = x;
    a[n - 2] = x + 1;
    a[n] = x - 1;
    int cur = 1;
    for (int i = 0; i < 2 * n - 1; i++)
    {
        while (abs(cur - x) <= 1)
            cur++;
        if (a[i] == 0)
            a[i] = cur++;
    }

    for (int i = 0; i < 2 * n - 1; i++)
        printf("%d\n", a[i]);


	return 0;
}




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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    ll ans = 1;
    ll base = 1;
    while(h/base > 1){
        base *= 2;
        ans += base;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(ab.All(x => x <= 9) ? ab[0] * ab[1] : -1);
    }
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

#define MAX 100000
int A[MAX], n;

int partition(int p, int r) {
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int i, q;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    q = partition(0, n - 1);
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        if (i == q) cout << "[";
        cout << A[i];
        if (i == q) cout << "]";
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3512
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007  

int main(){
    int N; 
    cin >> N;
    N %= 1000;
    if(1000 - N == 1000) N = 0;
    else N = 1000 - N;
    cout << N << endl;
}

Measured memory_bytes: 3640
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define p 1000000007
using namespace std;

long long fac[200010],inv[200010],n,m,aa,bb,ans;

long long kasumi(long long a,long long b)
{
    long long ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

long long cc(int a,int b)
{
    if(a==b||b==0)
    {
        return 1;
    }
    return ((fac[a]*inv[b])%p*inv[a-b]%p);
}

long long get_(int x1,int y1,int x2,int y2)
{
    return cc(x2-x1+y2-y1,x2-x1);
}

int main()
{
    fac[1]=1;
    for(int i=2;i<=200000;i++)
    {
        fac[i]=(fac[i-1]*i)%p;
    }
    inv[200000]=kasumi(fac[200000],p-2);
    for(int i=199999;i>=1;i--)
    {
        inv[i]=(inv[i+1]*(i+1))%p;
    }
    scanf("%d%d%d%d",&n,&m,&aa,&bb);

    for(int i=1;i<=n-aa;i++)
    {
        ans+=(get_(1,1,i,bb)*get_(i,bb+1,n,m))%p;
        ans%=p;
    }

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

Measured memory_bytes: 3328
n,m = map(int, input().split())

ans = 0

#辺を取り除くことはabのセットとなっている要素から取り除くことと等価。頂点を消すのではない。
h_list = list(map(int, input().split()))
c = 0
max_list = [0]*(n+1)

for i in range(m):
    a,b = map(int, input().split())

    max_list[a] = max(max_list[a],h_list[b-1])
    max_list[b] = max(max_list[b],h_list[a-1])


for i in range(1,n+1):
    if h_list[i-1] > max_list[i]:
        ans += 1

print(ans)


Measured memory_bytes: 20132
def main():
	H, W = map(int,input().split())
	pos = [""]*H
	for i in range(H):
		pos[i] = input()

	offset = [[-1, 0], [1, 0], [0, -1], [0, 1]]
	def bfs(s, h, w):
		queue = [[0, 0, 0]]
		is_visited = [[False for _ in range(w)] for _ in range(h)]
		is_visited[0][0] = True
		while queue:
			cur = queue.pop(0)
			for o in offset:
				y, x = cur[0]+o[0], cur[1]+o[1]
				if x < 0 or x >= w or y < 0 or y >= h:
					continue
				if x == w-1 and y == h-1:
					return cur[2]+1
				if is_visited[y][x]:
					continue
				if s[y][x] == ".":
					queue.append([y, x, cur[2]+1])
					is_visited[y][x] = True
		return -1

	white_num = 0
	for i in range(H):
		for j in range(W):
			if pos[i][j] == ".":
				white_num += 1
	route = bfs(pos, H, W)
	if route == -1:
		print(-1)
	else:
		print(white_num-route-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

struct SegmentTree{
    ll n;
    vl node;
public:
    SegmentTree(vl v){
        ll sz = v.size();
        n = 1;
        while(n<sz) n*=2;
        node.resize(2*n-1,inf);
        
        //一番下に元配列を代入
        rep(i,sz) node[i+n-1] = v[i];
        
        //子供の小さいほうをとってく
        //ここは問題によって変わる
        mrep(i,n-2) node[i] = node[2*i+1]+node[2*i+2];
    }
    
    SegmentTree(ll ngo){
        ll sz = ngo;
        n = 1;
        while(n<sz) n*=2;
        node.resize(2*n-1,0);
        //一番下に元配列を代入
        //子供の小さいほうをとってく
        //ここは問題によって変わる
    }
    
    void update(ll x,ll val){
        //一番下にアクセス
        x += (n-1);
        
        node[x] += val;
        while(x>0){
            x = (x-1)/2;
            node[x] = node[2*x+1]+node[2*x+2];
        }
    }
    //区間[a,b)を探す
    ll get(ll a,ll b,ll k=0,ll l=0,ll r=-1){
        //最初は区間[0,n)
        if(r<0) r=n;
        
        //てきとう
        if(r <= a || b <= l) return 0;
        
        if(a<=l && r<=b) return node[k];
        
        ll ngol = get(a,b,2*k+1,l,(l+r)/2);
        ll ngor = get(a,b,2*k+2,(l+r)/2,r);
        return ngol+ngor;
    }
};


int main(void){
    ll n,q;
    string s;
    cin>>n>>s>>q;
    vector<SegmentTree> vst(26,n);
    //rep(i,26) vst.push_back(SegmentTree(n));
    //cout<<vst[0].get(0,1)<<endl;
    rep(i,26){
        rep(j,n){
            if(s[j] - 'a'==i) vst[i].update(j,1);
        }
    }
    rep(i,q){
        ll typ;
        cin>>typ;
        if(typ == 1){
            ll ind;
            char c;
            cin>>ind>>c;
            ind--;
            if(s[ind] != c){
                vst[s[ind]-'a'].update(ind,-1);
                vst[c-'a'].update(ind,1);
                s[ind] = c;
            }
        }
        else{
            ll l,r;
            cin>>l>>r;
            l--;
            ll ans = 0;
            rep(j,26){
                if(vst[j].get(l,r)>0) ans++;
            }cout<<ans<<endl;
        }
    }
}

Measured memory_bytes: 222212
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s;
	cin>>s;
	int d=s.size();
	int dp[2][2][2][2][11]={};
	dp[0][0][0][0][0]=1;
	for(int i=1; i<d; i++) dp[1][0][0][0][i]=1;
	for(int i=0; i<d; i++){
		for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][1][k][l][i+1]+=(dp[1][1][k][l][i]+dp[1][0][k][l][i]);
		for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][k][1][l][i+1]+=(dp[1][k][1][l][i]+dp[1][k][0][l][i]);
		for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][k][l][1][i+1]+=(dp[1][k][l][1][i]+dp[1][k][l][0][i]);
		if(3<s[i]-'0'){
			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][1][k][l][i+1]+=(dp[0][1][k][l][i]+dp[0][0][k][l][i]);
		}else if(3==s[i]-'0'){
			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[0][1][k][l][i+1]+=(dp[0][1][k][l][i]+dp[0][0][k][l][i]);
		}
		if(5<s[i]-'0'){
			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][k][1][l][i+1]+=(dp[0][k][1][l][i]+dp[0][k][0][l][i]);
		}else if(5==s[i]-'0'){
			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[0][k][1][l][i+1]+=(dp[0][k][1][l][i]+dp[0][k][0][l][i]);
		}
		if(7<s[i]-'0'){
			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][k][l][1][i+1]+=(dp[0][k][l][1][i]+dp[0][k][l][0][i]);
		}else if(7==s[i]-'0'){
			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[0][k][l][1][i+1]+=(dp[0][k][l][1][i]+dp[0][k][l][0][i]);
		}
	}
	cout<<dp[0][1][1][1][d]+dp[1][1][1][1][d]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	#define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	int n, m; cin >> n >> m;
	if (m % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}
	vector< vector<int> > g(n);
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b; --a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	vector<int> used(n, 0);
	
	function<bool(int, int)> dfs = [&](int v, int p) {
		used[v] = 1;
		int parity = 0;
		for (int to : g[v]) {
			if (to == p || used[to] == 2) {
				continue;
			}
			if (used[to] == 1) {
				parity ^= 1;
				cout << v+1 << " " << to+1 << "\n";
				continue;
			}
			if (!dfs(to, v)) {
				cout << v+1 << " " << to+1 << "\n";
				parity ^= 1;
			}
		}
		used[v] = 2;
		if (parity) {
			assert(p >= 0);
			cout << v+1 << " " << p+1 << "\n";
		}
		return parity;
	};
	dfs(0, -1);
	
	return 0;
}


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

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define endl '\n'
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

using ll = long long;
using P = pair<ll, ll>;

/*追加部分*/



/*main関数*/

int main() {
FASTIO;
    int n; cin >> n;
    set<int> d;
    for(int i = 0; i < n; i++){
        int in; cin >> in;
        d.insert(in);
    }

    cout << d.size() << endl;

return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)


char s[100001];

int main() {
  scanf("%s", s);
  int n = strlen(s);

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

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


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

int main()
{
    int table[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << table[k-1] << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		String[] a;
        int r=0,t=0,h=0;
        for(int i=0;i<n;i++){
            a=br.readLine().split(" ");
            r=a[0].compareTo(a[1]);
            if(r>0){ t+=3;
            }else if(r<0){ h+=3;
            }else{ t++; h++; }
        }
		System.out.println(t+" "+h);
	}
}

Measured memory_bytes: 25188
S = input()
w = int(input())
s = ''
if w == 1:
  print(S)
else:
  if len(S) % w == 0:
    for i in range(len(S) // w):
      s += S[i * w]
    print(s)
  else:
    for i in range((len(S) // w) + 1):
      s += S[i * w]
    print(s)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

struct Dijkstra{
  ll INF=1000000000000000009;
  ll MAX_V=1000000;
  ll st = -1;
  struct edge{ll to, cost;};
  typedef pair<ll, ll> p;
  vector<vector<edge>> G;
  vector<ll> pre, d;
  priority_queue<p, vector<p>, greater<p> > que; //class, inner, compair
  Dijkstra(ll s){
    G.resize(s+2);
    pre.resize(s+2, -1);
    d.resize(s+2, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(edge{b, c});
  }
  void init(){
    for(int i=0;i<d.size();i++) pre[i] = -1, d[i] = INF;
  }
  void dijkstra(int start){
    init();
    st = start;
    d[start]=0;
    que.push(p(0, start));
    while(!que.empty()){
      p p_now=que.top(); que.pop();
      ll v = p_now.second;
      if(d[v]<p_now.first) continue;
      for(int i=0;i<G[v].size();i++){
        edge e = G[v][i];
        if(d[e.to]>d[v]+e.cost){
          d[e.to]=d[v]+e.cost;
          pre[e.to] = v;
          que.push(p(d[e.to], e.to));
        }
      }
    }
  }
  vll get_path(int now){
    vll ret;
    while(now!=-1){
      ret.push_back(now);
      now = pre[now];
    }
    return ret;
  }
};
int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  ll a, b, c;
  Dijkstra D(n);
  set<vll> s;
  for(int i=0;i<m;i++){
    std::cin >> a >> b >> c;
    D.insert(a, b, c);
    s.insert(vll{a, -b});
  }
  ll r = 0;
  for(int i=1;i<=n;i++){
    auto right = s.lower_bound(vll{i, -10000000000});
    if(right==s.end()||(*right)[0]!=i) continue;
    ll now_r = -1*(*right)[1];
    //std::cout << "now" << i << '\n';
    for(int j=now_r;j>max((ll)i, r);j--) {
      //std::cout << j << " " << j-1 << '\n';
      D.insert(j, j-1, 0);
    }
    r = max(r, now_r);
  }
  D.dijkstra(1);
  std::cout << (D.d[n]==D.INF?-1:D.d[n]) << '\n';
  return 0;
}


Measured memory_bytes: 20864
N = int(input())

def factorize(n):
     a = []
     # 2で割り切れるまでnを割り続ける
     while n % 2 == 0:
         a.append(2)
         n //= 2
     f = 3
     # 3からはじめて各奇数で割り切れるまでnを割り続ける
     # nの最大約数は√nなので、f*fで計算
     while f * f <= n:
         if n % f == 0:
             a.append(f)
             n //= f
         else:
             f += 2
     if n != 1:
         a.append(n)
     return a
    
fs = factorize(N)

from collections import Counter
fc = Counter(fs)

ans = 0
i = 1
for k, v in fc.items():
    # print(k, v)
    k2, v2 = k,v
    while v2 >= i:
        # print(k, v, i)
        ans += 1
        v2 -= i  
        i += 1
    i = 1

print(ans)

Measured memory_bytes: 9468
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;

	int ans = X/(Y+Z);
	if (X%(Y+Z)<Z) ans--;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mk make_pair


int main()
{
  ll a;
  cin>>a;
  ll c[a];
  for(ll i=0;i<a;i++)
  {
    cin>>c[i];
  }
  ll pre[a],suff[a];
  for(ll i=0;i<a;i++)
  {
    if(i==0)
    pre[i]=c[i];
    else
    {
      pre[i]=(c[i]^pre[i-1]);
    }
  }
  for(ll i=a-1;i>=0;i--)
  {
    if(i==(a-1))
    {
      suff[i]=c[i];
    }
    else
    {
      suff[i]=c[i]^suff[i+1];
    }
  }
  for(ll i=0;i<a;i++)
  {
    if(i==0)
    cout<<suff[i+1]<<" ";
    else if(i==(a-1))
    cout<<pre[i-1]<<" ";
    else{
    ll k=pre[i-1]^suff[i+1];
    cout<<k<<" ";
    }

  }
}


Measured memory_bytes: 8244
#include<bits/stdc++.h> 
#include<tr1/unordered_map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
using namespace std;
typedef long long ll;
ll n;
ll a[505][505]={0};
ll b[505][505];
ll d[4][2]={0,1,0,-1,-1,0,1,0};
int main()
{
	scanf("%lld",&n);
	ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			a[i][j]=min(min(i,j),min(n-1-i,n-1-j));
			b[i][j]=1;
		}
	}
	queue<ll> q;
	for(ll i1=0;i1<n*n;i1++)
	{
		ll as;
		scanf("%lld",&as);
		ll x=(as-1)/n,y=(as-1)%n;
		cnt+=a[x][y];
		b[x][y]=0;
		q.push(as-1);
		while(q.size())
		{
			ll no=q.front();q.pop();
			ll x=no/n,y=no%n;
			ll now=a[x][y]+b[x][y];
			for(ll i=0;i<4;i++)
			{
				ll dx=x+d[i][0],dy=y+d[i][1];
				if(dx==n||dx==-1||dy==n||dy==-1) continue;
				if(now<a[dx][dy]) a[dx][dy]=now,q.push(dx*n+dy);
			}
		}
	}
	printf("%lld",cnt);
}

Measured memory_bytes: 7644
s=input()
t=input()

ans=10**9
for i in range(len(s)-len(t)+1):
  ss=s[i:i+len(t)]
  t_ans=0
  for j in range(len(t)):
    if ss[j]!=t[j]:
      t_ans+=1
  ans=min(ans,t_ans)

print(ans)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
#define int long long
int V[1<<10],C[1<<10];
int T[11111];
int n,m,w,t;
int l[10],x[10],y[10];
void dfs(int u,int b,int d){
  if(C[b]<0) C[b]=d+abs(x[u])+abs(y[u]);
  C[b]=min(C[b],d+abs(x[u])+abs(y[u]));
  for(int i=0;i<n;i++){
    if((b>>i)&1) continue;
    dfs(i,b+(1<<i),d+abs(x[u]-x[i])+abs(y[u]-y[i]));
  }
}
signed main(){
  cin>>n>>m>>w>>t;
  string s[m];
  int v[m],p[m];
  for(int i=0;i<m;i++) cin>>s[i]>>v[i]>>p[i];
  string r[10][10];
  int q[10][10];
  for(int i=0;i<n;i++){
    cin>>l[i]>>x[i]>>y[i];
    for(int j=0;j<l[i];j++) cin>>r[i][j]>>q[i][j];
  }
  map<string,int> msi;
  for(int i=0;i<m;i++) msi[s[i]]=i;
  memset(V,0,sizeof(V));
  for(int b=0;b<(1<<n);b++){
    memset(T,-1,sizeof(T));
    T[0]=0;
    for(int i=0;i<n;i++){
      if(!((b>>i)&1)) continue;
      for(int j=0;j<l[i];j++){
	int W=v[msi[r[i][j]]],D=p[msi[r[i][j]]]-q[i][j];
	if(D<=0) continue;
	for(int k=0;k<=w;k++){
	  if(T[k]<0) continue;
	  if(k+W>w) continue;
	  T[k+W]=max(T[k+W],T[k]+D);
	}
      }
    }
    for(int i=0;i<=w;i++) V[b]=max(V[b],T[i]);
  }
  memset(C,-1,sizeof(C));
  C[0]=0;
  for(int i=0;i<n;i++) dfs(i,1<<i,abs(x[i])+abs(y[i]));
  memset(T,-1,sizeof(T));
  T[0]=0;
  for(int b=0;b<(1<<n);b++){
    //cout<<b<<" "<<V[b]<<" "<<C[b]<<endl;
    if(V[b]<=0) continue;
    for(int k=0;k<=t;k++){
      if(T[k]<0) continue;
      if(k+C[b]>t) continue;
      T[k+C[b]]=max(T[k+C[b]],T[k]+V[b]);
    }
  }
  int ans=0;
  for(int i=0;i<=t;i++) ans=max(ans,T[i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3296