akhauriyash/Code-Regression huggingface dataset:
package main

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

var si = bufio.NewScanner(os.Stdin)

func readInt() int {
        si.Scan()
        r, _ := strconv.Atoi(si.Text())
        return r
}

type UnionTree struct {
        e int
        s int
        p *UnionTree
}

func (u *UnionTree) Root() *UnionTree {
        if u.p == nil {
                return u
        }
        root := u.p.Root()
        if u.p != root {
                u.p = root
        }
        return root
}
func (u *UnionTree) same(v *UnionTree) bool {
        return u.Root() == v.Root()
}
func (u *UnionTree) unite(v *UnionTree) {
        vRoot := v.Root()
        uRoot := u.Root()
        if uRoot == vRoot {
                return
        }
        if uRoot.e > vRoot.e {
                uRoot.p = vRoot
                vRoot.s += uRoot.s
        } else {
                vRoot.p = uRoot
                uRoot.s += vRoot.s
        }
}
func main() {
        si.Split(bufio.ScanWords)
        si.Buffer(make([]byte, 0), 10000000)
        N, M := readInt(), readInt()
        e := make([][2]int, M)
        for i := 0; i < M; i++ {
                a, b := readInt()-1, readInt()-1
                e[i] = [2]int{a, b}
        }
        ret := make([]int, M+1)
        base := N * (N - 1) / 2
        u := make([]*UnionTree, N)
        for i := 0; i < N; i++ {
                u[i] = &UnionTree{i, 1, nil}
        }

        for i := M - 1; i >= 0; i-- {
                if !u[e[i][0]].same(u[e[i][1]]) {
                        ret[i] = u[e[i][0]].Root().s * u[e[i][1]].Root().s
                        u[e[i][0]].unite(u[e[i][1]])
                }
                ret[i] += ret[i+1]
        }
        for i := 1; i <= M; i++ {
                fmt.Println(base - ret[i])
        }
}

