akhauriyash/Code-Regression huggingface dataset:
/*
Author : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com


" when you are not practicing someone else is ,
 and the day u meet them u will lose "

*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 200050

#define ll long long
#define ld long double
#define lli long long int

#define pb push_back
#define INF 1000000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))

#define loop(i,n) for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define mci map<char,lli>
#define vi vector<lli>
#define vbool vector<bool>
#define seti set<lli>
#define pii pair<lli,lli>
#define pcc pair<char,char>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvec(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvec(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}


int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    lli n;
    cin>>n;
    if(n>=30)
        print("Yes");
    else
        print("No");


  }
return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
 
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define pii pair<ll,ll>

const ll maxn = 1e5 + 101;
ll w[maxn],v[maxn];
ll f[maxn];
int main(){
    ll n,W;
    scanf("%lld%lld",&n,&W);
    for(ll i=1;i<=n;++i){
        scanf("%lld%lld",w+i,v+i);
    }
    for(ll i=1;i<=n;++i){
        for(ll l=W;l>=w[i];--l){
            f[l]=max(f[l],f[l-w[i]]+v[i]);
        }
    }
    printf("%lld\n",f[W]);
    return 0;
}

Measured memory_bytes: 4544
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> H >> W >> K;
    vector<vector<char>> s(H, vector<char>(W));
    vector<vector<int>> res(H, vector<int>(W));
    int cake = 0;
    vi v;
    for (int i = 0; i < H; i++) {
        int tmp = cake;
        int prev = 0;
        for (int j = 0; j < W; j++) {
            cin >> s[i][j];
            if (s[i][j] == '#') {
                cake++;
                for (int k = prev; k <= j; k++) {
                    res[i][k] = cake;
                    for (int l = 0; l < v.size(); l++) {
                        res[i - v[l]][k] = cake;
                    }
                }
                prev = j + 1;
            }
        }
        if (tmp == cake) {
            v.push_back(v.size() + 1);
        } else {
            for (int j = prev; j < W; j++) {
                res[i][j] = res[i][prev - 1];
                for (int l = 0; l < v.size(); l++) {
                    res[i - v[l]][j] = res[i][prev - 1];
                }
            }
            v.clear();
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (res[i][j] == 0) {
                res[i][j] = res[i - 1][j];
            }
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1536
A, B = map(int, input().split())
S = input()

for i in range(A):
    if S[i].isdecimal():
        pass
    else:
        print("No")
        exit()

if S[A] == "-":
    pass
else:
    print("No")
    exit()

for i in range(A + 1, A + B + 1):
    if S[i].isdecimal():
        pass
    else:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 61860
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val d = sc.nextInt()

    println(problem134_b(n, d))
}

fun problem134_b(n: Int, d: Int): Int {

    val canKanshi = 2 * d + 1

    return if (n % canKanshi == 0) {
        (n / canKanshi)
    } else (n / canKanshi) + 1
}

Measured memory_bytes: 31260
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
 
 
signed main(){
  int n;
  cin>>n;
  vector<int> A(n);
  vector<int> B(n);
  cin>>A>>B;
 
  int k = 0;
  int b = 0;
  for(int i=0;i<n;i++){
    if(A[i] < B[i]){
      k += (B[i] - A[i])/2;
    }
    if(A[i] > B[i]) b += A[i]-B[i];
  }
  
  int ans = k >= b;
  cout<<(ans? "Yes":"No")<<endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d; 
   if (a + b > c + d){ 
  cout << "Left" << endl;
   }
  else if (a + b == c + d){ 
  cout << "Balanced" << endl;
   }
   else 
   {cout << "Right" << endl; 
   }
}


Measured memory_bytes: 256
def init_max(init_max_val):
    #set_val
    for i in range(n):
        seg_max[i+num_max-1]=init_max_val[i]    
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2]) 
    
def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])
    
def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = -1

# #num_max:n以上の最小の2のべき乗
# num_max =2**(n-1).bit_length()
# seg_max=[ide_ele_max]*2*num_max

N,K = map(int,input().split())
A = [int(input()) for _ in range(N)]
n = 1000000
lis = [0] * 1000000


num_max =2**(n-1).bit_length()
seg_max=[ide_ele_max]*2*num_max


init_max(lis)
dp = [0] * (N+1)
for i in range(N):
    val = query_max(max(0,A[i]-K),A[i]+K+1) +1
    dp[i] = val
    update_max(A[i],val)
print(max(dp))


Measured memory_bytes: 120092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

ll gcd(ll x, ll y)
{
	ll r;

	if (x == 0 || y == 0)  // 引数チェック
	{
		fprintf(stderr, "引数エラーです。\n");
		return 0;
	}

	// ユーグリッドの互除法
	while ((r = x % y) != 0)  // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}

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

	ll a, b, c, d, n, m, ans = 0, ret = M;
	string s, t;
	bool flag = false;
	cin >> a >> b >> c;
	if(b / a >= c) cout << c << endl;
	else cout << b / a << endl;
	return 0;
}


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

int main() {
  int n;
  string s;
  
  cin >> n >> s;
  
  vector<int> r;
  
  for (int i = 0; i < s.length(); ++i) {
     if (s[i] == 'R') {
       r.push_back(i);
     }
  }
  int count = 0;
  
  for (int i = 0; i < r.size(); ++i) {
    if (r[i] >= r.size()) count++;
  }
  
  cout << count << endl;
  
  
}

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


using namespace std;


int main(void) {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double ha = 2 * M_PI * (H / 12) + (2 * M_PI / 12) * (M / 60);
    double ma = 2 * M_PI * (M / 60);
    double x;
    if (ha >= ma) {
        x = ha - ma;
    } else {
        x = ma - ha;
    }
    if (x > M_PI) {
        x = 2 * M_PI - x;
    }
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(x));
    printf("%.16f\n", ans);
}


Measured memory_bytes: 4320
n = int(input())
a = list(map(int, input().split()))

count = 0
sum_i = a[0]

if a[0] < 0:
    sum_i = 1
    pos_count = 1 - a[0]
    for i in range(1, n):
        if sum_i < 0:
            sum_i += a[i]
            if sum_i <= 0:
                pos_count += 1 - sum_i
                sum_i = 1
        elif sum_i > 0:
            sum_i += a[i]
            if sum_i >= 0:
                pos_count += sum_i + 1
                sum_i = -1
    sum_i = a[0]
    neg_count = 0
    for i in range(1, n):
        if sum_i < 0:
            sum_i += a[i]
            if sum_i <= 0:
                neg_count += 1 - sum_i
                sum_i = 1
        elif sum_i > 0:
            sum_i += a[i]
            if sum_i >= 0:
                neg_count += sum_i + 1
                sum_i = -1
    if neg_count < pos_count:
        count = neg_count
    else:
        count = pos_count
elif a[0] > 0:
    sum_i = a[0]
    pos_count = 0
    for i in range(1, n):
        if sum_i < 0:
            sum_i += a[i]
            if sum_i <= 0:
                pos_count += 1 - sum_i
                sum_i = 1
        elif sum_i > 0:
            sum_i += a[i]
            if sum_i >= 0:
                pos_count += sum_i + 1
                sum_i = -1
    sum_i = -1
    neg_count = 1 + a[0]
    for i in range(1, n):
        if sum_i < 0:
            sum_i += a[i]
            if sum_i <= 0:
                neg_count += 1 - sum_i
                sum_i = 1
        elif sum_i > 0:
            sum_i += a[i]
            if sum_i >= 0:
                neg_count += sum_i + 1
                sum_i = -1
    if neg_count < pos_count:
        count = neg_count
    else:
        count = pos_count
else:
    sum_i = 1
    pos_count = 1
    for i in range(1, n):
        if sum_i < 0:
            sum_i += a[i]
            if sum_i <= 0:
                pos_count += 1 - sum_i
                sum_i = 1
        elif sum_i > 0:
            sum_i += a[i]
            if sum_i >= 0:
                pos_count += sum_i + 1
                sum_i = -1
    sum_i = -1
    neg_count = 1
    for i in range(1, n):
        if sum_i < 0:
            sum_i += a[i]
            if sum_i <= 0:
                neg_count += 1 - sum_i
                sum_i = 1
        elif sum_i > 0:
            sum_i += a[i]
            if sum_i >= 0:
                neg_count += sum_i + 1
                sum_i = -1
    if neg_count < pos_count:
        count = neg_count
    else:
        count = pos_count

print(count)


Measured memory_bytes: 14340
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m;
int a[100010];
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	int t=(n-1)/(m-1);
	if ((n-1)%(m-1)) t++;
	cout <<t;
	return 0;
}


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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0 && s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        } 
        else if(i%2==1&&s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
class Rank
  attr_accessor :id, :point
  def initialize(place, point)
    @id = place
    @point = point
  end
end

while s = gets
  n, m = s.split.map(&:to_i)
  break if n == 0 && m == 0

  arr = Array.new(m)
  m.times do |i|
    arr[i] = Rank.new(i+1, 0)
  end

  n.times do |i|
    points = gets.split.map(&:to_i)
    m.times do |j|
      arr[j].point += points[j]
    end
  end

  arr.sort! do |a, b|
    if a.point == b.point
      a.id <=> b.id
    else
      b.point <=> a.point
    end
  end

  puts arr.map(&:id).join(" ")
end

Measured memory_bytes: 6128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

bool isPrime(int n) {
	if (n == 1) return false;
	int i;
	for (i = 2; i*i <= n; i++) {
		if (n%i == 0) return false;
	}
	return true;
}
int main() {
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i, n;
	cin >> n;
	i = 0;
	while (n) {
		if (isPrime(5 * i + 1) == true) {
			cout << 5 * i + 1;
			if (n != 1) cout << " ";
			n--;
		}
		i++;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc109_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<string> s(N);
  set<string> ss;
  rep(i, N) {
    cin >> s[i];
    ss.insert(s[i]);
  }
  if (s.size() != ss.size()) {
    cout << "No" << endl;
    return 0;
  }

  bool ok = true;
  rep(i, N - 1) {
    if (s[i][s[i].size() - 1] != s[i + 1][0]) {
      ok = false;
      break;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
S=input()
N=len(S)
count=0
if S[0]=="A":
	if S[2:-1].count("C")==1 and S[1]!="C"and S[-1]!="C":
		P=S.replace("A","")
		Q=P.replace("C","")
		if Q.islower():
			print("AC")
		else:
			print("WA")
	else:
		print("WA")
else:
	print("WA")

Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))
if min(a) != 0:
  ans = 1
  for i in range(n):
    ans = ans*a[i]
    if 10**18 < ans:
      print(-1)
      break
  if ans <= 10**18 and ans != 0:
      print(ans)
else:
  print(0)

Measured memory_bytes: 21600
#include <iostream>
using namespace std;
#define int long long

int n, x;

int length(int a, int b) {
	if (b == 0) return 0;
	return b * (a / b) + length(b, a % b);
}

signed main() {
	cin >> n >> x;
	cout << 3 * length(n - x, x) << endl;
	return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a+b >= a-b){
    if(a+b >= a*b) cout << a+b;
    else cout << a*b;
  }
  else{
    if(a-b >= a*b) cout << a-b;
    else cout << a*b;
  }
  return 0;
}

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

using namespace std;

int main()
{
    string a, b, c;
    int n;

    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;

    int count = 0;

    for (int i = 0; i < n; i++)
    {
        int ia, ib, ic;
        ia = a[i];
        ib = b[i];
        ic = c[i];
        if (ia == ib && ib == ic)
        {
            continue;
        }

        if(ia == ib || ib == ic || ia == ic){
            count++;
        }else{
            count = count + 2;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
gets

head_tail, heading = ["", ""], 0

$<.each do |line|
  line.chomp!
  if line == "1"
    heading = 1 - heading
  elsif line[0,3] == "2 1"
    head_tail[heading] << line[-1]
  else
    head_tail[1-heading] << line[-1]
  end
end

s.reverse! unless heading.zero?
ans = head_tail[heading].reverse + s + head_tail[1-heading]
puts ans




Measured memory_bytes: 3196
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

class coord{
public:
    int x, y;
};
bool comp(coord c1, coord c2){
    if(c1.x>c2.x)
        return 0;
    else if(c1.x<c2.x)
        return 1;
    else{
        if(c1.y>c2.y)
            return 0;
        else
        return 1;
    }
}

void mun(vector<vector<int>> &d, int r1, int r2, int c1, int c2, int num){
    for(int i = r1; i<=r2; i++){
        for(int j = c1; j<=c2; j++){
            d[i][j] = num;
        }
    }
}
int main()
{
    int m, n, k;
    cin >> m;
    cin >> n;
    cin >> k;
    vector<coord> straw;
    coord z;
    z.x = -1;
    z.y = -1;
    straw.push_back(z);
    int max_r = 0;
    for(int i = 0; i<m; i++){
        for(int j = 0; j<n; j++){
            char c;
            cin >> c;
            if(c=='#'){
                coord c;
                c.x = i;
                c.y = j;
                straw.push_back(c);
                max_r = i;
            }
        }
    }
    z.x = n;
    z.y = n;
    straw.push_back(z);
    vector<vector<int>> d(m);
    for(int i = 0; i<m; i++){
        vector<int> temp(n);
        d[i] = temp;
    }
    // cout << m << n << k << endl;
    // cout << straw.size() << endl;
    int prev = 0;
    for(int i = 1; i<=k; i++){
        // cout << i << endl;
        int r1, r2, c1, c2;
        if(straw[i].x == straw[i-1].x){
            c1 = straw[i-1].y+1;
        }
        else{
            prev = straw[i-1].x+1;
            c1 = 0;
        }
        if(straw[i].x == straw[i+1].x){
            c2 = straw[i+1].y-1;
        }
        else{
            c2 = n-1;
        }
        r2 = straw[i].x;
        if(r2==max_r)
            r2 = m-1;
        r1 = prev;
        // cout << "r1 = " << r1 << " r2 = " << r2 << endl;
        // cout << "c1 = " << c1 << " c2 = " << c2 << endl;
        mun(d, r1, r2, c1, c2, i);
    }
    
    for(int i = 0; i<m; i++){
        for(int j = 0; j<n; j++){
            cout << d[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1780
#--- define function ---#
def num_check(n, l):
    if 2 * n == len(l):
        return True
    else:
        return False

#--- main ---#
num = int(input())
l = input().split()
list = [int(i) for i in l]

if not num_check(num, list):
    print("Invalid numbers.")
    exit()

list.sort()

meet = 0
for i in range(num):
    num1 = int(list.pop(0))
    list.pop(0)
    meet += num1

print(meet)


Measured memory_bytes: 3060
#include <complex>
#include <iostream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int val;
        cin >> val;
        v.push_back(val);
    }
    sort(v.begin(), v.end());
    
    long long sum = 0;
    
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            for (int k = j+1; k < n; k++) {
                if (v[i] + v[j] > v[k]) sum++;
                else break;
            }
        }
    }
    
    cout << sum << endl;
    
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc104/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

int D;
ll G;
vector<int> p;
vector<int> c;
int inf = 1000000000;

int func(int bit, int point){
    int cnt = 0;
    for(int i = D - 1; i >= 0; i--){
        if(!(bit & (1 << i))){// bitのi番目が立ってなかったら
            rep(j, p[i] - 1){
                point += 100 * (i + 1);
                cnt++;
                if(point >= G){
                    return cnt;
                }
            }
        }
    }
    if(point >= G) return cnt;
    else return inf;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    cin >> D >> G;
    p.resize(D);
    c.resize(D);
    rep(i, D){
        cin >> p[i];
        cin >> c[i];
    }
    int ans = inf;

    // 100i点問題をすべて解くかどうかで，2^D通りのbit全探索
    rep(bit, (1 << D)){
        int cnt = 0;
        ll point = 0;
        rep(i, D){
            if(bit & (1 << i)){
                cnt += p[i];
                point += (i + 1) * 100 * p[i] + c[i];
            }
        }
        if(point >= G) ans = min(ans, cnt);
        else ans = min(ans, cnt + func(bit, point));
    }

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

Measured memory_bytes: 256
D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]
p_dice = (0, 0, 0, 1, 1, 2, 2, 3)*3

def rotate_dice(L0):
    L = L0[:]
    for k in p_dice:
        yield L
        L[:] = (L[e] for e in D[k])

while 1:
    N = int(input())
    if N == 0:
        break
    res = []
    for i in range(N):
        cube = input().split()
        for dice in rotate_dice(cube):
            if dice in res:
                break
        else:
            res.append(cube)
    print(N - len(res))


Measured memory_bytes: 5620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    string s;
    cin>>s;
    int m=s.size();
    set<char> st;
    for(int i=0;i<26;i++) st.insert(i+'a');
    rep(i,m){
        if(st.count(s[i])) st.erase(s[i]);
    }
    if(st.size()==0) cout<<"None"<<endl;
    else cout<<*begin(st)<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
 using namespace std;
 typedef long long ll;
 const int mod=1e9+7;
 ll quick_mod(ll a,ll b)
{
    ll ans = 1;
    while(b){
        if(b&1){
            ans = (ans*a)%mod;
            --b;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return ans%mod;
}
ll Inv(ll x){
	return quick_mod(x,mod-2);
}
ll C(ll n,ll m){
	if (m>n) return 0;
	ll ans = 1;
	for (int i = 1; i <= m; ++i) ans=ans*Inv(i)%mod*(n-i+1)%mod;
	return ans%mod;
}
 int main()
 {
 	ll n,a,b;
 	cin>>n>>a>>b;
 	ll ans=quick_mod(2,n)-1;
 	ans-=C(n,a)+C(n,b);
 	ans=(ans%mod+mod)%mod;
	cout<<ans<<endl;
 }

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

int main(){
    int h,w,i,j;
    cin >> h >> w;
    string a[h];
    for (i=0;i<h;i++){
        cin >> a[i];
    }

    for (i=0;i<h;i++){
        int f=0;
        for (j=0;j<w;j++){
            if (a[i][j] == '#'){
                f++;
            }
        }
        if (f == 0){
            for (j=0;j<w;j++){
                a[i][j] = '0';
            }
        }
    }
    for (j=0;j<w;j++){
        int f=0;
        for (i=0;i<h;i++){
            if (a[i][j] == '#'){
                f++;
            }
        }
        if (f == 0){
            for (i=0;i<h;i++){
                a[i][j] = '0';
            }
        }
    }

    for (i=0;i<h;i++){
        for (j=0;j<w;j++){
            if (a[i][j] == '0'){
                continue;
            }
            else{
                cout << a[i][j];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
 
int main() {
	int A,B,K,min,an;
  bool con = true;
    cin >> A >> B >> K;
    if(A>B)min = B;
    else min = A;
    for(int i = B;i>0;i--){
      if(A%i == 0 && B%i == 0)an++;
      if(an ==K){an++;cout << i << endl;}
    }
    
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2426&lang=jp
using namespace std;
typedef pair<int, int> pii;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<int> treasure_x(n), x(n);
	vector<int> treasure_y(n), y(n);

	for (int i = 0; i < n;i++) {
		cin >> treasure_x[i] >> treasure_y[i];
		x[i] = treasure_x[i]; y[i] = treasure_y[i];
	}

	sort(x.begin(), x.end()); sort(y.begin(), y.end());
	x.erase(unique(x.begin(), x.end()), x.end());
	y.erase(unique(y.begin(), y.end()), y.end());

	vector<vector<int>> dp(n + 2, vector<int>(n + 2, 0));
	for (int i = 0; i < n;i++) {
		int xind = lower_bound(x.begin(), x.end(), treasure_x[i]) - x.begin();
		int yind = lower_bound(y.begin(), y.end(), treasure_y[i]) - y.begin();
		dp[xind+1][yind+1]++;
	}

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


	for (int i = 0; i < m;i++) {
		int ans = 0;
		int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
		int x1ind = lower_bound(x.begin(), x.end(), x1) - x.begin();
		int y1ind = lower_bound(y.begin(), y.end(), y1) - y.begin();
		int x2ind = lower_bound(x.begin(), x.end(), x2+1) - x.begin();
		int y2ind = lower_bound(y.begin(), y.end(), y2+1) - y.begin();

		cout << dp[x2ind][y2ind] - dp[x2ind][y1ind] - dp[x1ind][y2ind] + dp[x1ind][y1ind] << endl;
	}
}

Measured memory_bytes: 100828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	ll x;
	cin >> x;
	ll cnt = 0;
	ll a = 100;
	while (1) {
		a *= 1.01;
		++cnt;
		if (a >= x) {
			break;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3624
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    LL n;
    cin >> n;
    string v;
    deque<string> T;
    for(int i=0;i<n;++i){
        cin >> v;
        if(i%2==n%2){
        T.push_back(v);
    }
    else{
        T.push_front(v);
    }
    }
    REP(i,n) cout << T[i] << " ";
}

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

int main() {
  int n; cin >> n;
  int happy[n][3] = {0};
    for (int i = 0; i < n; i++)
      for (int j = 0; j < 3; j++)
        cin >> happy[i][j];
  //入力
  int dp[n][3] = {0};
  for (int i = 0; i < 3; i++) dp[0][i] = happy[0][i];
  //dp表
  for (int i = 1; i < n; i++){
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+happy[i][0];
    dp[i][1] = max(dp[i-1][2],dp[i-1][0])+happy[i][1];
    dp[i][2] = max(dp[i-1][0],dp[i-1][1])+happy[i][2];
  }
  cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) <<endl;
}

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

int main() {
		string s, t;
		cin >> s >> t;
		bool flag = true;
		for(int i = 0; i < s.length(); i++) {
			if (s[i] != t[i]) {
					flag = false;
					break;
			}
		}
	
		if(flag) {
				cout << "Yes" << endl;
		} else {
				cout << "No" << endl;
		}
}


Measured memory_bytes: 3576
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
s = [0] * N
s[0] = A[0]
for i in range(1, N):
    s[i] = s[i - 1] + A[i]
s_c = Counter(s)
ans = s_c[0]
for key, val in s_c.items():
    ans += val * (val - 1) // 2
print(ans)

Measured memory_bytes: 44424
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=2e2;
int n;
int w[N+1],val[N+1],ans[N+1][(int)2e5];
void solve(int sum){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=sum;j++){
            if(j>=val[i]){
                ans[i][j]=min(ans[i-1][j],w[i]+ans[i-1][j-val[i]]);
            }
            else{
                ans[i][j]=ans[i-1][j];
            }
        }
    }
}
signed main()
{
     
    CHAL_BAAP_KO_MT_SIKHA
    int wt;
    cin>>n>>wt;
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>w[i]>>val[i];
        sum+=val[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=sum;j++){
            ans[i][j]=inf;
        }
    }
    for(int i=0;i<=n;i++){
        ans[i][0]=0;
    }
    solve(sum);
    int mx=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=sum;j++){
            if(ans[i][j]<=wt){
                mx=max(mx,j);
            }
        }
    }
    cout<<mx<<endl;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	int p[n];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int count = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((p[i - 1] < p[i] && p[i + 1] > p[i]) || (p[i - 1] > p[i] && p[i + 1] < p[i])) { count++; }
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3584
import collections
 
def counter_top(c, exclude):
  for a in c.most_common():
    if a[0] != exclude:
      return a
  return (object(), 0)
 
def conv_seq(seq, exclude=None):
  c = collections.Counter(seq)
  mc = counter_top(c, exclude)
  return sum(c.values()) - mc[1], mc[0]
 
input()
vals = list(map(int, input().split()))
s1, a = conv_seq(vals[::2])
s2, b = conv_seq(vals[1::2])
if a != b:
  print(s1 + s2)
else:
  s1_new, _ = conv_seq(vals[::2], exclude=b)
  s2_new, _ = conv_seq(vals[1::2], exclude=a)
  print(min(s1_new + s2, s1 + s2_new))

Measured memory_bytes: 17116
def main():
  N=int(input())
  #N=10000
  ans=[0]*(N+1)
  for x in range(1,101):
    for y in range(1,101):
      for z in range(1,101):
        n=x*x+y*y+z*z+x*y+y*z+z*x
        if n <= N:
          ans[n]+=1
        else:break
  for i in range(1,N+1):
    print(ans[i])
  #print(ans)
  pass
if __name__=='__main__':
  main()



Measured memory_bytes: 9428
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
class Restaurant {
public:
    //コンストラクタも改行した方が良い
    Restaurant(int serialNumber, string cityName, int score) : m_serialNumber(serialNumber), m_cityName(cityName), m_score(score) {}
    //constメンバ関数にしているのは良い
    int getSerialNumber() const {
        return m_serialNumber;
    }
    string getCityName() const {
        return m_cityName;
    }
    int getScore() const {
        return m_score;
    }
private:
    const int m_serialNumber;
    const string m_cityName;
    const int m_score;
};
 
bool lexicalOrder(const Restaurant* front, const Restaurant* back);
 
int main() {
    int numOfRestaurant;
    cin >> numOfRestaurant;
    
    //ガイドブックのクラスがあってもよかった
    vector<Restaurant*> guideBook;
    string cityName;
    int score;
    for (int i = 1; i <= numOfRestaurant; ++i) {
        cin >> cityName >> score;
        guideBook.push_back(new Restaurant(i, cityName, score));
    }
    
    sort(guideBook.begin(), guideBook.end(), lexicalOrder);
    
    for (Restaurant* restaurant : guideBook) {
        cout << restaurant->getSerialNumber() << endl;
    }
 
    for (Restaurant* restaurant : guideBook) {
        delete restaurant;
    }  
    
}

//ラムダ式にするか悩んだ
bool lexicalOrder(const Restaurant* front, const Restaurant* back) {
    if (front->getCityName() == back->getCityName()) {
        return front->getScore() > back->getScore();
    } else {
        return front->getCityName() < back->getCityName();
    }
}

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

int main(void){
    int n;
    cin >> n;
    int s=0;
    while(n>0){
        s+=n%10;
        n/=10;
    }
    if(s==1){
        cout << 10 << endl;
    }else{
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.io.*;

public class Main {
    
    static long attack_number(long h){
        if(h == 1L) return 1;
        return 2 * attack_number(h / 2L) + 1;
    }
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        br.close();
        
        System.out.println(attack_number(H));
    }
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
    
    int n;
    int a[99]={};
    int b[99]={};
    int c[99]={};
    int ans=0;
    int tmp=0;
    
    scanf("%d", &n);
    
    for(int i=1; i<=n; i++){
        
        scanf("%d", &a[i]);
        
    }
    
    for(int i=1; i<=n; i++){
        
        scanf("%d", &b[i]);
        ans += b[i];
        // printf("+%d\n", b[i]); // debug
        
    }
    
    for(int i=1; i<n; i++){
        
        scanf("%d", &c[i]);
        
    }
    
    for(int i=1; i<n; i++){
        
        tmp = a[i+1] - a[i];
        
        if(tmp==1){
            
            tmp = a[i];
            ans += c[tmp];
            // printf("++%d\n", c[tmp]); // debug
            
        }
        
    }
    
    printf("%d", ans);
    
    return 0;
    
}

Measured memory_bytes: 128
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main()
{
	int n;
	cin >> n;
	int cnt = 0;
	while(n--)
	{
		int x,y;
		cin >> x >> y;
		if(x==y) cnt++;
		else cnt = 0;
		if(cnt==3) break;
	}
	if(cnt == 3) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);
        int K = nextInt(r);
        int h[] = new int[N+K];
        for (int i = 0; i < N; i++) {
            h[i] = nextInt(r);
        }

        int dp[] = new int[N+K];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 1; j <= K; j++) {
                int abs = Math.abs(h[i+j]-h[i]);
                dp[i+j] = Math.min(dp[i+j], dp[i]+abs);
            }
        }
        System.out.println(dp[N-1]);
    }

    public static String nextString(InputStreamReader r) throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        return Integer.parseInt(nextString(r));
    }

    public static long nextLong(InputStreamReader r) throws Exception {
        return Long.parseLong(nextString(r));
    }
}


Measured memory_bytes: 45504
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,k=MI()
if k>((n-1)*(n-2))//2:
    print(-1)
else:
    count=0
    m=((n-1)*n)//2-k
    print(m)
    for i in range(n-1):
        for j in range(i+1,n):
            print(i+1,j+1)
            count+=1
            if count==m:
                sys.exit()

Measured memory_bytes: 42864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  int flag=0;
  int i;
  for(i=0;;i++){
    for(int j=0;j<N;j++){
      if(a.at(j)%2==0)a.at(j)/=2;
      else {flag++;break;}
    }
    if(flag>0)break;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
const int maxn = 100+10;
using namespace std;

int n;
int a[maxn];

void solve(){
    double sum = 0;
    for(int i = 1 ; i <= n ;i++){
        double cas = 1.0/a[i];
        sum += cas;
    }
    printf("%f\n",1.0/sum);
}

int main(){
    while(~scanf("%d",&n)){
        for(int i = 1; i <= n; i++){
            scanf("%d",&a[i]);
        }
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder.ABC124.A
{
    class Program
    {
        public static void Main()
        {
            // Solve(5, 3);
            // Solve(3, 4);
            // Solve(6, 6);
            // return;
            var str = Console.ReadLine().Split(' ');
            var A = int.Parse(str[0]);
            var B = int.Parse(str[1]);
            Solve(A, B);
        }

        static void Solve(int A, int B)
        {
            var coin = 0;
            if (A > B)
            {
                coin += A;
                --A;
            }
            else
            {
                coin += B;
                --B;
            }
            if (A > B)
            {
                coin += A;
                --A;
            }
            else
            {
                coin += B;
                --B;
            }
            Console.WriteLine(coin);
        }
    }
}


Measured memory_bytes: 11092
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var r int

	r += (n / 500) * 1000
	n = n % 500
	if n != 0 {
		r += (n / 5) * 5
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
namespace Collections
{
	class program
	{
    //static long MAX_LONG = 5000000000000000;
		static void Main(string[] args)
		{

			// 入力
			int N = int.Parse(Console.ReadLine());
      int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			int max = 0;
			int a = 0; // 左の方が大きい時１ふえる
			for(int i=N-1; i>0; i--)
			{
				//Console.WriteLine((i-1) + "  " + i + " " + input.Length);
				if(input[i-1] >= input[i])
				{
					a++;
					if(max < a)
					{
						max = a;
					}
				}
				else
				{
					a = 0;
				}
			}

			Console.WriteLine(max + "");
    }
	}
}


Measured memory_bytes: 24156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    int n;
    cin >> n;
    vector<int> a(n,IINF),b(n);
    REP(i,n-1) cin >> b[i];
    REP(i,n-1){
        a[i] = min(a[i], b[i]);
        a[i+1] = min(a[i+1], b[i]);
    }
    int ans = 0;
    REP(i,n) ans += a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self):
        self.parent_id = -1
        self.depth = 0
        self.children = []

global nodes

def calc_depth(node_id,arg_depth):

    nodes[node_id].depth = arg_depth
    for child in nodes[node_id].children:
        calc_depth(child, arg_depth+1)

V = int(input())
nodes =[]
for loop in range(V):
    node = Node()
    nodes.append(node)

for loop in range(V):

    table = list(map(int,input().split()))
    node_id = table[0]
    num = table[1]

    for i in range(num):
        child_id =table[2+i]
        nodes[node_id].children.append(child_id)
        nodes[child_id].parent_id = node_id

for i in range(V):
    if nodes[i].parent_id == -1:
        calc_depth(i,0)
        break

for i in range(V):

    print("node %d: parent = %d, depth = %d, "%(i,nodes[i].parent_id,nodes[i].depth),end = "")

    if nodes[i].parent_id == -1:
        print("root,",end = "")
    else:
        if len(nodes[i].children) == 0:
            print("leaf,",end = "")
        else:
            print("internal node,",end = "")

    print(" [",end = "")
    print(", ".join(map(str,nodes[i].children)),end ="")
    print("]")



Measured memory_bytes: 40700
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

int maximum;
map<pair<int,int>, int> mp, ans;
vector<vector<int>> tree;

void dfs(int col, int node, int per){
	int con = 1;
	
	maximum = max(col, maximum);
	
	for(int next : tree[node]){
		if(per == next) continue;
		if(col == con) con++;
		ans[{node,next}] = con++;
		
		dfs(con-1, next, node);
	}
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	vector<pair<int,int>> temp;
	
	int N;


	cin>>N;
	
	tree.resize(N);
	
	for(int i = 0; i < N-1; i++){
		int a, b;
		
		cin>>a>>b;
		
		a--, b--;
		
		tree[a].push_back(b);
		tree[b].push_back(a);
		mp[{a,b}] = i+1;
		mp[{b,a}] = i+1;
	}
	
	dfs(-1,0, -1);
	
	
	for(pair<pair<int,int>, int> p : ans){
		temp.push_back({mp[{p.first}], p.second});
	}
	
	cout<<maximum<<endl;
	
	sort(temp.begin(), temp.end());
	
	for(int i = 0; i < temp.size(); i++){
		cout<<temp[i].second<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 27256