akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void solve()
{
    auto abcd = readln.split.to!(long[]);
    auto A = abcd[0];
    auto B = abcd[1];
    auto C = abcd[2];
    auto D = abcd[3];

    if (A < B || D < B) {
        writeln("No");
        return;
    }
    if (C >= B) {
        writeln("Yes");
        return;
    }
    auto g = gcd(B, D);
    writeln(A%g + B-g > C ? "No" : "Yes");
}

void main()
{
    auto T = readln.chomp.to!int;
    foreach (_; 0..T) solve();
}

Measured memory_bytes: 380
fun main(arg: Array<String>) {
    var (X, Y, A, B, C) = listOfInt()
    val P = listOfLong().sortedDescending()
    val Q = listOfLong().sortedDescending()
    val R = listOfLong().toMutableList()
    R.addAll(P.subList(0, X))
    R.addAll(Q.subList(0, Y))
    R.sortDescending()
    var ans = R.subList(0, X + Y).sum()
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)


Measured memory_bytes: 103852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int S = sc.nextInt();

		int h, m, s;

		h = S / 3600;
		m = S / 60 % 60;
		s = S % 60;

		System.out.println(h + ":" + m + ":" + s);

		sc.close();

	}

}



Measured memory_bytes: 26424
while True :
    H, W = [int(temp) for temp in input().split()]
    
    if H == W == 0 :
        break
    
    for making in range(H):
        if making == 0 or making == (H - 1) : print('#' * W)
        else                                : print('#' + ('.' * (W - 2)) + '#')

    print()

Measured memory_bytes: 7612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n;cin>>n;
	ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll c=a[0];ll s=0;ll ans=0;
    for(int i=1;i<n;i++){
        if(a[i]<=c){
            s++;c=a[i];
        }else{
            c=a[i];s=0;
        }
        ans=max(ans,s);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
int mx[100010];
int main(){
    int n,t;cin >> n >> t;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=n-1;i>=0;i--){
        mx[i]=max(mx[i+1],a[i]);
    }
    int cnt=0;
    vector<int> num;
    for(int i=0;i<n;i++){
        if(a[i]<mx[i+1]) num.push_back(mx[i+1]-a[i]);
    }
    sort(num.rbegin(),num.rend());
    int ans=1;
    int x=num[0];
    for(int i=1;i<(int)num.size();i++){
        if(num[i]==x) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << ' ' << (a + b) * 2 << endl;
}


Measured memory_bytes: 3092
N, A, B = map(int, input().split())
if A==1 and B==A+1:
    print('Borys')
else:
    if (B-A)%2 == 0:
        print('Alice')
    elif (B-A)%2 == 1:
        print('Borys')
    else:
        print('Draw')

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  int n;
  cin >> n >> s;
  auto f = [](string s, string t) {
    int r = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      bool ok1 = false, ok2 = false;
      for (char &d : s) if (c == d) ok1 = true;
      for (char &d : t) if (c == d) ok2 = true;
      if (ok1 && ok2) r++;
    }
    return r;
  };
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    ans = max(ans, f(s.substr(0, i), s.substr(i, s.size())));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int selectionsort(vector<int> &A,int n){
  int minj,i,j,cnt = 0;
  for(i=0;i<n-1;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(A[i]!=A[minj])cnt++;
    swap(A[i],A[minj]);
  }
  return cnt;
}

