akhauriyash/Code-Regression huggingface dataset:
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            long ans=0;
            for(int i=1;i<n;i++){
                ans+=n/i;
                if(n%i==0){
                    ans--;
                }
            }
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


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

int main() {
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(), a.end());
  if(a[0] == a[1] && a[0] == 5 && a[2] == 7)
    cout<<"YES"<<endl;
  else 
    cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll fact[5005];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-fact[n%p])%p;
	}
	return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}

int n,k;

int main(void){
	fact[0]=1;
	for(ll i=1;i<=5000;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++){
		ll pos=n-k+1;
		ll v1=mod_comb(pos,i+1,MOD);
		ll v2=mod_comb(k-1,i,MOD);
		printf("%lld\n",v1*v2%MOD);
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt() - 1;
        int b = sc.nextInt() - 1;
        int c = sc.nextInt() - 1;

        int[] num = new int[100];
        num[a]++;
        num[b]++;
        num[c]++;
        sc.close();

        int cnt = 0;

        for (int i = 0; i < 100; i++) {
            if (num[i] != 0) {
                cnt++;
            }
        }
        System.out.println(cnt);

    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int f[300000], a[300000];
multiset<int> st;
signed main(){
  int n;
  scanf("%lld", &n);
  rep(i,n)scanf("%lld", &a[i]);
  sort(a, a+n, greater<int>());
  rep(i,n)st.insert(a[i]);
  int ans = 0;
  rep(i,n){
    if(st.count(a[i]) == 0)continue;
    auto it = st.lower_bound(a[i]);
    st.erase(it);
    int x = 1;
    while(x <= a[i])x *= 2;
    x = x-a[i];
    // printf("%lld\n", x);
    it = st.lower_bound(x);
    if(*it == x){
      ans++;
      st.erase(it);
    }
  }
  printf("%lld\n", ans);
  return 0;
}






Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;



int main(){
	int N,M;
	cin>>N>>M;
	cout<<N+M/2<<endl;
	return 0;
}

Measured memory_bytes: 768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DBannedK solver = new DBannedK();
        solver.solve(1, in, out);
        out.close();
    }

    static class DBannedK {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            long sum = 0;
            long[] count = new long[n + 1];
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
                count[arr[i]]++;
            }
            for (long x : count)
                sum += (x - 1) * x / 2;
            for (int i = 0; i < n; i++) {
                long clone = sum;
                clone -= count[arr[i]] * (count[arr[i]] - 1) / 2;
                clone += (count[arr[i]] - 1) * (count[arr[i]] - 2) / 2;
                pw.println(clone);
            }
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 53028
#include<stdio.h>

int main(){

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

		printf("\n");

	}

	return 0;

}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int P = 1e9+7;
const int maxn = 200050;

int h, w, a, b, Ans, fac[maxn];

int inv(int x)
{
	int ans = 1, b = P-2;
	while(b)
	{
		if(b&1) ans = (1ll*ans*x)%P;
		b >>= 1; x = (1ll*x*x)%P;
	}
	return ans;
}
int C(int n,int m)
{
	return ((1ll*fac[n]*inv(fac[n-m])%P)*inv(fac[m]))%P;
}
int main()
{
	cin >> h >> w >> a >> b;
	fac[0] = 1; fo(i,1,h+w-1) fac[i] = (1ll*fac[i-1]*i)%P;
	fo(i,b+1,w) Ans = (1ll*Ans+1ll*C(h-a+i-2,i-1)*C(a-1+w-i,a-1)%P)%P;
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi #, gcd
from fractions import gcd
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    A,B,C = ILI()

    ans = "No"
    if C - A - B < 0:
      for i in range(10**7):
        pass
    
    # A + 2sqrt(AB) + B < C
    if C - A - B  > 0 and  4 * A * B < (C- A - B) ** 2:
        ans = "Yes"

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5164
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

void monmo(){
    
}

int main() {
    int n,m;
    string s;
    cin>>n>>m;
    if(n==m)s="Yes";
    else s="No";
    cout<<s;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int m,d;cin>>m>>d;
    int ans=0;
    for(int i=11;i<=d;i++){
      int a=i%10,b=i/10;
      if(a>=2&&b>=2&&a*b<=m) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];

    int* dp = new int[n]();
    dp[1] = abs(arr[1]-arr[0]);
    for (int i = 2; i < n; ++i) {
        int one = dp[i-1] + abs(arr[i]-arr[i-1]);
        int two = dp[i-2] + abs(arr[i]-arr[i-2]);

        dp[i] = min(one,two);
    }

    cout<<  dp[n-1];
}

Measured memory_bytes: 4424
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String s = in.next();
            String t = in.next();
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            String u = in.next();

            if (u.equals(s)) a--;
            if (u.equals(t)) b--;
            // 出力
            out.println(String.valueOf(a) + " " + String.valueOf(b));

        }

    }
}



