akhauriyash/Code-Regression huggingface dataset:
from functools import reduce
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a, b):
    while a != 0:
        a,b=b%a,a
    return b
def lcm(x, y):
    return (x * y)//gcd(x, y)
t=reduce(gcd,a)
if t==1:
    if max(a)>=k:
        print('POSSIBLE')
        exit()
else:
    if k in a:
        print('POSSIBLE')
        exit()
    if k%t==0 and max(a)>=k:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


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

using namespace std;
#define PI acos(-1)
#define ll long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int maxn = 2e5 + 10;
void solve(){
    int n; cin >> n;
    cout << 2 * PI * n << endl;
}
int main(){
    IOS; int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3800
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

start = j = 7 % K
count = 1

#無限ループ
while True:
    #0の時
    if j == 0:
        print(count)
        exit()
        
    j = 10 * j + 7
    j = j % K
    count += 1
    
    #同じ数のループしているかチェック
    if j == start:
        print(-1)
        exit()

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	int ret=0;
	for (int i=1; i<=n; i++) {
		if(i>=n-i) break;
		ret++;
	}
	cout<<ret<<"\n";
	return 0;
}

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

int main() {
    char n[5];
    cin >> n;
    int a=n[0]-'0', b=n[1]-'0', c=n[2]-'0', d=n[3]-'0';

    if(a+b+c+d==7) cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7" << endl;
    else if(a+b+c-d==7) cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7" << endl;
    else if(a+b-c+d==7) cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7" << endl;
    else if(a+b-c-d==7) cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7" << endl;
    else if(a-b+c+d==7) cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7" << endl;
    else if(a-b+c-d==7) cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7" << endl;
    else if(a-b-c+d==7) cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7" << endl;
    else if(a-b-c-d==7) cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
     string s;
     int sum=0;
     cin>>s;
     for(int i=0;i<s.size();i++)
     {
     	sum+=(s[i]-'0');
     }
     if(sum%9==0)cout<<"Yes";
     else cout<<"No";
}

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