int main(){
  vector<int>a;
  int n,cnt,i;
  cin>>n;
  for (i=0;i<n;i++){
    cin>>cnt;
    a.push_back(cnt);
  }
  cnt=selectionsort(a,n);
  for(i=0;i<n-1;i++)
    cout<<a[i]<<" ";
  cout<<a[i]<<endl<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3164
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    ll ans = 1;
    int left = 0;
    rep(i, 2 * N) {
        if (S[i] == 'B' ^ (i % 2)) {
            left++;
        }
        else {
            ans = ans * left % MOD;
            left--;
        }
    }

    ll fact = 1;
    rep(i, N) fact = fact * (i + 1) % MOD;

    write(left ? 0 : ans * fact % MOD);
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
const int maxn=1e5+5;
using namespace std;
int L;
double ans;
inline int read() {
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9')
		f = (ch == '-' ? -1 : 1), ch = getchar();
	while (ch >= '0' && ch <= '9')
		x = x * 10 + ch - 48, ch = getchar();
	return x * f;
}
int main() {
	cin>>L;
    double aver=L/3.0;
	cout<<setprecision(12)<<fixed<<aver*aver*aver;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key; //unsigned : 正の数しか入らない。int の約二倍増える。8ビットの場合、最初のビットで正負に使われない。
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer cur;

  cur = nil->next;  //番兵(nil)の次の要素(先頭の要素)から辿る。
  while(cur != nil && cur->key != key){
    cur = cur->next;  //リストの一番最後の要素のnextはnilだから、最後は必ずnilになる。
  }
  return cur;  //nil か key の node が return される。
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil) return; //tが番兵(nil)の場合は処理をしない。
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  /*NodePointer t = nil->next;
    if ( t == nil ) return;*/
  deleteNode(nil->next);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  /* your code */  /*番兵(nil)の直後に要素を追加。*/
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32948
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""

input:
5 4
0 1
1 2
2 3
3 4

output:
1
2
3
"""

import sys

sys.setrecursionlimit(int(1e6))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        source, target = map(int, v_detail)
        init_adj_table[source].append(target)
        init_adj_table[target].append(source)
    return init_adj_table


def Tarjan(current, parents, visited, disc, low):
    global timer
    current_children_count = 0
    visited[current] = True
    disc[current] = low[current] = timer
    timer += 1

    for adj in adj_table[current]:
        if not visited[adj]:
            parents[adj] = current
            current_children_count += 1

            Tarjan(adj, parents, visited, disc, low)

            low[current] = min(low[current], low[adj])
            # current is root of DFS tree
            if parents[current] == -1 and current_children_count > 1:
                art_set.add(current)

            elif parents[current] != -1 and low[adj] >= disc[current]:
                art_set.add(current)

        elif adj != parents[current]:
            low[current] = min(low[current], disc[adj])

    # print(timer, parents, visited, disc, low)
    return None


def art_points():
    parents = [-1] * vertices
    visited = [False] * vertices
    disc = [float('inf')] * vertices
    low = [float('inf')] * vertices

    for v in range(vertices):
        Tarjan(v, parents, visited, disc, low)

    return art_set


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])
    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    timer = 0
    art_set = set()
    ans = art_points()
    if ans:
        print(*sorted(ans), sep='\n')

Measured memory_bytes: 23884
from scipy.sparse import*
e=enumerate
_,*s=open(0)
r=s+['#'*20]
*g,=eval('[0]*500,'*500)
for i,t in e(s):
 for j,u in e(t):k=i*20+j;g[k][k+1]=u>'#'<t[j+1];g[k][k+20]=u>'#'<r[i+1][j]
a=csgraph.johnson(csr_matrix(g),0)
print(int(max(a[a<999])))

Measured memory_bytes: 19344
//わからなかった

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int n, k;
  cin >> n >> k;
  if (n % k == 0) cout << 0 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 3560
<?php

while ($n = trim(fgets(STDIN))) {
	$data = array();
	for ($i = 0; $i < $n; $i++) {
		$data[] = trim(fgets(STDIN));
	}

	// ソート
	$sorted = $n;
	$count = 0;
	while ($sorted > 1) {
		for ($j = 0; $j < $sorted - 1; $j++) {
			$a = $data[$j];
			$b = $data[$j + 1];
			if ($a > $b) {
				$data[$j + 1] = $a;
				$data[$j] = $b;
				$count++;
			}
		}
		$sorted--;
	}
	echo $count . "\n";
}

Measured memory_bytes: 6592
import sys

X, N = map(int, sys.stdin.readline().strip().split())
P = set(map(int, sys.stdin.readline().strip().split()))

ans = X
ans_v = X
for i in range(102):
    if i in P:
        continue
    tmp = abs(X - i)
    if tmp < ans or (tmp == ans and i < ans_v):
        ans_v = i
        ans = tmp
        # print(ans, ans_v)
print(ans_v)

Measured memory_bytes: 9124
fun main() {
    val (l, r, d) = nextIntList()
    println(r.div(d).minus(l.minus(1).div(d)))
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);

}

class Solve {
public:
    void solve() {
//        string s;
//        cin >> s;
//        for (auto e : s) {
//            if (e == '7') {
//                cout << "Yes" << endl;
//                return;
//            }
//        }
//        cout << "No" << endl;

//        Int N;
//        cin >> N;
//        Int ans = N * (N + 1) / 2;
//        Int dec3 = (N / 3) * (N / 3 + 1) / 2 * 3;
//        Int dec5 = (N / 5) * (N / 5 + 1) / 2 * 5;
//        Int add15 = (N / 15) * (N / 15 + 1) / 2 * 15;
//        ans -= dec3;
//        ans -= dec5;
//        ans += add15;
//
//        cout << ans << endl;

        Int K;
        cin >> K;

        Int ans = 0;
        rep(i, 1, K + 1) {
            rep(j, 1, K + 1) {
                rep(k, 1, K + 1) {
                    Int d = gcd(gcd(i, j), k);
                    ans += d;
                }
            }
        }
        cout << ans << endl;


    }
};


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

    Solve().solve();


    return 0;
}


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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	string s;
	cin >> s;
	for(int i=0;i<s.length();i++)
		if(s[i] != ',')
			cout << s[i];
		else cout << " ";
	cout << "\n";	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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



int main() {

	ll N, M;

	cin >> N >> M;

	vector<ll> g[MAX];

	ll u, v;
	repn(i, M) {
		cin >> u >> v;
		g[u].push_back(N + v);
		g[N + u].push_back(2 * N + v);
		g[2 * N + u].push_back(v);
	}

	ll S, T;
	cin >> S >> T;

	queue<int> q;

	ll dis[MAX];

	repn(i, 3*N) dis[i] = -3;

	dis[S] = 0;

	q.push(S);

	while (!q.empty()) {
		ll w = q.front();
		rep(i, g[w].size()) {
			ll u = g[w][i];
			if (dis[u] == -3) {
				dis[u] = dis[w] + 1;
				q.push(u);
			}
		}

		q.pop();
	}

	cout << dis[T]/3;

	system("PAUSE");


}


Measured memory_bytes: 36984
s = input()
if (s =="SUN"):
    print(7)
elif (s =="MON"):
    print(6)
elif (s =="TUE"):
    print(5)
elif (s =="WED"):
    print(4)
elif (s =="THU"):
    print(3)
elif (s =="FRI"):
    print(2)
elif (s =="SAT"):
    print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    for (int i = 1; i <= 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#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(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = a+b, r = c+d;
	if(l > r)
		cout << "Left" << endl;
	else if(l < r)
		cout << "Right" << endl;
	else
		cout << "Balanced" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int s,w;
void solve(){
if(w>=s){
    cout<<"unsafe"<<endl;
}else{
    cout<<"safe"<<endl;
}
}

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

    solve();
    return 0;
}


Measured memory_bytes: 3620
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0
for i in range(N-1):
    for j in range(i+1, N-1):
        idx = bisect.bisect_left(L, L[i]+L[j])
        ans += max(0, idx-j-1)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <random>
#include <cstring>

using namespace std;

#ifdef LOCAL
#define fre() freopen("in", "r", stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

#define IOS std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define repi(a,b) for(int i=a;i<b;i++)
#define repj(a,b) for(int j=a;j<b;j++)
#define mst(a,b) memset(a,b,sizeof(a))

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;


int main() {
    int n;cin>>n;
    int l = n/100, r = n%100;
    if(l*5>=r)cout<<"1\n";
    else cout<<"0\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define mod 1000000007
long long mul(long long a,int b)
{
	return ((a%mod)*(b%mod))%mod;
}
long long bp[40];
long long sub(long long a,long long b)
{
	return (a+mod-b)%mod;
}
long long binpow(long long a, long long p){
  bp[0] = 1;
  bp[1] = a;
  for(int i = 2; i < 40; ++i){
    bp[i] = (bp[i - 1] * bp[i - 1]) % mod;
  }
  int d = 1;
  long long res = 1;

  while(p){
    if(p & 1){
      res = (res * bp[d]) % mod;
    }
    d++;
    p = p >> 1;
  }

  return res;
}
long long fc[100001];
long long divi(long long a,long long b)
{
	return mul(a, binpow(b, mod-2));
}
void calcfc()
{
	int i;
	fc[0]=1;
	fc[1]=1;
	for(i=1;i<=100000;i++)
		fc[i+1]=fc[i]*(i+1)%mod;
}
long long cmb(int n,int r)
{
	return divi(fc[n],mul(fc[r],fc[n-r]));
}

int main()
{
	int n,i,j,k;
	long long Q;
	int N[100001];
	scanf("%d",&n);
	calcfc();
	for(i=0;i<n+1;i++){
		scanf("%d",&N[i]);
	}
	for(j=0;j<n;j++){
		for(k=j+1;k<n;k++){
			if(N[j]==N[k]){
				break;
			}
		}
		if(N[j]==N[k]){
			break;
		}
	}
	for(i=1;i<=n+1;i++){
		if(i-1>(j+n-k))
			Q=0;
		else
			Q=cmb((j+n-k),i-1);
		printf("%lld\n",sub(cmb(n+1,i),Q));
	}
}


Measured memory_bytes: 2432
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#include <math.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 105;
const ll mod = 1e9+7;
const int lim = 1e5;

mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll l, ll r) {
    return (mt_rnd_64() % (r-l+1)) + l;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, d;
	cin >> n >> d;
	cout << n/(2*d+1) + bool (n%(2*d+1));
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations
from collections import deque

w, h = map(int, input().split())
mp = ["X" * (w + 4)] * 2 + ["XX" + input() + "XX" for _ in range(h)] + ["X" * (w + 4)] * 2
m_lst = []
holes = []
for y in range(2, h + 2):
  for x in range(2, w + 2):
    if mp[y][x] == "S":
      sx, sy = x, y
    if mp[y][x] == "G":
      gx, gy = x, y
    if mp[y][x] == "M":
      m_lst.append((x, y))
    if mp[y][x] == "#":
      holes.append((x, y))

move_costs = [[1] * (w + 4) for _ in range(h + 4)]
for x, y in holes:
  for ny in range(y - 2, y + 3):
    for nx in range(x - 2, x + 3):
      move_costs[ny][nx] = max(2, move_costs[ny][nx])

  for ny in range(y - 1, y + 2):
    for nx in range(x - 1, x + 2):
      move_costs[ny][nx] = 3

def shortest(x1, y1):
  INF = 10 ** 20
  vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
  costs = [[INF] * (w + 4) for _ in range(h + 4)]
  costs[y1][x1] = 0
  que = deque()
  que.append((0, x1, y1))
  while que:
    score, x, y = que.popleft()
    new_score = score + move_costs[y][x]
    for dx, dy in vec:
      nx, ny = x + dx, y + dy
      if mp[ny][nx] in {"S", "G", ".", "M"} and new_score < costs[ny][nx]:
        costs[ny][nx] = new_score
        que.append((new_score, nx, ny))
  return costs

edges = []
for x, y in m_lst:
  costs = shortest(x, y)
  edge = []
  for x2, y2 in m_lst:
    edge.append(costs[y2][x2])
  edge.append(costs[gy][gx])
  edges.append(edge)

start_cost = shortest(sx, sy)
goal_cost = shortest(gx, gy)
ans = 10 ** 20
for t in permutations(range(len(edges)), len(edges)):
  lst = list(t)
  score = 0
  for i in range(len(edges) - 1):
    score += edges[lst[i]][lst[i + 1]]
  xs, ys = m_lst[lst[0]]
  xf, yf = m_lst[lst[-1]]
  score += start_cost[ys][xs]
  score += edges[lst[-1]][-1]
  ans = min(ans, score)

print(ans)


Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

	const ll mod = 1000000007;
	ll n; cin >> n;
	string s, t; cin >> s >> t;
	ll ans = 1;
	ll i = 0;
	bool preOneFlag;
	if (s[i] == t[i]) {
		ans *= 3;
		preOneFlag = true;
		i++;
	}
	else {
		ans *= 6;
		preOneFlag = false;
		i += 2;
	}
	for ( ; i < s.size(); ) {
		if (preOneFlag) {
			if (s[i] == t[i]) {
				ans *= 2;
				preOneFlag = true;
				i++;
			}
			else {
				ans *= 2;
				preOneFlag = false;
				i += 2;
			}
		}
		else { // 上下別れている
			if (s[i] == t[i]) {
				ans *= 1;
				preOneFlag = true;
				i++;
			}
			else {
				ans *= 3;
				preOneFlag = false;
				i += 2;
			}
		}
		ans %= mod;
	}	
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n;
ll w[110];
ll mem_sum;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        mem_sum += w[i];
    }


    ll ans = LL_INF;
    ll mem = 0;
    for(int i = 0; i < n; i++){
        mem += w[i];
        if(ans > abs(mem_sum - 2*mem))   ans = abs(mem_sum - 2*mem);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
require 'pp'
require 'prime'
require 'set'

N=gets.chomp.split(' ').map{|n| n.to_i}.first

if Prime.prime?(N)
  puts N-1
  exit
end

a=0
b=0

mini = 1_000_000_000_000_0
source = Math.sqrt(N).to_i+1
1.upto(source) do |n|
  next if N%n!=0
  a=n
  b=N/n
  if ((a-1 + b-1) < mini)
    mini = a-1 + b-1
  end
end

puts mini

Measured memory_bytes: 2684
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;
void enqueue(P);
P dequeue();
void initialize(void);

void initialize(){
  head = 1;
 tail = n+1;
}

void enqueue(P x){
  Q[tail] = x;
  if (tail + 1 == LEN){
          tail=1;
  }
  else{
    tail++;
}
}

P dequeue(){
  P x;
  x = Q[head];
    if(head + 1 == LEN){
      head = 1;
}
    else{
      head++;
}
  return x;
}

int main(){
  int elaps = 0, c=0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  initialize();

  while(c!=n){
    if(Q[head].t>q){
      elaps+=q;
      Q[head].t-=q;
      enqueue(Q[head]);
      u=dequeue();
}

    else if(Q[head].t<=q){
      elaps+=Q[head].t;
      Q[head].t-=q;
      u=dequeue();
      printf("%s %d\n",u.name,elaps);
      c++;
}
}


  return 0;
}






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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n;
  cin >> n;
  int T, A;
  cin >> T >> A;

  vector<int> H(n);
  for (int &x : H) {
    cin >> x;
  }

  int ret = 0;
  double min_diff = 10000000;
  for (int i = 0; i < n; i++) {
    double temp = T - H.at(i) * 0.006;
    double diff = A - temp;
    if (diff < 0) {
      diff = -diff;
    }

    if (diff < min_diff) {
      min_diff = diff;
      ret = i;
    }
  }
  cout << ++ret << endl;
}


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

lint gcd(lint i,lint j){
    if(i < j)swap(i,j);
    while( j != 0 ){
        i %= j;
        swap(i,j);
    }
    return i;
}

void factrialzation (lint n, map<lint,lint> &expo){
    for( lint i = 2; i * i <= n; i++ ){
        while( n%i == 0 ){
            expo[i]++;
            n /= i;
        }
    }
    if( n != 1 )expo[n]++;
    return;
}

int main(){
    lint N,K; cin >> N >> K;
    lint C = gcd(N,K);
    map<lint,lint> expo;
    factrialzation(C,expo);
    lint ans = 1;
    ans += expo.size();
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include "limits.h"
#include <limits>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename H,typename... T>
void debug_out(H head,T... tail){
  std::cerr<<" "<<head;
  debug_out(tail...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long,long long>;

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<ll> d(n);
  rep(i,0,n)std::cin>>d[i];

  std::vector<std::vector<P>> graph(n);

  rep(i,0,m){
    ll u,v;
    std::cin>>u>>v;
    u--;v--;
    graph[u].push_back({v,i});
    graph[v].push_back({u,i});
  }

  rep(i,0,n){
    bool isok=false;
    for(auto e:graph[i])if(d[i]>=d[e.first])isok=true;
    if(!isok){
      std::cout<<-1<<"\n";
      return 0;
    }
  }

  std::vector<ll> cost(m,1e9);

  std::vector<ll> col(n,-1);

  auto dfs=[&](auto f,ll now,ll par)->void{
    if(col[now]!=-1)return;
    ll min=MOD,next=MOD,edge=MOD;
    for(auto e:graph[now]){
      if(d[e.first]<min){
        min=d[e.first];
        next=e.first;
        edge=e.second;
      }else if(d[e.first]==min&&e.first<next){
        next=e.first;
        edge=e.second;
      }
    }
    if(next==par){
      col[now]=0;
      cost[edge]=d[now];
    }else{
      f(f,next,now);
      col[now]=col[next]^1;
      cost[edge]=d[now];
    }
  };

  rep(i,0,n)dfs(dfs,i,-1);

  rep(i,0,n)std::cout<<((col[i]==0)?'W':'B');
  std::cout<<"\n";

  rep(i,0,m)std::cout<<cost[i]<<"\n";

  return 0;
}

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

int main() {
	int n;

	//入力
	cin >> n;
	vector<ll> a(n);
	rep(i,n) {
		cin >> a[i];
	}

	//
	int ans = 0;
	rep(i, n) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			++ans;
		}
	}

	//答え
	std::cout << ans << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <algorithm>
using namespace std;

typedef unsigned long long ll;

int n;
int a[100];
ll dp[100][21]; //dp[idx][sum]

ll rec(int idx, int sum)
{
    if(dp[idx][sum] != -1) {
        return dp[idx][sum];
    }
    
    ll ret = 0;
    if(sum + a[idx] <= 20) {
        ret += rec(idx + 1, sum + a[idx]);
    }
    if(sum - a[idx] >= 0) {
        ret += rec(idx + 1, sum - a[idx]);
    }

    return (dp[idx][sum] = ret);
}

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

    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < 21; j++) {
            if(i == n - 1 && j == a[n - 1]) {
                dp[i][j] = 1;
            } else {
                dp[i][j] = -1;
            }
        }
    }

    if(n == 100) {
        cout << rec(0, 0) / 2 << endl;
    } else {
        cout << rec(0, 0) << endl;
    }
}

Measured memory_bytes: 0
N = int(input())
S=[]
for i in range(N):
    s =list(input())
    S.append(s)
num=0
for a in range(N):
    t =1
    flag = True
    for i in range(N):
        if not flag:
            break
        for j in range(N):
            if i==j:
                continue
            #x = (i+a)%N
            #y=j
            if S[(j+a)%N][i]!=S[(i+a)%N][j]:
                t=0
                flag=False
                break
    if t:
        num+=1
print(N*num)



Measured memory_bytes: 44892
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long K = sc.nextLong();
		
		long[] A = new long[N];
		long sum = 0;
		
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			sum += A[i];
		}
		
		int numBinDigits = getMostSignificantBit(K);
		long[] netGainForDigit = new long[numBinDigits];
		
		for (int i = 0; i < numBinDigits; i++) {
			int oneCount = 0;
			int zeroCount = 0;
			for (int j = 0; j < N; j++) {
				if (getBitAt(A[j], i+1)) {
					oneCount++;
				} else {
					zeroCount++;
				}
			}
			int netChange = zeroCount - oneCount;
			netGainForDigit[i] = netChange * pow(2, i);
		}
		
		/*
		System.out.println("NetGains:");
		for (long n : netGainForDigit) {
			System.out.print(n + " ");
		}
		System.out.println();
		*/
		
		System.out.println(sum+getMax(K, netGainForDigit, numBinDigits-1, 0, 0));
	}
	
	public static long getMax(long K, long[] netGainForDigit, int digit, long curValue, long max) {
		if (digit < 0) {
			return max;
		}
		if (netGainForDigit[digit] > 0 && curValue + pow(2, digit) <= K) {
			if (curValue + pow(2, digit+1) <= K) {
				return getMax(K, netGainForDigit, digit-1, curValue + pow(2, digit), max + netGainForDigit[digit]);
			} else {
				return Math.max(getMax(K, netGainForDigit, digit-1, curValue + pow(2, digit), max + netGainForDigit[digit]), 
				getMax(K, netGainForDigit, digit-1, curValue, max));
			}
		} else {
			return getMax(K, netGainForDigit, digit-1, curValue, max);
		}
	}
	
	public static long pow(int a, int b) {
		long product = 1;
		for (int i = 0; i < b; i++) {
			product *= a;
		}
		return product;
	}
	
	public static boolean getBitAt(long A, int digit) {
		if (digit == 1 || A == 0) {
			return A%2 == 1;
		}
		return getBitAt(A/2, digit-1);
	}
	
	public static int getMostSignificantBit(long K) {
		if (K <= 1) {
			return 1;
		}
		return 1+getMostSignificantBit(K/2);
	}
}


Measured memory_bytes: 50668
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: i64 = 1e+9 as i64 + 7;
fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut xseq = vec![0; n];
    let mut yseq = vec![0; m];
    for i in 0..n {
        xseq[i] = read::<i64>();
    }
    for i in 0..m {
        yseq[i] = read::<i64>();
    }
    let mut w = 0;
    for i in 1..n {
        w = (w + i as i64 * (n - i) as i64 % MOD * (xseq[i] - xseq[i - 1])) % MOD
    }
    let mut h = 0;
    for i in 1..m {
        h = (h + i as i64 * (m - i) as i64 % MOD * (yseq[i] - yseq[i - 1])) % MOD
    }
    let ans = w * h % MOD;
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <stdio.h>

int main(void) {
	int H, W, i, j;
	while(1){
		scanf("%d %d", &H, &W);
		if((H==0)&&(W==0)){
			break;
		}
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				if((i%2==0)&&(j%2==0)||((i+1)%2==0)&&((j+1)%2==0)){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007

int main(){
    ll n,k;
    cin>>n>>k;
    ll t=n%k;
    cout<<min(t,abs(t-k))<<endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import Text.Printf

main = do
    n <- readLn :: IO Int
    ss <- replicateM n getLine
    let lst = map (\l->(l!!0,l!!1)) $ map (\s->map (\x->read x::Int) $ words s) ss
    let maxnum = snd $ last $ sortBy (\x y->compare (snd x) (snd y)) lst
    let minid = fst $ head $ sortBy (\x y->compare (fst x) (fst y)) $ filter (\i->(snd i)==maxnum) lst
    printf "%d %d\n" minid maxnum

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n){
    int a;
    cin >> a;
    if(i%2==0 && a%2==1) ans ++;
  }
  cout << ans << endl;
}

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

int main(void){
	int n, tmp, done = 0;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> tmp;
		a.push_back(tmp);
	}
	while(true){
		for (int i = 0; i < a.size(); ++i){
			if (a[i] % 2 != 0){
				cout << done << endl;
				return 0;
			}
		}
		done++;
		for (int i = 0; i < a.size(); ++i){
			a[i] = a[i] / 2;
		}
	}
}

Measured memory_bytes: 256
import sys
from decimal import Decimal
a, b = map(Decimal, input().split())

b *= 100
a = int(a)
b = int(b)
if list(str(int(a * b)))[:-2]:
    [sys.stdout.write(i) for i in list(str(int(a * b)))[:-2]]
    print("")
else:
    print(0)

Measured memory_bytes: 71396
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int tv[31][200005];

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

    rep(i, n){
        int s, t, ch;
        cin >> s >> t >> ch;
        ch--;
        tv[ch][2*s-1]++;
        tv[ch][2*t]--;
    }

    vector<int> s(200005);

    rep(i, c){
        rep(j, 200005){
            tv[i][j+1] += tv[i][j];
        }
        rep(j, s.size()){
            if(tv[i][j] != 0) s[j]++;
        }
    }

    int ans = 0;
    rep(i, s.size()) ans = max(ans, s[i]);

    cout << ans << endl;
}

Measured memory_bytes: 24448
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, k, a[MAXN];

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n >> k;
	int g = 0;
	rep(i, 1, n) {
		cin >> a[i];
		g = __gcd(g, a[i]);
		if(a[i] == k) {
			cout << "POSSIBLE";
			return 0;
		}
	}
	if(k > *max_element(a + 1, a + 1+ n)) {
		cout << "IMPOSSIBLE\n";
		return 0;
	}
	rep(i, 1, n) {
		if(a[i] > k && (a[i] - k) % g == 0) {
			cout << "POSSIBLE\n";
			return 0;
		}	
	}
	cout << "IMPOSSIBLE\n";
	
	return 0;
}

Measured memory_bytes: 640
N = int(input())
S = sorted([int(input()) for _ in range(N)])
flg = 0
if sum(S) % 10 != 0:
	print(sum(S))
	flg = 1
else:
	for i in S:
		if i % 10 == 0:
			pass
		else:
			print(sum(S) - i)
			flg = 1
			break
if flg == 0:
	print(0)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    
    System.out.println(Math.min(A, B) + Math.min(C, D));
  }
}

Measured memory_bytes: 23764
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   C : Integer;
begin
   Get (A);
   Get (B);
   Get (C);
   if A < B then
      if C < A then
         Put_Line ("No");
      elsif C > B then
         Put_Line ("No");
      else
         Put_Line ("Yes");
      end if;
   else
      if C > A then
         Put_Line ("No");
      elsif C < B then
         Put_Line ("No");
      else
         Put_Line ("Yes");
      end if;
   end if;
end Solve;

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

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

  int K, A, B; cin >> K >> A >> B;

  string ans = "NG";
  for (int i = K; i <= B; i += K) {
    if (i >= A) ans = "OK";
  }
  
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <tuple>
#define ll long long
using namespace std;


vector<int> divs[111111];

ll Sumit(ll N, ll low,ll high) {
    
    // N/low+N/low+1+....
    
    ll curr = low;
    
    ll ans = 0;
    
    while(curr <= high) {
        
        ll val = N/curr;
        
        if (val == 0)
            break;
        
        // N/x >= val
        
        // x <= N/val
        
        ll up = min(high,N/val);
        
        
        ans += (up-curr+1)*val;
        
        curr = up+1;
        
    }
    
    return ans;
    
    
    
}


ll BruteForce(ll N,ll K) {
    int ans=0;
    for(int a=1;a<=N;a++) {
        for(int b=1;b<=N;b++)
            if (a%b>=K)
                ans++;
    }
    return ans;
}

int main() {
    int N,K;
    cin>>N>>K;
    
    // (a%b) >= K
    // a = b*x+K
    // where b >= K+1
    ll ans = 0;
    
    for(int k=K;k<=N;k++) {
        
        // b >= k+1
        
        // b*x+k
        
        
        // (k+1)*x+k,(k+2)*x+k
        // k,(2*k+1),(2*k+2),...,
        
        // x=0,1,...,(N-k)/b
        
        // (N-k)/b+1
        
        
        ans += N-k;
        
        
        ans += Sumit(N-k,k+1,N);
        
        
        //for(int b=k+1;b<=N;b++)
          //  ans += (N-k)/b;
        
        
        
        
        
        
    }
    
    cout << ans-(K==0?N:0) << endl;
    //cout << BruteForce(N,K) << endl;

}

Measured memory_bytes: 2816
#include<cstdio>
#include<algorithm>
#define maxn 200005
#define D 20
#define INF 2147483647
using namespace std;
int n,v,x[maxn],vis[maxn],maxv[maxn],cnt[D],l[D][maxn],r[D][maxn],f1[maxn*5],f2[maxn*5],ans[maxn];
int upfind(int i,int pos)
{
	pos++;
	int p=upper_bound(l[i]+1,l[i]+cnt[i]+1,pos)-l[i]-1;
	if(p<=0) return pos;
	return max(r[i][p],pos-1);
}
int lowfind(int i,int pos)
{
	pos--;
	int p=lower_bound(r[i]+1,r[i]+cnt[i]+1,pos)-r[i];
	if(p>cnt[i]) return pos;
	return min(l[i][p],pos+1);
}
int main()
{
	scanf("%d%d",&n,&v);
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	x[0]=-INF,x[n+1]=INF;
	int log2;
	for(log2=0;(1<<log2)<=v;log2++);
	for(int lg=0;lg<=log2;lg++)
	{
		int d=v/(1<<lg);
		cnt[lg]=l[lg][1]=1;
		for(int i=1;i<=n;i++)
		{
			r[lg][cnt[lg]]=i;
			if(x[i+1]-x[i]>d) l[lg][++cnt[lg]]=i+1;
		}
		cnt[lg]--;
	}
	if(cnt[0]>log2+1)
	{
		for(int i=1;i<=n;i++) printf("Impossible\n");
		return 0;
	}
	int S=(1<<(log2+1));
	for(int s=0;s<S;s++) f1[s]=0,f2[s]=INF;
	f2[0]=n+1;
	for(int s=0;s<S;s+=2)
		for(int i=0;i<=log2;i++)
		{
			if(!(s&(1<<i))) continue;
			f1[s]=max(f1[s],upfind(i,f1[s-(1<<i)]));
			f2[s]=min(f2[s],lowfind(i,f2[s-(1<<i)]));
		}
	for(int i=1;i<=cnt[0];i++)
	{
		int ln=l[0][i],rn=r[0][i];
		for(int s1=0;s1<S;s1+=2)
		{
			int s2=S-s1-2;
			int lp=f1[s1],rp=f2[s2];
			if(lp>=ln-1&&rp<=rn+1) { ans[i]=true; break; }
		}
	}
	for(int i=1,pos=1;i<=n;i++)
	{
		printf("%s\n",ans[pos]?"Possible":"Impossible");
		if(x[i+1]-x[i]>v) pos++;
	}
}

Measured memory_bytes: 43264
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        if (a < 6) {
            System.out.println(0);
        } else if (a <= 12) {
            System.out.println(b / 2);
        } else  {
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 21844
function memoization(f) {
  const cache = {};
  return (...param) => {
    const c = cache[param];
    return typeof c === 'undefined' ? cache[param] = f(...param) : c;
  };
}

class _Node {
  constructor(id, parentId, leftId, rightId) {
    this.id = id;
    this.parentId = parentId;
    this.leftId = leftId;
    this.rightId = rightId;
  }
  get type() {
    return this.parentId === -1
        ? 'root'
        : this.leftId === -1 && this.rightId === -1
            ? 'leaf'
            : 'internal node'}
}

class BinaryTree {
  constructor() {
    this.nodes = [];
    this._nodeInfo = [];
    this.getDepth = memoization(this.getDepth.bind(this));
    this.getHeight = memoization(this.getHeight.bind(this));
  }
  static get Node() {return _Node;}

  add(id, leftId, rightId) {this.nodes[id] = new BinaryTree.Node(id, -1, leftId, rightId);}

  connect() {
    for (let i = 0; i < this.nodes.length; i++ ) this._nodeInfo[i] = {node:null, sibling:-1, degree:0};
    this.nodes.forEach(n => {
      if (n.leftId !== -1) {
        this.nodes[n.leftId].parentId = n.id;
        this._nodeInfo[n.leftId].sibling = n.rightId;
      }
      if (n.rightId !== -1) {
        this.nodes[n.rightId].parentId = n.id;
        this._nodeInfo[n.rightId].sibling = n.leftId;
      }
    });
    this.nodes.forEach(n => {
      this._nodeInfo[n.id] = {sibling: this._nodeInfo[n.id].sibling, node: n, degree: (n.leftId !== -1) + (n.rightId !== -1)}
    });
  }

  getDepth(id, i = 0) {
    let pid = this.find(id).parentId;
    return pid === -1 ? i : this.getDepth(pid, i + 1);
  }

  getHeight(id, i = 0) {
    if (id === -1) return i - 1;
    let n = this.find(id);
    let [lid, rid] = [n.leftId, n.rightId];
    return Math.max(this.getHeight(lid, i + 1), this.getHeight(rid, i + 1))
  }

  find(id) {return this.nodes[id]}

  print() {
    console.log(this._nodeInfo.map(o =>
      `node ${o.node.id}: parent = ${o.node.parentId}, sibling = ${o.sibling}, degree = ${o.degree}, depth = ${this.getDepth(o.node.id)}, height = ${this.getHeight(o.node.id)}, ${o.node.type}`
    ).join('\n'));
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let tree = new BinaryTree();
  lines.map(l => l.split(' ').map(Number)).forEach(line => tree.add(...line));
  tree.connect();
  tree.print();
})();



Measured memory_bytes: 16512