akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
using namespace std;

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

	int days=0;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < D; j++) {
			if ((j + 1) / 10 > 1 && (j + 1) % 10 > 1 && i + 1 == ((j + 1) / 10) * ((j + 1) % 10)) {
				days++;
			}
		}
	}

	cout << days << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,j,k,n,m,l;
  long long int sum;
  int **A;
  int **B;
  scanf("%d%d%d",&n,&m,&l);
  A=malloc(n*sizeof(int *));
  for(i=0;i<n;i++){
    A[i]=malloc(m*sizeof(int));}
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&A[i][j]);}}
  B=malloc(m*sizeof(int *));
  for(i=0;i<m;i++){
    B[i]=malloc(l*sizeof(int));}
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%d",&B[i][j]);}}
    for(i=0;i<n;i++){
      for(j=0;j<l-1;j++){
        sum=0;
        for(k=0;k<m;k++){
          sum=sum+A[i][k]*B[k][j];}
        printf("%lld ",sum);}
      sum=0;
      for(k=0;k<m;k++){
        sum=sum+A[i][k]*B[k][l-1];}
      printf("%lld\n",sum);}
  for(i=0;i<n;i++){
    free(A[i]);}
  free(A);
  for(i=0;i<m;i++){
    free(B[i]);}
  free(B);
  return 0;}

Measured memory_bytes: 680
#include <stdio.h>

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  double v;

  while ( scanf ( "%lf", &v ) == 1 )
  {
    int res = 0;

    v = v * v / ( 2. * 9.8 ) / 5.;
    while ( v >= res )
      ++res;

    printf ( "%d\n", res + 1 );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def z_algo(S):
    N = len(S)
    A = [0] * N
    i = 1
    j = 0
    A[0] = l = len(S)
    while i < l:
        while i + j < l and S[j] == S[i + j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l - i > k < j - A[k]:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k

    ret = 0
    for i in range(1, N):
        ret = max(ret, min(A[i], i))

    return ret


def main():

    N = in_n()
    S = in_s()

    ans = 0
    for i in range(N):
        ans = max(ans, z_algo(S[i:]))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77104
N, K = map(int, input().split())

ans = 0
Ns = list(range(N+1))
cumsum = [0]
for i in range(N+1):
    cumsum.append(cumsum[i] + Ns[i])

MOD = 10**9 + 7

for i in range(K, N+2): #k-->N+1
    tmp = cumsum[-1] - cumsum[-i-1] - cumsum[i] + cumsum[0] + 1
    ans += tmp
    ans %= MOD

print(ans)

Measured memory_bytes: 27008
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
 
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int SIZE = 31;
const int INF = 1<<27;
 
int G[SIZE][SIZE], C[4];
int H, W;
 
struct State {
  int x, y, d, cost;
  State() {}
  State(int x, int y, int d, int cost) : x(x), y(y), d(d), cost(cost) {}
  bool operator<(const State &s) const {
    return cost>s.cost;
  }
};
 
int dijkstra() {
  int cost[4][SIZE][SIZE];
  priority_queue<State> pq;
  pq.push(State(0,0,0,0));
  fill(cost[0][0], cost[4][0], INF);
  cost[0][0][0] = 0;
  while(!pq.empty()) {
    const State s = pq.top(); pq.pop();
    if(cost[s.d][s.y][s.x] < s.cost) continue;
    if(s.x == W-1 && s.y == H-1) return s.cost;
    for(int i=0; i<4; i++) {
      State t = s;
      t.cost += ( G[s.y][s.x] == i ? 0 : C[i] );
      t.d = (s.d + i) % 4;
      t.x += dx[t.d], t.y += dy[t.d];
      if(0 <= t.x && t.x < W 
     && 0 <= t.y && t.y < H 
     && cost[t.d][t.y][t.x] > t.cost) {
    pq.push(t);
    cost[t.d][t.y][t.x] = t.cost;
      }
    }
  }
   
  return INF;
}
 
int main() {
  while(cin >> W >> H, W+H) {
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
    cin >> G[i][j];
    for(int i=0; i<4; i++) cin >> C[i];
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 1328
module ABC134

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: calculate_num_monitor

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! variables for this <subroutine>
    integer(INT32) :: N
    integer(INT32) :: D

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*) N, D

    ! STEP.02
    ! calculate & output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') calculate_num_monitor (N, D)

    ! STEP.END
    return

  end subroutine task_B

  pure function calculate_num_monitor (num_tree_all, num_range) result(num_monitor)

    ! arguments for this <function>
    integer(INT32), intent(in) :: num_tree_all
    integer(INT32), intent(in) :: num_range

    ! variables for this <subroutine>
    integer(INT32) :: num_tree_watched

    ! return value of this <function>
    integer(INT32) :: num_monitor

    num_tree_watched = 2_INT32 * num_range + 1_INT32
    num_monitor      = num_tree_all / num_tree_watched
    
    if ( mod(num_tree_all, num_tree_watched) .ne. 0_INT32 ) then
      num_monitor = num_monitor + 1_INT32
    end if

    return

  end function calculate_num_monitor

end module ABC134


program main

  ! <module>s to import
  use, non_intrinsic :: ABC134

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;

    int ans=1;
    while(ans<=n){
        ans*=2;
    }

    cout<<(ans>1?ans/2:1)<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  vector<int> v(n), w(n);
  REP(i,n){
    scanf("%d %d", &v[i], &w[i]);
  }

  int dp[101][10010] = {};
  for(int i = 0; i < n; ++i){
    for(int j = 0; j <= W; ++j){
      if(j - w[i] >= 0){
        dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
      }else{
        dp[i+1][j] = dp[i][j];
      }
    }
  }

  int ans = 0;
  REP(i,W+1){
    ans = max(ans, dp[n][i]);
  }

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



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

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  priority_queue<int> Q;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    Q.push(a);
  }

  for (int i = 0; i < M; i++) {
    int t = Q.top();
    Q.pop(), Q.push(t / 2);
  }

  long long ans = 0;
  while (Q.size()) ans += Q.top(), Q.pop();

  cout << ans << endl;
}

Measured memory_bytes: 892
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = ToIntArray(input.ReadLine(), n);

        var xx = new long[n];

        xx[0] = 0;
        for(int i=0; i<n; i++) {
            if (i % 2 == 0) xx[0] += aa[i];
            else xx[0] -= aa[i];
        }

        for(int i=1; i<n; i++) {
            xx[i] = 2 * aa[i - 1] - xx[i - 1];
        }

        var buil = new StringBuilder();
        foreach(var i in xx) {
            buil.Append(i);
            buil.Append(' ');
        }
        return buil.ToString();
    }

    static List<long> ToIntArray(string strs, int n) {
        var ret = new List<long>(n);
        var spl =strs.Split(' ');
        for (long i = 0; i < n; i++)
            ret.Add(long.Parse(spl[i]));
        return ret;
    }
}