Measured memory_bytes: 23252
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long A, B, K, res, Mod = 998244353, F[301000], InvF[301000];
long long Pow(long long a, long long b) {
	long long r = 1;
	while (b) {
		if (b & 1)r = r*a%Mod;
		a = a*a%Mod; b >>= 1;
	}
	return r;
}
long long Comb(int a, int b) {
	return F[a] * InvF[b] % Mod*InvF[a - b] % Mod;
}
long long Get(int a, int b) {
	if (a > n || b > n || a < 0 || b < 0)return 0;
	return Comb(n, a)*Comb(n, b) % Mod;
}
int main() {
	int i;
	F[0] = 1;
	for (i = 1; i <= 300000; i++) {
		F[i] = F[i - 1] * i%Mod;
	}
	InvF[300000] = Pow(F[300000], Mod - 2);
	for (i = 300000; i >= 1; i--) {
		InvF[i - 1] = InvF[i] * i%Mod;
	}
	scanf("%d%lld%lld%lld", &n,&A,&B,&K);
	for (i = 0; i <= n; i++) {
		long long t = K - A*i;
		if (t >= 0 && t%B == 0 && t/B <= n) {
			res = (res + Get(i, t / B)) % Mod;
		}
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 4864
#![allow(unused_imports, dead_code)]
use std::f64::*;
use std::cmp::*;
use std::collections::*;

macro_rules! dump{
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const INF: i64 = 0x3f3f3f3f3f3f3f3f;
const MOD: i64 = 1000000007;
const NOTHING: usize = std::usize::MAX;
const DX: [usize; 4] = [1, 0, std::usize::MAX, 0];
const DY: [usize; 4] = [0, 1, 0, std::usize::MAX];

fn main() {
    let n: usize = readln();
    let a: Vec<i64> = readln();
    let mut s: i64 = 0;
    for i in 0..n {
        s += a[i];
    }

    let mut x: i64 = 0;
    let mut res: i64 = INF;
    for i in 0..n - 1 {
        x += a[i];
        res = min(res, (x - (s - x)).abs());
    }

    println!("{}", res);
}

trait Read {
    fn read(s: &str) -> Self;
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    
    
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, 26) mp['a' + i] = 0;
    rep(i, sz(s)) mp[s[i]]++;
    
    string ans;
    if (s == "zyxwvutsrqponmlkjihgfedcba") ans = "-1";
    if (sz(s) < 26) {
        string t = s;
        for (auto e : mp) {
            if (e.S == 0) {
                t += e.F;
                break;
            }
        }
        ans = t;
    } else { // case 4
        priority_queue<char, vector<char>, greater<char> > q;
        for (int i = 24; i >= 0; --i) {
            q.push(s[i + 1]);
            if (s[i] < s[i + 1]) {
   
                // out(q.top() << " " << s[i]);
                while (q.top() <= s[i]) { /* out(q.top()); */ q.pop(); }
                s = s.substr(0, i);
                s += q.top();
                ans = s;
                break;
            }
            
        }
        
    }
    out(ans);
}




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

const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007ll;
//const long long MOD = 998244353ll;
const int INF = 1000000001;

long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}

ll gcd(ll x, ll y) {
  if (x == 0) return y;
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;
  while (q-- > 0) {
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    ll xo = 0ll;
    for (int i = 2; i < n; ++i) xo ^= a[i];
    ll sum = a[0] + a[1];
    if (xo > sum) {
      cout << -1 << endl;
      continue;
    }
    ll dif = a[0] + a[1] - xo;
    if (dif & 1ll) {
     cout << -1 << endl;
     continue;
    }
    dif >>= 1;
    int maxr = 42;
    bool fail = false;
    bool ones[maxr];
    for (int j = 0; j < maxr; ++j) {
      ll mask = (1ll << (maxr - 1 - j)); 
      ones[j] = false;
      if (dif & mask) {
        if (xo & mask) {
          fail = true;
          break;
        } else {
          //cout << " ones " << j << endl;
          ones[j] = true;
        }
      }
    }
    if (fail) {
     cout << -1 << endl;
     continue;
    }
    ll MMM = (1ll << (maxr + 1));
    ll dyn[maxr + 1][2];
    dyn[0][0] = 0ll;
    dyn[0][1] = MMM;
    for (int i = 0; i < maxr; ++i) {
      ll mask = (1ll << (maxr - 1 - i)); 
      if (xo & mask) {
        if (a[1] & mask) {
          dyn[i + 1][0] = dyn[i][0] | mask;
          dyn[i + 1][1] = dyn[i][1];
        } else {
          dyn[i + 1][0] = dyn[i][0];
          dyn[i + 1][1] = min(dyn[i][1], dyn[i][0] | mask);
        }
      } else {
        if (ones[i]) { 
          if (a[1] & mask) {
            dyn[i + 1][0] = dyn[i][0] | mask; 
            dyn[i + 1][1] = dyn[i][1] | mask;
          } else {
            dyn[i + 1][0] = MMM;
            dyn[i + 1][1] = min(dyn[i][1], dyn[i][0]) | mask;
          }
        } else {
          if (a[1] & mask) {
            dyn[i + 1][0] = MMM;
            dyn[i + 1][1] = dyn[i][1]; 
          } else {
            dyn[i + 1][0] = dyn[i][0];
            dyn[i + 1][1] = dyn[i][1];
          }
        }
      }
      //cout << " for I+1 " << i + 1 << " mask:  " << mask << " dyn ::: "  << dyn[i + 1][0] << " ::: " << dyn[i + 1][1] << endl;
      assert (dyn[i + 1][1] > a[1]);
      assert (dyn[i + 1][0] >= MMM || dyn[i + 1][0] <= a[1]);
    }
    if (dyn[maxr][0] < MMM) {
      assert (dyn[maxr][0] == a[1]);
      //if ((dyn[maxr][1] ^ (sum - dyn[maxr][1])) != xo) {
       // cout << -1 << endl; 
      //} 
      //else
      cout << 0 << endl;
    } else {
      if (dyn[maxr][1] >= sum) {  //|| ((dyn[maxr][1] ^ (sum - dyn[maxr][1])) != xo)) {
        cout << -1 << endl; 
      } else {
        assert (dyn[maxr][1] > a[1]);
        cout << dyn[maxr][1] - a[1] << endl; 
      }
    }

  }
  return 0;
}


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


using namespace std;


void are(string s, int n,int N){
  
  for(int i=0; i <= n+1;i++){
    string b; 
    b = s+(char)('a'+i);
    //cout << b << s.size()<< endl;
    if(b.size()>=N){
      cout << b << endl;
    }else{
      are(b,max(n,i),N);
    }

  }
 
}

int main(){
  string s="a";
  int n;
  cin >> n;
  if(n==1){
    cout <<"a"<<endl;
    return 0;
  }
  //cout << s << s.size() <<endl;
  //return 0;
  are(s,0,n);
return 0;   
}

Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>

using namespace std;
using ll = long long;

#define nl "\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define trav(x) for(auto& i: x)

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

	int n;
	cin >> n;
	vector<int> a(n);
	ll sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(all(a));
	sum -= a[n - 1] / 2;
	cout << sum;
}