Measured memory_bytes: 9344
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	
	int w,h;
	int k,l;
	while (cin >> w >> h) {
		if (w == 0 && h == 0) {
			break;
		}
		int hyou[100][100] = {0};
		char chyou[100][100];
		k = 0;
		l = 0;
		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				cin >> chyou[j][i];
			}
		}
		while (1) {
			if (hyou[k][l] == 1) {
				cout << "LOOP" << endl;
				break;
			}
			hyou[k][l] = 1;
			if (chyou[k][l] == '>') {
				k++;
			} else if (chyou[k][l] == '<') {
				k--;
			} else if (chyou[k][l] == '^') {
				l--;
			} else if (chyou[k][l] == 'v') {
				l++;
			} else {
				cout << k << " " << l << endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pi;

#define fi first
#define se second

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

int n, m, a, b, res[1001][1001];

int main() {
#ifdef dream_maker
//  freopen("tst.in", "r", stdin);
#else
  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
#endif
  n = read(), m = read(), a = read(), b = read();
  for (int i = 1; i <= n; i++) for (int j = 1; j <= a; j++) res[i][j] ^= 1;
  for (int i = 1; i <= b; i++) for (int j = 1; j <= m; j++) res[i][j] ^= 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d", res[i][j]);
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 5120
/**
*    author:  yuya1234
*    created: 17.07.2020 09:35:03
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  string s;
  cin>>s;

  int a[26];
  MEMSET(a,0);
  REP(i,SZ(s))
  {
    a[s[i]-'a']++;
  }

  int tmp=27;
  REP(i,26)
  {
    if(a[i]==0)chmin(tmp,(int)i);
  }

  if(SZ(s)<26)cout<<s+(char)(tmp+'a')<<endl;
  else if(s=="zyxwvutsrqponmlkjihgfedcba")cout<<-1<<endl;
  else
  {
    string ss=s;
    next_permutation(ss.begin(),ss.end());
    int idx;
    REP(i,SZ(s))
    {
      if(s[i]!=ss[i])
      {
        idx=i;
        break;
      }
    }
    cout<<ss.substr(0,idx+1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        System.out.println(t/a*b);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25348
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    vector<int> H(N);
    REP(i, 0, N) cin >> H[i];
    vector<vector<int>> G(N);
    REP(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<bool> good(N, true);
    REP(i, 0, N) {
        if (good[i] == false) continue;
        for (auto g : G[i]) {
            if (H[i] <= H[g]) {
                good[i] = false;
            } else if (H[i] >= H[g]) {
                good[g] = false;
            }
        }
    }
    int ans = 0;
    REP(i, 0, N) if (good[i]) {
        ans++;
        // cout << "i : " << i + 1 << endl;
    }

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

Measured memory_bytes: 8800
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - k + 1; i++) {
            min = Math.min(min, a[i + k - 1] - a[i]);
        }
        out.println(min);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 38940
import itertools
n , m = map(int,input().split())
hen = [list(map(int,input().split())) for _ in range(m)]
#n , m = 3,3 # n頂点の数　m辺の数
#hen = [[1, 2], [1, 3], [2, 3]]

ans = 0
x = [i for i in range(2,n+1)]
candi = itertools.permutations(x)
for i in candi: #
  now = 1
  for next in i: # j 次の頂点
    if [now,next] in hen or [next,now] in hen:
      now = next
    else:
      ck = 0
      break
  else:
    ans += 1

print(ans)



Measured memory_bytes: 3060
program main
  implicit none
  integer i,N,maxA,maxA2,maxl
  integer, allocatable :: A(:)
  !read(*, *) (L(i), i = 1,N)
  read(*, *) N
  allocate(A(N))
  do i = 1,N
    read(*,*) A(i)
  end do
  maxA = maxval(A)
  do i = 1,N
    if (A(i) == maxA) then
      A(i) = 0
      maxl = i
      exit
    end if
  end do
  do i = 1,N
    if (i == maxl) then
      write(*,*) maxval(A)
    else
      write(*, *) maxA
    end if
  end do
end program main


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

using namespace std;

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

bool in_range(int i, int j) {
  return 0 <= i && i < 4 && 0 <= j && j < 4; 
}

vector<int> x(4), y(4);

bool G[4][4];

int rec(int i, int j) {
  
  int ni = i, nj = j + 1;
    
  if(nj == 4) {
    ni ++;
    nj = 0;
  }
  
  if(ni == 4) return G[i][j];

  if(G[i][j]) return rec(ni, nj);
  
  int ret = 0;

  G[i][j] = 1;
  
  rep(k, 4) {
    int pi = i + y[k], pj = j + x[k];
    if(!in_range(pi, pj)) continue;
    if(G[pi][pj]) continue; // iranai ?
    G[pi][pj] = 1;
    ret += rec(ni, nj);
    G[pi][pj] = 0;
  }
  
  G[i][j] = 0;
  
  return ret;
}

int main() {

  while(1) {
    rep(i, 4) {
      cin >> x[i] >> y[i];
      if(cin.eof()) exit(0);
    }
    
    rep(i, 4) rep(j, 4) G[i][j] = 0;
    cout << rec(0, 0) << endl;
  }
  
  return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  // x を除去
  string s2(s);
  s2.erase(remove(s2.begin(), s2.end(), 'x'), s2.end());
  string rs2(s2);
  reverse(rs2.begin(), rs2.end());
  if (s2 != rs2) {
    cout << -1 << endl;
    return 0;
  }
  int left = 0;
  int right = n - 1;
  int res = 0;
  while (left < right) {
    if (s[left] == s[right]) {
      left++;
      right--;
    } else if (s[left] == 'x') {
      res++;
      left++;
    } else if (s[right] == 'x') {
      res++;
      right--;
    } else {
      assert(false);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3844
#include <iostream>

using namespace std;

int main()
{
	int n, m;

	while (cin >> n >> m, n || m) {
		int N[1001], M[1001];

		for (int i = 1; i <= n; ++i) cin >> N[i];
		for (int i = 1; i <= m; ++i) cin >> M[i];

		int a = 1;

		int i = 1;

		int f = 1;
		while (a < n) {
			a += f ? M[i++] : N[a];
			f ^= 1;
		}

		cout << i-1 << endl;
	}
}

Measured memory_bytes: 1164
from collections import deque

q = deque(input())
Q = int(input())
reverse = -1

for i in range(Q):
    X = input().split()
    if X[0] == "1":
        reverse *= -1
    # if X[1] == "1":
    elif X[1] == "1":
        if reverse == -1:
            q.appendleft(X[2])
        else:
            q.append(X[2])
    elif X[1] == "2":
        if reverse == -1:
            q.append(X[2])
        else:
            q.appendleft(X[2])
# if reverse == 1: q.reverse()

if reverse == -1:
    print(''.join(q))
else:
    print(''.join(list(q)[::-1]))

Measured memory_bytes: 10100
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var numbers = input.split("\n");
var min = 0;
var max = 9;


numbers.forEach(function(number) {
  var combinations = 0;
  for(var i = min; i <= max; i++) {
    for(var j = min; j <= max; j++) {
      for(var k = min; k <= max; k++) {
        for(var l = min; l <= max; l++) {
          if(i + j + k + l === parseInt(number, 10)) {
            combinations++;
          }
        }
      }
    }
  }
  console.log(combinations);
});

Measured memory_bytes: 15784
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;


int main(){
	fast_io();
	const int N = 1000005;
	int n;
	cin >> n;
	int a[N] = {};
	fu(i,1,n){
		cin >> a[i];
		if(a[i] == i)a[i] = 1;
		else a[i] = 0;
	}
	int ans = 0;
	fu(i,1,n-1){
		if(a[i] == 1){
			++ans;
			a[i] = a[i+1] = 0;
		}
	}
	if(a[n])++ans;
	cout << ans << '\n';
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 1000000007
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define maxn 200005

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



int n;
ll poj[maxn];
ll sum;
ll niz[maxn];
int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    ff(i,1,n){
        cin >> niz[i];
        poj[niz[i]]++;
    }
    ff(i,1,n)sum += ((poj[i] * (poj[i] - 1))/2);
    ff(i,1,n){
        int x = niz[i];
        sum -= ((poj[x] * (poj[x] - 1))/2);
        poj[x]--;
        sum += ((poj[x] * (poj[x] - 1))/2);
        cout << sum << endl;
        sum -= ((poj[x] * (poj[x] - 1))/2);
        poj[x]++;
        sum += ((poj[x] * (poj[x] - 1))/2);
    }
    return 0;
}


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


int main() {
 #define int long long
  int N,X,Y;
  
  cin >> N >> X >> Y;
  int l;
  vector<int>box(N-1);
  for(int i=1;i<=X;i++){
    for(int j=i+1;j<=X;j++){
      l=j-i;
      box.at(l-1)++;
    }
    for(int j=X+1;j<Y;j++){
      l=X-i+min(j-X,Y-j+1);
      box.at(l-1)++;
    }
    for(int j=Y;j<=N;j++){
      l=j-i-Y+X+1;
      box.at(l-1)++;
    }
  }
  for(int i=X+1;i<Y;i++){
    for(int j=i+1;j<Y;j++){
      l=min(j-i,i-X+Y-j+1);
      box.at(l-1)++;
    }
    for(int j=Y;j<=N;j++){
      l=j-Y+min(Y-i,i-X+1);
      box.at(l-1)++;
    }
  }
  for(int i=Y;i<N;i++){
    for(int j=i+1;j<=N;j++){
      l=j-i;
      box.at(l-1)++;
    }
  }
  for(int i=0;i<(N-1);i++){
    cout << box.at(i) << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 1e6 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int LN = 22;

long long n, m, u, v, k, t, q, x, d, p, a, b, c, s;


string str;
int cnt[N];
int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> str;
   for (int i = 0; i < (int)str.size() - 1; ++i) {
      if (str[i] == 'L') continue;
      int j = i + 1;
      while (str[j] != 'L') ++j;
      for (int k = i; k < j; ++k) {
         if ((j - k) % 2 == 1) {
            cnt[j - 1]++;
         } else cnt[j]++;
      }
      i = j;
   }
   
   for (int i = str.size() - 1; i >= 1; --i) {
      if (str[i] == 'R') continue;
      int j = i - 1;
      while (str[j] != 'R') --j;
      for (int k = i; k > j; --k) {
         if ((k - j) % 2 == 1) {
            cnt[j + 1]++;
         } else cnt[j]++;
      }
      i = j;
   }
   
   for (int i = 0; i < str.size(); ++i) cout << cnt[i] << " ";
   cout << endl;
}


Measured memory_bytes: 1104
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, m := scanInt(), scanInt()
	c, d := make([]bool, n), make([]bool, n)
	for i := 0; i < m; i++ {
		a, b := scanInt()-1, scanInt()-1
		if a == 0 {
			c[b] = true
		}
		if b == n-1 {
			d[a] = true
		}
	}

	for i := 0; i < n; i++ {
		if c[i] && d[i] {
			fmt.Fprintln(wr, "POSSIBLE")
			return
		}
	}
	fmt.Fprintln(wr, "IMPOSSIBLE")
}


Measured memory_bytes: 4680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0026
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] coordinate = new int[14, 14];
            for (int i = 0; i < 14; i++)
            {
                for (int j = 0; j < 14; j++)
                {
                    coordinate[i, j] = 0;
                }
            }

            string str;
            while ((str = Console.ReadLine()) != null)
            {
                int[] input = str.Split(',').Select(int.Parse).ToArray();
                int x = input[0] + 2;
                int y = input[1] + 2;
                int size = input[2];
                if (size >= 1)
                {
                    coordinate[x, y]++;
                    coordinate[x + 1, y]++;
                    coordinate[x - 1, y]++;
                    coordinate[x, y + 1]++;
                    coordinate[x, y - 1]++;
                }
                if (size >= 2)
                {
                    coordinate[x + 1, y + 1]++;
                    coordinate[x + 1, y - 1]++;
                    coordinate[x - 1, y + 1]++;
                    coordinate[x - 1, y - 1]++;
                }
                if (size >= 3)
                {
                    coordinate[x + 2, y]++;
                    coordinate[x - 2, y]++;
                    coordinate[x, y + 2]++;
                    coordinate[x, y - 2]++;
                }
            }

            int countZero = 0;
            int max = 0;
            for (int i = 2; i < 12; i++)
            {
                for (int j = 2; j < 12; j++)
                {
                    if (coordinate[i, j] == 0)
                    {
                        countZero++;
                    }
                    if (coordinate[i, j] > max)
                    {
                        max = coordinate[i, j];
                    }
                }
            }
            Console.WriteLine(countZero);
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 16348
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datX) = readLine.split(" ").map(_.toInt)
    val datA = readLine.split(" ").map(_.toInt)
    val datB = datA.toList.sorted

    def distCandy(result: Int, candy: Int, child: List[Int]): Int = (candy, child) match {
      case (n, _) if(n == 0) => result
      case (_, Nil) => result - 1 // 全員に配ってまだ余った時に最後に押し付ける処理
      case (n, m :: _) if (n < m) => result
      case (n, m :: tail) if (n >= m) => distCandy(result + 1, n - m, tail)
    }
    val ans = distCandy(0, datX, datB)

    println(ans)
  }
}


Measured memory_bytes: 25520
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

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

    g = tuple(set() for _ in range(N))
    h = [0] * N  # 入り次数
    for _ in range(M):
        L, R, D = map(int, input().split())
        L -= 1
        R -= 1
        g[L].add((R, D))
        h[R] += 1

    dist = [-1] * N

    def dfs(s):
        dist[s] = 0
        dq = deque([s])
        while dq:
            v = dq.popleft()
            for u, d in g[v]:
                if ~dist[u]:
                    if dist[u] != dist[v] + d:
                        return False
                else:
                    dist[u] = dist[v] + d
                    dq.append(u)
        return True

    # 始点からのパスを処理
    for s in range(N):
        if h[s]: continue  # sに入ってくるパスがあるので、sを始点にしない
        # if ~dist[s]: continue
        if not dfs(s):
            print('No')
            return

    # サイクルを処理（どの点も入るパスがあり、処理できていない）
    for s in range(N):
        if ~dist[s]: continue
        if not dfs(s):
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 55872
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	vector<string> s(3);
	
	rep(i,3){
		cin >> s[i];
		cout << (char)(s[i][0] - ('a'-'A'));
	}
 	return 0;
}

Measured memory_bytes: 256
times = int(input())
range_distance=input().split()
ini=int(range_distance[0])
end=int(range_distance[1])

dev = end - ini 
num = 0
cnt=0

for i in range(dev+1):
    num = ini + i
    if num % times ==0:
        cnt +=1
        break

if cnt >0:
    print("OK")              
else:
    print("NG")
    


Measured memory_bytes: 61804
K, A, B = map(int, input().split())
if B-A <= 2:
    print(K+1)
    exit()

if A+1 > K:
    print(K+1)
elif (K-A-1)//2*(B-A)+(K-A-1)%2+(A-1)+(B-A)+1 > K+1:
    print((K-A-1)//2*(B-A)+(K-A-1)%2+(A-1)+(B-A)+1)
else:
    print(K+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    int t_gcd = 0;
    for(int a = 1; a <= k; a++)
    {
        for(int b = 1; b <= k; b++)
        {
            for(int c = 1; c <= k; c++)
            {
                t_gcd = t_gcd + __gcd(a, __gcd(b, c));
                //cout<<t_gcd<<endl;
            }
        }
    }
    cout<<t_gcd<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <math.h>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int H,W,K;
    cin >> H >> W >> K;

    Int cand = max(H,W);

    Int ans = K/cand;

    if(K%cand > 0){
        ans++;
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll status[1000005];
void siv(){
    ll N = 1000000;
    ll i, j;
    for (i = 2; i <= N;i++){
        if(status[i]==0){
            status[i] = i;
            for (j = i * i; j <= N; j += i){
                if(status[j]==0){
                    status[j] = i;
                }
            }
        }
    }
    status[1] = 1;
}
ll fre[1000005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    siv();
    ll i,j,k,l,n,m;
    cin>>n;
    ll data[n + 1];
    for (i = 1; i <= n;i++)
        cin >> data[i];
    ll GCD = 0;
    for (i = 1; i <= n;i++){
        ll temp = data[i];
        GCD = __gcd(temp, GCD);
        ll pre = -1;
        while(temp!=1){
            if(pre!=status[temp]){
                pre = status[temp];
                fre[pre]++;
            }
            temp /= status[temp];
        }
    }
    if(GCD!=1){
        cout << "not coprime\n";
    }
    else{
        ll cnt = 0;
        for (i = 1; i <= 1000000;i++){
            if(fre[i]>1)
                cnt++;
        }
        if(cnt>=1){
            cout << "setwise coprime\n";
        }
        else
            cout << "pairwise coprime\n";
    }
    return 0;
}

Measured memory_bytes: 26960
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i > 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  char a, b;
  cin >> a >> b;
  bool flag = false;
  if (a == b) flag = true;
  cout << (flag ? 'H' : 'D') << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
long long N, P;

int main() {
	cin >> N >> P;
	int f = 0;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		if (a % 2 == 1) f = 1;
	}
	long long a = 1;
	if (f) {
		while (N - 1) {
			a *= 2;
			N--;
		}
		
	}
	else if (!f) {
		while (N) {
			a *= 2;
			N--;
		}
		a *= (1 - P);
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
w = ['dream','dreamer','erase','eraser']
flag = True
while flag:
    flag = False
    if len(s)<5:
        break
    for i in w:
        if s[-len(i):] == i:
            s = s[:-len(i)]
            flag = True
if s:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)
int main(void)
{
    lli K,X;
    scanf("%lld %lld",&K,&X);
    rept(i,-K+1,K){
        printf("%lld ",X+i);
    }
    return 0;
}

Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [I() for _ in range(n)]
    for c in a:
        if c % 2 == 1:
            return 'first'
    return 'second'


print(main())


Measured memory_bytes: 9540
n = gets.chomp.to_i
a = []
n.times do
    a << gets.chomp.to_i
end
done = Array.new(n,0)

i = 1
count = 1
while(done[i-1]==0)
    if a[i-1] == 2
        puts count
        exit
    end
    done[i-1] = 1
    count += 1
    i = a[i-1]
end
puts -1

Measured memory_bytes: 3452
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<array>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;

static const int MAX=1000000;
static const int nil=-1;
int n;
vector<int> g[MAX];
int color[MAX];

void dfs(int r,int c){
    stack<int> s;
    s.push(r);
    color[r]=c;
    while(!s.empty()){
        int u=s.top();s.pop();
        for(int i=0;i<g[u].size();i++){
            int v=g[u][i];
            if(color[v]==nil){
                color[v]=c;
                s.push(v);
            }
        }
        
    }
    
    
    
}
void assignColor(){
    
    int id=1;
    rep(i,n)color[i]=nil;
    rep(i,n){
        if(color[i]==nil){
            dfs(i,id);
            id++;
        }
    }
    
    
}

int main(){
    int s,t,m,q;
    cin>>n>>m;
    rep(i,m){
        cin>>s>>t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    assignColor();
    
    cin>>q;
    
    rep(i,q){
        cin>>s>>t;
        if(color[s]==color[t]){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
  /*  rep(i,n){
        cout<<i<<" "<<color[i]<<endl;
    }*/
    

return 0;
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int M, D;
  std::cin >> M >> D;
  int cnt = 0;
  for (int i = 22; i <= D; i++) {
    int d0, d1;
    d0 = i / 10;
    d1 = i % 10;
    if (d0 < 2 || d1 < 2)
      continue;
    int m = d0 * d1;
    if (m > 0 && m <= M) {
      cnt++;
    }
  }
  print(cnt);
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadInt;
            var B = cin.ReadInt;

            var ans = Min(A * N, B);
            WriteLine(ans);
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int C = 26;
const int N = 365;
ll a[N+10][C+10];
ll c[C+10];

ll getScore(vi &ans)
{
	ll satisfaction = 0;
	vi las(C+1,-1);
	for(int i=0;i<ans.size();i++)
	{
		satisfaction += a[i][ans[i]];
		las[ans[i]]=i;
		for(int j=0;j<C;j++)
		{
			satisfaction-=c[j]*(i-las[j]);
		}
		cout<<satisfaction<<'\n';
	}
	return max(0LL, ll(1e6)+satisfaction);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<C;i++) cin>>c[i];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<C;j++)
		{
			cin>>a[i][j];
		}
	}
	vi ans(n,0);
	for(int i=0;i<n;i++)
	{
		cin>>ans[i]; ans[i]--;
	}
	getScore(ans);
	//cout<<getScore(ans)<<'\n';
}


