akhauriyash/Code-Regression huggingface dataset:
use std::cmp::Ordering;

fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn lower_bound<T: Ord>(sorted: &[T], x: &T) -> usize {
    let mut low = 0;
    let mut high = sorted.len();

    while low != high {
        let mid = (low + high) / 2;
        match sorted[mid].cmp(x) {
            Ordering::Less => low = mid + 1,
            Ordering::Greater | Ordering::Equal => high = mid,
        };
    }

    low
}

fn main() {
    let n = read1::<usize>();
    let mut a = readn::<usize>(" ");
    let mut b = readn::<usize>(" ");
    let mut c = readn::<usize>(" ");

    a.sort();
    b.sort();
    c.sort();

    let mut an = vec![0; n];
    let mut bn = vec![0; n];

    for i in 0..n {
        let bni = lower_bound(&b, &(a[i] + 1));
        an[i] = bni;
    }

    for i in 0..n {
        let cni = lower_bound(&c, &(b[i] + 1));
        bn[i] = cni;
    }

    let mut bs = vec![0; n + 1];
    for i in 1..n+1 {
        bs[n-i] = bs[n-i+1] + (n - bn[n-i]);
    }

    let mut ans = 0;
    for i in 0..n {
        ans += bs[an[i]];
    }
    println!("{}", ans);
}

Measured memory_bytes: 13632
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());

    int r = Integer.parseInt(sc.next());
    int s = Integer.parseInt(sc.next());
    int p = Integer.parseInt(sc.next());

    String t = sc.next();
    RSP[] enemyArray = toRspArray(t);
    RSP[] allWinArray = allWinArray(enemyArray);
    RSP[] strict = strict(allWinArray, k);

    long ans = 0;
    for (RSP rsp : strict) {
      switch (rsp) {
        case R:
          ans += r;
          break;
        case S:
          ans += s;
          break;
        case P:
          ans += p;
          break;
        case ANY:
          break;
      }
    }
    pw.println(ans);
  }

  static RSP[] toRspArray(String t) {
    RSP[] rsps = new RSP[t.length()];
    for (int i = 0; i < rsps.length; i++) {
      rsps[i] = RSP.of(String.valueOf(t.charAt(i)));
    }
    return rsps;
  }

  static RSP[] allWinArray(RSP[] enemy) {
    RSP[] rsps = new RSP[enemy.length];
    for (int i = 0; i < rsps.length; i++) {
      rsps[i] = enemy[i].toWin();
    }
    return rsps;
  }

  static RSP[] strict(RSP[] allWin, int k) {
    RSP[] strict = Arrays.copyOf(allWin, allWin.length);
    for (int i = 1; i <= k; i++) {
      for (int j = i - 1; j < strict.length; j += k) {
        int current = j;
        int next = j + k;
        int nextNext = next + k;
        if (next >= strict.length) {
          continue;
        }
        if (nextNext >= strict.length) {
          if (strict[current] == strict[next]) {
            strict[current] = RSP.ANY;
          }
          continue;
        }
        if (strict[current] == strict[next]) {
          if (strict[next] == strict[nextNext]) {
            strict[next] = RSP.ANY;
          } else {
            strict[current] = RSP.ANY;
          }
        }
      }
    }
    return strict;
  }

  enum RSP {
    R("r") {
      @Override
      RSP toWin() {
        return RSP.P;
      }
    },
    S("s") {
      @Override
      RSP toWin() {
        return RSP.R;
      }
    },
    P("p") {
      @Override
      RSP toWin() {
        return RSP.S;
      }
    },
    ANY("any") {
      @Override
      RSP toWin() {
        return RSP.ANY;
      }
    };

    RSP(String v) {
      this.v = v;
    }

    abstract RSP toWin();

    String v;

    static RSP of(String s) {
      return Arrays.stream(values()).filter(v -> s.equals(v.v)).findFirst().get();
    }
  }
}


