akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(void){
  char s[3];
  cin >> s[0] >> s[1] >> s[2];
  int count = 0;
  for(int i = 0;i < 3;i++){
    if(s[i] == '1') count++;
  }
  cout << count << '\n';
}


Measured memory_bytes: 256
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
 
        final Scanner sc = new Scanner(System.in);
        String hoge =sc.next();
        System.out.println(hoge.substring(0,3));
        /* 
        long N = sc.nextLong();
        int ans=0;
        long q =2;
 
        //1だった時はさっさと終わらす
        if(N==1){
            System.out.println(0);
            return;
        }
 
        //本編
        while(q*q<=N){
            //qを決定する
            if(N%q ==0){
                //qの累積を全部発見する
                for(int i = 1; N>=Math.pow(q,i);i++){
                    if(N%Math.pow(q, i)==0){
                        //発見するたびにカウントアップ
                        ans++;
                        //発見するたびに除算
                        N = (long) (N / Math.pow(q, i));
                    }
                }
                //qの累積は見つけ尽くしたので、Nからqを完全に取り除く
                while(N%q ==0){
                    N = N/q;
                }
            }   
            q++;
        }

        //1以外の数が搾りカスとして出たら足してあげる
        if(N != 1){ans++;}
            System.out.println(ans);*/
    }
} 

Measured memory_bytes: 35720
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0'))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define bye return 0
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    char c;
    int a, b;
    
    cin >> a >> c >> b;

    if(c=='+')
    	cout << a+b << "\n";
    else
    	cout << a-b << "\n";

  
   bye;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll n,k;
vec a(1e5+10);
vec dp(1e5+10,-1);

ll win(ll f) {
  if(dp[f]>-1) return dp[f];
  set<ll> cnt;
  for(ll i=0;i<n&&(f-a[i]>=0);i++) {
    cnt.insert(win(f-a[i]));
  }
  for(ll i=0;i<=k;i++) {
    if(!cnt.count(i)) {
      return dp[f]=i;
    }
  }
}

int main() {
  cin >> n >> k;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  if(win(k)) {
    cout << "First" << endl;
  }
  else {
    cout << "Second" << endl;
  }
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] a = new int[h+1][w+1];
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        StringBuilder ans = new StringBuilder();
        StringBuilder tmp = new StringBuilder();
        boolean move = false;
        int dir = 1;
        int prex = 1;
        int prey = 0;
        int cnt = 0;
        int tmpCnt = 0;
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                int x = dir < 0 ? w - j + 1 : j;
                if(!move){
                    if(a[i][x] % 2 != 0){
                        move = true;
                    }
                }else{
                    tmp.append(prey + " " + prex + " " + i + " " + x + "\n");
                    tmpCnt++;
                    if(a[i][x] % 2 != 0){
                        ans.append(tmp.toString());
                        tmp = new StringBuilder();
                        move = false;
                        cnt += tmpCnt;
                        tmpCnt = 0;
                    }
                }
                prey = i;
                prex = x;
            }
            dir *= -1;
        }
        System.out.println(cnt);
        System.out.print(ans.toString());

        sc.close();
    }

}


Measured memory_bytes: 100772
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;

typedef pair<long long, long long> Pair;

int w, h;
long long p[100001], q[100001];
priority_queue<Pair, vector<Pair>, greater<Pair>> p_queue;

class UF {
public:
    int size;
    int *id;
    UF(int n) {
        size = n+1;
        id = new int[n+1];
        for(int i=0; i<=n; i++)
        {
            id[i] = i;
        }
    }
    
    ~UF() {
        delete [] id;
    }
    
    int find(int p) {
        if (p != id[p]){
            id[p] = find(id[p]);
        }
        return id[p];
    }
    
    void unite(int x, int y)    {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        id[i] = j;
        size--;
    }
    
    bool connected(int x, int y)    {
        return find(x) == find(y);
    }
};

long long ans;