Measured memory_bytes: 33116
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
using namespace std;

int cmp = 0;

queue<int> merge(queue<int> q1, queue<int> q2){
	queue<int> ma;
	while(q1.size() || q2.size()){
		if(!q2.size() || (q1.size() && q1.front() < q2.front())){
			ma.push(q1.front());
			q1.pop();
		}else{
			ma.push(q2.front());
			q2.pop();
		}
		cmp++;
	}
	return ma;
}
queue<int> sort(queue<int> q){
	queue<int> nq;
	while(q.size() - nq.size() > 1){
		nq.push(q.front());
		q.pop();
	}
	if(!nq.size()) return q;
	return merge(sort(nq), sort(q));
}

int main() {
	int n;
	scanf("%d", &n);
	
	queue<int> q;
	while(n--){
		int i;
		scanf("%d", &i);
		q.push(i);
	}
	
	q = sort(q);
	while(q.size()){
		printf("%d%c", q.front(), q.size()==1 ? '\n' : ' ');
		q.pop();
	}
	printf("%d\n", cmp);
	
    return 0;
}

Measured memory_bytes: 10428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

int main(){	
	long long A;
	long long B;
	scanf("%lld",&A);
	scanf("%lld",&B);
	A--;
	B--;
	bool init1 = true, init2 = true;
	ll h = 0;
	bool res[100][100];
	while(A != 0 || B != 0 || init1 || init2) {
		if (A != 0 || init1) {
			rep(i, 100) {
				if (i%2==0 && A != 0) {
					res[h][i] = false;
					A--;
				} else {
					res[h][i] = true;
				}
			}
			rep(i, 100) {
				res[h+1][i] = true;
			}
			init1 = false;
		} else {
			rep(i, 100) {
				res[h][i] = false;
			}
			rep(i, 100) {
				if (i%2==0 && B != 0) {
					res[h+1][i] = true;
					B--;
				} else {
					res[h+1][i] = false;
				}
			}
			init2 = false;
		}
		h += 2;
	}
	cout << h << " 100" << endl; 
	rep(i, h) {
		rep(j, 100) {
			if (res[i][j]) cout << "#"; else cout << ".";
		}
		cout << endl;
	}
	return 0;
}



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

