akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;

    vector<long long int> x(n), y(n), z(n);
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }

    long long int ans = 0;
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                vector<long long int> xyz(n);
                for(int l=0; l<n; l++){
                    xyz[l]
                    += x[l] * (int)pow(-1,i)
                    +  y[l] * (int)pow(-1,j)
                    +  z[l] * (int)pow(-1,k);
                }
                sort(xyz.begin(), xyz.end());
                reverse(xyz.begin(), xyz.end());

                long long int sum = 0;
                for(int l=0; l<m; l++){
                    sum += xyz[l];
                }
                if(ans < sum) ans = sum;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

using namespace std;
#define int ll

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N;
	cin >> N;
	vector<pair<int, int>> v;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		v.emplace_back(a, b);
	}
	sort(all(v), [](pair<int, int> a, pair<int, int> b){return a.first + a.second > b.first + b.second;});
	int res = 0;
	rep(i, N) {
		if (i % 2 == 0) {
			res += v[i].first;
		} else {
			res -= v[i].second;
		}
	}
	cout << res << endl;
}

void solve()
{
}


Measured memory_bytes: 2420
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    string S;cin >> S;
    int K;cin >> K;
    set<string> retu;
    int N = S.size();
    for(int i = 1;i <= min(N,10);i++){
        for(int j = 0;j<=S.size()-i;j++){
            string T = S.substr(j,i);
            retu.insert(T);
        }
    }
    int count = 1;
    for(string R : retu){
        if(count == K) {
            cout << R << endl;
            return 0;
        }
        count++;
    }
}

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

int main(){
	int n;
	cin>>n;
	vector<int> d1(n);
	vector<int> d2(n);
	for(int i=0;i<n;i++){
		cin>>d1[i]>>d2[i];
	}
	vector<bool> flag(n,false);
	for(int i=0;i<n;i++)
		if(d1[i]==d2[i]) flag[i]=1;
	bool op=false;
	for(int j=2;j<n;j++){
		if(flag[j]&&flag[j-1]&&flag[j-2]){
			op=1;
			break;
		}
	}
	if(op){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3544
#import numpy as np
import copy
import heapq

n, m = map(int, input().split())
a_list = list(map(int, input().split()))

tmp_list = list(map(lambda x: x*(-1), a_list))
#print(tmp_list)
heapq.heapify(tmp_list)

#ticket_list = np.zeros(n)

for i in range(m):
    max_value = heapq.heappop(tmp_list)*(-1)
    heapq.heappush(tmp_list, (-1)*(max_value//2))

print(-sum(tmp_list))

#ans = 0
#for j in range(n):
#    ans += a_list[j] // (2**(ticket_list[j]))

#print(str(int(ans)))

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define ROF2(i,x,y) for(int i = (y) ; i >= (x) ; --i)
#define MP make_pair
#define ODD(x) (((x)&1)==0?(0):(1))
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

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

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        os << x[0];
        for (int i=1;i<x.size();i++) os << endl << " " << x[i];
    } else os << "[]";
    os << "]";
    return os;
}

const int NMAX=2E5+1;
int x[NMAX],p[NMAX];
int main() {
    int n;scanf("%d",&n);
    FOR(i,n){scanf("%d",&x[i]);p[i]=i;}
    sort(p,p+n,[=](int i,int j){return x[i]<x[j];});
    int n2=n/2, a=x[p[n2-1]], b=x[p[n2]];
    int ret[n];
    FOR(i,n2)
        ret[p[i]]=b;
    FOR2(i,n2,n)
        ret[p[i]]=a;
    FOR(i,n) printf("%d\n",ret[i]);
    return 0;

}

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

public class AtCoderE
{
    static void Main()
    {
        int n;
        int p;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            p = int.Parse(words[1]);
        }
        string s = Console.ReadLine();
        char[] array = s.ToArray();

        if (10 % p == 0)
        {
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                int num = int.Parse(array[i].ToString());
                if (num % p == 0)
                {
                    ans += i + 1;
                }
            }
            Console.WriteLine(ans);
            return;
        }

        int[] modSum = new int[n + 1];
        int tenMod = 1;
        for (int i = n - 1; i >= 0; i--)
        {
            int num = int.Parse(array[i].ToString());
            modSum[i] = ((num * tenMod % p) + modSum[i + 1]) % p;
            tenMod = (tenMod * 10) % p;
        }

        long answer = 0;
        int[] counts = new int[p];
        for (int i = 0; i <= n; i++)
        {
            answer += counts[modSum[i]];
            counts[modSum[i]]++;
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 19296
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

struct edge{int to; ll cost;};
typedef pair<ll,int> P;

void dijkstra(int s, vector<ll> &d, const vector<vector<edge>> &G){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d.begin(),d.end(),INF);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int K; cin >> K;
    vector<vector<edge>> G(K);
    vector<ll> d(K);
    REP(i,K) {
        G[i].push_back((edge){(i+1)%K,1});
        G[i].push_back((edge){(i*10)%K,0});
    }
    dijkstra(1,d,G);
    cout << d[0]+1 << endl;
    return 0;
}

Measured memory_bytes: 9208
"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");
const rows = input.trim().split("\n");

const header = rows.shift().split(" ").map(Number);
const N = header[0];
const K = header[1];

const map = {};
for (let i = 0; i < K; i++) {
  rows[2 * i + 1].split(" ").forEach((n) => {
    map[n] = n;
  });
}

const result = N - Object.keys(map).length;
console.log(result);


Measured memory_bytes: 29692
import java.io.*;
import java.util.Stack;

public class Main {
	public static void main(String args[]) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s;
			Stack<Integer> a = new Stack<Integer>();
			while((s = reader.readLine()) != null) {
				int x = Integer.parseInt(s);
				if(x>0 && x<=10)
					a.push(x);
				else
					System.out.println(a.pop());
			}
		}
		catch(IOException e) {
			System.out.println(e);
		}
	}
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