Measured memory_bytes: 3736
#![allow(unused)]

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

fn isqrt(n: i64) -> i64 {
    (n as f64).sqrt() as i64
}

#[proconio::fastout]
fn main() {
    input! {
        n: i64,
    }

    let mut m = n;
    let mut ans = 0;
    for i in 2.. {
        if i * i > n {
            break
        }

        let mut e = 0i64;
        while m % i == 0 {
            m /= i;
            e += 1;
        }
        if e > 0 {
            ans += (isqrt(8 * e + 1) - 1) / 2
        }
    }

    if m != 1 {
        ans += 1;
    }

    println!("{}", ans);
}


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

// solve
int main(){

    int N, Q;
    scanf("%d %d", &N, &Q);

    int A[100000] = {}, judge[50000] = {};
    long long odd[100001] = {}, even[100001] = {};
    for(size_t i = 0; i < N; ++i){
        scanf("%d", &A[i]);
        odd[i + 1] += odd[i];
        even[i + 1] += even[i];
        if(i & 1)odd[i + 1] += A[i];
        else even[i + 1] += A[i];
    }

    int sz = (N + 1) / 2;
    judge[sz - 1] = 1 << 30;
    for(size_t i = 1; i < sz; ++i){
        judge[sz - i - 1] = (A[N - i - 1] + A[N - i - i - 1]) >> 1;
    }

    while(Q--){
        int X;
        scanf("%d", &X);
        int pos = (judge + sz) - lower_bound(judge, judge + sz, X);
        long long ans = even[N] - even[N - pos] + odd[N] - odd[N - pos];
        if(N & 1)ans += even[N - pos - pos + 1] - even[0];
        else ans += odd[N - pos - pos + 1] - odd[0];
        printf("%lld\n", ans);
    }

}