int solve(int n ,  int dp[] , int h[])
{
    int c = 99999999;
    if(dp[n] != -1) return dp[n];
  	if(n == 1) return dp[n] = abs(h[1] - h[0]);
  	if(n == 0) return dp[n] = 0 ;
  	else 
    {
      	c = min(abs(h[n-2] - h[n]) + solve(n-2 , dp ,   h) , abs(h[n-1] - h[n]) + solve(n-1 , dp ,  h));
      	return dp[n] =  c ;
    }
}



int32_t main()
{






  	int n;
  	cin>>n;
  	int i;
  	int h[n];
  	int dp[n]; 
  	for(i=0;i<n;i++) cin>>h[i];
  	memset(dp , -1 , sizeof(dp));
  	int ans = solve(n-1  ,dp ,  h);
  	
  	cout<<ans<<endl;
  	return 0; 

	

}	

Measured memory_bytes: 10612
import java.util.HashMap;
import java.util.Scanner;
class Main {
	long[][] total;
	Scanner scan = new Scanner(System.in);
	HashMap<Integer,Integer> hm;
	
	public static void main(String args[]){
		Main app = new Main();
		
		
		while(true){
			if(app.input() == -1){
				break;
			}
			app.exec();
		}
	}
	
	public int input(){
		int count=0,n,number;
		hm = new HashMap<Integer,Integer>();
		
		n = scan.nextInt();
		if(n == 0){
			return -1;
		}
		total = new long[n][2];
		for(int i=0;i<n;i++){
			number = scan.nextInt();
			if(hm.containsKey(number)){
				total[hm.get(number)][1] += scan.nextLong()*scan.nextLong();
			}else{
				total[count][0] = number;
				total[count][1] = scan.nextLong()*scan.nextLong();
				hm.put(number,count);
				count++;
			}
		}
		
		return 1;
	}
	
	public void exec(){
		boolean flag = true;
		
		for(int i=0;i<hm.size();i++){
			if(total[i][1] >= 1000000){
				System.out.println(total[i][0]);
				flag = false;
			}
		}
		if(flag){
			System.out.println("NA");
		}
	}
}

Measured memory_bytes: 25024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;
constexpr ll MAX = 2000;

ll N, D[MAX], E[MAX];

int main()
{
    ll count = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> D[i] >> E[i];
    }
    for (int i = 0; i < N - 2; i++)
    {
        if (D[i] == E[i] && D[i + 1] == E[i + 1] && D[i + 2] == E[i + 2])
        {
            count += 1;
        }
    }
    if (count > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int a, b, c;
  ci(a, b, c);
  a == b && b == c ? co(1) : a == b || b == c || c == a ? co(2) : co(3);
}

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

using namespace std;