main(){
  int w,h,n; cin >> w >> h >> n;
  int x,y,a;
  vi data(4);
  data[1]=w;
  data[3]=h;

  rep(i,n){
    cin >> x >> y >> a;
    a--;
    if(a == 0 && data[0] < x) data[0] = x;
    else if(a == 1 && x < data[1]) data[1] = x;
    else if(a == 2 && data[2] < y) data[2] = y;
    else if(a == 3 && y < data[3]) data[3] = y;
  }

  int ans = 0;
  if(data[1] > data[0] && data[3] > data[2]) ans = (data[1] - data[0]) * (data[3] - data[2]);
  cout << ans << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

#n,x = [int(i) for i in readline().split()]
#n = int(input())
h,w = [int(i) for i in readline().split()]
b = [readline().strip() for _ in range(h)]

sx,sy = 0,0
gx,gy = h-1,w-1

dx4=[0, 1, 0,-1]
dy4=[1, 0,-1, 0]
#dx8=[0, 1, 0,-1,1,-1,1,-1]
#dy8=[1, 0,-1, 0,1,1,-1,-1]

from collections import deque 
#############################################################################
#   初期設定
#############################################################################
#memo: 負なら未確認、0以上なら最短距離
memo = [[-1]*w for _ in range(h)]
q = deque()
#初期状態をキューに入れる-----------------------------------------------------
#キューに入れる時点で使用したかどうかのmemoを更新-----------------------------
q.append((sx,sy)) #初期状態をキューに入れる
memo[sx][sy] = 0 #初期状態を訪問済みにする
""" "S,G"表記の場合
for i in range(h):
    for j in range(w):
        if b[i][j] == "S": 
            q.append((sx,sy)) #初期状態をキューに入れる
            memo[sx][sy] = 0 #初期状態を訪問済みにする
        if b[i][j] == "G":
            gx,gy = i,j
"""
#############################################################################
#   BFS
#############################################################################
while q: #キューが空になるまで
    x,y = q.popleft() #キューから情報を取り出す
    #(x,y)の各隣に対して処理-------------------------------------
    for i in range(4):
        nx = x + dx4[i]
        ny = y + dy4[i]
        #範囲外ならスキップ---------------------------------------------------
        if nx < 0 or nx>=h or ny <0 or ny>=w: continue
        #壁ならスキップ-------------------------------------------------------
        if b[nx][ny] == "#": continue
        #(nx,ny)が確認済みならスキップ----------------------------------------
        if memo[nx][ny] >= 0: continue
        #(nx,ny)が未確認のとき、確認済みにしてキューに入れる------------------
        memo[nx][ny] = memo[x][y]+1
        q.append((nx,ny))


res = 1+memo[gx][gy]

if res == 0:
    print(-1)
    exit()

for i in range(h):
    for j in range(w):
        if b[i][j] == ".": res -= 1

print(-res)








Measured memory_bytes: 3316
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

public class Hello{
    public static void Main(){

        string[] line = Console.ReadLine().Split(' ');
        int a = int.Parse(line[0]);
        int b = int.Parse(line[1]);
        int c = int.Parse(line[2]);
        int[] ans = new int[10];

        for(var i = 0; i < 10; i++)
        {
            if(i == 0)
            {
                ans[i] = a * c - b; 
                Console.WriteLine(ans[i]);
            }
            else
            {
                ans[i] = a * ans[i - 1] - b; 
                Console.WriteLine(ans[i]);
            }
            
        }
       
    }
}

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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	n *= 2;
	vector<int> l(n);
	for(int i = 0; i < n; i++) cin >> l[i];
	sort(l.begin(), l.end());
	int ans = 0;
	for(int i = 0; i < n; i += 2) ans += l[i];
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

int N;
string puzzle[256];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};