Measured memory_bytes: 256
//refer editorial
// we have applied binary search using lower_bound
//dry run on sample test case to understand
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=200006;
const int INF=2e9;//take infinity as a number which is greater than max value of ai
int a[N];
int ans[N];
vector<vector<int>> G;
int n;
vector<int> dp;
void dfs(int u,int par)
{
    int pos=lower_bound(dp.begin(),dp.end(),a[u])-dp.begin();
    int roll=dp[pos];
    dp[pos]=a[u];
    ans[u]=lower_bound(dp.begin(),dp.end(),INF)-dp.begin()-1;
    for(auto v:G[u])
    {
        if(v==par)
        continue;
        dfs(v,u);
    }
    dp[pos]=roll;
}
int main()
{
    cin>>n;
    G.assign(n+1,vector<int>());
    dp.assign(n+1,INF);dp[0]=-INF;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=1;i<=n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(1,1);
    for(int i=1;i<=n;i++)
    cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 27988
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	Int ans = 0;
	Int cnt = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'B') { ++cnt; }
		else { ans += cnt; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
import math
import itertools

def calc_dist(u, v):
    return math.sqrt(((u[0] - v[0]) * (u[0] - v[0])) + ((u[1] - v[1]) * (u[1] - v[1])))

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

dist_sum = 0.0
for v in itertools.permutations(cities, n):
    dist = 0.0
    for i in range(1, n):
        dist += calc_dist(v[i], v[i - 1])
    dist_sum += dist
dist_sum /= math.factorial(n)
print(dist_sum)

Measured memory_bytes: 3064
import sys,collections

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  field=[S() for _ in range(h)]

  ans=0
  visited=[[-1 for __ in range(w)] for _ in range(h)]
  q=collections.deque()
  for i in range(h):
    for j in range(w):
      if field[i][j]=='#':
        continue
      q.append((i,j))
      for _i in range(h):
        for _j in range(w):
          visited[_i][_j]=-1
      visited[i][j]=0
      _ans=0
      while q:
        y,x=q.popleft()

        for dy,dx in ((-1,0),(0,1),(1,0),(0,-1)):
          ny=y+dy
          nx=x+dx
          if not 0<=ny<h:
            continue
          if not 0<=nx<w:
            continue
          if field[ny][nx]=='#':
            continue
          if visited[ny][nx]!=-1:
            continue
          _ans=visited[y][x]+1
          visited[ny][nx]=_ans
          q.append((ny,nx))
      ans=max(ans,_ans)
  return ans

# main()
print(main())


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  string s; cin >> s;
  string res;
  if (s == "Sunny") {
    res = "Cloudy";
  } else if (s == "Cloudy") {
    res = "Rainy";
  } else {
    res = "Sunny";
  }
  cout << res << endl;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
   int a,b,c,k;
   cin>>a>>b>>c>>k;
   int count=0;
   while(a>=b){
       b *= 2;
       count++;
   }
   while(b>=c){
       c *= 2;
       count++;
   }
   
   if(count <= k) cout<<"Yes"<<endl;
   else
   {
       cout<<"No"<<endl;
   }
   
 
 
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <deque>
typedef long long lint;
const int N=1e5+5;
int n,m;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x<y?y:x;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace G{
	int cnt,fir[N];
	struct edge{
		int to,nx;
	}eg[N<<1];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	void solve(){
		static bool vis[N];
		std::deque <int> dq;
		vis[1]=1;
		dq.push_back(1);
		{
			int tmp=eg[fir[1]].to;
			vis[tmp]=1;
			dq.push_back(tmp);
		}
		for(;;){
			const int x=dq.front();
			int fr=0;
			for(int i=fir[x]; !fr&&i; i=eg[i].nx){
				if(!vis[eg[i].to]) fr=eg[i].to;
			}
			if(!fr) break;
			vis[fr]=1;
			dq.push_front(fr);
		}
		for(;;){
			const int x=dq.back();
			int to=0;
			for(int i=fir[x]; !to&&i; i=eg[i].nx){
				if(!vis[eg[i].to]) to=eg[i].to;
			}
			if(!to) break;
			vis[to]=1;
			dq.push_back(to);
		}
		printf("%d\n",(int)dq.size());
		while(!dq.empty()){
			printf("%d ",dq.front());
			dq.pop_front();
		}
		puts("");
	}
}

int main(){
#ifdef LOCAL
	freopen("path.in","r",stdin);
	freopen("path.out","w",stdout);
#endif
	n=nxi(),m=nxi();
	for(int i=1; i<=m; ++i){
		const int a=nxi(),b=nxi();
		G::add(a,b);
		G::add(b,a);
	}
	G::solve();
	return 0;
}


Measured memory_bytes: 3200
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define SG string
#define DB double
#define LL long long
using namespace std;
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	LL N=Read(),M=Read();
	if(N>=M&&N%M==0){
		Write(0); 
	} else {
		Write(1);
	}
	return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
s=[input() for _ in range(H)]
S=[]
S.append(['.' for _ in range(W+2)])
for i in range(H):
    s[i]='.'+s[i]+'.'
    S.append(list(s[i]))
S.append(['.' for _ in range(W+2)])
ans=True
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=='#':
            flag=False
            for k in range(-1,2,2):
                if S[i+k][j]=='#' or S[i][j+k]=='#':
                    flag=True
                    break
            if flag==False:
                ans=False
                break
    else:
        continue
    break
if ans:
    print("Yes")
else:
    print("No")            

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

using namespace std;

typedef long long ll;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  cin >> l;
  int b = 0, res = 1;
  for (int i=0; i<n; i++) {
    b += l[i];
    if (b > x) break;
    res++;
  }
  cout << res << endl;
  return 0;
}


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

