akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
long int a[500000],l[500000],r[500000];
int c=0;
void ms(int,int);
void m(int,int,int);
int main(){
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    
    ms(0,n);
    
    for(i=0;i<n-1;i++){
        printf("%d ",a[i]);
    }
    printf("%d\n%d\n",a[n-1],c);
    
    return 0;
}

void ms(int left, int right){
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        ms(left,mid);
        ms(mid,right);
        m(left,mid,right);
    }
}

void m(int left,int mid,int right){
    int n,m,i,j,k;
    n = mid-left;
    m = right -mid;
    for(i=0;i<n;i++)l[i]=a[left+i];
    for(i=0;i<m;i++)r[i]=a[mid+i];
    i=0;
    j=0;
    l[n]=10000000000;
    r[m]=10000000000;
    for(k=left;k<right;k++){
        c++;
        if(l[i]<=r[j]){
            a[k]=l[i];
            i++;
        }
        else{
            a[k]=r[j];
            j++;
        }
    }
}



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

long long n, x, y, d;

int main(void){
    cin >> n >> d;
    d*=d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        if(x*x+y*y <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M, Q;
	cin >> N >> M >> Q;

	vector<vector<Int>> x(N,vector<Int>(N));
	Int L, R;
	for (Int i = 0; i < M; i++) {
		cin >> L >> R;
		L--;
		R--;
		x[L][R]++;
	}

	//二次元累積和
	vector<vector<Int>> s(N + 1, vector<Int>(N + 1));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < N; j++) {
			s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] + x[i][j] - s[i][j];
		}
	}

	//クエリ
	Int p, q;
	for (Int i = 0; i < Q; i++) {
		cin >> p >> q;
		p--;
		q--;

		Int ans = s[q + 1][q + 1] - s[p][q + 1] - s[q + 1][p] + s[p][p];

		//cout << ans << "\n";
		printf("%lld\n", ans);
	}

}


Measured memory_bytes: 4864
#include <iostream>
#include <vector>

using namespace std;