void dfs(int x, int y){
  puzzle[x][y] = '-';
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      int nx = x + dx[i], ny = y + dy[j];
      if(nx < 0 || ny < 0 || nx >= N || ny >= N) continue;
      if(puzzle[nx][ny] != 'o') continue;
      dfs(nx, ny);
    }
  }
  return;
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> puzzle[i];
  }

  int count = 0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(puzzle[i][j] == 'o'){
	dfs(i, j);
	count++;
      }
    }
  }

  //  cout << count << endl;
  cout << (int)((count - 1) / 3) << endl;
  return 0;
}

Measured memory_bytes: 3196
import numpy as np

s = input()
K = int(input())

# Number of alphabets are 27.
# 1 <= len(s) <= 5000
# 1 <=     K  <= 5

dic = set()

for l in range(1, K+1):
    for i in range(len(s) - l + 1):
        substr = s[i:i+l]
        dic.add(substr)

lst = sorted(list(dic))
# print(lst)
print(lst[K-1])


Measured memory_bytes: 13624
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let x: Vec<i32> = readnc();
    let L: i32 = read();
    let q: usize = read();
    let queries: Vec<(usize, usize)> = readn(q);

    let mut right: Vec<Vec<usize>> = vec![vec![0; n]; 18];

    {
        let mut head = 0;
        for i in 0..n {
            while head+1 < n && x[head+1] - x[i] <= L {
                head += 1;
            }
            right[0][i] = head;
        }
    }

    for k in 1..right.len() {
        for i in 0..n {
            right[k][i] = right[k-1][right[k-1][i]];
        }
    }

    for &(a, b) in &queries {
        let mut len = 0;
        let mut head = min(a - 1, b - 1);
        let to = max(a - 1, b - 1);
        for k in (0..right.len()).rev() {
            if right[k][head] < to {
                len += 1<<k;
                head = right[k][head];
            }
        }
        if head != to {
            len += 1;
        }
        println!("{}", len);
    }
}



Measured memory_bytes: 25212
#include <stdio.h>

int main() {
  int input;
        int ji, hun, byo;

        scanf("%i", &input);
 
        ji = input / 3600;
  hun = (input % 3600) / 60;
  byo = (input % 3600) % 60;
  
  printf("%i:%i:%i\n", ji, hun, byo);


}


Measured memory_bytes: 2108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		String str, s[];
		
		int n, res;
		while(!(str = reader.readLine()).equals("0")){
			n = Integer.valueOf(str);
			
			s = reader.readLine().split(" ");
			res = 0;
			for(int i = 1; i < n; i += 2){
				res += app.check(s[i], s[i - 1]);
			}
			System.out.println(res);
		}
		reader.close();
	}
	public int check(String x, String y){
		char l[] = x.toCharArray();
		char r[] = y.toCharArray();
		
		if(l[0] == r[0]){
			return 0;
		}else return 1;
	}
}

Measured memory_bytes: 26696
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int a,b;
    cin >> a >> b;
    string A, B;
    REP(i, b){
        A += to_string(a);
    }
    REP(i, a){
        B += to_string(b);
    }
    
    if(A>B)pr(B);
    else pr(A);
}