Measured memory_bytes: 3840
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var A = ReadIntArray();
            if (A[0] + A[1] < 24)
            {
                Console.WriteLine(A[0] + A[1]);
            }
            else
            {
                Console.WriteLine(A[0] + A[1] - 24);
            }
        }





//ここからテンプレート
        //1行に1入力
        private static string ReadString() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(ReadString()); }
        private static long ReadLong() { return long.Parse(ReadString()); }
        private static double ReadDouble() { return double.Parse(ReadString()); }
        //1行に複数入力(配列で取得)
        private static string[] ReadStringArray() { return ReadString().Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries); }
        private static int[] ReadIntArray() { return ReadStringArray().Select(int.Parse).ToArray(); }
        private static long[] ReadLongArray() { return ReadStringArray().Select(long.Parse).ToArray(); }
        private static double[] ReadDoubleArray() { return ReadStringArray().Select(double.Parse).ToArray(); }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,k; cin >> n >> k;
	if(k>(n-1)*(n-2)/2){
		cout << -1<< endl;
		return 0;
	}
	vvi to(n);
	rep2(i,1,n) to[0].push_back(i);
	int m = n-1;
	int cnt = (n-1)*(n-2)/2-k;
	bool exitFlag=false;
	for(int u=1; u<n; u++){
		for(int v=u+1; v<n; v++){
			if(cnt==0){
				exitFlag=true;
				break;
			}			
			to[u].push_back(v);
			m++; cnt--;			
		}
		if(exitFlag)break;
	}
	cout << m << endl;
	rep(u,n)for(auto v:to[u]) cout << u+1 << " " << v+1 << endl;

}




Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int x,y,n;
    scanf("%d%d",&x,&y);
    
    if(x < y){
       n = x;
       x = y;
       y = n;
        
    }
    while(y > 0){
      n = x%y;
      x = y;
      y = n;
    }
    printf("%d\n",x);
    return 0;
}




Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  int x;
  int i;
  int B;
  int sum=0;
  cin >> N >> K;
  for(i=0; i<N; i++){
    cin >> x;
    if(K>x)
      B=K-x;
    else 
      B=x-K;
    if(x>B)
      sum+=B;
    else
      sum+=x;
  }
  cout << sum*2 << endl;
}
   
    
  