Measured memory_bytes: 48656
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define  inf 0x3fffffff 
int main()
{
	long long n, m;
	int i;
	while (scanf("%lld%lld", &n, &m) != EOF)
	{
		long long a = (n * 2 + m) / 4;
		if (n >= m / 2)
			printf("%lld\n", m /2);
		else
		printf("%lld\n", a);
	}
	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 10005

ll min(ll a , ll b){
    if(a < b)   return a;
        return b;
}

ll l , r , ans;
bool used[MAXX];

int main()
{
    _FastIO;
    cin >> l >> r;
    if(l > (r + 2020)){
        cout << "0" << endl;
        return 0;
    }
    ll ans = 2018;
    for(ll i = l; i < r; i++){
        for(ll j = i + 1; j <= r; j++){
            ans = min(ans , ((i * j) % 2019));
            if(!ans)    break;
        }
        if(!ans)    break;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  long long N;
  cin >> N;
  int ans=11;
  for (int i=1;i<=sqrt(N);i++){
    if (N%i==0){
      int x=N/i;
      string y=to_string(x);
      int z=y.size();
      ans=min(ans,z);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();

		double x = Math.abs(x1 - x2);
		double y = Math.abs(y1 - y2);

		x *= x;
		y *= y;

		double dist = Math.sqrt(x + y);
		System.out.println(dist);

	}

}


Measured memory_bytes: 28144
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int h, w;
	cin >> h >> w;
	vs a(h);
	rep(i, h)cin >> a[i];

	string t = "##";
	rep(i, w) {
		t += '#';
	}
	cout << t << endl;
	rep(i, h) {
		cout << '#' << a[i] << '#' << endl;
	}
	cout << t << endl;

	return 0;
}


Measured memory_bytes: 256
/*AOJ 0013*/

#include<iostream>
#include<stack>
#include<queue>

using namespace std;

int main(){

	stack<int> data;
	queue<int> ans;

	int tmp;

	cin>>tmp;

	data.push(tmp);

	int flag = 0;
	while(cin>>tmp){

		flag = 0;

		if(tmp == 0){
			ans.push(data.top());
			data.pop();
		}
		else{
			data.push(tmp);
		}

	}
	while(ans.size()!=0){
		cout<<ans.front()<<endl;
		ans.pop();
	}

	return 0;
}

Measured memory_bytes: 0
N = gets.to_i
Se = []
So = []
(N + 1).times{|i| So << []; Se << []}
(N - 1).times{|i|
  u, v, w = gets.chomp.split(" ").map(&:to_i);
  w.even? ? (Se[u] << v; Se[v] << u) : (So[u] << v; So[v] << u)
}

vtx = Array.new(N + 1, 0)
vtx[1] = 1
q = [1]
while(q.size > 0) do
  v = q.shift
  Se[v].select{|i| vtx[i] == 0}.each{|j| vtx[j] = vtx[v];  q.push(j)}
  So[v].select{|i| vtx[i] == 0}.each{|j| vtx[j] = -vtx[v]; q.push(j)}
end

(1..N).each{|i|
  puts vtx[i] == 1 ? '1' : '0'
}


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

#define int long long

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

signed main() {
	int W, H, N;
	cin >> W >> H >> N;
	vector<pair<int,int> > tmp;
	int A = -1, B = -1;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		A = max(a, A);
		B = max(b, B);
		tmp.push_back(make_pair(a, b));
	}
	sort(tmp.begin(), tmp.end());
	vector<int> ma(N);
	
	for (int i = N - 1; i >= 0; i--) {
		ma[i] = tmp[i].second;
		if (i != N - 1) {
			ma[i] = max(ma[i], ma[i + 1]);
		}
	}
	int ans = 1000000000;
	int j = 0;
	for (int i = 0; i < N-1; i++) {
		if (tmp[i].first != tmp[i + 1].first) {
			//cout << ans << endl;
			//cout << tmp[i].first << " " << ma[i + 1] << endl;
			ans = min(ans,tmp[i].first + ma[i + 1]);
			j++;
		}
	}
	ans = min(ans, B);
	ans = min(ans, A);
	cout << ans << endl;
	return 0;
}


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

Measured memory_bytes: 17324
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	t := make([]string, len(s))
	for i := range t {
		t[i] = string(s[i])
	}
	for v := 'a'; v <= 'z'; v++ {
		if !strings.Contains(s, string(v)) {
			fmt.Println(s + string(v))
			return
		}
	}
	if !nextPermutation(t) {
		fmt.Println(-1)
	} else {
		i := 0
		for string(s[i]) == t[i] {
			fmt.Print(string(s[i]))
			i++
		}
		fmt.Println(t[i])
	}

}