int b[1000001];

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  
  for(int i = 0; n > i; i++){
    cin >> a[i];
  	b[a[i]]++;
  }
  
  int ans = 0;
  
  for(int i = 0; 1000001 > i; i++){
    if(b[i] == 1)
	    ans += b[i];
  	if(b[i] > 0){
    	for(int j = i;1000001 > j; j += i)
        	b[j] = 0;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

public class ABC164A {
	private static void Main(string[] args) {
		var input = ReadIntsAsArray();
		var s = input[0];
		var w = input[1];

		var answer = (w >= s) ? "unsafe" : "safe";
		Console.WriteLine(answer);
	}

	private static int[] ReadIntsAsArray() => Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
}

Measured memory_bytes: 28208
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



int main(){
  int a,b; cin>>a>>b;
  if(b==1) cout<<0<<endl;
  else if(a>=b) cout<<1<<endl;
  else{
    int cnt=0;
    while(true){
      b-=a;
      if(b<=0) {cout<<cnt+1<<endl; return 0;}
      else{
        b+=1;
        cnt++;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define x first
#define y second
 
using namespace std;
 
int tmp[1000005];
int chk_dup[1000005];
int solve()
{
	int n;
	vector<int> A;
  	int in;
  	int re = 0;
	cin >> n;
	
	for(int i=0;i<n;i++)
    {
		cin >> in;
		if(chk_dup[in] == 0)
		A.push_back(in);
		chk_dup[in]++;
    }
    if(n == 1)
		return 1;
	sort(A.begin(),A.end());
	if(A[0] == 1)
	{
		if(chk_dup[1] == 1)
			return 1;
		else
			return 0;
	}
	for(auto it: A)
	{
		if(tmp[it] == 0)
		{
			if(chk_dup[it] == 1)
				re++;
			for(int j=1;it*j<=1000000;j++)
			{
				tmp[it*j] = 1;
			}
		}
	}
	return re;
}
int main() 
{
	// freopen("d.in","r",stdin);
	cout << solve() << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define nl "\n"
#define LLMAX 1e18

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,0,n){
  	cin >> a[i];
  }
  if(n<=k+1){
    cout << abs(a[n-1]-a[0]) << nl;
    return 0;
  }
  ll dp[n];
  fill(dp,dp+n,LLMAX);
  dp[0]=0;
  rep(i,1,n){
  	if(i<=k)
      dp[i]=abs(a[i]-a[0]);
    else{
    	rep(j,1,k+1){
          dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
  }
  cout << dp[n-1] << nl;
  return 0;
}


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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long a, b, c, d;

long long solve();

int main() {
  cin >> a >> b >> c >> d;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = b - a + 1, lcm = LCM(c, d);
  ans -= b / c - (a - 1) / c;
  ans -= b / d - (a - 1) / d;
  ans += b / lcm - (a - 1) / lcm;
  return ans;
}

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

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    ll N, K;
    cin >> N >> K;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    ll INF = 1e10;
    vector<ll> dp(N, INF);
    dp[0] = 0;

    for(int i = 1; i < N; i++){
        vector<ll> costs(K, INF);
        for(int j = 1; j <= K; j++){
            if(i - j >= 0){
                costs[j-1] =  dp[i-j] + abs( v[i] - v[i-j] );
            }
        }
        sort( all(costs) );
        dp[i] = costs.front();
    }
    
    cout << dp[N - 1] << endl;


}

Measured memory_bytes: 1792
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {
      
      BufferedReader br =
        new BufferedReader(new InputStreamReader(System.in));
        
      String str = br.readLine();
      int x = Integer.parseInt(str);
      
      //System.out.println( x^3 ); 
      System.out.println( x*x*x );
      //System.out.println( Math.pow(x,3));
      //System.out.println( (int)Math.pow(x,3));

   }
}

Measured memory_bytes: 24228
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector

/*  <<bit全探索>>
 
    for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
        bitset<ビット数> s(tmp);
    }
*/
 
/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 
typedef long long ll;

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


int main() { 

    int N, M;
    cin >> N >> M;
    
    vec<int> H(N);
    vec<int> I(N, 0);

    rep(i,N){
        cin >> H.at(i);
    }
    
    rep(i, M){
        int A, B;
        cin >> A >> B;
        if(H.at(A-1) > H.at(B-1)){
            I.at(B-1) = 1;
        }
        if(H.at(A-1) < H.at(B-1)){
            I.at(A-1) = 1;
        }
        if(H.at(A-1) == H.at(B-1)){
            I.at(A-1) = 1;
            I.at(B-1) = 1;
        }

    }
    
    int cnt;
    rep(i, N){
        if(I.at(i) == 0){
            cnt++;
        }
    }

    cout << cnt << endl;
}

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

int main(){
  string s;
  string t;
  cin>>s>>t;
  
  bool ans = false;
  
  if(s.size()+1 == t.size()){
    ans = true;
  	for(int i=0;i<s.size();i++){
    	if(s.at(i) != t.at(i)){
          ans = false;
        }
  	}
  }
  if(ans) cout << "Yes" << endl;
  else cout <<"No" << endl;
  
  return 0;
}

Measured memory_bytes: 3604
from collections import deque
h, w, *s = open(0).read().split()
h = int(h)
w = int(w)

q = deque()
used = [False] * (h * w)

ans = 0
for i in range(h):
    for j in range(w):
        if not used[i * w + j]:
            bcnt = 0
            cnt = 0

            q.append((i, j))
            used[i * w + j] = True
            cnt += 1
            bcnt += s[i][j] == '#'

            while len(q):
                y, x = q.popleft()
                for dy, dx in [(0, 1), (1, 0), (0, -1), (-1, 0)]:
                    ny = y + dy
                    nx = x + dx
                    if 0 <= nx < w and 0 <= ny < h and s[y][x] != s[ny][nx] and not used[ny * w + nx]:
                        q.append((ny, nx))
                        used[ny * w + nx] = True
                        cnt += 1
                        bcnt += s[ny][nx] == '#'
            ans += bcnt * (cnt - bcnt)
print(ans)


Measured memory_bytes: 10416
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int d;
  while(cin>>d){
    if(d == 0)
      break;

    vector<int> v;
    v.push_back(0);
    v.push_back(-d);
    v.push_back(d);

    int n,m;
    cin>>n;
    cin>>m;
    for(int i = 1;i<n;i++){
      int tmp;
      cin>>tmp;
      v.push_back(tmp);
      v.push_back(tmp-d);
    }
    sort(v.begin(),v.end());

    int ans = 0;
    for(int i = 0;i<m;i++){
      int k;
      cin>>k;
      //cout<<"lower:"<<*(lower_bound(v.begin(),v.end(),k-d)-1)<<endl;
      ans += min(*lower_bound(v.begin(),v.end(),k)-k,k-(d+*(upper_bound(v.begin(),v.end(),k-d)-1)));
      //cout<<"ans:"<<ans<<endl;
    }

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

Measured memory_bytes: 2124
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a==b||b==c||a==c){
		if (a==b && b==c){
			printf("1\n");
		}else{
		printf("2\n");
		} 
	}else{
		printf("3\n");
	}
	return 0;
}

Measured memory_bytes: 128
(* O(|s|) *)
let solve s =
  let rec loop i =
    if i <= 0 then
      "YES"
    else
      let match_size = List.fold_left
        (fun match_size each ->
          if match_size <> 0 then
            match_size
          else
            let len = String.length each in
            if i - len < 0 then
              match_size
            else
              if String.sub s (i - len) len = each then len else match_size)
        0
        ["dream"; "dreamer"; "erase"; "eraser"]
      in
        if match_size = 0 then
          "NO"
        else
          loop (i - match_size)
  in
    loop (String.length s)

let _ = read_line () |> solve |> print_endline

Measured memory_bytes: 3968
#!/usr/bin/env python3


def solv(n, w):
    dmin = 10000
    for i in range(1, n):
        lw = sum(w[:i])
        rw = sum(w[i:])
        dmin = min(dmin, abs(lw-rw))
    return dmin


if __name__ == '__main__':

    n = int(input())
    w = list(map(int, input().split()))

    ans = solv(n, w)

    print(ans)


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

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

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}

enum struct Color {
	Red, Green, None
};

int main(int, char**)
{
	long long X;
	scanf("%lld",&X);
	long long Y;
	scanf("%lld",&Y);
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	long long C;
	scanf("%lld",&C);
	vector<pair<Color, ll>> apples(A + B + C);
	for(ll i = 0 ; i < A ; i++){
		ll tmp;
		scanf("%lld",&tmp);
		apples[i] = make_pair(Color::Red, tmp);
	}
	for(ll i = 0 ; i < B ; i++){
		ll tmp;
		scanf("%lld",&tmp);
		apples[A + i] = make_pair(Color::Green, tmp);
	}
	for(ll i = 0 ; i < C ; i++){
		ll tmp;
		scanf("%lld",&tmp);
		apples[A + B + i] = make_pair(Color::None, tmp);
	}

	sort(apples.begin(), apples.end(), [](const pair<Color, ll>& l, const pair<Color, ll>& r) { return l.second > r.second; });
	ll sum = 0;
	ll red_count = 0, green_count = 0, count = 0;
	for (ll i = 0; i < A + B + C && count < X + Y; ++i)
	{
		if (apples[i].first == Color::Red)
		{
			if (red_count >= X)		continue;
			++red_count;
			++count;
		}
		else if (apples[i].first == Color::Green)
		{
			if (green_count >= Y)	continue;
			++green_count;
			++count;
		}
		else
		{
			++count;
		}
		sum += apples[i].second;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  string s;
  cin >> s;
  int ans; 
  string op;
  vector<int> num(4);
  rep(i,4){
      num[i] = s[i]-'0';
  }
  rep(bit,1<<3){
    ans = num[0];
    rep(i,3){
      if(bit&(1<<i)){
        ans+=num[i+1];
        op[i]='+';
      }else{
        ans -= num[i+1];
        op[i]='-';
      }
    }
    if(ans == 7){
        break;
    }
  }
  cout<< num[0] << op[0] << num[1] << op[1] << num[2] << op[2] << num[3]  << "=7" << endl;
}


Measured memory_bytes: 3600
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	in := nextSlice()
	solve(in)
}

func solve(buf []string) {
	reply = strconv.Itoa(hoge(0, buf[0]))
	fmt.Println(reply)
}

func hoge(a int, s string) int {
	sum := a
	for i := 1; i < len(s); i++ {
		n, _ := strconv.Atoi(s[:i])
		sum += hoge(a+n, s[i:])
	}
	ab, _ := strconv.Atoi(s)
	return ab + sum
}

func foo(sum int, s string) int {
	res := sum
	for i := 1; i < len(s); i++ {
		a, _ := strconv.Atoi(s[:i])
		res += foo(sum+a, s[i:])
	}
	num, _ := strconv.Atoi(s)
	return res + num
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

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

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

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp> 
using namespace boost::multiprecision; 
using namespace std;
#define endl "\n"
#define ll long long
//#define ONLINE_JUDGE
long long power(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;     
    x = x % p; 
    if (x == 0) return 0; 

    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
int main()
{
	/*
		Jainam Shah's Code
	*/
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ll N;
	cin>>N;
	int128_t ans = 1;
	int128_t arr[N];
	for(int i=0;i<N;i++){
		cin>>arr[i];
	}
	int128_t limit = 1;
	for(int i=0;i<18;i++)
		limit*=10;
	for(int i=0;i<N;i++)
	{
		if(arr[i]==0)
		{
			ans=0;
		}
	}
	for(int i=0;i<N;i++)
	{
		ans*=arr[i];
		if(ans==0)
		{
			break;
		}
		if(ans>limit)
		{
			ans=-1;
			break;
		}
	}
	if(ans>limit)
	{
		ans = -1;			
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 6796
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, K; cin >> N >> K;
  int a[N]; rep(i,N) cin >> a[i];

  cout << 1+(N-2)/(K-1) << endl;

  

  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	var P, Q, R int
	fmt.Scan(&P, &Q, &R)
	r := math.MaxInt64
	r = min(r, P+Q)
	r = min(r, P+R)
	r = min(r, Q+R)
	fmt.Println(r)
}
func min(a, b int) int {
	if b < a {
		return b
	}
	return a
}


Measured memory_bytes: 512
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a + b == 15) System.out.println("+");
		else if(a * b == 15) System.out.println("*");
		else System.out.println("x");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <utility>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
#define X real()
#define Y imag()

using P = complex<double>;
using L = pair<P, P>;

const double EPS = 1e-10;
const double INF = 1e15;

double dot(P a, P b){ return a.X*b.X + a.Y*b.Y;}
double cross(P a, P b){ return a.X*b.Y - a.Y*b.X;}

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b, c) > EPS) return 1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < -EPS) return -2;
  if(norm(c) - norm(b) > EPS) return 2;
  return 0;
}

bool is_cross(L a, L b){
  return (ccw(a.first, a.second, b.first)*ccw(a.first, a.second, b.second) <= 0) &&
    (ccw(b.first, b.second, a.first)*ccw(b.first, b.second, a.second) <= 0);
}

double dijkstra(vector< vector< pair<int, double> > > &G){
  int Nb = G.size();
  vector<double> D(Nb, INF);
  priority_queue< pair<double, int> > wait;
  wait.emplace(0,0);
  while(!wait.empty()){
    int v = wait.top().second;
    double d = -wait.top().first;
    wait.pop();
    if(d > D[v]) continue;
    D[v] = d;
    for(int i = 0; i < G[v].size(); ++i){
      int v_ = G[v][i].first;
      double d_ = d + G[v][i].second;
      if(D[v_] > d_){
        D[v_] = d_;
        wait.emplace(-d_, v_);
      }
    }
  }
  return D[1];
}

double solve(vector<P> &A, vector<P> &B){
  int Nb = B.size();
  L l = L(A[0], A[1]);
  vector< vector< pair<int, double> > > G(Nb);
  for(int i = 0; i < Nb; ++i){
    for(int j = 0; j < Nb; ++j){
      if(i == j) continue;
      if(!is_cross(l, L(B[i],B[j]))) G[i].emplace_back(j, abs(B[i]-B[j])); 
    }
  }
  return dijkstra(G) + abs(A[0] - A[1]);
}

int main() {
  int Na, Nb;
  cin >> Na >> Nb;
  vector<P> A(Na), B(Nb);
  for(int i = 0; i < Na; ++i){
    double x, y;
    cin >> x >> y;
    A[i] = P(x, y);
  }
  for(int i = 0; i < Nb; ++i){
    double x, y;
    cin >> x >> y;
    B[i] = P(x, y);
  }
  double ans = min(solve(A, B), solve(B, A));
  if(ans >= INF - EPS) cout << -1 << endl;
  else printf("%.12f\n", ans);
  return 0;
}



Measured memory_bytes: 19204
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[] H = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int[] ans = new int[N];
		for (int i = 1; i < N; i++)
		{
			if(H[i] <= H[i - 1])
				ans[i] = ans[i - 1] + 1;
            else
				ans[i] = 0;
		}
		Console.WriteLine(ans.Max());
		Console.ReadKey();
	}
}