Measured memory_bytes: 256
_,_,m = gets.split.map(&:to_i)
list_a = gets.split.map(&:to_i)
list_b = gets.split.map(&:to_i)
discount = []
m.times { discount << gets.split.map(&:to_i) }
min = list_a.min + list_b.min
discount.each do |ia,ib,d|
  min = [min,list_a[ia-1] + list_b[ib-1] - d].min
end
puts min


Measured memory_bytes: 28896
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
int find(int a){
     if(par[a]==a)return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);if(a==b)return ;
     parent[b]=a;
}*/
 
 
 
 
 
 
 












int main(){
     ll h,w;
     cin>>h>>w;
     ll res=h*w;
     for(ll i=1;i<=h;i++){
          ll t1=(h-i)/2,t2=(h-i+1)/2;
          ll ans1=min(t1,min(i,t2)),ans2=max(t1,max(t2,i));
          res=min(res,w*(ans2-ans1));
          t1=w/2,t2=(w+1)/2;
          ans1=t1*(h-i),ans2=t2*(h-i);
          ll ans3=i*w;
          res=min(res,max(ans1,max(ans2,ans3))-min(ans1,min(ans2,ans3)));
     }
     for(int i=1;i<=w;i++){
          ll t1=(w-i)/2,t2=(w-i+1)/2;
          ll ans1=h*i,ans2=h*t1,ans3=h*t2;
          res=min(res,max(ans1,max(ans2,ans3))-min(ans1,min(ans2,ans3)));
          t1=h/2,t2=(h+1)/2;
          ans1=i*h,ans2=t1*(w-i),ans3=t2*(w-i);
          res=min(res,max(ans1,max(ans2,ans3))-min(ans1,min(ans2,ans3)));
     }
     cout<<res;
}


























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