struct edge{ll to, cap, cost, rev; };

ll V;
vector<edge> G[MAX_V];
ll h[MAX_V];
ll dist[MAX_V];
ll prevv[MAX_V], preve[MAX_V];

void add_edge(ll from, ll to, ll cap, ll cost){
	G[from].push_back((edge){to, cap, cost, G[to].size()});
	G[to].push_back((edge){from, 0, -cost, G[from].size()-1});
}

ll min_cost_flow(ll s, ll t, ll f){
	ll res = 0;
	fill(h, h+V, 0);
	while(f > 0){	
		priority_queue<P, vector<P>, greater<P> > que;
		fill(dist, dist+V, INF);
		dist[s] = 0;
		que.push(P(0,s));
		while(!que.empty()){
			P p = que.top(); que.pop();
			ll v = p.second;
			if(dist[v] < p.first) continue;
			for(ll i = 0; i < G[v].size(); i++){
				edge &e = G[v][i];
				if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
					dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					que.push(P(dist[e.to],e.to));
				}
			}
		}
		if(dist[t] == INF){
			return -1;
		}
		for(ll v = 0; v < V; v++) h[v] += dist[v];
		
		ll d = f;
		for(ll v = t; v != s; v = prevv[v]){
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d*h[t];
		for(ll v = t; v != s; v = prevv[v]){
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}

ll n;
ll a[1000];
ll b[1000];
set<ll> se;
set<ll>::iterator it;

int main(){
    cin >> n;
    rep(i,n){
        cin >> a[i] >> b[i];
        add_edge(0,i+1,1,0);
        se.insert(a[i]);
        se.insert(b[i]);
    }
    ll cnt = n+1;
    it = se.end();
    it--;
    ll hoge = (*it);
    for(it = se.begin(); it != se.end(); it++){
        ll x = *it;
        rep(i,n){
            if(a[i] == x){
                add_edge(i+1,cnt,1,-1*b[i]+hoge);
            }
            if(b[i] == x){
                add_edge(i+1,cnt,1,-1*a[i]+hoge);
            }
        }
        cnt++;
    }
    rep(i,n){
        add_edge(i+1,cnt,1,0+hoge);
    }
    for(ll i = n+1; i < cnt; i++){
        add_edge(i,cnt+1,1,0);
    }
    add_edge(cnt,cnt+1,INF,0);
    V = cnt+2;
    cout << -1*(min_cost_flow(0,cnt+1,n)-n*hoge) << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
#define linf 0x7f7f7f7f
int n ;
ll W, c ;
ll w[N], v[N], dp[N] ;

signed main(){
	scanf("%d%lld", &n, &W) ;
	for (int i = 1; i <= n; i++) scanf("%lld%lld", &w[i], &v[i]) ; // weight ans value
	for (int i = 1; i <= n; i++) c += v[i] ;
	for (int i = 0; i <= c; i++) dp[i] = linf ;
	dp[0] = 0 ;
	for (int i = 1; i <= n; i++)
	for (int j = c; j >= v[i]; j--)
	dp[j] = min(dp[j], dp[j - v[i]] + w[i]) ;
	for (ll i = c; i >= 0; i--)
	if (dp[i] <= W) {
		printf("%lld\n", i) ;
		break ;
	}
	return 0 ;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<algorithm>
#include<bitset>
#include<queue>
#include <math.h>
#define int long long
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define PIII pair<pair<int,int>,int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define M (L+R)/2
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)


const int N = 1000*1000 + 2137;

int test;

int n,x;

int res;

int curRes;

int b[N],l[N],r[N];

VPI g;

int pref[N],suf[N];

bool check(int mid){
	int full = min(mid / x, n);
	int zostanie = mid - full * x;

	REP(i,n){
		int res = 0;

		if (i >= full){
			// debug(full);
			// assert(full >= N);
			res = pref[full];
		}else{
			res = pref[full + 1] - g[i].st;

			if (i == n - 1){
				zostanie += x;
			}
		}

		int index = g[i].nd;

		int ile = min(b[index], zostanie);

		int zyskLow = ile * l[index] + r[index] * (zostanie - ile);

		// debug(mid, full, ile, zyskLow, res, curRes);

		if (zyskLow + curRes + res >= 0){
			return true;
		}
	}

	return false;
}

void solve()
{
	cin >> n >> x;

	FOR(i,1,n){
		cin >> b[i] >> l[i] >> r[i];

		curRes -= l[i] * b[i];

		g.eb((x - b[i]) * r[i] + l[i] * b[i], i);
	}

	sort(g.begin(),g.end());
	reverse(g.begin(),g.end());

	if (curRes == 0){
		cout << 0;
		return;
	}

	FOR(i,1,n){
		pref[i] = g[i-1].st + pref[i-1];
	}

	pref[n+1] = pref[n];

	int l = 0, r = x * n + 100;

	while(l != r){
		int mid = (l+r)/2;	

		if (check(mid)){
			r = mid;
		}else{
			l = mid + 1;
		}
	}

	cout << l;

    return;
}

int32_t main()
{
    boost

    test=1;

	for(int i=1; i <= test; i++){
        solve();
	}

    return 0;
}


Measured memory_bytes: 14192
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct UnionFind{
    vector<ll> par;
    vector<ll> siz;

    void init(ll n){
        for(ll i=0;i<n;i++){
            par.push_back(i);
            siz.push_back(1);
        }
    }
    ll root(ll x){
        //根を返す
        if(par[x]==x){
            return x;
        }
        else{
            return (par[x]=root(par[x]));
        }
    }
    bool sameParent(ll x,ll y){
        return(root(x)==root(y));
    }
    void unite(ll x, ll y){
        x=root(x);y=root(y);
        if(x==y)    return;
        //データ構造->小を大にくっつける
        if(siz[x]<siz[y]) swap(x,y);
        siz[x] += siz[y];
        par[y]=x;
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[i]=make_pair(a,b);
    }
    sort(ALL(v));
    ll ans=0;
    int ind=0;
    while(ind<m){
        int l=v[ind].first;
        int r=v[ind].second;
        while(v[ind].first<r){
            chmin(r,v[ind].second);
            ind++;
        }
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m, l = -1e9, r = 1e9; cin>>n>>m;
	for (int i=0; i<m; ++i){
		int x, y; cin>>x>>y;
		l = max(l, x);
		r = min(r, y);
	}
	cout<<max(r-l + 1, 0);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include <wchar.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll h,w,dp[1010][1010],mod=1e9+7;
string s[1010];

int main(void){
	cin>>h>>w;
	rep(i,h)cin>>s[i];
	//
	rep(i,h)rep(j,w)dp[i][j]=0;
	dp[0][0]=1;
	//
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#')continue;
			if(i+1<h && s[i+1][j]=='.'){
				dp[i+1][j] = (dp[i+1][j]+dp[i][j]) % mod;
			}
			if(j+1<w && s[i][j+1]=='.'){
				dp[i][j+1] = (dp[i][j+1]+dp[i][j]) % mod;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{
	long long int n;

	//input
	cin >> n;



	//calc
	long long int ans = 0;

	long long int a = (long long int)ceil(sqrt(n));
	long long int b = (long long int)ceil(sqrt(n));

	while (1 <= a){
		if (n == a * b){
			break;
		}

		if (n < a * b){
			a--;
		}

		b = (long long int)ceil((double)n / a);
	}

	if (a <= 1){
		ans = n - 1;
	}
	else{
		ans = a + b - 2;
	}

	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int R = scanner.nextInt();
			int C = scanner.nextInt();
			if ((R | C) == 0)
				break;
			int[] b = new int[C];
			for (int i = 0; i < R; i++)
				for (int j = 0; j < C; j++) {
					int a = scanner.nextInt();
					b[j] = b[j] * 2 + a;
				}
			int ans = 0;
			loop:
			for (int x = 0; x < (1 << R); x++) {
				int k = 0;
				for (int j = 0; j < C; j++) {
					int aa = b[j];
					int bb = aa ^ x;
					int cc = Integer.bitCount(bb);
					k += Math.max(cc, R - cc);
					if ((C - j -1) * R + k <= ans)
						continue loop;
				}
				ans = Math.max(ans, k);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 75496
d = dict()

n = int(input())
a = [int(x) for x in input().split()]

for x in a:
  d[x - 1] = d.setdefault(x - 1, 0) + 1
  d[x] = d.setdefault(x, 0) + 1
  d[x + 1] = d.setdefault(x + 1, 0) + 1

print(sorted(d.items(), key=lambda x : x[1],  reverse=True)[0][1])

Measured memory_bytes: 27944
#include<stdio.h>
int main(void)
{
	int n,i,s;
	int hi;
	int koku,suu;
	int koku2,suu2;
	scanf("%d %d %d %d %d",&hi,&koku,&suu,&koku2,&suu2);
	i=0;
	n=0;
	while(koku>0){
		koku-=koku2;
		n++;
	}
	while(suu>0){
		suu-=suu2;
		i++;
	}
	if(n<=i){
		hi=hi-i;
	}
	else{
		hi=hi-n;
	}
	printf("%d\n",hi);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int a, b, k, tmp, ans;
  scanf("%lld %lld %lld", &a, &b, &k);
  if(a > b){
    tmp = a;
    a = b;
    b = tmp;
  }

  vector<long long int> v;
  for(int i=1;i<=a;i++){
    if(a%i == 0 && b%i == 0){
      v.push_back(i);
    }
  }

  sort(v.begin(), v.end(), greater<int>());

  ans = v[k-1];

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

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = []
c = []
for i in range(m):
	a, b = map(int, input().split())
	if a == 1:
		ab.append(b)
	if b == n:
		c.append(a)
if len(set(ab) & set(c)) == 0:
	print ("IMPOSSIBLE")
else:
	print ("POSSIBLE")

Measured memory_bytes: 71128
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[1LL<<17] = {};
ll N;
ll a[18][18];
ll calc(ll state){
    ll &res = dp[state];
    if(~res) return res;
    res = 0;
    ll cnt = __builtin_popcount(state);
    if(cnt <= 1) return 0;
    rep(i,0,N){
        rep(j,i+1,N){
            if(((state>>i)&1) && ((state>>j)&1)) res += a[i][j];
        }
    }
    ll res2 = 0;
    for(int bit = (state-1) & state; ; bit = (bit-1) & state){
        if(bit == 0) break;
        res2 = max(res2, calc(bit) + calc(state - bit));
    }
    // rep(bit,0,state){
    //     res2 = max(res2, calc(bit) + calc(state|(~bit)));
    // }

    res = max(res, res2);
    return res;
    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,0,N){
        rep(j,0,N){
            cin >> a[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    ll ans = calc((1LL<<N)-1);
    print(ans);

    

}

Measured memory_bytes: 1280
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#include<math.h>

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)
#define PI 3.14159265358979323846264338327950L
#define MOD 1e9+7

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
} 

int main(){
    go(); 

    // code here
    int a,b,c,d;cin>>a>>b>>c>>d;
    double x = (double)a/d;
    x = ceil(x);
    double y = (double)c/b;
    y = ceil(y);
    cout<<(x>=y?"Yes":"No");
} 



Measured memory_bytes: 3512
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;
int a[N][20];

void solve(int test)
{
  string s;
  cin >> s;
  n = (int)s.size();
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      a[i][0] = i + 1;
    }
    else {
      a[i][0] = i - 1;
    }
  }
  for (int i = 1; i < 20; ++i) {
    for (int j = 0; j < n; ++j) {
      a[j][i] = a[a[j][i - 1]][i - 1];
    }
  }
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    ++ans[a[i][19]];
  }
  for (int val : ans) {
    cout << val << ' ';
  }
  cout << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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


int inf = 1e9 + 5;
 
int main()
{
	int n; cin>>n;
	vector<int> height(n);
	for(int i=0; i<n; i++)
	{
		cin>>height[i];
	}

	vector<int> dp(n+2,inf);dp[0] = 0;
	for(int i=0; i<n; i++)
		{
			dp[i+1]= min(dp[i]+abs(height[i]-height[i+1]),dp[i+1]);
			dp[i+2]= min(dp[i]+abs(height[i]-height[i+2]),dp[i+2]);
		}
		cout<<dp[n-1];



    
    return 0;
    
}    


	








Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static long mod = 1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        memo = new int[k+1];

        long res = 0;
        long[] num = new long[k+1];
        for(int i=k; i>=1; i--) {
            long a = b(k / i, n);
            for(int b = 2; i * b <= k; b++) {
                a += mod - num[i * b];
                a %= mod;
            }
            num[i] = a;
            res += num[i] * i;
            res %= mod;
        }

        System.out.println(res);
    }

    static int[] memo;

    static int b(int a, int b) {
        if(memo[a] > 0) return memo[a];
        long res = 1;
        for(int i=0; i<b; i++) {
            res *= a;
            res %= mod;
        }
        return memo[a] = (int)res;
    }


}

Measured memory_bytes: 36904