//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 30684
N = int(input())
A = tuple(map(int, input().split()))

ans = []

for i, j in enumerate(A):
    ans.append((j, i+1))

ans.sort()

for i, j in ans:
    print(j, end='')
    if i == len(ans):
        print()
    else:
        print(' ', end='')


Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

const ll MAX_SIZE = 500005;
array<ll, MAX_SIZE> fac, inv, finv;
void finit() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % MOD;
    finv[MAX_SIZE - 1] = modpow(fac[MAX_SIZE - 1], MOD - 2, MOD);
    for(ll i = MAX_SIZE - 1; i > 0; i--) finv[i - 1] = finv[i] * i % MOD;
    
    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, MOD - 2, MOD);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % MOD; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % MOD * finv[a - b] % MOD; }

int main() {
    init();
    finit();
    ll N, M;
    cin >> N >> M;

    ll ans = 0, mn = comb(M, N) * fac[N] %MOD;
    ll b = 0;
    // i個以上重複と仮定
    rep(i, N + 1){
        ll n = N - i; // 異なる個数
        if(i&1)
            b -= comb(N, i) * comb(M - i, n) % MOD * fac[n] % MOD;
        else
            b += comb(N, i) * comb(M - i, n) % MOD * fac[n] % MOD;
    }

    ans = mn * (b%MOD + MOD) % MOD;

    cout << ans << endl;
}