int main() {
    cin >> w >> h;
    for (int i=0; i<=w-1; i++) {
        cin >> p[i];
        p_queue.push(make_pair(p[i], i));
    }
    
    for (int i=0; i<=h-1; i++) {
        cin >> q[i];
        p_queue.push(make_pair(q[i], i+1000000));
    }
    
    UF uf_w(w), uf_h(h);
    ans = 0;
    
    while (!p_queue.empty()) {
        Pair t = p_queue.top();
        long long len = t.first;
        int idx = t.second;
        if (idx<1000000) {
            if (!uf_w.connected(idx, idx+1)) {
                ans += uf_h.size * len;
                uf_w.unite(idx, idx+1);
            }
        } else {
            idx -= 1000000;
            if (!uf_h.connected(idx, idx+1)) {
                ans += uf_w.size * len;
                uf_h.unite(idx, idx+1);
            }
        }
        p_queue.pop();
    }
    
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 5740
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  n = get_int
  s, t = get_strs
  chars = []
  0.upto(n-1) do |i|
    chars << s[i]
    chars << t[i]
  end
  puts chars.join("")
end

if __FILE__ == $0
  main
end

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int N;  cin >> N;
	vector<double>x(N);
	vector<string>u(N);
	double ans = 0;
	for (int i = 0;i < N;i++) {
		cin >> x[i] >> u[i];
		if (u[i] == "JPY") {
			ans = ans + x[i];
		}
		else if (u[i] == "BTC") {
			ans = ans + x[i] * 380000.0;
		}
	}
	cout << ans << endl;
}

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

