akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from collections import deque
from itertools import product
import heapq


def read():
    H, W = map(int, input().strip().split())
    CH, CW = map(int, input().strip().split())
    DH, DW = map(int, input().strip().split())
    S = [[0 for j in range(W)] for i in range(H)]
    for i in range(H):
        s = list(input().strip())
        for j in range(W):
            if s[j] == "#":
                S[i][j] = -2
            else:
                S[i][j] = -1
    return H, W, CH, CW, DH, DW, S


def solve(H, W, CH, CW, DH, DW, S):
    DIR0 = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    DIR1 = [
        (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
        (-1, -2), (-1, -1), (-1, 1), (-1, 2),
        (0, -2), (0, 2),
        (1, -2), (1, -1), (1, 1), (1, 2),
        (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)
    ]
    q = deque()
    q.appendleft((CH-1, CW-1, 0))
    while q:
        # キューの先頭から候補を取り出す
        y0, x0, d0 = q.popleft()
        if 0 <= S[y0][x0] < d0:
            continue
        S[y0][x0] = d0
        # 距離0で到達可能な場所をキューの先頭に入れる
        for dy, dx in DIR0:
            ny, nx = y0 + dy, x0 + dx
            if 0 <= ny < H and 0 <= nx < W and S[ny][nx] == -1:
                q.appendleft((ny, nx, d0))
        # 距離1で到達可能な場所をキューの末尾に入れる
        for dy, dx in DIR1:
            ny, nx = y0 + dy, x0 + dx
            if 0 <= ny < H and 0 <= nx < W and S[ny][nx] == -1:
                q.append((ny, nx, d0+1))
    return S[DH-1][DW-1]


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 235676
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long
#define trace(x) cerr << #x << " = " << x << endl
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main()
{
   /*
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("ouput.txt","w",stdout);
    #endif 
   */

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t; cin>>t;
    //int flag = 1;
    int cnt = 0;
    while(t--){
          int d1, d2;
	  cin>>d1>>d2;
	  if(d1 == d2 )
		  cnt++;
	  else{
		  cnt = 0;
	  }
	   if(cnt == 3){
		   cout<<"Yes"<<endl;
		   break;
	   }
	   	   
    }
    if(cnt!= 3)
	    cout<<"No"<<endl;
    return 0;
} 


Measured memory_bytes: 3636
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = map(int, input().split())
ans = 0
if a <= k:
    ans += a*1
if a > k:
    ans += k*1
    print(ans)
    exit()
if b <= (k-a):
    ans += b*0
if b > (k-a):
    ans += 0*(k-a)
    print(ans)
    exit()
if c <= (k-a-b):
    ans += c*(-1)
    print(ans)

if c > (k-a-b):
    ans += (-1)*(k-a-b)
    print(ans)


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

namespace solution
{
  string s,t;
  vector<vector<char>> build_table() {
    int n = s.size();
    int m = t.size();
    vector<vector<int>>dp(n + 1, vector<int>(m + 1, 0));
    vector<vector<char>>dir(n + 1, vector<char>(m + 1, 'N'));
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (s[i-1] == t[j-1]) {
          dp[i][j] = dp[i-1][j-1] + 1;
          dir[i][j] = 'D'; // diagonal
        } else {
          if (dp[i-1][j] > dp[i][j-1]) {
            dp[i][j] = dp[i-1][j];
            dir[i][j] = 'U'; // up
          } else {
            dp[i][j] = dp[i][j-1];
            dir[i][j] = 'L'; // left
          }
        }
      }
    }
    return dir;
  }
  string solve() {
    vector<vector<char>>dir = build_table();
    string lcs = "";
    int i = s.size();
    int j = t.size();
    // while (i >= 0 && j >= 0) {
    for (int k = 0; k < 2*max(s.size(), t.size()); k++) {
      if (i <= 0 || j <= 0) break;
      char d = dir[i][j];
      if (d == 'D') {
        lcs += s[i-1];
        i--;j--;
      } else if (d == 'L') {
        j-=1;
      } else {
        i-=1;
      }
    }
    reverse(lcs.begin(), lcs.end());
    return lcs;
  }
}

int main() {
  cin >> solution::s >> solution::t;
  cout << solution::solve() << endl;
  return 0;
}

Measured memory_bytes: 44544
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		HashSet<Integer> list = new HashSet<Integer>();

		for(int i = 0; i < n; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			if(a == 0) {
				list.add(b);
				System.out.println(list.size());

			}else if(a == 1){
				System.out.println(list.contains(b) ? "1" : "0");
			
			}else if(a == 2) {
				
				list.remove(b);
				
			}
		}
	}
}