Measured memory_bytes: 15284
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define FOR(i,s,n) for(int i=s;i<n;i++)
#define ROF(i,n,e) for(int i=n;i>e;i--)
#define Debug(x) cout<<x<<"\n";
#define Debug2(x,y) cout<<x<<" "<<y<<"\n";
#define TEST(t) while(t--)
#define mod 1e9+7
#define MAX 1000005    //10^5+5
#define MAXQ 200005    //2*10^5+5
#define pi pair<int,int>
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define ll long long
#define f first
#define s second
typedef pair<int,int> pii;
typedef pair<int,pii> node;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll a,b;
    cin>>a>>b;
    cout<<((a*b)/(__gcd(a,b)))<<"\n";
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    int n,a,b,ans=0;
    cin >> n;
    fol(i,n){
        cin >> a>>b;
        ans += b-a+1;
    }
    cout << ans <<endl;
}

int main(){
/*/Debug by file input
    ifstream fin("input");
    cin.rdbuf(fin.rdbuf());// */
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int dp[1 << 21];
Int n;
Int a[23][23];
Int bitcnt[1<<21];

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

    dp[0] = 1;
    for(int s = 1;s < (1<<n);s++){
        bitcnt[s] = bitcnt[s/2] + s%2;
        for(int l = 0;l < n;l++){
            if((s >> l) % 2 == 0)continue;
            dp[s] += dp[s - (1 << l)] * a[bitcnt[s] - 1][l];
            dp[s] %= MOD;
        }
    }
    cout << dp[(1 << n) - 1] << endl;    
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

int main()
{
	ll n = 0;
	cin >> n;
	vector<ll> color( n, 0 );
	REP(i,n) cin >> color[i];

	vector<ll> dp( n + 1, 0 );
	dp[0] = 1;
	vector<ll> last( 200010, -1 );

	REP( i, n )
	{
		ll j = last[color[i]];
		if( j >= 0 && j + 1 < i )
		{
			dp[i+1] += dp[j+1];
		}
		dp[i+1] += dp[i];
		last[color[i]] = i;
		constexpr ull mod =  1e9 + 7;
		dp[i+1] %= mod;
	}

	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std ;
#define int long long

int n , a[105] , dp[105][2] ;

int call (int i,int ok) {
    if (i>n) return ok ;
    if (dp[i][ok] != -1) return dp[i][ok] ;
    int ans = 0 ;
    if (a[i]%2 == 0) {
        ans += call(i+1,1) ;
        ans += 2*call(i+1,ok) ;
    }
    else {
        ans += call(i+1,ok) ;
        ans += 2*call(i+1,1) ;
    }
    return dp[i][ok] = ans ;
}


main () {

    cin >> n ;
    for (int i = 1; i <= n ; i++) cin >> a[i] ;
    memset (dp , -1 , sizeof dp) ;
    cout << call(1,0) ;

}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc100/tasks/abc100_b

d, n = map(int, input().split())
if d == 0:
    if n == 100:
        ans = 101
    else:
        ans = n
else:
    if n == 100:
        ans = 100 ** d * 101
    else:
        ans = 100 ** d * n
print(ans)

Measured memory_bytes: 38512
#include<cstdio>
#include<string.h>
long long int f(long long int x,long long int y)
{
	if(x%y==0)
	return y;
	else
	return(f(y,x%y));
}
int main()
{    
    long long int a,b,t;
    scanf("%lld%lld",&a,&b);
    if(b>a)
    {
    	t=b;b=a;a=t;
	}
	printf("%lld",a*b/f(a,b));
}   

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n = as.nextInt();
		int m = as.nextInt();
		if(n==1){
			n = 14;
		}
		if(m==1){
			m = 14;
		}
		if(n<m){
			System.out.println("Bob");
		}else if(n>m){
			System.out.println("Alice");
		}else{
			System.out.println("Draw");
		}
	}
}