int main() {
  vector<vector<int>> a(3,vector<int>(3));
  rep(i,3) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  vector<vector<int>> c(3,vector<int>(3,0));
  int n;
  cin >> n;
  
  rep(i,n) {
    int b; 
    cin >> b;
    rep(i,3) rep(j,3) if(a[i][j] == b) c[i][j] = 1;
  }
  
  rep(i,3) {
    int cnt = 0;
    rep(j,3) {
      cnt += c[i][j];
    }
    if(cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  rep(i,3) {
    int cnt = 0;
    rep(j,3) {
      cnt += c[j][i];
    }
    if(cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
 
    cnt = 0;
    rep(j,3) {
      cnt += c[j][j];
    }
    if(cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
    
    cnt = 0;
    rep(j,3) {
      cnt += c[j][2-j];
    }   
    if(cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
package main

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

// INF default value at dict
const INF = 100100100

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	input :=  splitAndAtoi(nextLine(stdin))
	h, w := input[0], input[1]
	//fmt.Printf("%d %d\n", h, w)
	
	maze := make(map[Pair]string)
	sDict := make(map[Pair]int)
	for i :=0; i< h; i++ {
		line := strings.Split(nextLine(stdin), "")
		for j :=0; j < w; j++ {
			//fmt.Printf("%s", line[j])
			maze[Pair{i,j}] = line[j]
			sDict[Pair{i,j}] = INF
		}
		//fmt.Printf("\n")
	}
	//fmt.Printf("maze is..\n")
	//fmt.Printf("%v\n", maze)

	ans := 0
	for i:=0; i<h; i++ {
		for j:=0; j<w; j++ {
			// BFS all points
			current := Pair{i,j}
			// # is not become start point
			if maze[current] == "#" {
				continue
			}

			// init dict
			dict := make(map[Pair]int)
			for k,v := range sDict {
				dict[k] = v
			}
			
			//fmt.Printf("dict is.. %v\n", dict)
			q := Queue{}
			update := func(point Pair,x int) {
				// return if already touched
				if dict[point] != INF {
					return
				}
				dict[point] = x
				q.Push(point)
			}
			update(current, 0)
			for !q.Empty() {
				target := q.Pop()
				
				for _ , v := range target.Adjacents(h,w) {
					if maze[v] == "#" {
						continue
					}
					//fmt.Printf("update dict at %v value is %v\n", v, dict[target] +1)
					update(v, dict[target] + 1)
				}
			}
			//fmt.Printf("i %d j %d\n", current.first, current.second)
			//fmt.Printf("%v\n", dict)

			// find max dict
			for i:=0; i <h; i++ {
				for j:=0; j <h; j++ {
					current = Pair{i,j}
					if dict[current] == INF {
						continue
					}

					ans = max(ans, dict[current])
				}
			}
		}
	}

	fmt.Printf("%d", ans)
}

// Pair a
type Pair struct {
	first int
	second int
}

// Adjacents list adjacents nodes
func(p Pair) Adjacents(h,w int)[]Pair{
	var r []Pair
	di := []int{-1, 0, 1, 0}
	dj := []int{0, -1, 0, 1}
	for dir:=0; dir < 4; dir++ {
		ni := p.first + di[dir]
		nj := p.second + dj[dir]
		// ignore ivalid target
		if ni < 0 || ni >= h || nj < 0 || nj >= w {
			continue
		}

		r = append(r, Pair{ni,nj})
	}
	return r
}

// Queue a
type Queue struct{
	v []Pair
}


// Push for queue
func(q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func(q *Queue) Pop() Pair{
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func(q Queue) Front() Pair{
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool{
	return len(q.v) == 0
}

func splitAndAtoi(s string) []int {
	ss := strings.Split(s, " ")
	var r []int
	for _, s := range ss {
		i, _ := strconv.Atoi(s)
		r = append(r, i)
	}

	return r
}

func nextNumber(s *bufio.Scanner) int {
	i, _ := strconv.Atoi(nextLine(s))
	return i
}

func nextLine(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

func max(a,b int) int {
	return int(math.Max(float64(a), float64(b)))
}

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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

int32_t main() {
	FAST_IO;
	
	int n, k;
	cin >> n >> k;
	
	int h[n];
	for (int& x: h) cin >> x;
	
	vi dp(n);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = INF;
		for (int j = 1; j <= k; j++) {
			if (i-j >= 0) {
				dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
			}
		}
	}
	
	cout << dp[n-1] << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


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

public class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		int[][] D = new int[N][2];
		for (int i = 0; i < N; i++) {
			st = nl();
			D[i][0] = ni(st);
			D[i][1] = ni(st);
		}
		
		String ans = "No";
		for (int i = 0; i < N-2; i++) {
			if (D[i][0] == D[i][1] &&
					D[i+1][0] == D[i+1][1] &&
					D[i+2][0] == D[i+2][1]) {
				ans = "Yes";
				break;
			}
		}
		
		out.println(ans);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static String rl() throws IOException {
		return f.readLine();
	}

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(rl());
	}

	static long nlg() throws IOException {
		return Long.parseLong(rl());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
}


Measured memory_bytes: 33128
#include <cstdio>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;

int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }

}

Measured memory_bytes: 3560
N,K=map(int,input().split())
h=[int(input()) for _ in range(N)]
h.sort()

def h_find(list,n):
    k=list[n-1]-list[0]
    for i in range(1,len(list)-n+1):
        k2=list[i+n-1]-list[i]
        if k2<k:
            k=k2
        if k==0:
            break
    return k

print(h_find(h,K))

Measured memory_bytes: 7384
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;
template<typename T>
T fastPow(T a, T b, T mod = 0) {
	if (a == 0 and b == 0) {
		return -1;
	}
	if (a == 0) {
		return 0;
	}
	if (b == 0) {
		return 1;
	}
	long long tmp = fastPow(a, b / 2, mod);
	if (mod != 0) {
		if (b % 2 == 0) {
			return (tmp * tmp) % mod;
		}
		else {
			return ((tmp*tmp) % mod * (a % mod)) % mod;
		}
	}
	else {
		if (b % 2 == 0) {
			return (tmp*tmp);
		}
		else {
			return tmp * tmp * a;
		}
	}
}
int main() {
	vector<bool> NGList(fastPow(10LL, 6LL) + 1, false);
	vector<bool> discoverList(fastPow(10LL, 6LL) + 1, false);
	ll numA;
	cin >> numA;
	vector<ll> aList(numA);
	for (ll i = 0; i < numA; i++) {
		ll tmp;
		cin >> tmp;
		if (discoverList[tmp] == true) {
			NGList[tmp] = true;
		}
		else {
			ll nowt = tmp + tmp;
			while (nowt <= fastPow(10LL, 6LL)) {
				NGList[nowt] = true;
				nowt += tmp;
			}
		}
		discoverList[tmp] = true;
		aList[i] = tmp;
	}
	ll ans = 0;
	for (ll i = 0; i < numA; i++) {
		if (NGList[aList[i]] == false) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;

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

    int n;
    cin >> n;
    
    if(n%2==0){
        cout << n * (n - 2) / 2 << endl;

        forx(i,1,n){
            forx(j,i+1,n+1){
                if(i+j==n+1)
                    continue;
                cout << i << ' ' << j << endl;
            }
        }
    }

    else{
        cout << (n - 1) * (n - 1) / 2 << endl;
        forx(i, 1, n)
        {
            forx(j, i + 1, n + 1)
            {
                if (i + j == n)
                    continue;
                cout << i << ' ' << j << endl;
            }
        }
    }

    return 0;
}

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

using namespace std;

char x[105];
long long k;
int hv;

int main() {
	scanf("%s%lld", x, &k);
	while (x[hv] == '1')
		hv++;
	k--;
	if (k < hv)
		printf("1\n");
	else
		printf("%c\n", x[hv]);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n; cin>>n;
  vector<ll> a(100001);
  ll sum{};
  for(int i=0; i<n; i++){
    int a0; cin>>a0;
    sum += a0;
    a.at(a0)++;
  }
  int q; cin>>q;
  for(int i=0; i<q; i++){
    ll b,c; cin>>b>>c;
    sum += (c-b)*a.at(b);
    a.at(c) += a.at(b);
    a.at(b) = 0;
    cout << sum << endl;
  }
  
}

Measured memory_bytes: 4028
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
using namespace std;

int vs[100000+10];
vector<pair<int,int> > ps;

int main(void) {
  int n;
  scanf("%d", &n);
  map<int,int> m;
  REP(i, n) {
    scanf("%d", &vs[i]);
    m[vs[i]]++;
  }
  FOR(it, m) {
    ps.push_back(*it);
  }
  int res = 0;
  REP(i, ps.size()) {
    int cnt = ps[i].second;
    res = max(res, cnt);
  }
  REP(i, ps.size()) {
    int cnt = ps[i].second;
    if(i > 0 && ps[i].first - ps[i-1].first <= 2) {
      cnt += ps[i-1].second;
    }
    res = max(res, cnt);
  }
  REP(i, ps.size()) {
    int cnt = ps[i].second;
    if(i > 0 && ps[i].first - ps[i-1].first == 1) {
      cnt += ps[i-1].second;
    }
    if(i+1 < (int)(ps.size()) && ps[i+1].first - ps[i].first == 1) {
      cnt += ps[i+1].second;
    }
    res = max(res, cnt);
  }
  printf("%d\n", res);
 
  return 0;
}


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

using namespace std;

typedef long long ll;



int main() {
    ios::sync_with_stdio(0); 

    string s;
    cin >> s;
    if (s.back() == 's') {
        s += "es";
    }
    else {
        s += 's';
    }
    cout << s << endl;

    return 0;
}


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

int main(){
  int n,m;
  ll k;
  cin >> n >> m >> k;
  vector<int> A(n);
  vector<int> B(m);
  rep(i,n) cin >> A[i];
  rep(i,m) cin >> B[i];
  ll t=0;
  rep(i,m) t+=B[i];
  int j = m;
  int ans = 0;
  rep(i,n+1){
    while(j>0&&t>k){
      j--;
      t -= B[j];
    }
    if(t>k)break;
    ans = max(ans,i+j);
    if(i==n)break;
    t += A[i];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

	int price = 700;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') {
			price += 100;
		}
	}

	cout << price << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())

A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)


def yes_or_no():
    sorted_index = np.argsort(B)
    if A[sorted_index[0]] > B[sorted_index[0]]:
        return 0
    sum_A = [A[sorted_index[0]]]
    for i in range(1, N):
        next_num = sum_A[i-1] + A[sorted_index[i]]
        sum_A.append(next_num)
        if next_num > B[sorted_index[i]]:
            return 0
        
    return 1

if yes_or_no():
    print("Yes")
else:
    print("No")

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

import queue
k = int(input())

q = queue.Queue()

for i in range(1, 10):
    q.put(i)

for i in range(k):
    tmp = q.get()
    if tmp % 10 != 0:
        q.put(10*tmp + tmp % 10 - 1)
    q.put(10*tmp + tmp % 10)
    if tmp % 10 != 9:
        q.put(10*tmp + tmp % 10 + 1)
print(tmp)


Measured memory_bytes: 12452
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
	//ifstream cin("input.txt");

	string s;
	getline(cin, s);

	bool isC = false, isF = false;
	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == 'C')
			isC = true;
		if (isC && s[i] == 'F')
			isF = true;
	}

	if (isC && isF)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	
	return 0;
}


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


int main() {
  int64_t N;
  cin>>N;
  
  int64_t K=0;
  int64_t G=0;
  for(int i=0;i<N;i++){
    int64_t a;
    cin>>a;
    if(a%2==0) G++;
    else K++;
  }
  if(K==1&&G==0){
    cout<<"YES"<<endl;
    return 0;
  }
  if(K%2==1){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
      
  }
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
void printAns(int arr[], int len) {
	using std::cout;
	using std::endl;
	for (int i = 0; i < len; i++)
	{
		if (i)
			cout << " ";
		cout << arr[i];
	}
	cout << endl;
}
int main() {
	int len;
	cin >> len;
	int* arr = new int[len];
	for (int i = 0; i < len; i++)
		cin >> arr[i];
	//insertion sort
	/* for (int i = 0; i < len - 1; i++) {
		printAns(arr, len);
		for (int j = i + 1; j > 0; j--) {
			if (arr[j - 1] > arr[j])
				swap(arr[j - 1], arr[j]);
		}
	}
	printAns(arr, len);*/
	//bubble sort
	/*int step = 0;
	for (int i = 0; i < len - 1; i++) {
		for (int j = len - 1; j > i; j--) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j], arr[j - 1]);
				step++;
			}
		}
	}
	printAns(arr, len);
	cout << step << endl;*/
	//brush sort
	int step = 0;
	for (int i = 0; i < len - 1 ; i++) {
		if (arr[i] > arr[i + 1]) {
			swap(arr[i], arr[i + 1]);
			step++;
		}
		for(int j=i;j>0;j--){
			if (arr[j] < arr[j - 1]) {
				swap(arr[j], arr[j - 1]);
				step++;
			}
		}
	}
	printAns(arr, len);
	cout << step << endl;
	return 0;
}


Measured memory_bytes: 3096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int H, W;
    int N;
    int[] A;
    void Solve() {
        //input
        H = io.Int;
        W = io.Int;
        N = io.Int;
        A = new int[N];
        for (int i = 0; i < N; ++i)
            A[i] = io.Int;
        //cal
        int[,] C = new int[H, W];
        bool rev = false;
        int nowIndex = 0;
        for (int i = 0; i < H; ++i) {
            if (!rev)
                for (int j = 0; j < W; ++j) {
                    if (A[nowIndex] > 0) {
                        C[i, j] = nowIndex + 1;
                    } else {
                        nowIndex++;
                        C[i, j] = nowIndex + 1;
                    }
                    A[nowIndex]--;
                    if (j == W - 1)
                        rev = !rev;
                } 
            else
                for (int j = W - 1; j >= 0; --j) {
                    if (A[nowIndex] > 0) {
                        C[i, j] = nowIndex + 1;
                    } else {
                        nowIndex++;
                        C[i, j] = nowIndex + 1;

                    }
                    A[nowIndex]--;
                    if (j == 0)
                        rev = !rev;
                }
        }
        //ret
        for (int i = 0; i < H;++i){
            for (int j = 0; j < W-1;++j){
                Console.Write(C[i,j]+" ");
            }
            Console.WriteLine(C[i,W-1]);
        }
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  while(cin >> n  >> m){
    TSTART();
    cout << (n-1) * (m-1) << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int Q, H, S, D;
int N;

long long int ans;

void input()
{
	cin >> Q >> H >> S >> D;
	cin >> N;
}

void process()
{
	int value[4] = {Q, H, S, D};
	unsigned int sum = N * 4;
	
	for (int i = 1; i < 4; i++){
		if (value[i - 1] * 2 < value[i]){
			value[i] = value[i - 1] * 2;
		}
	}
	
	ans = (sum / 8);
	ans *= value[3];
	sum %= 8;
	for (int i = 0; sum > 0; i++, sum /= 2){
		if (sum % 2 == 1){
			ans += value[i];
		}
	}
}

void draw()
{
	cout << ans << endl;
}

int main()
{
	input();
	process();
	draw();
	
	return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm(x,y):
  return x*y//math.gcd(x,y)
l=reduce(lcm,a)
b=list(map(lambda x:l//x,a))
m=10**9+7
print(sum(b)%m)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, m;
    cin >> n >> m;
    int a = (m + 1) / 2;
    for (int i = 0; i < a; ++i) {
        cout << i+1 << " " << i+1 + 2*(a-i-1) + 1 << endl;
    }
    for (int i = 0; i < m / 2; ++i) {
        cout << 2*a + 1 + i << " " << 2*a + 1 + i + 2*(m/2-i-1) + 2 << endl;
    }
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
signed main(){
    int N;
    cin>>N;
    int X[N];
    vector<int>c(N);
    REP(i,N){
        cin>>X[i];
        c[i]=X[i];
    }
    sort(c.begin(),c.end());
    int lm=c[N/2-1];
    int rm=c[N/2];
    REP(i,N){
        if(X[i]<=lm)cout<<rm<<endl;
        else cout<<lm<<endl;
    }
}


Measured memory_bytes: 5376
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
const ll mod = 1e9+7;
const ll inf = 1e18;

//

int main(void){
	ll n,m,a,sum=0,ans=0;
	map<ll,ll> s;
	cin>>n>>m;
	rep(i,n){
		cin>>a;
		sum=(sum+a) % m;
		s[sum]++;
	}
	for(auto itr = s.begin(); itr != s.end(); ++itr) {
		ll b = itr->second;
		// printf("%lld,%lld,C:%lld\n",itr->first,b,b*(b-1)/2);
		if(itr->first==0)ans+=b;
		ans+=b*(b-1)/2;
    }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define M 1000000007
#define MM 2000000000000000000
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define r2 1.41421356237
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  int n;
  cin>>n;
  int l=0;
  bool ok=0;
  int a[110]={},b[110]={};
  for(int i=0;i<n;i++) {
  	cin>>a[i]>>b[i];
  }
  for(int i=0;i<n-2;i++) {
  	if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]) { ok=1; break; }
  }
  if(ok) { cout<<"Yes"; }
  else { cout<<"No"; }
  //}
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    lint x = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 2; i < n; ++i) {
        x ^= a[i];
    }
    map<array<lint, 3>, lint> cache;
    function<lint(lint, lint, lint)> dfs = [&](lint a, lint b, lint x) {
        if (((a & 1) ^ (b & 1)) != (x & 1))
            return inf;
        if (a == 1 || a == 0) {
            if ((a ^ b) == x)
                return 0LL;
            else
                return inf;
        }
        lint c = inf, d = inf;
        if (a != 0)
            c = dfs((a - 1) >> 1, (b + 1) >> 1, x >> 1) * 2 + 1;
        d                       = dfs((a) >> 1, (b) >> 1, x >> 1) * 2;
        return cache[{a, b, x}] = min({inf, c, d});
    };
    lint ret = dfs(a[0], a[1], x);
    if (ret == inf)
        cout << -1 << "\n";
    else
        cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3576
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int ans=0;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='p')ans--;
        }
        System.out.println(ans+s.length()/2);
    }
    
    
}

Measured memory_bytes: 24732
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
    LL n,k;cin>>n>>k;
    if(k%2){
        LL m = n/k;
        cout<<m*m*m<<endl;
        return 0;
    }else{
        LL kk = k/2;
        LL m = n/kk;
        //kkの倍数で奇数と偶数を分ける
        if(!kk%2)cout<<m*m*m<<endl;
        else{
            if(m%2){
                LL res = (m/2+1)*(m/2+1)*(m/2+1)+(m/2)*(m/2)*(m/2);
                cout<<res<<endl;
            }else{
                LL res = (m/2)*(m/2)*(m/2)*2;
                cout<<res<<endl;
            }
        }
    }
}
//あっててください


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];

    bool flag = false;
    REP(i, N) if(B[i] < A[i]) flag = true;
    if(flag){
        cout << -1 << endl;
        return 0;
    }
    
    vector<ll> C(N);
    REP(i, N) C[i] = B[i];

    priority_queue<pll> pq;
    REP(i, N){
    	if(B[i] != A[i]) pq.push({B[i], i});
    }

	ll res = 0;
	while(!pq.empty()){
		auto tmp = pq.top();pq.pop();
		ll idx = tmp.second;
		ll sum = C[(idx+1)%N] + C[(idx-1+N)%N];
		ll r = (C[idx] - A[idx])/sum;
		if(r == 0){
			cout << -1 << endl;
            return 0;
		}
		C[idx] -= r*sum;
		if(C[idx] != A[idx]) pq.push({C[idx], idx});
        res += r;
        //cout << C << endl;
	}
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int d;
	cin >> d;
	if (d == 25) {
		cout << "Christmas" << endl;
	} 
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (d == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
}

Measured memory_bytes: 256
{ 80
var
 s:ansistring;
 i,x,y,z,k:longint;
begin
 readln(s);
 for i:=1 to length(s) do
  begin
   if s[i]='W' then x:=1+k;
   if s[i]='N' then z:=1+k;
   if s[i]='E' then y:=1+k;
   if s[i]='S' then k:=1+k;
  end;
 if (x=y) and (y=z) and (z=k) then writeln('Yes') else
  if (x=y) and (z=0) and (k=0) then writeln('Yes') else
   if (x=0) and (y=0) and (k=z) then writeln('Yes') else
     writeln('No');
end.
}
var
 s:ansistring;
 i,x,y,z,k:longint;
begin
 readln(s);
 for i:=1 to length(s) do
  begin
   if s[i]='W' then x:=1;
   if s[i]='N' then z:=1;
   if s[i]='E' then y:=1;
   if s[i]='S' then k:=1;
  end;
 if (x=1) and (y=1) and (z=1) and (k=1) then writeln('Yes') else
  if (x=1) and (y=1) and (z=0) and (k=0) then writeln('Yes') else
   if (x=0) and (y=0) and (z=1) and (k=1) then writeln('Yes') else
    if (x=0) and (y=0) and (z=0) and (k=0) then writeln('Yes') else
     writeln('No');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define RREP(i, n) for(int i=0; i>(int)(n); i--)
#define ALL(v) v.begin(), v.end()
#define INF 1e10
typedef long long ll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;

int h[100001], dp[100001];

int main(void){
	int N, K;
	cin >> N >> K;
	REP(i, N){
		cin >> h[i];
	}
	REP(i, N){
		dp[i] = INF;
	}
	dp[0] = 0;
	REP(i, N){
		REP(k, K){
			chmin(dp[i+k+1], dp[i]+abs(h[i]-h[i+k+1]));
		}
	}
	cout << dp[N-1] << "\n";
	return 0;
}


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


typedef long long int ll;
# define PI 3.14159265358979323846

int main(){
  ll n,m;
  cin>>n>>m;
  vector <ll> a;
  ll sum=0;
  ll i;
  for(i=0;i<m;i++){
    ll x;
    cin>>x;
    a.push_back(x);
    sum+=x;
  }
  if(n>=sum){
    cout<<n-sum<<endl;
  }
  else{
    cout<<-1<<endl;
  }

  return 0;
}


Measured memory_bytes: 3724
N, M = map(int, input().split())
S = list(input())
temp = S[0]
ind = 0
cs = [1]
for i in range(N - 1):
  if S[i] == S[i + 1]:
    cs[ind] += 1
  else:
    cs.append(1)
    ind += 1
    temp = S[i + 1]
#print(cs)
cscs = [cs[0]] + [0] * (len(cs))
for i in range(len(cs) - 1):
  cscs[i + 1] = cscs[i] + cs[i + 1]
cscs = [0] + cscs
css = [cs[0]] + [0] * (len(cs))
for i in range(len(cs) - 1):
  css[i + 1] = css[i] + cs[i + 1] - 1
css = [0] + css
#print(css)
#print(cscs)
res = 0
for i in range(len(css) - 2 * M):
  temp = css[-2] - css[i + 2 * M] + css[max(i, 0)]
  #print(temp,css[-2],css[i + 2 * M],css[max(i - 1, 0)])
  res = max(res, cscs[i + 2 * M] - cscs[i] + temp)
  #print(res - 1, i, i + 2 * M)
if len(css) - 2 <= 2 * M + 1:
  print(N - 1)
else:
  print(res - 1)



Measured memory_bytes: 51340
import math
a, b, x = map(int, input().split())
calc_atan = lambda x: math.degrees(math.atan(x))
if x > a**2*b/2:
  print(calc_atan(2*b/a-2*x/a**3))
else:
  print(calc_atan(a*b**2/2/x))

Measured memory_bytes: 3188
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    string S; cin >> S;
    int Q; cin >> Q;

    bool rev = false;

    string left = "", right = "";

    for (int q = 0; q < Q; q++) {
        int T; cin >> T;
        
        if (T == 1) rev = !rev;

        if (T == 2) {
            int F; string c; cin >> F >> c;
            if((F==1 & !rev) || (F==2 && rev)) left += c;
            if((F==1 & rev) || (F==2 && !rev)) right += c;
        }
    }

    if (rev) {
        reverse(right.begin(), right.end());
        reverse(S.begin(), S.end());
        cout << right << S << left << endl;
    }
    else {
        reverse(left.begin(), left.end());
        cout << left << S << right << endl;
    }
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1088
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

long long int gcd(long long int a, long long int b){
	return (b > 0)? gcd(b, a % b) : a ;
}

int main(void) {
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    for(int i=0; i<N; i++) {
        cin >> x.at(i);
    }
    x.push_back(X);
    sort(x.begin(), x.end());
    adjacent_difference(x.begin(), x.end(), x.begin());
    int ans = x.at(1);
    for(int i=2; i<=N; i++) {
        ans = gcd(ans, x.at(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main(){
	var A, B, C, K int
	fmt.Scan(&A, &B, &C, &K)
	s := []int{A,B,C}
	sort.Ints(s)
	e := len(s)-1
	for i:=0;i<K;i++{
		s[e] *= 2
	}

	res := 0
	for r := range s {
		res += s[r]
	}

	fmt.Println(res)
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

int main(void) {
  int N;
  cin >> N;

  vector<int> L(N);
  REP(i, N) cin >> L[i];

  sort(all(L));

  ll ans = 0;
  for(int i = 0; i < N; i++){
      for(int j = i + 1; j < N; j++){
          auto ite = lower_bound(all(L), L[i] + L[j]) - L.begin();
          ans += ite - 1 - j;
      }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

typedef long long int ll;
#define f first
#define s second
#define Mp make_pair
#define pb push_back
#define ppb pop_back
#define Lb lower_bound
#define Ub upper_bound
#define all(x) x.begin(), x.end()
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll Maxn = 1e5+5, N = 1e6+5, Mod = 1e9+7, Inf = 1e18, Log = 22;
ll Power(ll x, ll t){
    if (t == 0){
        return 1;
    }
    return ((t%2 ? x : 1)*Power((x*x)% Mod, t/2))%Mod;
}
ll n, k, dp[Maxn], ans;
int main(){
    fast_io
    cin >> n >> k;
    for (ll i = k; 1 <= i; i--){
        dp[i] = (Power(k/i, n))%Mod;
        for (ll j = 2*i; j <= k; j += i){
            dp[i] -= dp[j];
            dp[i] += Mod;
            dp[i] %= Mod;
        }
        ans += (dp[i]*i)%Mod;
        ans %= Mod;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4428
#!/usr/bin/env python3
import math
import sys

n = int(input())

a = math.ceil(math.sqrt(n))

ans = sys.maxsize

for i in range(1, a + 1):
    if (n % i) == 0:
        ans = min(ans, max(i, n / i))

print(int(math.log10(ans) + 1))


Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	int res=0;
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) res+=max(0,(int)(i-(upper_bound(a.begin(),a.end(),a[j]-a[i])-a.begin())));
	cout<<res<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <iomanip>
#include <ios>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int n = s.length();
  
  long ans = 0;
  long W = 0;
  
  for(int i=0;i<n;i++){
    if(s[i] == 'W'){
      W++;
      ans += i;
    }
  }
  for(int i=0;i<W;i++){
    ans -= i;
  }
  
  cout << ans << endl;
  
  return 0;
}

    

  
  


Measured memory_bytes: 640
function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0]);
  var b = parseInt(input[1]);

  var num = b - a;
  var result = 0;
  function treeHeight(number) {
    for (var i = 1; i <= number; i++) {
      result += i;
    }
    return result;
  }

  var treeB = treeHeight(num);
  console.log(treeB - b);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define maxs 2020202
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
long long sum[maxs];

int main()
{
    int n;
    long long x;
    while(~scanf("%d",&n)){
        sum[0] = 0;
        for(int i=1;i<=n;i++){
            scanf("%lld",&x);
            sum[i]=sum[i-1]+x;
        }
        long long mis = LONG_LONG_MAX,tmp;
        for(int i=1;i<n;i++){
            tmp = abs(sum[n]-sum[i] - sum[i]);
            if(tmp <mis)
                mis = tmp;
        }
        printf("%lld\n",mis);
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(0 <= b - c){
        printf("delicious");
    }
    else{
        if(a >= c - b)
            printf("safe");
    else{
        printf("dangerous");
    }        
    }
    return 0;
    
}


Measured memory_bytes: 128
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int H = sc.nextInt();
	        int W = sc.nextInt();
	        int[] m = new int[26];
	        for(int i=0;i<H;i++) {
	        	String S =sc.next();
	        	char[] c=S.toCharArray();
	        	for(int j=0;j<W;j++) {
	        		m[c[j]-'a']++;
	        	}
	        }
	        int f1=0;
	        int f2=0;
	        if(H%2==1&&W%2==1) {
	        	f1=H/2+W/2;
	        	f2=1;
	        } else if(H%2==1) {
	        	f1=W/2;
	        } else if(W%2==1) {
	        	f1=H/2;
	        }
	        for(int i=0;i<26;i++) {
	        	if(m[i]%2==1) {
	        		f2--;
	        	}
	        	if(m[i]%4==2) {
	        		f1--;
	        	}
	        }
	        String ans="Yes";
	        if(f1<0||f2<0) {
	        	ans="No";
	        }
	        
	        System.out.println(ans);
	       
	    }

	}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    ll N;
    cin>>N;
    v A(N);
    rep(i,0,N)cin>>A[i];
    sort(all(A));
    cout<<A[A.size()-1]-A[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
if len(s)%2==0:
    for i in range(len(s)):
        if s[i]=='p' and s[-1-i]!='q' or s[i]=='q' and s[-1-i]!='p' or s[i]=='d' and s[-1-i]!='b' or s[i]=='b' and s[-1-i]!='d':
                print('No')
                break
    else:
        print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
import java.util.*;

class Main{
	public static void main(String[] args){
		int a;
		int b;
		
		Scanner cin = new Scanner(System.in);
		a=cin.nextInt();
		b=cin.nextInt();
		
		if(a>b){
			System.out.println("a > b");
		}else if(a<b){
			System.out.println("a < b");
		}else{
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26120
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Thu Apr 26 11:01:25 2018
//
package main

import (
	"fmt"
	"sort"
)

var N, K int
var A []int

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

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

func main() {
	fmt.Scan(&N, &K)

	A = make([]int, N)
	for i := range A {
		fmt.Scan(&A[i])
	}

	sort.Ints(A)
	max := A[len(A)-1]
	if max < K {
		fmt.Println("IMPOSSIBLE")
		return
	}

	if N == 1 {
		if A[0] == K {
			fmt.Println("POSSIBLE")
			return
		}
		fmt.Println("IMPOSSIBLE")
		return
	}

	g := gcd(A[0], A[1])
	for i := 2; i < len(A)-1; i++ {
		g = gcd(g, A[i])
	}
	if K%g == 0 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 5504