func nextPermutation(t []string) bool {
	n := len(t)
	i := n - 2
	for i >= 0 && t[i] >= t[i+1] {
		i--
	}
	if i < 0 {
		return false
	}
	j := i + 1
	for j < n && t[j] > t[i] {
		j++
	}
	j--
	t[i], t[j] = t[j], t[i]

	left := i + 1
	right := n - 1

	for left < right {
		t[left], t[right] = t[right], t[left]
		left++
		right--
	}
	return true
}


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

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
    fio;
    ll t, l, a, n, q, k, i, m, c, u, f, j, p, r, x, y, s, b, d;

    cin >> n;
    c = 0;
    for (i = 1; i <= n; i++)
    {
        cin >> p;
        if (p % 2 != 0 && i % 2 != 0)
            c++;
    }
    cout << c;
    return 0;
}


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

typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define IMX INT_MAX
#define IMN INT_MIN
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl; 
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main() 
{
  //OJ; // For Input and Output File
  FIO;
long long int Sum=0;
  string nm;
  cin >> nm;
  
  for(int i=0;i<nm.length();i++)
  {
    Sum+=nm[i]-'0';
  }
  if (Sum % 9 == 0)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
return 0;
   
}

Measured memory_bytes: 3708
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let n: usize = get_one();
    let ps: Vec<usize> = get_vec();
    let mut ans = 0;

    let mut i = 0;
    while i < n {
        if ps[i] == i+1 {
            ans += 1;
            i += 1;
        }
        i += 1;
    }

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

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


Measured memory_bytes: 4352
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def main():
    s=input()
    oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    ko=list("abcdefghijklmnopqrstuvwxyz")
    if s in oo:
        print("A")
    else:
        print("a")









if __name__ == "__main__":

    main()

Measured memory_bytes: 72592
#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define fr first
#define sc second
#define ll long long int
#define bit(idx) idx&(-idx)
#define bin(x, a) bitset<a>(x)
#define all(A) A.begin(), A.end()
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;



int main(){
	ios_base::sync_with_stdio(NULL); cin.tie(); cout.tie();
	string s, t; cin >> s >> t;
	if(t.substr(0, s.size()) == s) cout << "Yes\n";
	else cout << "No\n";
}
/**

*/

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <stdio.h>
#define rep(i,o,u) for(int i = o;i <= u; i++)
typedef unsigned long long ll;
using namespace std;
int a[21];
int n,q,m;
bool solve(int i, int m){
	if(m == 0) return true;
	if(m < 0) return false;
	if(i > n) return false;
	bool res = solve(i+1,m) || solve(i+1,m-a[i]);
	return res;
}