Measured memory_bytes: 161084
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    input!(n: usize, m: usize, x: [i64; n], y: [i64; m]);

    let sum = |x: Vec<i64>| -> Vec<i64> {
        let n = x.len();
        let mut sum_x = vec![0; n - 1];
        for i in 1..n {
            let segment = x[i] - x[i - 1];
            assert!(segment > 0);
            let left = i as i64;
            let right = (n - i) as i64;
            let sum = (left * right) % MOD;
            sum_x[i - 1] = (sum * segment) % MOD;
        }
        sum_x
    };

    let x = sum(x);
    let y = sum(y);
    let x: i64 = (x.iter().sum::<i64>()) % MOD;
    let y: i64 = (y.iter().sum::<i64>()) % MOD;
    println!("{}", (x * y) % MOD);
}


Measured memory_bytes: 12280
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

ll n, k;

int main() {
    int n;
    scanf("%d", &n);
    String s, a = "ABC";
    std::cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (i + 2 < s.length()) {
            if (s.substr(i, 3) == a) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

long lowest(long p, long low) {
    return ((low + p - 1) / p) * p;
}

long calcMin(int[] xs) {
    long n = xs[$ - 1];
    for (int i = cast(int)xs.length - 1; i >= 0; i--) {
        n = lowest(xs[i], n);
    }

    long m = n;
    for (int i = 0; i < xs.length; i++) {
        m -= m % xs[i];
    }

    return m == 2 ? n : -1;
}

long calcMax(int[] xs, long min) {
    long lo = min;
    long hi = long.max / 2 - 1;
    long ans = min;

    while (lo <= hi) {
        long m = (lo + hi) / 2;

        bool ok = true;
        long x = m;
        for (int i = 0; i < xs.length; i++) {
            x -= x % xs[i];
        }
        if (x != 2) ok = false;

        if (ok) {
            ans = max(ans, m);
            lo = m + 1;
        }
        else {
            hi = m - 1;
        }
    }

    return hi;
}

void main() {
    readint;
    auto xs = readints();

    auto min = calcMin(xs);
    if (min == -1) {
        writeln(-1);
    }
    else {
        auto max = calcMax(xs, min);
        writeln(min, " ", max);
    }
}

Measured memory_bytes: 4424
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

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

	int ans = 0;
	for(int i=0; i<100; i++){
		bool bef = false;
		for(int j=0; j<N; j++){
			if(!bef && i<h[j]){
				ans++;
				bef = true;
			}
			if(i >= h[j]) bef = false;
		}
	}
	cout << ans << endl;

	return 0;
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
  ll n, k;
  cin >> n >> k;
  vector<P> tmp(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    tmp[i] = P(a, b);
  }

  sort(tmp.begin(), tmp.end());
  for(auto itr : tmp){
    k -= itr.second;
    if(k <= 0){
      cout << itr.first << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 1024
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> Vi ;
typedef pair <int, int> Pii ;
typedef pair <ll, ll> Pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 2010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

inline int read(){
    int X = 0, w = 0 ;
	char ch = 0 ;
    while (!isdigit(ch)) { w |= ch == '-' ; ch = getchar() ; }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar() ;
    return w ? - X : X ;
}

void write(int x){
     if (x < 0) putchar('-'), x = - x ;
     if (x > 9) write(x / 10) ;
     putchar(x % 10 + '0') ;
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

int vis[N], ok[N][N], in[N], a[N] ;
vector <int> g[N] ;
int n ;

void dfs(int rt) {
	vis[rt] = 1 ;
	for (int i = 1; i <= n; i++)
	if (!vis[i] && ok[rt][i]) {
		in[i]++ ;
		g[rt].pb(i) ;
		dfs(i) ;
	}
}

void Top() {
	priority_queue <int> q ;
	for (int i = 1;  i <= n; i++) if (!in[i]) q.push(i) ;
	while (!q.empty()) {
		int now = q.top() ;
		q.pop() ;
		cout << a[now] << " " ;
		for (int i = 0; i < SZ(g[now]); i++) q.push(g[now][i]) ;
	}
}

signed main(){
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]) ;
	sort(a + 1, a + n + 1) ;
	clr(ok) ;
	for (int i = 1; i <= n; i++)
	for (int j = i + 1; j <= n; j++)
	if (__gcd(a[i], a[j]) != 1) ok[i][j] = ok[j][i] = 1 ;
	for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i) ;//连通块
	Top() ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


Measured memory_bytes: 16256
#include "bits/stdc++.h"
using namespace std;

const int N=1e5+20;

int n,a[N],dp[N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);

	dp[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;i++) dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	printf("%d",dp[n]);
}

Measured memory_bytes: 4484
def aop()
  i = 0
  b = []
  a =[]
  c = []
  while c = gets
    b = c.split(',').map(&:to_f)
    a[i] = b
    i += 1
  end
  t = 0
  for i in 1..a.length-2
    x = ((a[0][0]-a[i][0])**2 + (a[0][1]-a[i][1])**2)**(1/2.0)
    y = ((a[0][0]-a[i+1][0])**2 + (a[0][1]-a[i+1][1])**2)**(1/2.0)
    z = ((a[i+1][0]-a[i][0])**2 + (a[i+1][1]-a[i][1])**2)**(1/2.0)
    w = (x + y + z)/2.0
    s = (w*(w-x)*(w-y)*(w-z))**(1/2.0)
    t += s
  end
  puts t
end

aop()

Measured memory_bytes: 6936
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

int main(){
    string a, b;
    getline(cin, a);
    for(int i = 0; i < a.size(); i++){
        if(islower(a[i])){
            b += toupper(a[i]);
        }
        else if(isupper(a[i])){
            b += tolower(a[i]);
        }
        else b += a[i];
    }
    cout << b << endl;
}


Measured memory_bytes: 3208
import math
from collections import Counter

N = int(input())
prime_count = Counter()
def prime(n):
    for i in range(2, math.ceil(math.sqrt(n))+1):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1   

for i in range(1, N+1):
    prime(i)

ans = 0
# 75, 25, 15, 5, 3, 1
over75, over1 = [], []
for k, v in prime_count.items():
    if v >= 74:
        over75 += [k]
    elif v >= 1:
        over1 += [k]
#ans += len(over75) * len(over1)
#ans += len(over75) * (len(over75)-1)
ans += len(over75)

over25, over3 = [], []
for k, v in prime_count.items():
    if v >= 24:
        over25 += [k]
    elif v >= 2:
        over3 += [k]
ans += len(over25) * len(over3)
ans += len(over25) * (len(over25)-1)

over15, over5 = [], []
for k, v in prime_count.items():
    if v >= 14:
        over15 += [k]
    elif v >= 4:
        over5 += [k]
ans += len(over15) * len(over5)
ans += len(over15) * (len(over15)-1)

over5, over3 = [], []
for k, v in prime_count.items():
    if v >= 4:
        over5 += [k]
    elif v >= 2:
        over3 += [k]
ans += (len(over5) * (len(over5)-1))//2 * len(over3)
ans += len(over5) * ((len(over5)-1) * (len(over5)-2)) // 2
print(ans)

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

int main(){
  int N;
  cin >> N;
  int a[101];
  int sum;
  for(int i = 0; i < N ; i++){
    cin >> a[i];
  }
  int ans = 999999999;
  for(int i=-100 ; i <= 100; i++){
    sum = 0;
    for(int j = 0 ; j < N ; j++){
      sum = sum + ((a[j] - i) * (a[j] - i));
    }
    ans = min(sum , ans);

  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
// D - Binomial Coefficients
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using dbl = double;

int main(){
	int N; cin>>N;
	vi A(N); rpz(i, N) cin>>A[i];
	sort(all(A));
	int n = A[N-1], r = 0;
	dbl half = (dbl)n/2, mindiff = half;
	rpz(i, N-1){
		dbl diff = abs(half - A[i]);// |n/2 - ai|
		if(mindiff > diff){
			mindiff = diff;
			r = A[i];
		}
	}
	cout<< n <<" "<< r <<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 510200;
const long long MOD = 998244353;
const long long INF = 1e18;

int n, m;
int val[3][N];
vector<int> g[N];

long long inq(long long x, long long y)
{
    if (y == 0) return 1;
    long long l = inq(x, y / 2);
    if (y % 2) return l * l % MOD * x % MOD;
    return l * l % MOD;
}

void run1(int id)
{
    for (int i = 0; i <= n; i++) g[i].clear();
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> gr(n + 1);
    for (int i = n; i >= 1; i--)
    {
        vector<int> cnt(g[i].size() + 2);
        for (auto u : g[i])
        {
            if (i < u && gr[u] < g[i].size() + 2) cnt[gr[u]]++;
        }
        for (int j = 0; j < g[i].size() + 2; j++)
        {
            if (cnt[j] == 0)
            {
                gr[i] = j;
                val[id][j] = (val[id][j] + inq(INF % MOD, i)) % MOD;
                break;
            }
        }
    }
}

signed main()
{
    srand(time(NULL));
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin >> n;
    run1(0);
    run1(1);
    run1(2);
    long long ans = 0;
    int M = 1000;
    for (int x = 0; x < M; x++)
    {
        for (int y = 0; y < M; y++)
        {
            int z = x ^ y;
            ans = (ans + val[0][x] * val[1][y] % MOD * val[2][z]) % MOD;
        }
    }
    cout << ans;
}


Measured memory_bytes: 22896
#include<bits/stdc++.h>
using namespace std;
int n,a,b,sum;
void dfs(int x,int y,int ban){
    if(__builtin_popcount(ban^sum)==1){
        printf("%d %d ",y,x^y);
        return;
    }
    for(int i=0;i<n;i++)
        if((~(ban>>i)&1)&&(x>>i&1))
            for(int j=0;j<n;j++)
                if((~(ban>>j)&1)&&i!=j){
                    dfs(1<<j,y,ban|1<<i);
                    dfs(x^(1<<i)^(1<<j),y^(1<<i)^(1<<j),ban|1<<i);
                    return;
                }
}
int main(){
    scanf("%d%d%d",&n,&a,&b);
    sum=(1<<n)-1;
    if(__builtin_popcount(a^b)&1){
        printf("YES\n");
        dfs(a^b,a,0);
    }
    else
        printf("NO");
    return 0;
}


Measured memory_bytes: 1152
//
//  main.cpp
//  DPpractice
//
//  Created by abhishek kumar on 20/04/20.
//  Copyright © 2020 abhishek kumar. All rights reserved.
//

#include <iostream>
#include<vector>
using namespace std;
typedef long long int ll;
const long long int N=1000;
const int INF=1e9 + 5;
ll n,k,m,arr[N+1][N+1],dp[N+1][N+1],visited[N+1][N+1];


int main(int argc, const char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    vector<int> h(n);
    for(auto& it : h) cin>>it;
    vector<int> dp(n,INF);
    dp[0]=0;
    for(auto i=0;i<n;i++)
    {
        for(auto j=i+1;j<=i+k;j++)
            dp[j]= min(dp[j],dp[i] + abs(h[j]-h[i]));
    }
    cout<<dp[n-1];
  
    return 0;
        
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

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

int custom(pair<int, int> &a, pair<int, int> &b) {
  if(a.first == b.first) return (a.second < b.second);
  else return (a.first < b.first);
}
int main() {
  int h, n;
  cin >> h >> n;

  vector<long long> dp(20001, 1e18);

  dp[0] = 0;

  for(int i=0;i<n;i++) {
    long long a, b;
    cin >> a >> b;
    for(int j=0;j <= h;j++) {
      chmin(dp[j + a], dp[j] + b);
    }
  }

  long long ans = 1e18;

  for(int i=h;i<2e4;i++) {
    chmin(ans, dp[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

#include <iostream>

int main()
{
	int r;
	cin >> r;

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

}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String str = "",ans = "";

		Scanner sc = new Scanner(System.in);

		str = sc.next();


		for (int i = 0; i < str.length(); i++) {
			ans += "x";
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 21716
// Mon Sep 14 19:59:49 IST 2020  


#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int64 ii = (int64)a ; ii < (int64)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7;
const int64 big = INT64_MAX;

const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}
void printSet(multiset <int>v){
    cout << "===\n";
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}
int64 bigPower(int64 num, int64 n){
	int64 product = 1LL;
    forn(i,0,n)
      product = (product*num)%MOD1;
    return product;
}
int tests(){ 
      int n;
      cin >> n;
      vector <int> add, subtract;
      int x,y;
      forn(i,0,n){
         cin >> x >> y;
         add.push_back(x+y);
         subtract.push_back(x-y);
      }
      sort(all(add));
      sort(all(subtract));
      cout << max(add[n-1]-add[0],subtract[n-1]-subtract[0]);
  
      return 0;
}    
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 


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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int x,n;
        cin>>x>>n;
        vector< int > v;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            v.push_back(a);
        }
        if(find(v.begin(),v.end(),x)==v.end())
        {
            cout<<x<<endl;
        }
        else
        {
            sort(v.begin(),v.end());
            int i=1;
            while(1)
            {
                if(find(v.begin(),v.end(),x-i)==v.end())
                {
                    cout<<x-i<<endl;
                    break;
                }
                else if(find(v.begin(),v.end(),x+i)==v.end())
                {
                    cout<<x+i<<endl;
                    break;
                }
                i++;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int k,x;
    cin>>k>>x;
    if(k*500>=x){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl; 
    }






return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

vector<pair<ll, ll>> factorize(ll x)
{
    vector<pair<ll, ll>> ret;
    for(ll i=2;i*i <= x; ++i)
    {
        int count_divided = 0;
        while(x % i == 0)
        {
            x /= i;
            count_divided++;
        }

        if(count_divided != 0)
        {
            ret.push_back(make_pair(i, count_divided));
        }
    }
    if(x != 1)
    {
        ret.push_back(make_pair(x, 1));
    }

    return ret;
}

int main(){
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if(n == 2)
    {
        cout << 1 << endl;
        return 0;
    }
    auto n_fact = factorize(n);
    auto n_1_fact = factorize(n-1);

    ll ret = 1;
    for(auto pair : n_1_fact)
    {
        ret *= (pair.second + 1);
    }
    ret--;

    ll orig_n = n;
    for(ll i=1;i*i<=n;++i)
    {
        if(n % i == 0)
        {
            if(i != 1)
            {
                while(n % i == 0) n /= i;
                if(n % i == 1) ret++;
                n = orig_n;
            }
            if(i*i != n)
            {
                ll div = n/i;
                while(n % div == 0) n /= div;
                if(n % div == 1) ret++;
                n = orig_n;
            }   
        }
    }
    cout << ret << endl;
}

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

using ll=long long;

int Ketasuu(ll x) {
  int keta=0;
  while (0<x) {
    x/=10;
    keta++;
  }
  return keta;
}

int main() {
  ll N; cin >>N;
  int ans=Ketasuu(N);
  for (ll A=1;A*A<=N;A++) {
    if (N%A) continue;
    ll B=N/A;
    int cur=max(Ketasuu(A),Ketasuu(B));
    if (cur<ans) ans=cur;
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000
int isprime(int);
int main(){
  int n[N],status,i,a=0,count=0;
  for(i=0;i<N;i++){
    status=scanf("%d",&n[i]);
    if(status==EOF)break;
    a++;
  }
  for(i=0;i<a;i++){
    count=count+isprime(n[i]);
  }
  printf("%d\n",count);
  return 0;    
}
int isprime(int x){
  int i;
    if(x==2)return 1;
    else if(x<2 || x%2==0)return 0;
    i=3;
    while(i<=sqrt(x)){
      if(x%i==0)return 0;
      i=i+2;
    }
    return 1;
}

Measured memory_bytes: 632
#include <stdio.h>

int main()
{
	int n, i, j;
	int table[37], temp[37] = {0};
	
	for (i = 0; i <= 9; ++i) {
		table[i] = 1;
	}
	for (i = 0; i <= 9; ++i) {
		for (j = 0; j <= 9; ++j) {
			temp[i + j] += table[i] * table[j];
		}
	}
	for (i = 0; i <= 36; ++i) {
		table[i] = 0;
	}
	for (i = 0; i <= 18; ++i) {
		for (j = 0; j <= 18; ++j) {
			table[i + j] += temp[i] * temp[j];
		}
	}
	
	while (scanf("%d", &n) != EOF) {
		if (n >= 0 && n <= 36) {
			printf("%d\n", table[n]);
		} else {
			printf("0\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 608
n, m = list(map(int, input().split()))
sc = [list(map(int, input().split())) for _ in range(m)]
def check(i):
    ss = str(i)
    if len(ss) != n:
        return False
    for s, c in sc:
        if ss[s-1] != str(c):
            return False
    return True
for i in range(1000):
    if check(i):
        print(i)
        exit()
print(-1)


Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b&&b<c){
	if(a==b){
	printf("No\n");
	}
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
MOD = 998244353

n, k = map(int, input().split())
left=[]
right=[]
for _ in range(k):
    l,r=map(int, input().split())
    left+=[l]
    right+=[r]
pref = [0,1]

for i in range(n-1):
    new = 0
    for j in range(k):
        new += pref[max(0,i+2-left[j])] - pref[max(0,i+1-right[j])]
        #print(pref[max(0,i+2-left[j])], pref[max(0,i+1-right[j])])
    pref.append((pref[-1] + new) % MOD)
print(new % MOD)


Measured memory_bytes: 81616
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, K;
unsigned long long T; 

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d", &N, &K);
	T = K;
	for(int i = 0; i < N - 1; i++) T *= (K - 1);
	printf("%llu", T);
}

Measured memory_bytes: 256
nums = int(input())
ary = list(range(nums))
result = -1
for i in range(nums):
    ary[i] = int(input())

check = ary[0]
for i in range(nums):
    if check  == 2:
        result = i+1
        break
    check = ary[check-1]
print(result)

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

int n,m,a,b;
vector<int> adjl[100005];

int s,e;
bool started = false;

int ways(int node, int parent){
    if (node==s){
        if (started) return 0;
        started = true;
    }
    if (node==e) return 1;
    int way = 0;
    for (int x : adjl[node]){
        if (x!=parent && x!=s){
            way+=ways(x,node);
        }
    }
    return way;
}


int main(){
s = -1; e = -1;
scanf("%d%d",&n,&m);
for (int x = 0; x<m; x++){
    scanf("%d%d",&a,&b);
    a--;b--;
    adjl[a].push_back(b);
    adjl[b].push_back(a);
}

for (int x = 0; x<n; x++){
    if (adjl[x].size()%2!=0){
        printf("No");
        return 0;
    }
}

int c = 0;
for (int x = 0; x<n; x++){
    if (adjl[x].size()>=6){
        printf("Yes");
        return 0;
    }
    if (adjl[x].size()>=4){
        c++;
        if (s==-1){
            s = x;
        }
        else{
            e = x;
        }
    }
    if (c>=3){
        printf("Yes");
        return 0;
    }
}

if (ways(s,-1)==2){
    printf("Yes");
    return 0;
}
printf("No");
}


Measured memory_bytes: 8064
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        x=999-n
        if str(n)[0]==str(n)[1]==str(n)[2]:
            return n
        for i in range(x+1):
            n+=1
            if str(n)[0]==str(n)[1]==str(n)[2]:
                return n
    print(main())
resolve()

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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  int N;
  cin >> N;
  vector<float> x(N);
  vector<string> u(N);
  REP(i, N) {
    cin >> x[i] >> u[i];
  }
  float Y = 0;
  REP(i, N) {
    if(u[i] == "JPY") {
      Y += x[i];
    } else {
      Y += x[i] * 380000;
    }
  }
  cout << Y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int janken[5];
	char hantei[5];
	int i;
	int g, c, p;
	
	
	while(1){
		
		
		g = c = p = 0;
		
		for(i = 0; i < 5; i++){
			scanf("%d", &janken[i]);
			if(janken[0] == 0){
				break;
			}
			if (janken[i] == 1){
				g = 1;
				hantei[i] = 'g';
			}
			else if(janken[i] == 2){
				c = 1;
				hantei[i] = 'c';
			}
			else{
				p = 1;
				hantei[i] = 'p';
			}
		}
		if(janken[0] == 0){
			break;
		}
		
		if ((g == 1 && c == 0 && p == 0)||(g == 0 && c == 1 && p == 0)||(g == 0 && c == 0 && p == 1)){
			for (i = 0; i < 5; i++){
				janken[i] = 3;
			}
		}
		
		else if(g == 1 && c == 1 && p == 1){
			for(i = 0; i < 5; i++){
				janken[i] = 3;
			}
		}
		
		else {
			if (g == 1 && c == 1 && p == 0){
				for (i = 0; i < 5; i++){
					if (hantei[i] == 'g'){
						janken[i] = 1;
					}
					else{
						janken[i] = 2;
					}
				}
			}
			else if (g == 0 && c == 1 && p == 1){
				for (i = 0; i < 5; i++){
					if (hantei[i] == 'c'){
						janken[i] = 1;
					}
					else{
						janken[i] = 2;
					}
				}
			}
			else if (g == 1 && c == 0 && p == 1){
				for (i = 0; i < 5; i++){
					if (hantei[i] == 'p'){
						janken[i] = 1;
					}
					else{
						janken[i] = 2;
					}
				}
			}
		}
		
		for(i = 0; i < 5; i++){
			printf("%d\n", janken[i]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10,INF=0x3f3f3f3f;
int n,q,op,x;
ll now;
struct segtree{
	int n;
	struct node{int l,r,mx,cnt,se;}e[N<<2];
	#define l(p) e[p].l
	#define r(p) e[p].r
	#define m(p) e[p].mx
	#define c(p) e[p].cnt
	#define s(p) e[p].se
	void up(int p){
        c(p)=0;
        m(p)=max(m(p<<1),m(p<<1|1));
        s(p)=max(s(p<<1),s(p<<1|1));
        if(m(p<<1)!=m(p<<1|1))s(p)=max(s(p),min(m(p<<1),m(p<<1|1)));
        if(m(p<<1)==m(p))c(p)+=c(p<<1);
        if(m(p<<1|1)==m(p))c(p)+=c(p<<1|1);
	}
	void bld(int p,int l,int r){
		l(p)=l;r(p)=r;c(p)=-1;
		if(l==r){m(p)=n;s(p)=-1;c(p)=1;return;}
		int mid=l+r>>1;
		bld(p<<1,l,mid);bld(p<<1|1,mid+1,r);
		up(p);
	}
	void MIN(int p,int v){
        if(v>=m(p))return;
        m(p)=v;
	}
	void init(int _n){n=_n;bld(1,1,n);}
	void psd(int p){
        MIN(p<<1,m(p));
        MIN(p<<1|1,m(p));
    }
    void Min(int p,int ql,int qr,int v){
        if(v>=m(p))return;
        if(ql<=l(p)&&r(p)<=qr&&s(p)<v){
            MIN(p,v);
            return;
        }
        psd(p);
		int mid=l(p)+r(p)>>1;
        if(ql<=mid)Min(p<<1,ql,qr,v);
		if(qr>mid)Min(p<<1|1,ql,qr,v);
		up(p);
    }
	int ask(int p,int x){
		if(l(p)==r(p))return m(p);
		int mid=l(p)+r(p)>>1;
		psd(p);
		int ans=0;
		if(x<=mid)ans=ask(p<<1,x);
		else ans=ask(p<<1|1,x);
		up(p);
		return ans;
	}
}row,col;
int main(){
    scanf("%d%d",&n,&q);
    now=1ll*(n-2)*(n-2);
    row.init(n);
    col.init(n);
    for(int i=1;i<=q;++i){
        scanf("%d%d",&op,&x);
        if(op==1){
            int pos=col.ask(1,x);
            now-=pos-2;
            row.Min(1,1,pos-1,x);
        }
        else{
            int pos=row.ask(1,x);
            now-=pos-2;
            col.Min(1,1,pos-1,x);
        }
    }
    printf("%lld\n",now);
    return 0;
}


Measured memory_bytes: 24348
class Calc:
    def __init__(self, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def nCr(self, n, r):
        r = min(n - r, r)
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod

    def nHr(self, n, r):
        return self.nCr(n - 1 + r, r)


def main():
    MOD = 10 ** 9 + 7

    N, M, K = map(int, input().split())

    calc = Calc(max_value=N * M - 2, mod=MOD)

    t = 0
    for d in range(1, N):
        t = (t + (N - d) * d) % MOD
    t = t * M * M * calc.nCr(N * M - 2, K - 2) % MOD

    u = 0
    for d in range(1, M):
        u = (u + (M - d) * d) % MOD
    u = u * N * N * calc.nCr(N * M - 2, K - 2) % MOD

    ans = (t + u) % MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18804
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <set>

using namespace std;

const int INF = 1 << 29;
typedef long long LL;
typedef pair<int, int> P;

int n, q;

int main(void)
{
	while(cin >> n >> q && n)
	{
		vector<LL> stds(n);
		vector<LL> stdsBuf(n);

		for (int i = 0; i < n; i++)
			cin >> stds[i], stdsBuf[i] = stds[i];
		sort(stds.begin(), stds.end());

		multiset<LL> leaders;
		for (int i = 0; i < q; i++)
		{
			string s;
			int num;
			cin >> s >> num;
			if(s[0] == 'A') // Add
			{
				leaders.insert(stdsBuf[--num]);
			}
			else if(s[0] == 'R') // Remove
			{
				leaders.erase(leaders.lower_bound(stdsBuf[--num]));
			}
			else // Check
			{
				LL lb = 0, ub = 1000000001LL;
				while (ub != lb)
				{
					LL mid = (lb + ub) / 2;
					int pos, fails = 0, pre = 0;

					for (multiset<LL>::iterator it = leaders.begin(); it != leaders.end(); it++)
					{
						pos = lower_bound(stds.begin(), stds.end(), *it - mid) - stds.begin();
						fails += max(pos - pre, 0);
						pre = upper_bound(stds.begin(), stds.end(), *it) - stds.begin();
					}
					fails += max(n - pre, 0);
					
					if(fails > num) lb = mid + 1;
					else ub = mid;
				}

				if(ub == 1000000001LL) cout << "NA";
				else cout << lb;
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 16768
#include <stdio.h>

int main(void)
{
	float a, b;
	
	while (scanf("%f %f", &a, &b) != EOF){
	
		if ((a < 35.50) && (b < 71)){
			printf("AAA\n");
		}
	
		else if ((a < 37.50) && (b < 77)){
			printf("AA\n");
		}
	
		else if ((a < 40) && (b < 83)){
			printf("A\n");
		}
	
		else if ((a < 43) && (b < 89)){
			printf("B\n");
		}
	
		else if ((a < 50) && (b < 105)){
			printf("C\n");
		}
	
		else if ((a < 55) && (b < 116)){
			printf("D\n");
		}
	
		else if ((a < 70) && (b < 148)){
			printf("E\n");
		}
	
		else {
			printf("NA\n");
		}
	}
	
	return (0);
	
}

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

int main() {
    int a,b;
    int s=0;
    cin >> a >> b;
    if (a>b){
        s=a+(a-1);
    }
    else if(a==b){
        s=2*a;
    }
    else if(a<b){
        s=b+(b-1);
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 606, mo = 1e9+7;
int n,a[N],f[303][303][303],v[303][303],pos[N];bool gg[N];
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
int main() {
	read(n);rep(i,1,n*2){read(a[i]);if(a[i]>=1)pos[a[i]]=i;}
	for(int i=1;i<=n*2;i+=2)if(a[i]>=1&&a[i+1]>=1)gg[a[i]]=gg[a[i+1]]=1;
	int ini=0;for(int i=1;i<=n*2;i+=2)ini+=a[i]<0&&a[i+1]<0;
	f[ini][0][0]=1;
	rep(t,1,n*2)if(!gg[t]){
		static int g[303][303],h[303][303];
		rep(i,0,ini)rep(j,0,n)h[i][j]=v[i][j],g[i][j]=f[i][j][v[i][j]],f[i][j][v[i][j]]=0;
		memset(v,0,sizeof(v));
		if(pos[t]){
			rep(i,0,ini)rep(j,0,n)rep(k,h[i][j],h[i][j])if(g[i][j]){
				if(j)add(f[i][j-1][k],1LL*g[i][j]*j%mo),v[i][j-1]=k;
				add(f[i][j][k+1],g[i][j]),v[i][j]=k+1;
			}
		}
		else{
			rep(i,0,ini)rep(j,0,n)rep(k,h[i][j],h[i][j])if(g[i][j]){
				add(f[i][j+1][k],g[i][j]),v[i][j+1]=k;
				if(k)add(f[i][j][k-1],g[i][j]),v[i][j]=k-1;
				if(i)add(f[i-1][j][k+1],1LL*g[i][j]*i%mo),v[i-1][j]=k+1;
			}
		}
	}
	cout<<f[0][0][0];
	return 0;
}


Measured memory_bytes: 109568
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  string s;
  cin>>s;
  int n=s.length();
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(s[i]=='0'&&s[i+1]=='0'){
      ans++;
      s[i+1]='1';
    }else if(s[i]=='1'&&s[i+1]=='1'){
      ans++;
      s[i+1]='0';
    }
  }
  if(ans>n/2) ans=n-ans;
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	ll n;
	cin>>n;
	
	if(n%2)
		cout<<0;
	else
	{
		ll ct=0;
		
		for(ll i=10;n/i>=1;i*=5)
		{
			ct+=(n/i);
		}
		cout<<ct;
	}
}

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

using namespace std;


#define MAXN 300001
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, w[MAXN]={}, e[MAXN]={};
  cin >> n;
  string s;
  cin >> s;
  int cur = 0;
  for (int i = 0; i < n; ++i) {
    w[i] = cur;
    if (s[i]=='W') w[i] = cur++;
  }
  cur = 0;
  for (int i = n-1; i >= 0; --i) {
    e[i] = cur;
    if (s[i]=='E') e[i] = cur++;
  }
  int ans = n;
  for (int i = 0; i < n; ++i) {
    ans = min(ans, e[i]+w[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  string N;
  cin >> N;
  ll K;
  cin >> K;
  ll len = N.size();
  vector<vector<vector<ll>>> dp(len + 1, vector<vector<ll>>(K + 2, vector<ll>(2, 0)));
  ll cnt = 0;
  dp.at(0).at(0).at(0) = 1;
  for (ll i = 0; i < len; ++i) {
    for (ll j = 0; j <= K; ++j) {
      if (N[i] == '0') {
        dp.at(i + 1).at(j).at(0) = dp.at(i).at(j).at(0);
      }
      else {
        dp.at(i + 1).at(j + 1).at(0) = dp.at(i).at(j).at(0);
      }
      dp.at(i + 1).at(j + 1).at(1) += dp.at(i).at(j).at(1) * 9;
      dp.at(i + 1).at(j).at(1) += dp.at(i).at(j).at(1);

      if (N[i] != '0') {
        dp.at(i + 1).at(j).at(1) += dp.at(i).at(j).at(0);
        dp.at(i + 1).at(j + 1).at(1) += dp.at(i).at(j).at(0) * (N[i] - '0' - 1);
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < 2; ++i) {
    ans += dp.at(len).at(K).at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MOD 1000000007
#define pi 3.141592653589793238
#define ll long long int
#define P pair<ll, ll>
#define VII vector<P>
#define P_B push_back

int n, k;
int n_l;
int v[100];
int DP[100001];

bool backtrack(int k) {

	if(k == 0) return false;

	if(DP[k] != -1) return DP[k];

	bool answer = false;
	for (int i = 0; i < n; i++) {

		if(v[i] > k) continue;
		if(backtrack(k-v[i]) == false) {
			answer = true;
			break; 
		}
	}

	return DP[k] = answer; 
}

int main() {
	
	// ll T; cin>>T; while(T--) 
	{
		
		cin>>n>>k;
		for (int i = 0; i < n; i++) cin>>v[i];
		memset(DP, -1, sizeof(DP));
		backtrack(k) ? cout<<"First" : cout<<"Second";

	}	
	return 0;
}

Measured memory_bytes: 7120
using System;
using System.Linq;
using static System.Console;

class Program{
	static void Main(){
		long h = long.Parse(ReadLine());
		Write(Saiki(h));
    }
  
  static long Saiki(long H){
  	if(H == 1){
    	return 1;
    }else{
    	return Saiki(H/2)*2+1;
    }
  }
  
}

Measured memory_bytes: 13140
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] strArray = System.Console.ReadLine().Trim().Split(' ');
            int x = int.Parse(strArray[0]);
            int y = int.Parse(strArray[1]);
            int xGroup;
            int yGroup;
            xGroup = Grouping(x);
            yGroup = Grouping(y);
            if(xGroup == yGroup)
            {
                System.Console.WriteLine("Yes");
            }
            else
            {
                System.Console.WriteLine("No");
            }
        }
        static int Grouping(int a)
        {
            int[] group1 = new int[] { 1, 3, 5, 7, 8, 10, 12 };
            int[] group2 = new int[] { 4, 6, 9, 11 };
            if (Array.IndexOf(group1,a) >= 0)
            {
                return 1;
            }
            if (Array.IndexOf(group2, a) >= 0)
            {
                return 2;
            }
            return 3;
        }
    }
}

Measured memory_bytes: 11220
import itertools

n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
# n = 3
# xy =[[0,0],[0,1],[1,0]]

l = list(range(n))
cl = []
for i in itertools.permutations(l):
  cl.append(i)
# print(cl[0][1])
total = 0
N = len(cl)
for i in range(N):
  for j in range(1,n):
    now = cl[i][j]
    past = cl[i][j-1]
    total += ((xy[now][0] - xy[past][0])**2+(xy[now][1] - xy[past][1])**2)**0.5
print(total/N)

Measured memory_bytes: 7924