int main(){
  int N,M,K;
  cin>>N>>M>>K;
  bool flag=0;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      if((i*(M-j)+j*(N-i))==K){
        flag=1;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
  return 0;  
}


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

int main(){
    int n;
    while(cin>>n,n){
        int a,b,c,d,x,y,z,w;
        while(n--){
            cin>>a>>b>>c>>d>>x>>y>>z>>w;
            int o=a*x-b*y-c*z-d*w;
            int p=a*y+b*x+c*w-d*z;
            int q=a*z-b*w+c*x+d*y;
            int r=a*w+b*z-c*y+d*x;
            cout<<o<<" "<<p<<" "<<q<<" "<<r<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */

#ifndef H_make_vector
#define H_make_vector

#include <cstddef>
#include <type_traits>
#include <vector>

namespace detail {
  template <typename Tp, size_t N>
  std::vector<Tp> make_vector(
      std::vector<size_t>& sizes,
      typename std::enable_if<(N == 1), Tp const&>::type x
  ) {
    return std::vector<Tp>(sizes[0], x);
  }
  template <typename Tp, size_t N>
  auto make_vector(
      std::vector<size_t>& sizes,
      typename std::enable_if<(N > 1), Tp const&>::type x
  ) {
    size_t size = sizes[N-1];
    sizes.pop_back();
    return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
        size, make_vector<Tp, N-1>(sizes, x)
    );
  }
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x = Tp()) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

#endif  /* !defined(H_make_vector) */

#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

int main() {
  auto a = make_vector({3_zu, 3_zu}, 0);
  for (auto& ai: a)
    for (auto& aij: ai) scanf("%d", &aij);

  size_t n;
  scanf("%zu", &n);
  std::vector<int> b(n);
  for (auto& bi: b) scanf("%d", &bi);

  auto g = make_vector({3_zu, 3_zu}, 0);
  for (auto bi: b) {
    for (size_t i = 0; i < 3; ++i)
      for (size_t j = 0; j < 3; ++j)
        if (a[i][j] == bi)
          g[i][j] = 1;
  }

  bool ok = false;
  ok |= (g[0][0] && g[0][1] && g[0][2]);
  ok |= (g[1][0] && g[1][1] && g[1][2]);
  ok |= (g[2][0] && g[2][1] && g[2][2]);
  ok |= (g[0][0] && g[1][0] && g[2][0]);
  ok |= (g[0][1] && g[1][1] && g[2][1]);
  ok |= (g[0][2] && g[1][2] && g[2][2]);
  ok |= (g[0][0] && g[1][1] && g[2][2]);
  ok |= (g[0][2] && g[1][1] && g[2][0]);

  puts(ok? "Yes": "No");
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//素因数分解O(√n)
map<ll,ll>M;
void prime_factor(int n){
  for(int i=2;i*i<=n;i++){
    while(n%i==0){
      M[i]++;
      n/=i;
    }
  }
  if(n!=1)M[n]++;;
  return;
}

int main(){
  ll n;cin>>n;
  for(int i=1;i<=n;i++){
     prime_factor(i);
  }
  ll ans=1;
  for(auto p:M){
   if(p.first==1)continue;
    ans*=p.second+1;
    ans%=MOD;
  }
  cout<<ans<<endl;
}
    
  

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string s; cin >> s;

    int ans = 0;
    int margin = 0;
    for (char c: s) {
        if (c == 'g') {
            if (!margin) {
                ++margin;
            } else {
                --margin;
                ++ans;
            }
        } else if (c == 'p') {
            if (!margin) {
                ++margin;
                --ans;
            } else {
                --margin;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void){
	int a,b;
	char op;
	op = '+';

	while(op != '?'){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '+'){
			printf("%d\n",a+b);
		}
		else if(op == '-'){
			printf("%d\n",a-b);
		}
		else if(op == '*'){
			printf("%d\n",a*b);
		}
		else if(op == '/'){
			if(b !=0){
				printf("%d\n",a/b);
			}
			else{
				break;
			}
		}
		else{
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 600
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}


// Main Code
void solve() {
    int x, y;
    cin >> x >> y;
    if (x == 1 && y == 1) cout << 1000000 << "\n";
    else cout << (max(4 - x, 0) + max(4 - y, 0)) * 100000 << "\n";
    return;
}


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

long c2(long n) {
  return n * (n - 1) / 2;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N), cnt(N + 1);
  for (int i = 0, a; cin >> a; i++) A.at(i) = a, cnt.at(a)++;

  long sum = 0;
  for (int i : cnt) sum += c2(i);

  for (int i = 0; i < N; i++) {
    int tmp = cnt.at(A.at(i));
    cout << sum - c2(tmp) + c2(tmp - 1) << endl;
  }
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int a,b;
  cin >> a >> b;
  int c=a+b;
  if(a%3==0||b%3==0||c%3==0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}

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

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

const long long INF =1LL << 60;

int N;
long long h[1000010];

long long dp[1000010];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) cin >> h[i];
  
  for (int i = 0; i < N; i++) dp[i] = INF;
  
  dp[0] = 0;
  
  for (int i = 0; i < N; i++) {
    chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }
  
  cout << dp[N - 1] << endl;
}
    

Measured memory_bytes: 5120
#include<bits/stdc++.h>                          
using namespace std;
int n,a[107],sum1,sum2;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i+=2) sum1+=a[i];
    for(int i=2;i<=n;i+=2) sum2+=a[i];
    if(n%2==1) cout<<sum1-sum2<<endl;
    else cout<<sum2-sum1<<endl;
    return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String SArray[] = S.split("");
		int count = 0;

		for(int i = 0; i < S.length(); i++) {
			if (SArray[i].equals("1")){
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

int frq[1000007];
int main(){
	Lancer();
	ll n, i = 1;
	cin >> n;
	while (1)
	{
		frq[n]++;
		i++;
		n = ((n % 2 == 0) ? n / 2 : ((3 * n) + 1));
		if (frq[n])
			break;
		frq[n]++;
	}
	cout << i;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3700
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int s = in.ni(), w = in.ni();
        out.println((w>=s)?"unsafe":"safe");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 32928
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,m;cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}


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

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

int main() {
  int n, ans = 0;
  cin >> n;
  int lr[n][2];
  rep(i, n) { cin >> lr[i][0] >> lr[i][1]; }
  rep(i, n) { ans = ans + lr[i][1] - lr[i][0] + 1; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main(str)
  lines = str.split("\n").map { |x| x.split(" ").map(&:to_i) }
  k = lines[0][0]
  a, b = lines[1]
  n = 0
  loop do
    return "OK" if (a..b).include?(n)
    return "NG" if b < n
    n += k
  end
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("OK", main("7
500 600"))
    assert_equal("NG", main("7
500 501"))
  end
end




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

using namespace std;

typedef long long ll;

#ifdef LOCAL
#include "debug.h"
#define debug(...) debug_vars(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

void debug2(const vector<int>& data)
{
  for (int i = 0; i < data.size(); i++) {
    cout << data[i] << " ";
  }
  cout << endl;
}

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("file.1", "r", stdin);

  ll n, q;
  cin >> n >> q;
  vector<int> c(n);
  // debug(n, q);
  string s;
  cin >> s;
  int i, j;
  int cnt = 0;
  c[0] = cnt;
  for (i = 1; i < n; i++) {
    if (s[i - 1] == 'A' && s[i] == 'C') {
      cnt++;
    }
    c[i] = cnt;
  }
  // debug2(c);
  for (i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    int ans = 0;
    ans = c[r] - c[l];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1488
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func max32(a, b int32) int32 {
	if a > b {
		return a
	}
	return b
}

var dp [][]int32
var maxL int

func makeTbl(N int, v, w []int) {
	N = min(N, len(v))
	dp = make([][]int32, N+1)
	for n := 0; n <= N; n++ {
		dp[n] = make([]int32, maxL+1)
	}
	// out(v, w, N)

	for n := 1; n < N; n++ {
		prev := n / 2
		// out("cur", n, "prev", prev)
		for i := 0; i <= maxL; i++ {
			if w[n] <= i {
				dp[n][i] = max32(dp[prev][i], dp[prev][i-w[n]]+int32(v[n]))
			} else {
				dp[n][i] = dp[prev][i]
			}
		}
		// out(n, dp[n][:10])
	}
}

func calc(s, L int, v, w []int) int {
	N := len(v)
	n := 1 << uint(N)
	ret := 0
L0:
	for i := 0; i < n; i++ {
		sumw := 0
		sumv := 0
		for j := 0; j < N; j++ {
			if (i>>j)%2 == 1 {
				sumw += w[j]
				sumv += v[j]
			}
			if sumw > L {
				continue L0
			}
		}
		// out(strconv.FormatInt(int64(i), 2), sumw, sumv, L)
		rest := L - sumw
		sumv += int(dp[s][rest])
		ret = max(ret, sumv)
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	v := make([]int, N+1)
	w := make([]int, N+1)
	for i := 1; i <= N; i++ {
		v[i], w[i] = getInt(), getInt()
	}

	Q := getInt()
	AV := make([]int, Q)
	AL := make([]int, Q)

	for i := 0; i < Q; i++ {
		AV[i], AL[i] = getInt(), getInt()
		maxL = max(maxL, AL[i])
	}

	const lv = 2048
	makeTbl(lv, v, w)

	val := make([]int, 18)
	weight := make([]int, 18)

	wb := bufio.NewWriter(os.Stdout)
	defer wb.Flush()
	for i := 0; i < Q; i++ {
		L := AL[i]
		V := AV[i]
		// out(V, L, dp[V][:L])
		if V < lv {
			fmt.Fprintln(wb, dp[V][L])
			continue
		}
		idx := 1
		for V >= lv {
			val[idx] = v[V]
			weight[idx] = w[V]
			V /= 2
			idx++
		}
		// out(val, weight, V, L)
		ret := calc(V, L, val[:idx], weight[:idx])
		fmt.Fprintln(wb, ret)
	}
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n, k, x, y;
	cin >> n >> k >> x >> y;
	cout << x * min(n, k) + y * (n - min(n, k)) << '\n';
	return 0;
}

Measured memory_bytes: 256
# C + T = X
# 2 * C + 4 * T = Y
# T = X - C
# 2 * C + 4 * (X - C) = Y
# - 2 * C = Y - 4 * X
# C = 2 * X - Y // 2
# T = -X + Y // 2


def main():
    X, Y = map(int, input().split())
    C = 2 * X - Y // 2
    T = -X + Y // 2
    print("Yes" if 0 <= C and 0 <= T and C + T ==
          X and 2 * C + 4 * T == Y else "No")
    return


main()


Measured memory_bytes: 9116
/*
 * FileName:     model
 * CreatedDate:  2020-07-11 15:25:36 +0900
 * LastModified: 2020-07-11 15:39:14 +0900
 */

#include <stdio.h>

int main(void){
    int m, n;
    scanf("%d%d",&m, &n);
    long s=1, c=m, MOD=1000000007;
    while(n){
	if(n%2){
            s=s*c%MOD;
        }
	c=c*c%MOD;
	n/=2;
    }
    printf("%ld\n",s);
    return 0;
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

const int D = 80 * 160 + 10;
const int D2 = D * 2;
typedef bitset<D2> bs;

int a[100][100];
bs dp[90][90];

int main()
{
  int w, h;
  cin >> h >> w;
  rep(i, h) rep(j, w)
  {
    int x;
    cin >> x;
    a[i][j] = x;
  }
  rep(i, h) rep(j, w)
  {
    int x;
    cin >> x;
    a[i][j] = abs(x - a[i][j]);
  }
  dp[0][0][D - a[0][0]] = 1;
  dp[0][0][D + a[0][0]] = 1;
  rep(i, h) rep(j, w)
  {
    if (i)
    {
      dp[i][j] |= dp[i - 1][j] << a[i][j];
      dp[i][j] |= dp[i - 1][j] >> a[i][j];
    }
    if (j)
    {
      dp[i][j] |= dp[i][j - 1] << a[i][j];
      dp[i][j] |= dp[i][j - 1] >> a[i][j];
    }
  }
  int ans = D2;
  rep(i, D2)
  {
    if (dp[h - 1][w - 1][i])
    {
      ans = min(ans, abs(i - D));
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 24704
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int b[k+1]={0};
    for(int i=1;i<k+1;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[j]<=i)
            {
                if(b[i-a[j]]==0)
                {
                    b[i]=1;
                    break;
                }
            }
        }
    }
    if(b[k])
    cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 640
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	a--;b--;
	if(a%2==b%2){
		printf("%lld\n",(b-a)/2);
	}else{
		long long ret=inf*2;
		long long L=a+1;
		ret=min(ret,L+(b-a-1)/2);
		long long R=n-b;
		ret=min(ret,R+(b-a-1)/2);
		printf("%lld\n",ret);
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll N, M, K; cin >> N >> M >> K;
  for (ll n = 0; n <= N; ++n) {
    for (ll m = 0; m <= M; ++m) {
      auto k = n*M + m*N - 2*n*m;
      if (k == K) {
        cout << "Yes" << CRLF;
        return;
      }
    }
  }
  cout << "No" << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int n,tm[1001]; char c1[1001],c2[1001],c3[1001]; int main() {int ans = 0; cin>>n>>c1>>c2>>c3; for(int i=0;i<n;i++) { memset(tm,0,sizeof(tm)); tm[ c1[i] ]++;tm[ c2[i] ]++;tm[ c3[i] ]++; ans += 3 - max( tm[ c1[i] ] , max( tm[ c2[i] ],tm[ c3[i] ] )  );   }  cout<<ans;  }

Measured memory_bytes: 256
let () =
  let n, h = Scanf.scanf "%d %d " (fun a b -> a, b) in
  let l =  Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d %d " (fun a b -> (a, b))) in

  let a = List.map (fun (a,b) -> a) l in
  let b = List.map (fun (a,b) -> b) l in

  let a =  List.sort (fun x y -> if x > y then -1 else if x = y then 0 else 1) a in
  let b =  List.sort (fun x y -> if x > y then -1 else if x = y then 0 else 1) b in

  let max_a = List.hd a in

  let bs = List.filter (fun x -> x > max_a) b in

  let rec f last res = function
    | [] -> res
    | hd :: tl -> 
      let last = last - hd in f last (last :: res) tl
  in
  let bd1 = f h [] bs in
  let bd2 = List.filter (fun x -> x > 0) bd1 in
  let bd1_len = List.length bd1 in
  let bd2_len = List.length bd2 in

  if bd1_len <> bd2_len then Printf.printf "%d\n" @@ bd2_len + 1
  else
    let b_sum = List.fold_left (+) 0 bs in

    Printf.printf "%d\n" @@ bd1_len +
                            (
                              if (h - b_sum) mod max_a = 0 then
                                (h - b_sum) / max_a
                              else 
                                (h - b_sum) / max_a + 1
                            )



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

void swap(int *a, int *b){
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
	
}

int main(){
	int arr[10];
	for(int i = 0; i < 10; i++){
		cin >> arr[i];
	}
	for(int i = 0; i < 10; i++)
		for(int j = 0; j < 10; j++)
			if(arr[i] < arr[j])
				swap(&arr[i], &arr[j]);
	cout << arr[9] << endl << arr[8] << endl << arr[7] << endl;
}


Measured memory_bytes: 3124
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 100010;
int n, sum[maxn], b[maxn], tree[maxn * 2], a[maxn];
long long tot;
void add(int x) { x += n + 1; for(; x <= n * 2 + 2; x += x & -x) tree[x]++; }
int query(int x) { x += n + 1; int ret = 0; for(; x; x -= x & -x) ret += tree[x]; return ret; }
bool check(int mid) {
    for(int i = 1; i <= n; i++) if(a[i] <= mid) b[i] = 1; else b[i] = -1;
    for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + b[i];
    memset(tree, 0, sizeof(tree));
    add(0);
    long long ret = 0;
    for(int i = 1; i <= n; i++) {
        ret += query(sum[i] - 1);
        add(sum[i]);
    }
    return ret >= tot;
}
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int l = 1, r = 1e9, ans = 0;
    tot = 1ll * n * (n + 1) / 2; 
    tot = tot / 2 + 1;
    while(l <= r) {
        int mid = (l + r) >> 1;
        if(check(mid)) r = mid - 1, ans = mid;
            else l = mid + 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2176
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string A, B;
	
	cin >> A >> B;

	int i = 0;
	while( (i < A.size()) && (i < B.size()))
	{
		cout << A[i] << B[i];
		i++;
	}

	while (i < A.size())
	{
		cout << A[i++];
	}

	while (i < B.size())
	{
		cout << B[i++];
	}

	cout << endl;

	
	return 0;
}


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

template <class T>
T gcd(T a, T b) {
    if (a < b) std::swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main() {
    long long n;
    std::vector<std::vector<long long>> v(500, std::vector<long long>(500, 1));
    std::vector<long long> lp(10000), pr(1010);
    auto prit = pr.begin();
    // linear sieve
    for (int i = 2; i < 10000 && prit != pr.end(); i++) {
        if (!lp[i]) {
            lp[i] = i;
            *prit = i;
            prit++;
        }
        for (auto it = pr.begin(); *it <= lp[i] && *it * i < 10000 && it != prit; it++) lp[*it * i] = *it;
    }

    for (int i = 0; i < 500; i++) {
        for (int j = 0; j < 500; j++) {
            if ((i + j) % 2) {
                v[i][499 - j] *= pr[500 + (i + j - 1) / 2];
            } else {
                v[i][j] *= pr[(i + j) / 2];
            }
        }
    }

    for (int i = 0; i < 500; i++) {
        for (int j = 0; j < 500; j++) {
            if (v[i][j] > 1) continue;
            auto num = 1ll;
            if (i > 0) num = lcm(num, v[i - 1][j]);
            if (i != 499) num = lcm(num, v[i + 1][j]);
            if (j > 0) num = lcm(num, v[i][j - 1]);
            if (j != 499) num = lcm(num, v[i][j + 1]);
            v[i][j] = num + 1;
        }
    }

    std::cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) std::cout << v[i][j] << " ";
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 5248
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == n){
                cout << "Yes" << '\n';
                return 0;
            }
        }
    }
    cout << "No" << '\n';
}


Measured memory_bytes: 888
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////
#define int long long

void solve(){

	int n;
	cin>>n;
	string ans;
	while(n){

		int x = n%26;
		
		if(x==0){
			ans.pb('z');
			n/=26;
			--n;
		}
		else {
			ans.pb('a' + x - 1);
			n/=26;
		}
	}

	reverse(ans.begin(),ans.end());

	cout<<ans<<endl;
}

signed main(){

	fast;
	int t = 1;
	//cin>>t;
	for(int i = 1 ; i <= t ; ++i)
		solve();
}

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

int main(){
   int A,B,C,D;
   cin>>A>>B>>C>>D;
   int E,F;
   E=A*B;
   F=C*D;
   if(E>F){
       cout<<E<<endl;
   }else{
       cout<<F<<endl;
   }
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
typedef pair<int,int> pi;
template <typename T> void chmax(T& a, T b) {a = max(a,b);}
template <typename T> void chmin(T& a, T b) {a = min(a,b);}
//#define cerr if (0) cout

int n;
set<string> st;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string str;
		cin >> str;
		st.emplace(str);
	}
	cout << (int)st.size();
	return 0;
}


Measured memory_bytes: 19212
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b>a*n){
			System.out.println(a*n);
		}else{
			System.out.println(b);
		}
	}
}




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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int x; cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,ans=0; cin>>n;
    vector<int> d(n,0);
    rep(i,n) cin>>d[i];
    rep(i,n)rep(j,n)if(i!=j) ans+=d[i]*d[j];
    cout<<ans/2<<endl;
}


Measured memory_bytes: 3588
#include<stdio.h>

int main(){
  int n,i;
  int number[100];
  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf(" %d",&number[i]);
  }

  printf("%d",number[n-1]);
  for(i=1; i<n; i++){
    printf(" %d",number[n-i-1]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 1e5 + 5;
int a[maxn], dp[maxn];

int main() {
    int n;
    scanf("%d", &n);
    REP(i, n) scanf("%d", a + i);
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]),
                    dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
ll a,b,c,k;
cin >> a >> b >> c >> k;
ll ans = (c+b) -(a+c);
if(k%2==0)ans*=-1;
cout << ans << endl; 
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void pos(vector<int> &A) {
	int N = A.size();
	for(int i = 0; i < N - 1; i++) {
		cout << i + 1 << " " << i + 2 << endl;
	}
}

void neg(vector<int> &A) {
	int N = A.size();
	for(int i = N; i >= 2; i--) {
		cout << i << " " << i - 1 << endl;
	}
}

void solve() {
	int N;
	cin >> N;
	vector<int> A(N);
	
	bool positive = false, negative = false;
	int mi = 0, ma = 0;
	int mi_i = 0, ma_i = 0;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] > 0) {
			positive = true; 
			if (ma < A[i]) {
				ma = A[i];
				ma_i = i;
			}
		}
		if (A[i] < 0) {
			negative = true; 
			if (mi > A[i]) {
				mi = A[i];
				mi_i = i;
			}
		}
	}

	if (!positive && !negative) {
		cout << 0 << endl;
		return;
	}
	if (positive && !negative) {
		cout << N - 1 << endl;
		pos(A);
	} else if (!positive && negative) {
		cout << N - 1 << endl;
		neg(A);
	} else {
		if (abs(mi) > abs(ma)) {
			cout << 2 * N - 1 << endl;
			for(int i = 0; i < N; i++) {
				cout << mi_i + 1 << " " << i + 1 << endl;
			}
			neg(A);
		} else {
			cout << 2 * N - 1 << endl;
			for(int i = 0; i < N; i++) {
				cout << ma_i + 1 << " " << i + 1 << endl;
			}
			pos(A);
		}

	}



}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

int main() {
  int h, w;
  cin>>h>>w;
  int a[h][w];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cin>>a[i][j];
    }
  }
  int i = 0;
  int j = 0;
  vector<pair<int, int> > odds;
  int tmp_cnt = 0;
  int cnt = 0;
  while (i < h) {
    while (j >= 0 && j <= w - 1) {
      if (odds.size() % 2 == 1) {
        ++tmp_cnt;
      }
      if (a[i][j] % 2 != 0) {
        odds.emplace_back(i, j);
      }
      if (odds.size() % 2 == 0) {
        cnt += tmp_cnt;
        tmp_cnt = 0;
      }
      if (i % 2 == 0) {
        ++j;
      } else {
        --j;
      }
    }
    ++i;
    if (j == w) --j;
    if (j == -1) ++j;
  }
  cout<<cnt<<endl;
  for (int i=0; i<odds.size()/2; i++) {
    auto p1 = odds[2*i];
    auto p2 = odds[2*i + 1];
    int y = p1.first;
    int x = p1.second;
    int gy = p2.first;
    int gx = p2.second;
    while (x != gx || y != gy) {
      cout<<y+1<<" "<<x+1<<" ";
      if (y % 2 == 0) {
        ++x;
      } else {
        --x;
      }
      if (x == w) {
        --x;
        ++y;
      } else if (x == -1) {
        ++x;
        ++y;
      }
      cout<<y+1<<" "<<x+1<<endl;
    }
  }
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >>N;
    vector<pll> seg(N);
    rep(i, N) {
        ll x, l; cin >> x >> l;
        seg[i].first = x - l;
        seg[i].second = x + l;
    }
    sort(all(seg), [](pll& a, pll& b){return a.second<b.second;});
    // rep(i, N) D2(seg[i].first, seg[i].second);
   
    int ans = 1;
    int prev = 0;
    rep1(i,N) {
        if (seg[i].first >= seg[prev].second) {
            ans++;
            prev = i;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

char str[1005];
char v[1005][33];
int  n[1005];
int main()
{
  int i,j,k=0;
  int maxi=0;

  gets(str);

  rep(i,1000){
    rep(j,33)
    {
      if(str[k]==' '|| str[k]=='\0'){
	v[i][j]='\0';
	k++;
	break;
      }
      v[i][j]=str[k];
      k++;
    }
    if(k>=strlen(str))break;
  }
  int num=i+1;

  rep(i,num)
    {
      n[i]=0;
    }

  rep(i,num){
    if( strlen(v[maxi]) < strlen(v[i]) )
      maxi=i;
    if(n[i])continue;
    for(j=i+1;j<num;j++){
      if(strcmp(v[i],v[j])==0){
	n[i]++;
	n[j]++;
      }
    }
  }
  int mode=0;

  for(i=1;i<num;i++)
    if(n[mode]<n[i])
      mode=i;

  cout<<v[mode]<<" ";
  cout<<v[maxi]<<endl;
}

Measured memory_bytes: 1132
n = int(input())
a = str(input())
b = str(input())
c = str(input())

ans = 0
for i in range(n):
    if a[i] == b[i]:
        if a[i] == c[i]:
            continue
        else:
            ans += 1
    elif a[i] == c[i]:
        ans += 1
    elif b[i] == c[i]:
        ans += 1
    else:
        ans += 2

print(int(ans))

Measured memory_bytes: 3064
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int n = 1;
        while_LB:
        while (n <= 1000) {
            for (int i = 1; i <= 1000; i++) {
                n = K * i;
                if (n >= A && n <= B) {
                    System.out.println("OK");
                    break while_LB;
                }

            }
            System.out.println("NG");
        }
    }
}


Measured memory_bytes: 35612
n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = A[0]
INF = 1000000000000000000
for i in range(1,n):
    l,r = len(str(ans)),len(str(A[i]))
    if l+r > 21:
        ans = -1
        break
    else:
        ans = ans * A[i]
        if ans > INF:
            ans = -1
            break
print(ans)


Measured memory_bytes: 21656
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int h, w, n; cin >> h >> w >> n;

	int x = max(h, w);
	
	cout << (n+x-1)/x<< endl;
	return 0;
}

Measured memory_bytes: 256