Measured memory_bytes: 21844
a = input()[::-1]
b = input()[::-1]
c = input()[::-1]
d = input()[::-1]
e = input()[::-1]

total = 0

menu_list = []

menu_list.append(a)
menu_list.append(b)
menu_list.append(c)
menu_list.append(d)
menu_list.append(e)

menu_list2 = []

for i in range(len(menu_list)):
    if menu_list[i][:1] == '0':
        total += int(menu_list[i][::-1])
    else:
        menu_list2.append(menu_list[i])

menu_list2.sort()
menu_list2.reverse()

menu_time = 0

j = 0

for menu2 in menu_list2:
    menu_time = int(menu2[::-1])

    if j == len(menu_list2)-1:
        total += menu_time
    else:
        total += menu_time + 10 - menu_time % 10

    j += 1

print(total)

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n%2 != 0) {
    cout << "No" << endl;
  }
  else {
    string t = "", u = "";
    for (int i = 0; i < s.size(); i++) {
      if (i < n/2) {
        t += s[i];
      }
      else {
        u += s[i];
      }
    }
    if (t == u) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define fi first
#define se second
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
#define INF (ll)1e18
#define ll long long
#define P pair<ll, ll>
#define vll vector<ll>
#define vvll vector<vll>

ll n, m, st;
vector<vector<P> > g;
void solve1(void) {
    vll dist(n, INF);
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(0, st)); dist[st] = 0;
    while (q.size()) { 
        // q = {(d, v)} : 未確定な頂点vに距離dで到達可能である（dは最適とは限らない）
        // dist[v] : 頂点vに到達可能な距離のうち、今までの最小値
        //
        // vの初出がここに来た時点で、dist[v]が最適であることは保証されている！
        P st = q.top(); q.pop();
        ll d = st.fi, v = st.se;
        if (d > dist[v]) continue; // 同じvに異なる距離dで到達可能だが、最適なものだけを見ればよい
        rep(i, g[v].size()) {
            P edge = g[v][i];
            ll u = edge.fi, cost = edge.se;
            if (dist[v] + cost >= dist[u]) continue;
            dist[u] = dist[v] + cost;
            q.push(P(dist[v] + cost, u));
        }
    }
    rep(i, n) {
        if (dist[i] == INF) 
            cout << "INF" << endl;
        else
            cout << dist[i] << endl;
    }
}