using namespace std;

int DiceInfo[100][7];
vector<string> DicePosition;
const string WEDirection = "364136";
const string NSDirection = "265126";
const string LRDirection = "453245";

void swap(string &ans, int pos, const string &direction) {
	char tmp;

	tmp = ans[direction[pos] - '0'];
	ans[direction[pos + 0] - '0'] = ans[direction[pos + 1] - '0'];
	ans[direction[pos + 1] - '0'] = ans[direction[pos + 2] - '0'];
	ans[direction[pos + 2] - '0'] = ans[direction[pos + 3] - '0'];
	ans[direction[pos + 3] - '0'] = tmp;
	//cout << "=" << ans << endl;
}

void solve() {
	int len;
	string ans;

	ans = "0123456";
	DicePosition.push_back(ans);
	for (int i = 0; i < 3; ++i) {
		swap(ans, i, WEDirection);
		DicePosition.push_back(ans);
	}

	len = DicePosition.size();
	for (int i = 0; i < len; ++i) {
		ans = DicePosition[i];
		for (int k = 0; k < 3; ++k) {
			swap(ans, k, NSDirection);
			DicePosition.push_back(ans);
		}
	}

	len = DicePosition.size();
	for (int i = 0; i < len; ++i) {
		ans = DicePosition[i];
		for (int k = 0; k < 3; ++k) {
			swap(ans, k, LRDirection);
			DicePosition.push_back(ans);
		}
	}
}

bool judge(int n) {
	int len, j;

	len = DicePosition.size();
	for (int i = 0; i < len; ++i) {
		for (int k = 0; k < n; ++k) {
			for (int l = k + 1; l < n; ++l) {
				for (j = 1; j < 7; ++j) {
					if (DiceInfo[k][DicePosition[i][j] - '0'] != DiceInfo[l][j]) {
						break;
					}
				}
				if (j == 7) {
					return false;
				}
			}	
		}
	}

	return true;
}

int main() {
	int n;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j < 7; ++j) {
			cin >> DiceInfo[i][j];
		}
	}
	solve();
	if (judge(n)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3216