Measured memory_bytes: 256
program cheating_nim
  implicit none
  integer :: n, a, x, m, i, k
  logical :: b(0:31)
  a = 0
  b = .false.
  read(*,*) n
  x = 0
  do i = 1, n
    read(*,*) a
    x = xor(x,a)
    b(trailing_zeros(a)) = .true.
  end do
  m = 0
  do while (x.gt.0)
    k = 31-leading_zeros(x)
    if (b(k)) then
      x = xor(x,2**(k+1)-1)
      m = m+1
    else
      m = -1
      exit
    end if
  end do
  write(*,'(i0)') m
  stop
contains
  real(8) function log2(x)
    implicit none
    real(8), intent(in) :: x
    log2 = log(x)/log(2.d0)
    return
  end function log2
  function leading_zeros(x) result(z)
    implicit none
    integer, intent(in) :: x
    integer :: z
    z = 32
    if (x.eq.0) return
    z = 31-floor(log2(real(x,8)))
    return
  end function leading_zeros
  function trailing_zeros(x) result(z)
    implicit none
    integer, intent(in) :: x
    integer :: z, i
    z = 32
    if (x.eq.0) return
    do i = 0, 31
      if (btest(x,i)) then
        z = i
        exit
      end if
    end do
    return
  end function trailing_zeros
end program cheating_nim

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

N = int(input())
Pi = list(map(int, input().split()))
Ps = sorted(Pi)

count = 0
for i in Pi:
    s = Ps.pop(0)
    if i != s:
        count += 1