int main() {
    long long a;
    double b;

    {
        string s;
        cin >> s;
        a = atoll(s.c_str());
    }

    {
        string s;
        cin >> s;
        b = atof(s.c_str());
    }

    long long c = (b + 0.0001) * 100; // 0.0001 は若干不足する場合用
    long long ans = (a * c) / 100;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3224
#include <cstdio>
#include <cmath>
#include <iostream>
#include <ctime>
#include <vector>
#include <cstdlib>
using namespace std;
char op[3];
int main(){
    int n;
int a,b,c,d;
cin >> n;
d = n%10;
n = (n-d)/10.0;
c = n%10;
n = (n-c)/10.0;
b = n%10;
n = (n-b)/10.0;
a = n%10;
if (a+b+c+d == 7){
    op[0] = '+';
    op[1] = '+';
    op[2] = '+';
}else if(a+b+c-d == 7){
    op[0] = '+';
    op[1] = '+';
    op[2] = '-';
}else if(a+b-c+d == 7){
    op[0] = '+';
    op[1] = '-';
    op[2] = '+';
}else if(a-b+c+d == 7){
    op[0] = '-';
    op[1] = '+';
    op[2] = '+';
}else if(a-b-c+d == 7){
    op[0] = '-';
    op[1] = '-';
    op[2] = '+';
}else if(a-b+c-d == 7){
    op[0] = '-';
    op[1] = '+';
    op[2] = '-';
}else if(a+b-c-d == 7){
    op[0] = '+';
    op[1] = '-';
    op[2] = '-';
}else{
    op[0] = '-';
    op[1] = '-';
    op[2] = '-';
}
cout << a << op[0] << b << op[1] << c << op[2] << d << "=7\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int mm;
	string str;
	cin >> str;
	mm=(str.at(5)-48)*10+str.at(6)-48;
	if(mm>4){
		cout << "TBD";
	}else{
		cout << "Heisei";
	}
	return 0;
}


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

struct UnionFind {
  vector<int> parent;
  vector<int> siz; // 素集合のサイズを表す

  // n要素で初期化
  UnionFind(int n) {
    siz.resize(n, 1);
    for (int i = 0; i < n; i++) {
      parent.push_back(i);
    }
  }

  // 木の根を求める
  int find(int x) {
    if (parent.at(x) == x) {
      return x;
    } else {
      parent.at(x) = find(parent.at(x));
      return parent.at(x);
    }
  }

  // xとyの属する集合を併合
  void unite(int x, int y) {
    int p = find(x);
    int q = find(y);
    if (p == q) return;

    if (siz.at(p) < siz.at(q)) swap(p, q);
    siz.at(p) += siz.at(q);
    parent.at(q) = p;
  }

  // xとyが同じ集合に属するか否か
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // 素集合のサイズ
  int size(int x) {
    return siz.at(find(x));
  }
};

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

  vector<vector<int>> fr(N), br(N);
  UnionFind u(N);
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    u.unite(A, B);
    fr.at(A).push_back(B);
    fr.at(B).push_back(A);
  }

  rep(i, K) {
    int C, D;
    cin >> C >> D;
    C--; D--;
    br.at(C).push_back(D);
    br.at(D).push_back(C);
  }

  rep(i, N) {
    int ans = u.size(i) - fr.at(i).size() - 1;
    for (int x : br.at(i)) {
      if (u.same(i, x)) ans--;
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 14920
class Solver
  def main
    a, b, c = gets.split.map(&:to_i)

    ans = 0
    if c <= a + b + 1
      # 毒入り全部OKなので全部OK
      ans = b + c
    else
      # 毒入り食べられる数
      ans = a + b + 1
      # 美味しい解毒剤入り
      ans += b
    end

    puts ans

  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 1788
program main
  implicit none
  integer i, N, X, T
  read(*, *)N, X, T
  !read(*, *) (L(i), i = 1,N)
  if (mod(N,X) == 0) then
  	write(*, *)(N/X)*T
    else
    write(*, *)(N/X+1)*T
    endif
end program main


Measured memory_bytes: 2824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int dx[] = {0,1,0,-1};
int dy[] = {1, 0, -1,0};
int main()
{
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                continue;
            }
            bool flag = false;
            rep(k,4){
                if (i + dy[k] >= h || i + dy[k]<0){
                    continue;
                }
                if (j + dx[k] >= w || j + dx[k] < 0)
                {
                    continue;
                }
                if(s[i+dy[k]][j+dx[k]]=='#'){
                    flag = true;
                }
            }
            if(flag==false){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int a, b; cin >> a >> b;
    if (a > 0 && b >= 0) cout << "Positive" << endl;
    if (a <= b && b < 0) {
        if ((b-a+1) % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
    if (a <= 0 && b >= 0) cout << "Zero" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
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; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007

ll modncr(ll n, ll r){
  auto modbeki = [](ll x, ll nn){
    ll res = 1;
    while(nn > 0){
      if(nn & 1) res = res * x % MOD;
      x = x * x % MOD;
      nn >>= 1;
    }
    return res;
  };

  if(n < r) return 0;
  if(r == 0 || r == n) return 1;
  if(r > n-r) r = n-r;

  ll a = 1, b = 1;
  for(int i = 0; i < r; i++){
    a *= (n - i);
    a %= MOD;
  }
  for(int i = 0; i < r; i++){
    b *= (i + 1);
    b %= MOD;
  }
  ll c = modbeki(b, MOD-2);
  return a * c % MOD;
}

ll nhr(ll n, ll r){
  return modncr(n+r-1, r);
}

int main(){
  ll N, M;
  cin >> N >> M;
  ll ans = 1;
  map<ll, ll> factor;
  for(ll i = 2; i*i <= M; i++){
    ll counter = 0;
    while(M%i==0){
      M /= i;
      if(!factor.count(i)) factor[i] = 1;
      else factor.at(i)++;
    }
  }
  if(M != 1){
    if(!factor.count(M)) factor[M] = 1;
    else factor.at(M)++;
  }
  for(auto ite = factor.begin(); ite != factor.end(); ite++){
    ll r = ite->second;
    ans *= nhr(N, r);
    ans %= MOD;
  }
  cout << ans << endl;
}

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

int main(){
	int n,i,j,mul,num,m=0;
	cin >> n;
	int a[n];
	int ans[n];
	for(i = 0; i < n; i++){
		cin >> a[i];
	}
	for(i = 0; i < n; i++){
		ans[i] = 0;
	}

	for(i = n; i >= 1; i--){
		mul = n/i;
		num = 0;
		for(j = 2; j <= mul; j++){
			num = num + ans[i*j-1];
		}
		if(num%2 == a[i-1]){
			ans[i-1] = 0;
		}
		else if(num%2 != a[i-1]){
			ans[i-1] = 1;
			m++;
		}
	}

	cout << m << "\n";
	for(i = 0; i < n; i++){
		if(ans[i] == 1){
			cout << i+1 << " ";
		}
	}
	return 0;
}


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

typedef long long ll;

void solve() {
	double n;
	cin >> n;
	double req = ceil(n / 1.08);
	if (floor(req * 1.08) == n) {
		cout << req;
	} else {
		cout << ":(";
	}
}


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

	int tt = 1;
	// cin >> tt;
	for (int i = 1; i <= tt; ++i) {
		// cout << "Case #" << i << ": ";
		solve();
	}

	return 0;
}


Measured memory_bytes: 3756
import sys
stdin = sys.stdin
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


a,b,c = li()

if a%2 == 1 and b%2 == 1 and c%2 == 1:
    print(min(a*b, b*c, c*a))
else:
    print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD =  1000000007;
const int INF = 1e11;
using Graph = vector<vector<int>>;

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

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

  vector<int> dp(N+10);
  dp[3] = 1; dp[4] = 1; dp[5] = 1;
  for( int i = 6; i <= N; i++ ){
    dp[i] = dp[i-1]+dp[i-3];
    dp[i] %= MOD;
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int abc;
  cin >> abc;
  int a = abc / 100;
  int b = (abc - a * 100) / 10;
  int c = (abc - a * 100 - b * 10) / 1;
  cout << a + b + c << endl;
}

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

int main(){
  int n;
  cin >> n;
 
  vector<int> a(n);
  vector<int> aa(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    aa[i] = a[i];
  }

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

  for(int i=0; i<n; i++){
    if(aa[i]==a.at(n-1)) cout <<  a.at(n-2) << endl;
    else                 cout <<  a.at(n-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int A = Integer.parseInt(sc.next());
	static int B = Integer.parseInt(sc.next());
	public static void main(String[] args) {
		int ansa =0, ansb = 0;
		if (N < A+B) {
			ansb = A+B-N;
		}
		ansa = Math.min(A, B);
		System.out.println(ansa+" "+ansb);
	}
}


Measured memory_bytes: 23764
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
long long a[1000000];
int main()
{
	long long k,i,n;
	scanf("%lld %lld",&k,&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	long long m=a[0]+k-a[n-1];
	for(i=1;i<n;i++)
	{
		if(a[i]-a[i-1]>m) m=a[i]-a[i-1];
	}
	printf("%lld",k-m);
	return 0;
}

Measured memory_bytes: 1792
def solve(brd, bits)
  if bits == (1<<8) - 1
    brd.map{ |bs| puts bs.map{ |b| b ? '.' : 'Q' }.join }
    return
  end
  y = -1
  (0..7).each do |i|
    if (bits & (1<<i)) == 0
      y = i
      break
    end
  end
  (0..7).each do |x|
    if brd[y][x] && check(y, x, brd)
      brd[y][x] = false
      bits += 1<<y
      solve(brd, bits)
      bits -= 1<<y
      brd[y][x] = true
    end
  end
end
 
def check(y, x, brd)
  (1..7).each do |i|
    [-1, 1].each do |dy|
      (-1..1).each do |dx|
        ny = y + dy * i
        nx = x + dx * i
        if 0 <= ny && ny < 8 && 0 <= nx && nx < 8
          return false unless brd[ny][nx]
        end
      end
    end
  end
  true
end

brd = 8.times.map{ [true] * 8 }
bit = 0
gets.to_i.times do
  r, c = gets.split.map(&:to_i)
  bit += 1<<r
  brd[r][c] = false
end

solve(brd, bit)

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

// input
int N, M;
vector<int> A, B;

set<P> s;
multiset<int> w;


void input() {
    cin >> N >> M;
    A = B = vector<int>(M);
    rep(i, M) cin >> A[i] >> B[i];
}


int main() {
    input();
    rep(i, M) {
        s.insert(P(A[i], B[i]));
        w.insert(B[i]);
    }
    int ans = 0;
    while (!w.empty()) {
        ans++;
        int v = *w.begin();
        auto x = s.upper_bound(P(v, 0));
        auto itr = s.begin();
        while (itr != x) {
            w.erase(w.find(itr->second));
            s.erase(itr++);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 13468
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){
    
    ll N, M;
    cin >> N >> M;
    cout << (1900 * M + 100 * (N - M)) * (1 << M) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#define maxDataNum 67108864
int nBaseDecode(std::string a,int n,std::string table="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"){
  int ans=0,i;
  for (i=0;i<a.length();i++){
    ans*=n;
    ans+=table.find(a[i]);
  }
  ans+=(std::pow(4,a.length())-4)/3;
  return ans;
}

int main(){
  int numOrder,dataNum,i;
  std::string order,data;
  bool *dataList;
  dataList = new bool[maxDataNum];
  for (i = 0; i < maxDataNum; ++i) {
    dataList[i]=false;
  }
  std::cin >> numOrder;
  for (i = 0; i < numOrder; ++i) {
    std::cin >> order >> data;
    dataNum=nBaseDecode(data,4,"ACGT");
    if (order=="insert"){
      dataList[dataNum]=true;
    }else{
      if (dataList[dataNum]){
        std::cout << "yes" << '\n';
      }else{
        std::cout << "no" << '\n';
      }
    }
  }
  delete[] dataList;
}



Measured memory_bytes: 68148
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 2e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	ll n,p;
	cin >> n >> p;
	ll a[n];
	ll dig[2] = {0,0};
	REP (i,n) {
		cin >> a[i];
		dig[a[i] % 2]++;
	}
	ll ans = pow(2,dig[0]) * ((ll)pow(2,dig[1]) / 2);
	if (!dig[1] && !p) ans = pow(2,dig[0]);
	cout << ans << endl;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#include <cmath>

#define int long long

using namespace std;

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int ans = 0;
  const int mod = 1e9 + 7;
  const int c = (k * (k - 1) / 2) % mod;

  for (int i = 0; i < n; i++) {
    int large = 0;
    int small = 0;

    for (int j = 0; j < n; j++) {
      if (a[j] > a[i]) {
        large++;
      } else if (a[j] < a[i]) {
        small++;
      }
    }

    ans += small * c;
    ans %= mod;
  }

  int temp = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] > a[j]) {
        temp++;
      }
    }
  }

  ans += temp * k;
  ans %= mod;

  cout << ans << endl;

  return 0;
}


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

int main()
{
    int A, B;

    cin >> A>> B;
    
    if((A-B*2)>0){
        cout << A - B * 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define INF 1000000000
int n,m[N][N],p[N];

int min(int a, int b){
  if(a<=b) return a;
  else return b;
}

void MatrixChainOrder(int p[]){
  int i,j,k,l,q;
  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=min(m[i][j],q);
      }
    }
  }
}

int main(){
  int i,r,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    if(i==0){
      p[i]=r;
      p[i+1]=c;
    } else p[i+1]=c;
  }
  p[n]=c;
  MatrixChainOrder(p); 
  printf("%d\n",m[1][n]);
  return 0;
}

Measured memory_bytes: 636
N,M=map(int,input().split())
lst=sorted([list(map(int,input().split())) for i in range(N)])
_sum_drink=0
money=0
for i in lst:
    if _sum_drink+i[1] < M:
        money += i[0]*i[1]
        _sum_drink += i[1]
    else:
        money += i[0]*(M-_sum_drink)
        _sum_drink += M-_sum_drink
    if _sum_drink == M:
        print(money)
        exit()

Measured memory_bytes: 28648
#include<cstdio>
#define f(i,a,b) for(register int i=a;i<=b;++i)
long long ans;
int a[10010],b[10010],n;
void dfs(int step)
{
	if(step>n)
	{
		f(i,1,n)if(b[i]%2==0){++ans;return;}
		return;
	}
	b[step]=a[step]-1;dfs(step+1);
	b[step]=a[step];dfs(step+1);
	b[step]=a[step]+1;dfs(step+1);
}
int main()
{
	scanf("%d",&n);
	f(i,1,n)scanf("%d",&a[i]);
	dfs(1);printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<cmath>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<stack>
#include<vector>
#include<string.h>
#include<string>
#include<iomanip>
#include <sstream>
#include<map>
#include<complex>
#include<set>
using namespace std;
#define rep(i,t,n)  for(ll i =(t);i<=(n);++i)
#define per(i,n,t)  for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define Decimal fixed<<setprecision(20)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e3 + 5;
typedef double db;



const int N = 10;
bool ok(int x) { return x >= 1 && x <= 9; }
int main() {
	FAST_IO;
	set<int> s;
	rep(i, 1, 9)rep(j, 1, 9) {
		s.insert(i*j);
	}
	int n;
	cin >> n;
	cout << (s.count(n) ? "Yes" : "No") << endl;
}         
/*
2
A 0 0 2
B 1 0 2


*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int main(void)
{
    using namespace std;
    int N;
    vector<int> an;
    cin >> N;
    an.resize(N);
    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        an[i] = ai;
    }
    sort(begin(an), end(an));

    int diff = 0;
    bool alice = true;
    for (int i = N - 1; i >= 0; i--) {
        if (alice) {
            diff += an[i];
        }
        else {
            diff -= an[i];
        }
        alice = !alice;
    }

    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,m,res[1002][1002],i,j,mod=1e9+7;
char a[1002][1002];
main(){
	cin>>n>>m;
	for(i=1;i<=n;i++)
	for(j=1;j<=m;j++)
	cin>>a[i][j];
	res[1][1]=1;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(a[i][j]=='#')
				res[i][j]=0;
			else{
				res[i][j]+=res[i-1][j]+res[i][j-1];
				res[i][j]%=mod;
			}
	cout<<res[n][m];
}

Measured memory_bytes: 9088
N = int(input())
S = str(input())
dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if j > i:
            tmp = min(j-i,dp[i][j])
            ans = max(tmp,ans)
print(ans)

Measured memory_bytes: 247432
import bisect
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in b:
    ans += bisect.bisect_left(a,i)*(n-bisect.bisect_right(c,i))
print(ans)

Measured memory_bytes: 22720
def solve(i,x1,x2,y1,y2):
    global n
    if i == n:
        return print(x2,y2)
    X1 = (2*x1+x2)/3
    Y1 = (2*y1+y2)/3
    X3 = (x1+2*x2)/3
    Y3 = (y1+2*y2)/3
    X2 = (X3+X1)/2+3**(0.5)*(Y1-Y3)/2
    Y2 = (3**(0.5)*(X3-X1)+(Y1+Y3))/2
    solve(i+1,x1,X1,y1,Y1)
    solve(i+1,X1,X2,Y1,Y2)
    solve(i+1,X2,X3,Y2,Y3)
    solve(i+1,X3,x2,Y3,y2)

n = int(input())
print(0,0)
solve(0,0,100,0,0)


Measured memory_bytes: 5704
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> edge;

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  if(n/2 < k){
    puts("-1");
    return 0;
  }
  
  vector< vector<edge> > ans;
  for(int i=0;i<n-1;i+=2){
    for(int j=0;j<(int)ans.size();j++){
      ans[j].push_back(edge(j,i));
      ans[j].push_back(edge(i/2+j,i+1));
    }
    if((int)ans.size()<k){
      vector<edge> tmp;
      for(int j=0;j<i/2;j++){
	tmp.push_back(edge(i/2+j,i));
	tmp.push_back(edge(j,i+1));
      }
      tmp.push_back(edge(i,i+1));
      ans.push_back( tmp );
    }
  }

  if(n&1){
    for(int i=0;i<k;i++)ans[i].push_back(edge(i,n-1));
  }

  for(int i=0;i<k;i++){
    if(i)cout << endl;
    for(edge e : ans[i])printf("%d %d\n",e.first+1, e.second+1);
  }
}

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

int main(){
  string S;
  cin >> S;
  
  char A='a';
  char alfabet;
  int count=0; 
  bool b=true;
  
  for(int i=0; i<26; i++){
    alfabet = A+i;
    
    for(int j=0; j<S.size();j++){
      if(S.at(j)==alfabet){count++;}
    }
    
    if(count%2==1){b=false;}
    count=0;
  }
  if(b){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
      
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

llint N, A, B;
llint S[100005];
llint R[100005][2];
llint dp[100005][2];
llint sum[100005][2];

int main(void)
{
	cin >> N >> A >> B;
	for(int i = 1; i <= N; i++) cin >> S[i];
	
	for(int i = 1; i <= N; i++){
		R[i][0] = upper_bound(S+1, S+N+1, S[i]-A) - S - 1;
		R[i][1] = upper_bound(S+1, S+N+1, S[i]-B) - S - 1;
	}
	
	/*for(int i = 1; i <= N; i++) cout << R[i][0] << " "; cout << endl;
	for(int i = 1; i <= N; i++) cout << R[i][1] << " "; cout << endl;
	cout << endl;
	*/
	
	llint zero[2] = {-1, -1};
	dp[0][0] = dp[0][1] = 1, sum[0][0] = sum[0][1] = 1;
	
	for(llint i = 2; i <= N; i++){
		for(int k = 0; k < 2; k++){
			llint r = min(R[i][k], i-2);
			dp[i-1][k] = sum[r][1-k];
			if(zero[1-k] >= 0) dp[i-1][k] += mod - sum[min(zero[1-k], r)][1-k];
			dp[i-1][k] %= mod;
		}
		if(S[i-1] > S[i] - A) zero[0] = i-2;
		if(S[i-1] > S[i] - B) zero[1] = i-2;
		for(int k = 0; k < 2; k++) sum[i-1][k] = sum[i-2][k] + dp[i-1][k], sum[i-1][k] %= mod;
		
		/*cout << zero[0] << " " << zero[1] << endl;
		for(int j = 0; j <= N; j++) cout << dp[j][0] << " "; cout << endl;
		for(int j = 0; j <= N; j++) cout << dp[j][1] << " "; cout << endl;
		cout << endl;*/
	}
	
	llint ans = 0;
	for(int j = 0; j <= N-1; j++){
		if(zero[0] < j) ans += dp[j][0];
		if(zero[1] < j) ans += dp[j][1];
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll x;
  cin>>x;
  cout<<(x==0?1:0)<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int q;cin>>q;
  for(int i = 0; q > i; i++){
    int c,b,e;cin>>c>>b>>e;
    auto ret = max_element(a.begin()+b,a.begin()+e);
    if(c==0){
      ret = min_element(a.begin()+b,a.begin()+e);
    }
    cout << *ret << endl;
  }
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N,K;
  cin >> N >> K;
  ll ans = 0;
  if(K >= N){
    ans = 0;
    cout << ans << endl;
    return 0;
  }

  vector<ll> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  sort(H.rbegin(), H.rend());
  for(int i = 0; i < N; i++){
    if(i < K){
      //
    } else { 
      ans += H.at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
N = STDIN.gets.to_i
i = STDIN.gets.split(" ")
j = STDIN.gets.split(" ")
location = [i,j]
candy = 0

x = 0
y = 0
x_max = N
candy_max = 0

while x_max > 0 do
  while x < x_max do
    candy = location[y][x].to_i + candy
    x += 1
  end
  candy = location[1][x_max- 1].to_i + candy
    x.upto(N) do |x_low|
      candy = location[1][x_low].to_i + candy
    end
    if candy > candy_max then
      candy_max = candy
    end
  candy = 0
  x = 0
  x_max -= 1
end
puts candy_max

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

ll cnt[26];

int main(){
  int n; cin >> n;
  string s; cin >> s;
  rep(i,n){
    cnt[s[i]-'a']++;
  }
  ll ans=1;
  rep(i,26){
    ans*=cnt[i]+1;
    ans%=mod;
  }
  ans--;
  if(ans<0) ans+=mod;
  cout << ans << endl;
  
}

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

using namespace std;

typedef long long int lli;

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

    int n;
    cin >> n;
    vector<pair<int, pair<int, int>>> pyr(n);

    for (int i=0; i<n; i++) cin >> pyr[i].second.first >> pyr[i].second.second >> pyr[i].first;
    sort(pyr.begin(), pyr.end(), greater<pair<int, pair<int, int>>>());

    for (int y=0; y<=100; y++) {
        for (int x=0; x<=100; x++) {
            int H = pyr[0].first + abs(x-pyr[0].second.first) + abs(y-pyr[0].second.second);
            bool flag = true;
            for (int i=1; i<n; i++) {
                if (max(H - abs(x-pyr[i].second.first) - abs(y-pyr[i].second.second), 0) != pyr[i].first) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << x << " " << y << " " << H << endl;
            }
        }
    }

    return 0;
}


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

int main(){
    
    int N;
    cin >> N;
    long long A[N];
    int a = 0;
    int b = 0;
    int c = 0;
    for(int i = 0; i < N;i++){
        cin >> A[i];
        
        if(A[i]%4==0)a++;
        else if(A[i]%2!=0)b++;
        else if(A[i]%2==0)c++;
        
    }
    //cout <<a << " "<<b <<endl;
    if(c == 0){
        if(a>=b-1)cout <<"Yes"<<endl;
        else cout << "No" <<endl;
    }else{
        if(a>=b)cout <<"Yes"<<endl;
        else cout << "No" <<endl;
    }
}

    
    



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < (int) s.size(); i++){
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N,K; cin>>N>>K;
  vi A(40);
  rep(i,0,N){
    int X; cin>>X;
    bitset<40> B(X);
    rep(j,0,40){
      if(B.test(j))
        A[j]++;
    }
  }
  vi C,D,E;
  rep(i,0,(1ll<<20)){
    if(i>K)
      break;
    bitset<20> B(i);
    int sum=0;
    rep(j,0,20){
      if(B.test(j))
        sum+=(N-A[j])*(1ll<<j);
      else
        sum+=A[j]*(1ll<<j);
    }
    C.pb(sum);
  }
  D.pb(0);
  rep(k,0,(1ll<<20)){
    int i=(k<<20);
    if(i>K)
      break;
    E.pb(i);
    bitset<40> B(i);
    int sum=0;
    rep(j,20,40){
      if(B.test(j))
        sum+=(N-A[j])*(1ll<<j);
      else
        sum+=A[j]*(1ll<<j);
    }
    int X=D.size();
    D.pb(max(sum,D[X-1]));
  }
  int ans=0;
  E.pb((1ll<<60));
  rep(i,0,C.size()){
    int P=K-i;
    int Q=disup(E,P);
    ans=max(ans,C[i]+D[Q]);
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 29544