int main(){
	cin >> n;
	rep(i,1,n) cin >> a[i];
	cin >> q;
	while(q--){
		cin >> m;
		if(solve(1,m)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>                                                                
#include <algorithm>                                                               
#include <vector>                                                                  
using namespace std;                                                               
                                                                                   
int main(void) {                                                                   
  int n;                                                                           
  cin >> n;                                                                        
  int x;                                                                           
  vector<int> a;                                                                   
  for (int i=0; i<n; i++) {                                                        
    cin >> x;                                                                      
    a.push_back(x);                                                                
  }                                                                                
  reverse(a.begin(),a.end());                                                      
  for (int i=0; i<a.size(); i++) {                                                 
    cout << (i==0?"":" ") << a[i] << flush;                                        
  }                                                                                
  cout << endl;                                                                    
  return 0;                                                                        
}                                                                                  
                           

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

int a, b;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> a >> b;
	if(a <= 5) b = 0;
	else if(a <= 12) b /= 2;
	cout << b << "\n";
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-

import sys

def main():
    a,v = map(int,input().split())
    b,w = map(int,input().split())
    t = int(input())

    if a == b:
        print("YES")
    elif a > b:
        if (a-v*t)-(b-w*t) <=0:
            print("YES")
        else:
            print("NO")
    else:
        if (w*t+b)-(v*t+a) <= 0:
            print("YES")
        else:
            print("NO")

if __name__ == "__main__":
    main()

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

using namespace std;


int main() {

    int r;
    cin >> r;

    cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
	
	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);
		int count = 0;
		
		
		
			for(int i = a; i <= b; i++ ){
				if(c % i == 0){
				count++;
				}
			}
		
		System.out.println(count);
		
	}
}

Measured memory_bytes: 24408
n, m = map(int, input().split())
s = input()
roulette = []

cur = n
while cur > m:
  for a in range(m):
    if s[cur - m + a] == '0':
      roulette.append(m - a)
      cur = cur - m + a
      break
  else:
    print(-1)
    break
else:
  roulette.append(cur)
  print(' '.join(map(str, roulette[::-1])))

Measured memory_bytes: 11124
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
L = LI()

"""
|A - B| < C |A + B|
"""

import itertools
cnt = 0
for v in itertools.permutations(L, 3):
    # print(len(set(v)))
    if len(set(v)) != 3 :
        continue

    a,b,c = v
    if abs(a - b) < c < a + b:
        cnt += 1
        # print(a,b,c)



print(cnt // 6)

Measured memory_bytes: 10856
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        StringBuilder sb = new StringBuilder();
        int ans = 0;
        int num = 0;
        if (a > b) {
            ans = b;
            num = a;
        } else {
            ans = a;
            num = b;
        }
        for (int i = 0; i < num; i++) {
            sb.append(ans);
        }
        sb.append("\n");
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
list = []

while True:
    H, W = [int(i) for i in input().split()]
    if H == 0 and W == 0:
        break
    list.append([H, W])

for i in range(len(list)):
    for j in range(list[i][0]):
        for k in range(list[i][1]):
            if j % 2 == 1:
                print('#',end='') if k % 2 == 1 else print('.',end='')
            else:
                print ('#',end='') if k % 2 == 0 else print('.',end='')
        print()
    print()

Measured memory_bytes: 9056
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;
int main() {
    ll n,k,t,ans=0;
    cin>>n>>k;
    vector<pair<ll,ll>>p;
    vector<ll>count(200001,0);
    for(ll i=0;i<n;i++){
        cin>>t;
        count[t]++;
    }
    ll s=0;
    for(ll i=1;i<=200000;i++){
        if(count[i]){
            p.push_back(make_pair(count[i],i));
        }
    }
    s=0;
    sort(p.begin(),p.end());
    while(p.size()-s>k){
        ans+=p[s].first;
        //cout<<ans<<endl;
        p[p.size()-1-s].second+=p[s].first;
        //cout<<p[p.size()-1-s].second<<endl;
        p[s].first=0;
        s++;
    }
    cout<<ans<<endl;


}
 

Measured memory_bytes: 7408
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
char a[2010];
char b[2010];
int n;
int L[2010];
int R[2010];
void upd(int &t, int x) {
	if (t > x) t = x;
}
int mm[2010];
int go(vector<pair<int, int> > &v) {
	sort(v.begin(), v.end());
	mm[v.size()] = 0;
	for (int j = (int)v.size() - 1; j >= 0; j--) {
		mm[j] = v[j].second;
		if (mm[j] < mm[j+1]) mm[j] = mm[j+1];
	}
	int res = mm[0];
	for (int j = 0; j < v.size(); j++) {
		upd(res, mm[j+1] + v[j].first);
	}
	return res;
}
int main() {
	scanf("%s", a);
	scanf("%s", b);
	for (; a[n]; n++) ;
	int cb = 0, ca = 0;
	for (int i = 0; i < n; i++) {
		a[i] -= '0';
		b[i] -= '0';
		ca += a[i];
		cb += b[i];
	}
	if (cb == 0) {
		if (ca == 0) puts("0");
		else puts("-1");
		return 0;
	}
	int ans = n * 4;
	for (int i = 0; i < n; i++) {
		int j = i;
		while (!b[j]) {
			R[i]++;
			if (++j >= n) j -= n;
		}
		j = i;
		while (!b[j]) {
			L[i]++;
			if (--j < 0) j += n;
		}
	}
	vector<pair<int, int> > v;
	for (int i = 0; i < n; i++) {
		int m = i;
		int tt = 0;
		v.clear();
		for (int j = 0; j < n; j++) {
			if (a[j] != b[m]) {
				++tt;
				if (R[j] > i) {
					v.push_back(make_pair(L[j], R[m]));
				}
			}
			if (++m >= n) m -= n;
		}
		upd(ans, tt + go(v) * 2 + i);
		v.clear();
		tt = 0;
		m = i ? n - i : 0;
		for (int j = 0; j < n; j++) {
			if (a[j] != b[m]) {
				++tt;
				if (L[j] > i) {
					v.push_back(make_pair(R[j], L[m]));
				}
			}
			if (++m >= n) m -= n;
		}
		upd(ans, tt + go(v) * 2 + i);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
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()
    if n == 0:
        return 0
    r = []
    i = 0
    while n != 0:
        ii = 2**(i+1)
        if n % ii != 0:
            r.append('1')
            if i % 2 == 0:
                n -= ii // 2
            else:
                n += ii // 2
        else:
            r.append('0')
        i += 1
    return ''.join(r[::-1])




print(main())


Measured memory_bytes: 6476
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
   int n;
   cin>>n;
   int act = 100000;
   for(int c=0;c<n;c++)
   {
       act = (act + act / 20);
        if(act % 1000) act = (act/1000+1)*1000;
   }
   cout<<act<<endl;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define inf 1000000007;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, x[200000], ta, mu;
vector<int> vec;

signed main() {
	cin >> n;
	rep(i, n) {
		cin >> x[i];
		vec.push_back(x[i]);
	}
	sort(vec.begin(), vec.end());
	ta = vec[n / 2 - 1];
	mu = vec[n / 2];
	rep(i, n) {
		if (x[i] < mu)cout << mu << endl;
		else if(x[i]>ta)cout << ta << endl;
		else if(ta==mu)cout << ta << endl;
	}
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 5488
#include<iostream>
#include <iomanip>

int main(){
double a,b,c,d,e,f,a_,b_,c_,d_,e_,f_;
double x,y;
double in;
while (std::cin >>a>>b>>c>>d>>e>>f){
in = (a*e - b*d);
a_ = e/in;
b_ = -1*b/in;
d_ = -1*d/in;
e_ = a/in;
x = c * a_ + f*b_;
y = c*d_ + f*e_;
std::cout << std::setprecision(3) << std::fixed << x << ' ' << std::setprecision(3) << std::fixed <<  y << std::endl;
}
    return 0;
}

Measured memory_bytes: 3188
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]

A.sort()
B.sort()
C.sort()

BiggerB=[0 for i in range(N)]
j=0
for i in range(N):
     while j<N:
        if C[j] > B[i]:
            BiggerB[i]=N-j
            break
        else:
            j+=1
for i in range(N-2, -1, -1):
    BiggerB[i]+=BiggerB[i+1]

ans=0
j=0
for i in range(N):
    while j<N:
        if B[j] > A[i]:
            break
        else:
            j+=1
    if j!= N:
        ans+=BiggerB[j]
print(ans)


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int x = sc.nextInt();

        int a = x / 500;
        int b = (x - a * 500) / 5;

        System.out.println(a * 1000 + b * 5);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 23124
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

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

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int n;

    cin >> n;
    map<string, int> tapu;

    REP(i, n) {
        string u;
        cin >> u;
        tapu[u]++;
    }


    cout << "AC x " << tapu["AC"] << "\n"
                                     "WA x " << tapu["WA"] << "\n"
                                                              "TLE x " << tapu["TLE"] << "\n"
                                                                                         "RE x " << tapu["RE"] << ""
         << endl;

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    string s, ans = "No";
    cin >> s;
    if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2)) ans = "Yes";
    if(s.at(0) == s.at(3) && s.at(2) == s.at(1) && s.at(1) != s.at(0)) ans = "Yes";
    if(s.at(0) == s.at(2) && s.at(1) == s.at(3) && s.at(1) != s.at(0)) ans = "Yes";
    cout << ans << endl;
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


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

int main(){
    int n;
    cin >>n;
    vector<string> blue(n);
  for(int i=0;i<n;i++){
    cin >>blue[i];
     }
  
  int m;
  cin >>m;
  vector<string> red(m);
   for(int i=0;i<m;i++){
    cin >>red[i];
     }
   
  int ans=0;
  for(int i=0;i<n;i++){
    int count=0;
    int stop=0;
    if(i>0){ 
     for(int j=0;j<i;j++){
       if(blue[i]==blue[j]){stop=1; break;}
     }
   }
    if(stop==1){continue;}
    
    for(int che=i;che<n;che++){
      if(blue[i]==blue[che]){count++;}
    }
     for(int che=0;che<m;che++){
      if(blue[i]==red[che]){count--;}
    }
    
    if(ans<count){ans = count;}
  }
  
  cout << ans<<endl;
  
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<setprecision(10)<<fixed;
	int H, W, h, w;
	cin>>H>>W>>h>>w;
	cout<<(H-h)*(W-w)<<'\n';
	return 0;
}


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

int main(){
    int H,W,K;
    char c[10][10];
    cin>>H>>W>>K;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>c[i][j];
        }
    }
    int cnt=0;
    for(int twoH=0;twoH<=(1<<H)-1;twoH++){
        for(int twoW=0;twoW<=(1<<W)-1;twoW++){
            int black=0;
            for(int i=0;i<=H-1;i++){
                for(int j=0;j<=W-1;j++){
                    if(((twoH>>i)&1)==0 && ((twoW>>j)&1)==0){
                        if(c[i+1][j+1]=='#'){
                            black++;
                        }
                    }
                }
            }
            if(black==K){
                cnt++;
            }    
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, a[10];
	cin >> n;
	REP(i, n) cin >> a[i];

	int oddcnt = 1;
	REP(i, n){
		if(a[i] % 2 == 0) oddcnt *= 2;
		else oddcnt *= 1;
	}

	cout << POW(3, n) - oddcnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A < C && B < C){
            System.out.println("No");
        }else if(C < A && C < B){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 35712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int main() {

	int N;
	cin >> N;

	int ret = 0;
	rep(i, N){
		ret += 800;
		if ((i+1) % 15 == 0) { ret -= 200; }
	}
	
	cout << ret << endl;
}

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

int main(){
    int N;
    cin >> N;
    string s[N] = {};
    for (int i = 0;i < N;i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s + N);;
    long long count = 1;
    long long ans = 0;
    for (int i = 0;i < N - 1;i++) {
        if (s[i] != s[i + 1]) {
            ans += count * (count - 1) / 2;
            count = 1;
        }
        else count += 1;
    }
    if (count > 1) ans += count * (count - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, x, n) for (int i = x; i < n; ++i)

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];

    int dp[k+1][n+1][n+1];
    int INF = 1e9+1;

    rep(i,k+1) rep(l,n+1) rep(r,n+1) dp[i][l][r] = -INF;
    dp[0][0][0] = 0;
    int ans = 0;

    rep(i,k)
        rep(l,n+1)
            rep(r,n+1)
            {
                if(l+r>min(i+1,n)) break;

                int tmp = -INF;

                if(l>0) tmp = max(tmp, dp[i][l-1][r]+v[l-1]);
                if(r>0) tmp = max(tmp, dp[i][l][r-1]+v[n-r]);

                if(i>0)
                {
                    if(l>0) tmp = max(tmp, dp[i-1][l-1][r]);
                    if(r>0) tmp = max(tmp, dp[i-1][l][r-1]);
                }

                dp[i+1][l][r] = tmp;
                ans = max(ans, tmp);
            }

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

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>

using namespace std;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    vector<int> west(N + 2, 0);
    vector<int> east(N + 2, 0);
    
    for(int i = 1; i <= N; i++){
        if(S[i - 1] == 'E'){
            east[i] = east[i - 1] + 1;
            west[i] = west[i - 1];
        }
        if(S[i - 1] == 'W'){
            west[i] = west[i - 1] + 1;
            east[i] = east[i - 1];
        }
    }
    east[N + 1] = east[N];
    
    int ans = INT_MAX;
    
    for(int i = 1; i <= N; i++){
        int cnt = west[i - 1] + (east[N + 1] - east[i]);
        ans = min(ans, cnt);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN


    ll a,b,c;cin>>a>>b>>c;
    cout<<a*b/2<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> h(n+1);
    vector<int> dp(n + 1);
    rep(i, n) cin >> h[i + 1];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]) ,
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    int ans = dp[n];
    cout << ans;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e5+5;

const ll MOD = 1000000007LL;

void solve() {

}

vector<PII> edges;

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

    int n, k;
    cin >> n >> k;

    int x = (n-1)*(n-2);
    x /= 2;
    if (x < k) {
        cout << -1;
        return 0;
    }

    for (int i=1; i<n; i++) {
        edges.push_back({1, i+1});
    }

    int i = 2, j = 3;
    while (x > k) {
        edges.push_back({i, j});
        x--;
        j++;
        if (j > n) {
            i++;
            j = i+1;
        }
    }

    cout << edges.size() << "\n";
    for (auto p: edges) {
        cout << p.first << " " << p.second << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MAX (ll)(5e3 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	ll n, m;
	cin >> n >> m;
	ll a[n];
	set<ll> vv;
	for (ll i = 0; i < n; i++) {	
		cin >> a[i];
		a[i] /= 2;
		ll xx = a[i], cc = 0;
		while (xx % 2 == 0 ){
			xx /= 2;
			cc++;
		}
		vv.insert (cc);
	}
	if (vv.size () > 1) {
		cout << "0\n";
		return 0;
	}
	ll pr = a[0];
	for (ll i = 1; i < n; i++) {
		pr = a[i] * pr / __gcd (pr, a[i]);
		if (pr > m) {
			cout << "0\n";
			return 0;
		}
	}
	cout << ((m / pr) + 1) / 2 << "\n";
}
		


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

int main() {
  int ans=0;
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i<N ; i++){
  cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  ans = vec.at(N-1) - vec.at(0);

  cout << ans << endl;
}




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

int main(){
  char c; // Express SHCD
  int num; // Num of card
  int cnt; // number of pieces
  bool card[4][53] = {}; // all false?
  cin >> cnt;
  for(int i=0; i<cnt; i++){
    int swi;
    cin >> c;
    cin >> num;
    switch(c){
      case 'S':
        swi = 0;
        break;
      case 'H':
        swi = 1;
        break;
      case 'C':
        swi = 2;
        break;
      case 'D':
        swi = 3;
        break;
    }
    card[swi][num-1] = true;
  }

  for(int i=0; i<4; i++){
    for(int j=0; j<13; j++){
      // cout << card[i][j] << endl;
      if(card[i][j] == false){
        switch(i){
          case 0:
            cout << "S ";
            break;
          case 1:
            cout << "H ";
            break;
          case 2:
            cout << "C ";
            break;
          case 3:
            cout << "D ";
            break;
        }
        cout << j+1 << endl;
      }
    }
  }
  return 0;
}



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

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

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = long.Parse(spl[0]);
        var b     = long.Parse(spl[1]);

        return XorAll(a, b);
    }

    static long XorAll(long a, long b) {
        if(a == 0) {
            var c = ((b+1) / 2) % 2;
            return (b % 2 == 0) ? (c ^ b) : c;
        }
        return XorAll(0, a - 1) ^ XorAll(0, b);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct ioi
{
	int x,i,type;
	ioi(){}
	ioi(int a,int b,int c){x=a,i=b,type=c;}
}p[20010];

int n,x[10010],y[10010],bin[20010],last[10010],counter[20010],sz,in_st[20010],co,order[200010],al[200010],st[200010],top;
vector<int> a[200010],b[200010];

void find_max(int p,int l,int r)
{
	sz=max(sz,p);
	if (l==r)
	{
		in_st[l]=p;
		return;
	}
	find_max(p*2,l,(l+r)/2);
	find_max(p*2+1,(l+r)/2+1,r);
}

void build(int p,int l,int r)
{
	if (l==r)
	{
		a[p].push_back(sz+counter[l]);
		//cout << p << " " << sz+counter[l] << "\n";
		return;
	}
	build(p*2,l,(l+r)/2);
	build(p*2+1,(l+r)/2+1,r);
	a[p].push_back(p*2);
	a[p].push_back(p*2+1);
	//cout << p << " " << p*2 << "\n";
	//cout << p << " " << p*2+1 << "\n";
}

void add_edge(int p,int l,int r,int u,int A,int B)
{
	if (r<A or l>B) return;
	if (l>=A and r<=B)
	{
		a[u].push_back(p);
		//cout << u << " " << p << "\n";
		//if (u==15) cout << l << " " << r << " ";
		return;
	}
	add_edge(p*2,l,(l+r)/2,u,A,B);
	add_edge(p*2+1,(l+r)/2+1,r,u,A,B);
}

void dfs(int u)
{
	al[u]=1;
	for (int i=0;i<a[u].size();i++)
		if (!al[a[u][i]]) dfs(a[u][i]);
	st[++top]=u;
}

void kora(int u,int root)
{
	//cout << u << " ";
	al[u]=root;
	for (int i=0;i<b[u].size();i++)
		if (!al[b[u][i]]) kora(b[u][i],root);
}

void korasaju()
{
	co=top=0;
	for (int i=1;i<=sz+2*n;i++)	
		al[i]=0;
	for (int i=1;i<=sz+2*n;i++)
		if (!al[i]) dfs(i);
	for (int i=1;i<=sz+2*n;i++)
		al[i]=0;
	for (int i=1;i<=sz+2*n;i++)
		b[i].clear();
	for (int i=1;i<=sz+2*n;i++)
		for (int j=0;j<a[i].size();j++)
			b[a[i][j]].push_back(i);
	while (top)
	{
		if (!al[st[top]]) kora(st[top],st[top]);
		top--;
	}

}	

bool check(int dis)
{
	dis--;
	for (int i=1;i<=sz+2*n;i++)
		a[i].clear();
	build(1,1,2*n);
	for (int i=1;i<=2*n;i++)
	{
		int L=lower_bound(bin+1,bin+2*n+1,bin[i]-dis)-bin,R=(upper_bound(bin+1,bin+2*n+1,bin[i]+dis)-bin)-1;
		//cout << i << " " << L << " " << R << "\n";
		if (i-1>=L) add_edge(1,1,2*n,i+sz,L,i-1);
		if (i+1<=R) add_edge(1,1,2*n,i+sz,i+1,R);
	}
	korasaju();
	for (int i=1;i<=2*n;i++)
		if (al[i+sz]==al[counter[i]+sz]) return false;
	return true;
}

int main()
{
	//freopen("input.txt","r",stdin);
	cin >> n;
	for (int i=1;i<=n;i++)
	{
		cin >> x[i] >> y[i];
		p[i]=ioi(x[i],i,0);
		p[i+n]=ioi(y[i],i,1);
	}
	sort(p+1,p+2*n+1,[](ioi a,ioi b){
		return (a.x<b.x);
	});
	for (int i=1;i<=2*n;i++)
	{
		bin[i]=p[i].x;
		if (last[p[i].i]) counter[i]=last[p[i].i],counter[last[p[i].i]]=i;
		else last[p[i].i]=i; 
	}
	find_max(1,1,2*n);
	int l=0,r=1e9+10,res=0;
	//cout << check(4);
	while (l<=r)
	{
		int m=(l+r)/2;
		if (check(m)) res=m,l=m+1;
		else r=m-1;
	}
	cout << res;
}

Measured memory_bytes: 29440