if count in [0,2]:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  string n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n.size(); i++) {
    if (n.at(i) == '2') ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
h_list = list(map(int, input().split()))

def check(h_list):
	prev = 0
	for h in h_list:
		if prev > h:
			return False
		elif prev < h:
			prev = h - 1
	return True

if check(h_list):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 14396
#include <stdio.h>

int main(void) {
    char c[3][4];
    for (int i = 0;i < 3;i++) {
        scanf("%s", c[i]);
    }

    printf("%c%c%c\n", c[0][0], c[1][1], c[2][2]);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {

    // 頂点数と辺数
    int n, m; cin >> n >> m;

    vector<int> a(m), b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
    }
    int ans = 0;
    for (int j = 0; j < m; j++) {

        // グラフ入力受取 (ここでは無向グラフを想定)
        Graph G(n);
        for (int i = 0; i < m; ++i) {
            if (i == j) continue;
            int aa = a[i];
            int bb = b[i];
            aa--;
            bb--;
            G[aa].push_back(bb);
            G[bb].push_back(aa);
        }

        // BFS のためのデータ構造
        vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
        queue<int> que;

        // 初期条件 (頂点 0 を初期ノードとする)
        dist[0] = 0;
        que.push(0); // 0 を橙色頂点にする

        // BFS 開始 (キューが空になるまで探索を行う)
        while (!que.empty()) {
            int v = que.front(); // キューから先頭頂点を取り出す
            que.pop();

            // v から辿れる頂点をすべて調べる
            for (int new_v : G[v]) {
                if (dist[new_v] != -1) continue; // すでに発見済みの頂点は探索しない

                // 新たな白色頂点 new_v について距離情報を更新してキューに追加する
                dist[new_v] = dist[v] + 1;
                que.push(new_v);
            }
        }
        bool can = true;
        for (int i = 0; i < n; i++) {
            if (dist[i] == -1) can = false;
        }
        if (!can) ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		/**/
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int H = I.nextInt();
		int W = I.nextInt();
		int ans = 0;
		while (N-->0) {
			int h = I.nextInt();
			int w = I.nextInt();
			ans+=h>=H&&w>=W?1:0;
		}
		O.pln(ans);
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 27316
#include <iostream>
#include <algorithm>
#include <string>
#include <deque>
using namespace std;

int main() {
    int T; cin >> T;
    cin.ignore();

    while(T--) {
        string line;
        getline(cin, line);
        line += "@";

        deque<char> Q;
        int cur = 0;
        int front = 0;
        int back = 0;
        int p = 0;

        Q.push_back(line[0]);
        p++;

        while(true) {
            if(line[p] == '@') break;

            if(line[p] == '<') {
                cur--;
                p += 2;

                if(!(front <= cur && cur <= back)) {
                    Q.push_front(line[p]);
                    front = cur;
                }

                p++;
            }
            else {
                cur++;
                p += 2;

                if(!(front <= cur && cur <= back)) {
                    Q.push_back(line[p]);
                    back = cur;
                }

                p++;
            }
        }

        while(!Q.empty()) {
            cout << Q.front();
            Q.pop_front();
        }
        cout << endl;
    }
}

Measured memory_bytes: 1204
use std::io;

macro_rules! parse_line {
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
                a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

fn main() {
    let (a, b) = parse_line!(u64, u64);
    let d = b - a;
    println!("{}", (d * (d - 1) / 2) - a);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back

const int N = 1<<20;

using namespace std;

int n, seg[2*N];
ll c, dp[202020], h[202020];

void push(int k){
	if(k<N){
		seg[2*k] = seg[k];
		seg[2*k+1] = seg[k];
		seg[k] = 0;
	}
}

void add(int a, int b, int k, int x, int y, int o){
	if(a>y || b<x) return;
	if(seg[k]) push(k);
	if(a==x && b==y){ seg[k] = o; return; }
	int d = (y-x+1)/2;
	add(a, min(b, y-d), 2*k, x, y-d, o);
	add(max(x+d, a), b, 2*k+1, x+d, y, o);
}

int gval(int k){
	k += N;
	for(int i=20; i>=0; i--) if(seg[(k>>i)]) push(k>>i);
	return seg[k];
}

bool ok(int a, int b, ll cr){
	if(dp[a]+(h[a]-cr)*(h[a]-cr) <= dp[b]+(h[b]-cr)*(h[b]-cr)) return 1;
	return 0;
}

int main(){

	cin >> n >> c;
	for(int i=1; i<=n; i++) cin >> h[i];

	seg[1] = 1;
	
	for(int i=2; i<=n; i++){

		int cp = gval(h[i]);
		dp[i] = dp[cp]+(h[i]-h[cp])*(h[i]-h[cp])+c;

		int md = h[i], be, en, dir = (h[cp]>h[i]) ? -1 : 1;
		
		for(int b=N; b>0; b/=2){
			if(md+b*dir>0 && md+b*dir<N && h[gval(md+dir*b)]*dir < h[i]*dir) md += b*dir;
		}
		if(md > 1 && md < N-1 && ok(i, gval(md+dir), md+dir)) md += dir;
		
		be = md; en = md;
		if(!ok(i, gval(md), md)) continue;

		for(int b=N; b>0; b/=2) if(be-b>0 && ok(i, gval(be-b), be-b)) be -= b;
		for(int b=N; b>0; b/=2) if(en+b<N && ok(i, gval(en+b), en+b)) en += b;

		add(be, en, 1, 0, N-1, i);
		
	}

	cout << dp[n] << endl;

	return 0;
}


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

void findit(int n,long double p[])
{
    long double dp[n+1][n+1];
    
    for(int i=0;i<=n;i++)
    {
        dp[0][i]=(long double)(0);
    }
    
    dp[0][0]=(long double)(1);
    
    for(int i=1;i<=n;i++)
    {
      dp[i][0]=dp[i-1][0]*(1-p[i-1]); 
    }
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j>i)
            {
                dp[i][j]=(long double)(0);
            }
            
            else
            {
                dp[i][j]=p[i-1]*dp[i-1][j-1]+(1-p[i-1])*dp[i-1][j];
            }
        }
    }
    
   
    
    long double ans=(long double)(0.00000000000);
   //cout<<ans<<" ";
    
    for(int i=n;i>=n/2+1;i--)
    {
      //  cout<<dp[n][i]<<" ";
        ans=ans+dp[n][i];
    }
 //   cout<<"\n";
    cout<<fixed<<setprecision(10)<<ans;
    
}


int main()

{
    int n;
    cin>>n;
    
    long double p[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    
    findit(n,p);
    
	
	return 0;
}


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

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    if(abs(a-b)>1000000000000000000) cout<<"Unfair"<<"\n";
    else if(k%2==0) cout<<a-b<<"\n";
    else cout<<b-a<<"\n";
    return 0;
}

Measured memory_bytes: 3616
import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;

int calc(int time, int[] n)
{
    if(n.length==0)
    {
        return time;
    }
    while(time%10!=0)
    {
        time++;
    }
    int res =int.max;
    for(int i =0;i < n.length;i++)
    {
        int[] cn = n.dup;
        auto e = cn[i];
        cn = cn.remove(i);
        auto m = calc(time + e, cn);
        res = min(res, m);
    }
    return res;
}
void main() {
    int[] list;
    for (int i = 0; i < 5; ++i) {
        list~=readln().strip.to!int;
    }
    writeln(calc(0, list));
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
new_a = [0] + a + [0]
total_distance = 0
for i in range(1, len(new_a)):
    distance = new_a[i] - new_a[i-1]
    total_distance += abs(distance)
for j in range(1, len(new_a) - 1):
    ans = total_distance - abs(new_a[j] - new_a[j-1]) - \
        abs(new_a[j+1] - new_a[j]) + abs(new_a[j + 1] - new_a[j-1])
    print(ans)


Measured memory_bytes: 20512
import java.util.*;

class Main{
	public static void main(String agrs[]){
Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int m = s/60;
		int h = m/60;
		s = s - m * 60;
		m = m - h * 60;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26348
#include <stdio.h>
#include <unistd.h>

void get_nums(int *array, int count)
{
    char c;
    int num;

    c = 0;
    while (c != 10)
    {
        if (read(0, &c, 1) == -1)
            return ;
        if (c != 32)
        {
            num = 0;
            while ('0' <= c && c <= '9')
            {
                num = num * 10 + c - '0';
                if (read(0, &c, 1) == 0)
                {
                    array[count++] = num;
                    return ;                    
                }
            }
            array[count++] = num;
        }
    }  
}

void get_stirngs(char *s, int i)
{
    char c;

    c = 0;
    while (c != 10)
    {
        if (read(0, &c, 1) == -1)
            return ;
        while (31 < c && c < 127)
        {
            s[i++] = c;
            if (read(0, &c, 1) == 0)
            {
                s[i] = 0;
                return ;                    
            }
        }
        s[i] = 0;
    }  
}

void get_ans(int x, int y, int i, int j)
{
    char s[x + 1];
    
    while (++j < y + 2)
    {
        if (0 < j  && j <= y)
            get_stirngs(s, 0);
        i = -1;
        while (++i < x + 2)
        {
            if (0 < j  && j <= y && 0 < i && i <= x)
                write(1, &s[i - 1], 1);
            else
                write(1, "#", 1);
        }
        write(1, "\n", 1);
    }
}

int main(void){
    int num[2];
    
    get_nums(num, 0);
    get_ans(num[1],num[0], -1, -1);
    return (0);
}


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  vector<bool> OK(N, true);
  for (int i = 0; i < N; i++) cin >> H[i];
  for (int i = 0; i < M; i++) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    if (H[s] <= H[t]) {
      OK[s] = false;
    }
    if (H[t] <= H[s]) {
      OK[t] = false;
    }
  }
  int good = 0;
  for (int i = 0; i < N; i++) {
    if (OK[i]) good++;
  }
  cout << good << endl;

  return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>

int main(void){
    int n,m,ans=0;
    scanf("%d%d",&n,&m);
    if(n>1){
        ans += n*(n-1)/2;
    }
    if(m>1){
        ans += m*(m-1)/2;
    }

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

Measured memory_bytes: 1696
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
  ll sum=0;
  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n) cin >> a[i];
  rep(i,n)sum+=a[i];
  vector<ll> v=divisor(sum);
  ll modulo=0;
  for(int i=v.size()-1;i>=0;i--){
   
    ll posi[n]={},nega[n]={};
    rep(j,n){
      posi[j]=a[j]%v[i];
      nega[j]=v[i]-a[j]%v[i];
    }
    sort(posi,posi+n);
    sort(nega,nega+n);
    ll posi_sum[n+1]={},nega_sum[n+1]={};
    for(int j=1;j<n+1;j++){
      posi_sum[j]=posi_sum[j-1];
      nega_sum[j]=nega_sum[j-1];
      posi_sum[j]+=posi[j-1];
      nega_sum[j]+=nega[j-1];
    }
    ll ret=inf;
    for(int j=0;j<n;j++){
      if(posi_sum[j]==(n-j)*v[i]-(posi_sum[n]-posi_sum[j]))ret=min(ret,posi_sum[j]);
      if(nega_sum[j]==(n-j)*v[i]-(nega_sum[n]-nega_sum[j]))ret=min(ret,nega_sum[j]);
    }
    if(ret<=k){
      cout << v[i] << endl;
      return 0;
    }
  }
return 0;}

Measured memory_bytes: 256
import sys
if sys.platform =='ios':
	sys.stdin=open('input.txt')

n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]

AC=[]
for i in range(n-1):
    if s[i]=="A":
        if s[i+1]=="C":
            AC.append(i)
#print(AC)

from bisect import bisect_right as br
from bisect import bisect_left as bl
for i in range(q):
    a=bl(AC,lr[i][0]-1)
    #print(i,AC,lr[i][0],a)
    b=br(AC,lr[i][1]-2)
    #print(a,b)
    print(b-a)

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

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

int main() {
    int L, A, B, C, D;
    cin >> L >> A >> B >> C >> D;
    cout << max(0, L - max((A + C - 1) / C, (B + D - 1) / D)) << endl;
}


Measured memory_bytes: 3064
while 1:
    n,m,a = list(map(int,input().split(' ')))
    if n ==0:break
    td ={}
    high =0
    for i in range(n):
        td[i] =[]
    for _ in range(m):
        h,p,q = list(map(int,input().split(' ')))
        td[p-1].append((h,q))
        td[q-1].append((h,p))
        if h > high:high =h 
    for i in range(n):
        td[i] = sorted(td[i],key = lambda edge:edge[0])
    current = a-1
    while 0!=len(td[current]):
        edge = td[current].pop()
        if high == edge[0]:
            current = edge[1] -1
            high -=1
        elif high > edge[0]:
            high = edge[0] -1
            current = edge[1]-1
        if high ==0:break
    print(current+1)
        
    


Measured memory_bytes: 5816
struct B{int w,s,v;}A[1111];
r;
comp(a,b)struct B*a,*b;{r=a->w+a->s-b->w-b->s;}
n,i,j;
long dp[22222],ans;
main(){
	scanf("%d",&n);
	for(;~scanf("%ld%ld%ld",&A[i].w,&A[i].s,&A[i].v);i++);
	qsort(A,n,sizeof(struct B),comp);
	for(i=0;i<n;i++)
	{
		for(j=A[i].s;j>=0;j--)ans=fmax(ans,dp[j+A[i].w]=fmax(dp[j+A[i].w],dp[j]+A[i].v));
	}
	printf("%ld",ans);
}


Measured memory_bytes: 380
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N, M;
int A[110];
double sum = 0;
int answer = 0;

int main() {
    cin >> N >> M;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }

    REP(i, N) {
        if (A[i] >= (sum / (4 * M))) answer++;
    }
    if (answer >= M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
// ALDS1_3_C Doubly linked list

#include <iostream>
#include <string>

struct list{
	int value;
	list *prev;
	list *next;
};

void insertElement(list *begin){
	list *new_data = new list;

	std::cin >> new_data->value;
	(begin->next)->prev = new_data;	// prev of next of new element
	new_data->next = begin->next;	// next of new element
	new_data->prev = begin;			// prev of new element (=begin)
	begin->next = new_data;			// next of begin (=new element)

	return;
}

void deleteElement(list *begin, list *end){
	int in_value;
	
	std::cin >> in_value;
	for(list *l=begin->next ; l!=end ; l=l->next){
		if(l->value == in_value){
			(l->prev)->next = l->next;
			(l->next)->prev = l->prev;
			break;
		}
	}

	return;
}

int main(int argc, char *argv[]){
	int n;
	list *begin = new list;
	list *end = new list;
	std::string command;

	// List initialize
	begin->next = end;
	end->prev = begin;

	std::cin >> n;
	for(int i=0 ; i<n ; i++){
		std::cin >> command;
		if(command == "insert"){
			insertElement(begin);
		}
		else if(command == "delete"){
			deleteElement(begin, end);
		}
		else if(command == "deleteFirst"){
			begin = begin->next;
		}
		else if(command == "deleteLast"){
			end = end->prev;
		}
	}

	list *l = begin->next;
	std::cout << l->value;
	for(l=l->next ; l!=end ; l=l->next){
		std::cout << " " << l->value;
	}
	std::cout << std::endl;

	return 0;
}



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

int main()
{
	int N;
	cin>>N;
    for (int h=1;h<=3500;h++)
        for (int n=1;n<=3500;n++)
        {
            double t=4.0/N-1.0/h-1.0/n;
            long long w=1.0/t;
            if (w>0&&4ll*h*n*w==1ll*N*n*w+1ll*N*h*w+1ll*N*h*n)
            {
                printf("%d %d %d",h,n,w);
                return 0;
            }
        }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

vector<int> G[MAX_N];
bool flag;
int visit[MAX_N];

void dfs(int u,int k,int& s,int& t)
{
    visit[u] = k;
    if(k > 0){
        s++;
    }else{
        t++;
    }
    rep(i,len(G[u])){
        if(visit[G[u][i]] == 0){
            dfs(G[u][i],-k,s,t);
            if(flag){
                return;
            }
        }else if(visit[G[u][i]] == k){
            flag = true;
            return;
        }
    }
}

map<int,int> mp;
bool dp[MAX_N];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    rep(i,m){
        int a,b;
        scanf("%d%d",&a,&b);
        G[a-1].pb(b-1),G[b-1].pb(a-1);
    }
    vector<P> vec;
    rep(i,n){
        if(visit[i] == 0){
            int r1 = 0,r2 = 0;
            dfs(i,1,r1,r2);
            if(flag){
                cout << "-1\n";
                return 0;
            }
            vec.pb(P(r1,r2));
        }
    }
    int sm = 0,al = 0;
    rep(i,len(vec)){
        sm += min(vec[i].fi,vec[i].se);
        al += max(vec[i].fi,vec[i].se);
        if(abs(vec[i].fi-vec[i].se) != 0){
            mp[abs(vec[i].fi-vec[i].se)]++;
        }
    }
    dp[0] = true;
    each(it,mp){
        int num = it.se;
        for(int i=1;num>0;i<<=1){
            int mul = min(i,num);
            for(int j=al-sm;j>=it.fi*mul;j--){
                if(dp[j-it.fi*mul]){
                    dp[j] = true;
                }
            }
            num -= mul;
        }
    }
    int mn = INF;
    rep(i,al-sm+1){
        if(dp[i]){
            cmn(mn,max(sm+i,al-i));
        }
    }
    if(n % 2 == 0){
        if(mn <= n/2){
            cout << (ll)n*n/2/2 - m << "\n";
        }else{
            cout << (ll)mn*(n-mn) - m << "\n";
        }
    }else{
        if(mn <= (n+1)/2){
            cout << (ll)(n-1)*(n+1)/2/2 - m << "\n";
        }else{
            cout << (ll)mn*(n-mn) - m << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 9768
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))



using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;


ll N, A, B;


vector<ll> a;

int main() {
	cin >> N;

	ll v;

	rep(i, N) {
		cin >> v;
		a.push_back(v);
	}

	ll index = 0;
	ll m = 0;
	rep(i, N) {
		if (abs(a[i]) > m) {
			index = i;
			m = abs(a[i]);
		}
	}
	cout << 2 * N << endl;
	if (a[index] > 0) {
		
		cout << index+1 << " " << N << endl;
		cout << index+1 << " " << N << endl;
		for (int i = 2; i <= N; i++) {
			cout << N << " " << N << endl;
			cout << N << " " << i << endl;
			
		}


	}
	else {
		cout << index + 1 << " " << 1 << endl;
		cout << index + 1 << " " << 1 << endl;
		for (int i = N-1; i >= 1; i--) {
			cout << 1 << " " << 1 << endl;
			cout << 1 << " " << i << endl;
		}

	}



	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
ans = 0
for i in range(1,10):
  for j in range(0,10):
    for k in range(0,10):
      x = 10000*i + 1000*j + 100*k + 10*j + i
      if a <= x <= b:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
char dp[100][100];
int a,b;
void paint(int x,int y){
    dp[x][y]='#';
    dp[x+1][y]='#';
    dp[x+1][y-1]='#';
    return ;
}
int main(void){
    cout<<100<<" "<<100<<endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            dp[i][j]='.';
        }
    }
    cin>>a>>b;
    b=b-1+(a==1);
    a--;
    int i;
    for(i=0;i<a/50;i++){
        for(int j=0;j<50;j++){
            paint(2*j,2*i+1);
        }
    }
    for(int j=0;j<a%50;j++){
        paint(2*j,2*i+1);
    }
    for(i=0;i<b/49;i++){
        for(int j=0;j<49;j++){
            dp[2*j+1][98-i*2]='#';
        }
    }
    for(int j=0;j<b%49;j++){
        dp[2*j+1][98-i*2]='#';
    }
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout<<dp[i][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256