int main(void) {
    cin >> n >> m >> st;
    g.resize(n);
    rep(i, m) {
        ll u, v, d; cin >> u >> v >> d;
        g[u].pb(P(v, d));
    }
    solve1();

    return 0;
}



Measured memory_bytes: 19352
#include<stdio.h>
#define N 100000

int main(){
  
  int array[N], n, i, num, temp, partition;
  
  scanf("%d",&n);

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

  num = array[n - 1];
  partition = 0;

  for(i = 0; i < n; i++)
    {
      if(array[i] <= num)
	{
	  temp = array[i];
	  array[i] = array[partition];
	  array[partition] = temp;
	  partition++;
	}
    }

  for(i = 0; i < n; i++)
    {
      if(i != 0)printf(" ");
      if(i == partition - 1)printf("[");
      printf("%d",array[i]);
      if(i == partition - 1)printf("]");
    }

  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2116
N,M=map(int,input().split())
S=[]
zentai=0
for i in range(M):
    K=list(map(int,input().split()))
    S.append(K[1:])
P=list(map(int,input().split()))
for i in range(2**N):
    switch=["off"]*N
    count=0
    for j in range(N):
        if ((i>>j)&1):
            switch[N-j-1]="on"
    ON_switch=[]
    for k in range(N):
        if switch[k]=="on":
            ON_switch.append(k+1)
    for m in range(M):
        cnt=0
        for n in range(len(S[m])):
            if S[m][n] in ON_switch:
                cnt+=1
        else:
            if cnt%2==P[m]:
                count+=1
    else:
        if count==M:
            zentai+=1
print(zentai)

Measured memory_bytes: 3064
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
div = [[ab[i][1] + ab[i][0], ab[i][0], ab[i][1]] for i in range(n)]
div = sorted(div, key=lambda x: x[0], reverse=True)

counta = 0
countb = 0
for i in range(n):
    if i % 2 == 0:
        counta += div[i][1]
    else:
        countb += div[i][2]

print(counta - countb)

Measured memory_bytes: 40136
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//900を解説AC
	llint n,K,i,j,h,ans=0;cin>>n>>K;n*=2;
	static int go[600];
	for(i=0;i<600;i++){go[i]=-1;}
	for(i=0;i<K;i++){
		int a,b;cin>>a>>b;
		a--;b--;
		go[a]=b;
		go[b]=a;
	}
	static llint dp[600][600]={0};
	static llint ziyu[601];
	for(i=0;i<n;i++){
		ziyu[i+1]=ziyu[i];
		if(go[i]==-1){ziyu[i+1]++;}
	}
	static llint tori[601]={0};
	tori[0]=1;
	for(i=2;i<=n;i+=2){tori[i]=(tori[i-2]*(i-1))%mod;}
	for(i=0;i<n;i++){//間隔
		for(j=0;j+i<n;j++){
			int x=j,y=j+i;
			bool dame=false;
			for(h=x;h<=y;h++){
				if(go[h]!=-1&&(go[h]<x||y<go[h])){dame=true;break;}
			}
			if(dame){continue;}
			
			int zi=ziyu[y+1]-ziyu[x];
			if(zi%2==1){continue;}
			dp[x][y]=tori[zi];
			for(h=x;h<y;h++){
				dp[x][y]-=dp[x][h]*tori[ziyu[y+1]-ziyu[h+1]];
				dp[x][y]%=mod;
			}
			ans+=dp[x][y]*tori[ziyu[n]-zi];
			ans%=mod;
			//cerr<<"x,y,dp"<<x<<","<<y<<","<<dp[x][y]<<endl;
		}
	}
	ans+=mod;ans%=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  ll mn = 1001001001, mx = -1001001001, imn = -1, imx = -1;
  rep(i, n){
    if(a.at(i) < mn){
      mn = a.at(i);
      imn = i;
    }
    if(a.at(i) > mx){
      mx = a.at(i);
      imx = i;
    }
  }
  cout << n+(n-1) << endl;
  if(abs(mn) > abs(mx)){
    rep(i, n){
      cout << imn+1 << " " << i+1 << endl;
    }
    rrep(i, n-1){
      cout << i+2 << " " << i+1 << endl;
    }
  }else{
    rep(i, n){
      cout << imx+1 << " " << i+1 << endl;
    }
    rep(i, n-1){
      cout << i+1 << " " << i+2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  std::string a, b;

  std::cin >> a >> b;
  if (a < b) {
    std::cout << "<" << std::endl;
  } else if (a == b) {
    std::cout << "=" << std::endl;
  } else {
    std::cout << ">" << std::endl;
  }
}

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

int main(){
	//freopen("readin.txt","r",stdin);
	int n;
	deque<int>q;
	scanf("%d",&n);
	bool l = 1;
	for(int i = 0;i < n;i++){
		int a;
		scanf("%d",&a);
		if(l) q.push_front(a);
		else q.push_back(a);
		l^=1;
	}
	if(!l)
		while(!q.empty()){
			printf("%d ",q.front());
			q.pop_front();
		}
	else
		while(!q.empty()){
			printf("%d ",q.back());
			q.pop_back();
		}
}

Measured memory_bytes: 3072
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int n,k;
int ans=INF;
void dfs(int cnt,int v){
    if(cnt==n){cmin(ans,v);return;}
    dfs(cnt+1,2*v);
    dfs(cnt+1,v+k);
}
int main(){
    cin>>n>>k;
    dfs(0,1);
    cout<<ans<<endl;
}


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define pii pair <int, int>
#define pll pair <ll, ll>
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
using namespace std;

string s;
int main () {
	IOS;

	cin >> s;
	int size = sz(s), ans = 0;
	for (int i = 0; i < size / 2; i++) {
		if (s[i] != s[size - i - 1]) {
			ans++;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s %s %s", $a, $b, $x);
$s = big_floor($a, $x);
if ($a % $x) $s++;
$t = big_floor($b, $x);
echo $t - $s + 1;

function big_floor($a, $b) {
	$c = sprintf("%d", floor($a / $b));
	if (strlen($c) <= 14) {
		if (strlen($a) > 14) {
			while ($c * $b > $a) $c--;
		}
		return $c;
	}
	$c = $m = null;
	$as = str_split($a, 10);
	foreach ($as as $a) {
		$k = strlen($a);
		if ($m) $a = $m . $a;
		$c .= sprintf("%0{$k}d", floor($a / $b));
		$m = $a % $b;
	}
	return ltrim($c, '0');
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n;
const lli mod = 1e9 + 7;
lli a[maxN], acc[maxN + 1];

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    for (int i = 0; i < n; i++)
      scanf("%lld", &a[i]);

    for (int i = 0; i < n; i++)
      acc[i + 1] = (acc[i] + a[i]) % mod;

    lli ans = 0;
    for (int i = 0; i < n; i++)
      ans = (ans + a[i] * (acc[n] - acc[i + 1] + mod) % mod) % mod;
    printf("%lld\n", ans);
  }
  return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
const ll MOD2 = 998244353;
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; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin >> n;
  cinv(p,n);
  
  //main
  int count = 0;
  for(int i=1; i<=n-2; i++){
    if((p[i+1]-p[i])*(p[i]-p[i-1]) > 0){ count ++; }
  }
  
  // output
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                long n = sc.nextLong();
                sc.close();
                long fia = 0;
                long fkh = 0;
                int yono = (int)Math.log10(n);
                for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                        if(n % i == 0){
                                fia = n / i;
                                fkh = i;
                                yono = Math.min(yono , Math.max((int)Math.log10(fia) , (int)Math.log10(fkh)));
                        }
                }
                System.out.println(yono + 1);
        }
}

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

int main(){
  vector<long long int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  if(((A[0]%2)*(A[1]%2)*(A[2]%2))%2==0){
    cout << "0" << endl;
  }else{
    sort(A.begin(),A.end());
    cout << A[0]*A[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n1=n2=n3=n4=0
for _ in range(3):
    a,b = map(int,input().split())
    if a==1:
        n1+=1
    elif a==2:
        n2+=1
    elif a==3:
        n3+=1
    else:
        n4+=1
    if b==1:
        n1+=1
    elif b==2:
        n2+=1
    elif b==3:
        n3+=1
    else:
        n4+=1
if n1*n2*n3*n4==4:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38256
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless, forM)
import Data.Vector.Unboxed.Mutable (IOVector, STVector)
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    [w, h] <- map read <$> words <$> getLine
    ps <- replicateM n ((\[x,y] -> (x, y)) <$> map read <$> words <$> getLine)
    [s, t] <- map read <$> words <$> getLine
    solve (w, h) ps (s, t) >>= print
    main

solve :: (Int, Int) -> [(Int, Int)] -> (Int, Int) -> IO Int
solve (w, h) ps (s, t) = do
  v <- VM.replicate ((w+1) * (h+1)) 0 :: IO (IOVector Int)
  forM [1..w] $ \i -> do
    forM [1..h] $ \j -> do
      p1 <- VM.read v (toIx (i-1, j-1))
      p2 <- VM.read v (toIx (i-1, j))
      p3 <- VM.read v (toIx (i, j-1))
      VM.write v (toIx (i, j)) (p2 + p3 - p1 + if (i, j) `elem` ps then 1 else 0)
  xs <- forM [1..w-s+1] $ \i -> do
    forM [1..h-t+1] $ \j -> do
      p1 <- VM.read v (toIx (i-1, j-1))
      p2 <- VM.read v (toIx (i-1, j+t-1))
      p3 <- VM.read v (toIx (i+s-1, j-1))
      p4 <- VM.read v (toIx (i+s-1, j+t-1))
      return $ p4 - p2 - p3 + p1
  return . maximum . concat $ xs
  where toIx (i, j) = (w+1) * j + i



Measured memory_bytes: 7152
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string temp;
    int r=0,_max=0;
    cin>>temp;
    for(int i=0;i<temp.size();i++)
    {
        if(temp[i]=='R')
            r++;
        else
            r=0;
        _max=max(_max,r);
    }
    cout<<_max;
    return 0;
}

Measured memory_bytes: 3152