akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		int ans = 3;
		if(a == b || b == c || a == c){
			ans = 2;
		}
		if(a == b && b == c){
			ans = 1;
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 19284
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<unsigned,unsigned> uupair;
typedef pair<int,int> iipair;
typedef vector<int> vec;
typedef vector<ll> llvec;
typedef vector<unsigned> uvec;
typedef vector<ull> ullvec;
typedef vector<uvec> grid;
typedef vector<vec> igrid;
typedef vector<string> svec;
typedef vector<svec> sgrid;
typedef vector<bool> bvec;
typedef vector<bvec> bgrid;
typedef vector<char> cvec;
typedef vector<uupair> uupvec;
typedef vector<iipair> iipvec;
typedef unordered_map<unsigned,unsigned> uuhmap;
typedef unordered_map<ll,ll> llllhmap;
typedef map<unsigned,unsigned> uumap;
typedef map<int ,unsigned> iumap;
typedef map<int,int> iimap;
typedef unordered_map<int ,unsigned> iuhmap;
typedef unordered_map<int,int> iihmap;
typedef unordered_map<unsigned,uvec> uuvechmap;
typedef unordered_map<ull,ull> ullullhmap;
typedef map<char,cvec> ccvecmap;
typedef unordered_set<unsigned> uhset;
typedef set<unsigned> uset;
const unsigned LIMIT=1e3;
const unsigned M=1e9+7;
unsigned h,w;
svec matrix;
int dp[LIMIT+1][LIMIT+1];

ull calculate(unsigned row,unsigned col)
{
    ull res=0;
    if(dp[row][col]!=-1)
        return dp[row][col];
    if(row==h && col == w)
    {
        return 1;
    }
    if(row !=h && matrix[row+1-1][col-1]=='.')
    {
        res=(res + calculate(row+1,col))%M;
        
    }
    if(col!=w && matrix[row-1][col+1-1]=='.')
    {
        res=(res + calculate(row,col+1))%M;
    }
    
    return dp[row][col]=res;
}
int main()
{
    cin>>h>>w;
    matrix.resize(h);
    for(unsigned i=0;i<h;++i)
    {
        cin>>matrix[i];
    }
    ull result=0;
    memset(dp,-1,sizeof dp);
    cout<<calculate(1,1);
}

Measured memory_bytes: 5376
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))

    b = [0]
    for num in a:
        b.append(b[-1]+num)
    
    dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
    
    for i in range(2,N+1):
        for j in range(N-i+1):
            dp[j][i] = min(dp[j][k]+dp[j+k][i-k] for k in range(1,i))+b[i+j]-b[j] 
    
    print(dp[0][-1])
        
if __name__ == "__main__":
    main()


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

int main() {
    int n, sum = 0;
    cin >> n;
    int a[25], b[25], c[25];
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        sum += b[i];
    }
    for (int i = 1; i < n; i++)
        cin >> c[i];
    for (int i = 2; i <= n; i++) {
        if (a[i] - a[i - 1] == 1) {
            sum += c[a[i - 1]];
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<queue>
#include<stack>
#include<ctime>
using namespace std;
string c,x="CODEFESTIVAL2016";
int ans=0;
int main(){
	cin>>c;
	int i;
	for(i=0;i<c.size();i++){
		if(c[i]!=x[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

typedef long long ll;


int main()
{
	
	ll w, h, x, y;
	int ans2;
	double ans;
	
	scanf("%lld %lld %lld %lld", &w, &h, &x, &y);
	
	ans = (w*h) / 2.0;
	
	if( ( fabs( (w/2.0) - x) < 1e-9) && ( fabs((h/2.0) - y) < 1e-9) ) ans2 = 1;
	else ans2 = 0; 
	
	printf("%lf %d\n", ans, ans2);
	
	return 0;
}

Measured memory_bytes: 128
// [abhishekvtangod]
// g++ -Wall -Wextra -Wshadow filename.cpp
#include<bits/stdc++.h>
using namespace std; 

#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)

typedef long long int ll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// oset<pair<ll,ll>> indexed_set;


#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif


// struct HASH{
//   size_t operator()(const pair<int,int>&x)const{
//     return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
//   }
// };




void solve()
{
		ll n,k;cin>>n>>k;
		ll temp=n%k;
		cout<<min(temp,abs(temp-k));
}


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

	//ll t;cin>>t;
	//while(t--)
	//{
		solve();
	//}
	

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  using psi = pair<string,int>;
  vector<pair<psi,int>> p(N);
  for(int i=0;i<N;i++){
    string S;
    int P;
    cin >> S >> P;
    auto t = make_pair(S,-P);
    auto &tmp=p;
    tmp.at(i) = make_pair(t,i+1);
  }
  
  sort(p.begin(),p.end());//stringの方が辞書順，intの方が昇順
  
  for(int i=0;i<N;i++){
    int z;
    tie(ignore,z)=p.at(i);
    cout << z << endl;
  }
  
}  

Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
  int N,a;
  scanf("%d",&N);
  if(N%1000 == 0 ){
  a = N/1000;
  }  else{
a = N/1000 + 1;
}
  int b = 1000*a-N;


   printf("%d\n",b);
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	long long K;
	scanf("%lld",&K);

	if (A >= K)
	{
		cout << A - K << " " << B << endl;
	}
	else
	{
		cout << "0 " << max(B - (K - A), 0ll) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];
    
    REP(i,N-1) a[i+1]+=a[i];

    int ans=1e18;
    for(int i=0;i<=N-2;i++){
        int score=abs(2*a[i]-a[N-1]);
        ans=min(ans,score);
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 1792
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,X;
	cin >> N >> X;
	vector<int> A(2*N-1,-1);
	int size = A.size();

	if( X==1 || X==(2*N-1) ){
		cout << "No" << endl;
		return;
	}
	if( N==2 ){
		cout << "Yes" << endl;
		for(int i=1;i<4;++i){
			cout << i << endl;
		}
		return;
	}
	if( X==2 ){//大 X 小 大
		A[N-2] = 3;
		A[N-1] = X;//2
		A[N] = 1;
		A[N+1] = 4;
		int num = 5;
		cout << "Yes" << endl;
		for(int i=0;i<size;++i){
			if( A[i] == -1 ){
				A[i] = num;
				++num;
				cout << A[i] << endl;
			}else{
				cout << A[i] << endl;
			}
		}
		return;
	}else{//小 X 大 小
		A[N-2] = X-2;
		A[N-1] = X;
		A[N] = X+1;
		A[N+1] = X-1;
		int num = 1;
		cout << "Yes" << endl;
		for(int i=0;i<size;++i){
			if( X-2 <= num && num <= X+1 ){
				num = X+2;
			}
			if( A[i] == -1 ){
				A[i] = num;
				++num;
				cout << A[i] << endl;
			}else{
				cout << A[i] << endl;
			}
		}
		return;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


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

int main(void){
	while(1){
		int time=7200;
		int h,t,m;
		scanf("%d%d%d",&h,&t,&m);
		if(h==-1 && t==-1 && m==-1)break;
		time-=h*3600+t*60+m;
		printf("%02d:%02d:%02d\n",time/3600,time%3600/60,time%60);
		time*=3;
		printf("%02d:%02d:%02d\n",time/3600,time%3600/60,time%60);
	}
    return 0;
}

Measured memory_bytes: 0
L = list(map(int, input().split()))
L.sort()
d1 = L[-1] - L[-2]
d2 = L[-1] - d1 - L[0]
if d2 % 2 == 0:
    print(d1 + d2 // 2)
else:
    print(d1 + d2 // 2 + 2)


Measured memory_bytes: 2940
import itertools

def main(N, M, X, CA):
    cand = []
    for n in range(N):  # n個選ぶ
        for ca in itertools.combinations(CA, n+1):
            s, price = f(ca)
            if all(i >= X for i in s):
                cand.append(price)
    if len(cand) == 0:
        print(-1)
    else:
        print(min(cand))


def f(lst):
    s = [0 for _ in range(M)]
    price = 0
    for ca in lst:
        price += ca[0]
        for i in range(M):
            s[i] += ca[i+1]
    return s, price





if __name__ == '__main__':
    N, M, X = list(map(int, input().split()))
    CA = []
    for _ in range(N):
        CA.append(list(map(int, input().split())))

    main(N, M, X, CA)


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int l, ansnode, ansedge;
vector<int>bit;
vector<PP>ans;
int cnt;

int main() {
	cin >> l;
	for (int i = 0;i < 25;i++) {
		if (l < (1 << i))break;
		if (l&(1 << i))bit.eb(1);
		else bit.eb(0);
	}
	ansnode = bit.size();
	for (int i = 0;i < bit.size() - 1;i++) {
		if (i != bit.size() - 2) {
			ans.eb(PP(i + 1, P(i + 2, 0)));
			ans.eb(PP(i + 1, P(i + 2, 1<<cnt)));
			cnt++;
			ansedge += 2;
		}
		else if (i == bit.size() - 2) {
			ans.eb(PP(i + 1, P(i + 2, 0)));
			ans.eb(PP(i + 1, P(i + 2, (1<<cnt))));
			cnt++;
			ansedge += 2;
		}
	}
	ll mx = l;
	for (int i = 0;i < bit.size() - 1;i++) {
		if (bit[i] == 1) {
			ll sum = 0;
			for (int j = 0;j < i;j++)sum += 1 << j;
			ans.eb(PP(i + 1, P(ansnode, mx - sum - 1)));
			mx = mx - sum - 1;
			ansedge++;
		}
	}
	cout << ansnode << ' ' << ansedge << endl;
	for (auto u : ans) {
		cout << u.fr << ' ' << u.sc.fr << ' ' << u.sc.sc << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

using namespace std;

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

int h, w;
v2_string s(30, v_string(30, ""));

int solve(pii start, pii goal)
{
    int d[30][30];

    irep(i, 30) {
        irep(j, 30) {
            d[i][j] = INF;
        }
    }

    queue<pii> q;
    q.push(start);
    d[start.first][start.second] = 0;

    while(q.size()) {
        
        pii p = q.front(); q.pop(); 
        if(p.first == goal.first && p.second == goal.second) { break; }

        irep(i, 4) {
            int row = dy[i] + p.first;
            int col = dx[i] + p.second;
            if(0 <= col && col < w && 0 <= row && row < h) {
                if(s[row][col] != "#" && d[row][col] == INF) {
                    d[row][col] = d[p.first][p.second] + 1;
                    q.push(pii(row, col));
                    //cout << row << "," << col << endl;
                }
            }
        }
    }

    if(d[goal.first][goal.second] != INF) {
        return d[goal.first][goal.second];
    } else {
        return -1;
    }
}

int main(void)
{
    int ans = -1;
    cin >> h >> w;

    irep(i, h) {
        irep(j, w) {
            char tmp;
            cin >> tmp;
            s[i][j] = tmp;
        }
    }

    irep(i, h) {
        irep(j, w) {
            irep(k, h) {
                irep(l, w) {
                    if(i == k && j == l) { continue; }
                    if(s[i][j] == "#" || s[k][l] == "#") { continue; }
                    pii start(i, j);
                    pii goal(k, l);
                    ans = max(ans, solve(start, goal));
                }
            }
        } 
    }
    
    cout << ans << endl;

    return 0;
}
/** atcodr **/


Measured memory_bytes: 256
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"math.h"



int main()
{
    int i,j,k,n,len;
    char a[100000];
    scanf("%d",&n);
    getchar();
    scanf("%s",a);
    len=strlen(a);
    if(n<len)
    {
        for(i=0;i<n;i++)
            printf("%c",a[i]);
        printf("...");
    }
    else
        printf("%s",a);

    return 0;
}


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

int main(){
  int64_t bufN;
  cin >> bufN;
  int64_t N= bufN;

  vector<int> pow(11);
  for(size_t i=0; i<pow.size(); i++){
    pow.at(i)= i*(i+1)/2;
  }

  int ans= 0;
  int64_t div= 2;
  while(div*div <= N){
    int cnt= 0;
    while(N%div==0){
      N/= div;
      cnt++;
    }
    auto itr= upper_bound(pow.begin(), pow.end(), cnt);
    ans+= distance(pow.begin(), itr-1);

    div++;
  }
  if(N > 1){ ans++; }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int64 n, k;
    cin >> n >> k;
    int64 a[200200];
    int64 f[200200];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];

    sort(begin(a), begin(a) + n);
    sort(begin(f), begin(f) + n, [](int64 x, int64 y){return x > y;});

    int64 af[200200];

    int64 l = -1;
    int64 r = 1e12 + 1;
    while (r - l > 1) {
        int64 x = l + (r - l) / 2;
        int64 t = 0;
        rep(i, n) {
            int64 ad = ceil(double(a[i] * f[i] - x) / double(f[i]));
            if (ad > 0) t += ad;
        }
        debug3(l, r, t);
        if (k < t) {
            l = x;
        } else {
            r = x;
        }
    }

    print(r);

    return 0;
}



Measured memory_bytes: 3456
import java.util.*;

public class Main {

  private static final int MAX_COUNT = 999;

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    String n = scan.next();
    int num = Integer.parseInt(n);
    int sum = 0;
    for (int i = 0; i < n.length(); i++) {
      sum += Integer.parseInt(n.substring(i, i + 1));
    }
    if (num % sum == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

    scan.close();
  }
}

Measured memory_bytes: 22740
// AOJ 2545: Lion
// 2017.10.5 bal4u@uu

#include <stdio.h>
#include <string.h>

int n, x, m;
int l[11], r[11], s[11];
int ll, rr, ss;
int ans[7], max;
int a[7], sum[7];

int combi(int k)
{
	int i, xx;


	if (k == n+1) {
		for (i = 1; i <= n ; i++) sum[i] = sum[i-1] + a[i];
	    for (i = 0; i < m; i++)
			if (sum[r[i]] - sum[l[i]-1] != s[i]) return 0;
		if (sum[n] > max) max = sum[n], memcpy(ans, a, sizeof(ans));
		return 1;
	}
	xx = x;	if (k >= ll && k <= rr && xx > ss) xx = ss;
	for (i = xx; i >= 0; i--) {
		a[k] = i;
		if (combi(k+1)) return 1;
	}
	return 0;
}
  
int main()
{
	int i;

	scanf("%d%d%d", &n, &x, &m);
	for (ss = 60, i = 0; i < m; i++) {
		scanf("%d%d%d", l+i, r+i, s+i);
		if (s[i] < ss) ss = s[i], ll = l[i], rr = r[i];
	}
	max = 0;
	if (!combi(1)) puts("-1");
	else {
		for (i = 1; i <= n; i++) {
			if (i > 1) putchar(' ');
			printf("%d", ans[i]);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1768
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const double PI = acos(-1.0);

int x[105], y[105];

int n;

double ang(int x, int y) {
	ll d1 = x * 1ll * x + y * 1ll * y;
	ll d2 = x * 1ll * x + (y - 1) * 1ll * (y - 1);

	double ret = acos((1.0 + d1 - d2) / (2.0 * sqrt(d1)));
	
	if (x < 0) {
		ret = 2.0 * PI - ret;
	}

	return ret;
}

void solve() {                   
	scanf("%d", &n);

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

    vector<double> arr;

    for (int i = 1; i <= n; ++i) {
		arr.clear();

    	for (int j = 1; j <= n; ++j) {
    		if (j == i) {
    			continue;
    		}

    		arr.pb(ang(x[j] - x[i], y[j] - y[i]));
    	}

    	sort(all(arr));
    	int sz = (int)arr.size();

    	double mx = 0.0;

		for (int j = 0; j + 1 < sz; ++j) {
			mx = max(mx, arr[j + 1] - arr[j] - PI);						
		}

		mx = max(mx, PI - arr.back() + arr[0]);
		printf("%.6f\n", mx / (2.0 * PI));
    }    
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n; ll maxhigh = 0; ll count = 0;
  
  for(ll i=0; i < n; i++){
	ll h; cin >> h;
    if(h >= maxhigh){
      maxhigh = h;
      count++;
    }
    
  }
  
  cout << count << endl;
}

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

int main() {
	int a, b; cin >> a >> b;
	int min8 = (a * 100 + 7) / 8;
	int max8 = ((a + 1) * 100 + 7) / 8 - 1;
	int min10 = (b * 100 + 9) / 10;
	int max10 = ((b + 1) * 100 + 9) / 10 - 1;

	if (min8 < min10) {
		if (max8 < min10) cout << -1;
		else cout << min10;
	}
	else {
		if (max10 < min8) cout << -1;
		else cout << min8;
	}
	return 0;
}

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

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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

int main(void){
	string s;
	cin >> s;
	REP(i, 2){
		bool ok = true;
		REP(j, 3){
			if(s[i+j] != s[i]){
				ok = false;
			}
		}
		if(ok){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

int main(){
	int n, k, tmp, l, r, cost;
	vector<int> x;
	cin >> n >> k;
	for (int i=0; i<n; i++){
		cin >> tmp;
		x.push_back(tmp);
	}
	int minCost = 1000000000;
	for(int i=0; i<n-k+1; i++){
		l = x[i];
		r = x[i+k-1];
		if(r<=0){
			cost = -l;
		}else if(r>0 and l<=0){
			if(-l<r) cost = -l*2 + r;
			else cost = -l + r*2;
		}else{
			cost = r;
		}
		if (cost<=minCost) minCost = cost;
	}
	cout << minCost << endl;

	return 0;
}


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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<"."
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<"."
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"."
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d<<"."
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
ll n,a,b,c,d;
void solve(){
	rep(i,n){
		ll s=a+i*c+(n-1-i)*(-d);
		if(s<=b&&b<=(s+(n-1)*(d-c))){
			cout<<"YES"<<endl;
			return;
		}
	}
	cout<<"NO"<<endl;
}

int main(){
	cin>>n>>a>>b>>c>>d;

	solve();
	return 0;
}


Measured memory_bytes: 256
import itertools
from statistics import mean

input = list(map(int, input().split()))
n = input[0]
m = input[1]
d = input[2]

if (d != 0):
    ans = (n - d) * 2 / (n ** 2) * (m - 1)
else:
    ans = (n - d) / (n ** 2) * (m - 1)

print(ans)


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

int main(){
    int64_t N, A, B;
    cin >> N >> A >> B;
    int64_t D = N/(A+B);
    int64_t ans = D*A + min(A, N%(A+B));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

ll dp[3010][3010];

int main(void){
	int n,t;
	cin>>n>>t;
	vector<P>p(n);
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		p[i]=make_pair(a,b);
	}
	sort(p.begin(),p.end());
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<t;j++){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			int nj = j+p[i].first;
			if(nj<t)dp[i+1][j+p[i].first]=max(dp[i+1][j+p[i].first],dp[i][j]+p[i].second);
		}
		int now = dp[i][t-1]+p[i].second;
		ans = max(ans,now);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 74204
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define aint(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 3005;
int dp[N][N], pre[N][N];
int a[N];
int iv2 = pwr(2, mod - 2);
map<int,int> m;
void solve(){
	int n, q;
	cin >> n >> q;
	fr(i, 1, n){
		cin >> a[i];
		m[a[i]] = 0;
	}
	int cc = 0;
	for(auto &it : m){
		it.se = ++cc;
	}
	fr(i, 1, n){
		a[i] = m[a[i]];
	}
	fr(i, 1, n){
		fr(j, 1, n){
			if(a[i] > a[j])
				dp[i][j] = 1;
		}
	}
	// fr(i, 1, n){
	// 	fr(j, 1, n){
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	fr(i, 1, q){
		int x, y;
		cin >> x >> y;
		int lol = (dp[x][y] + dp[y][x]);
		dp[x][y] = dp[y][x] = (iv2 * lol) % mod;
		fr(k, 1, n){
			if(k == x || k == y) continue;
			int lol = (dp[x][k] + dp[y][k]);
			dp[x][k] = dp[y][k] = (iv2 * lol) % mod;
			lol = (dp[k][x] + dp[k][y]) % mod;
			dp[k][x] = dp[k][y] = (iv2 * lol) % mod;
		}
		// fr(i, 1, n){
		// 	fr(j, 1, n){
		// 		cout << dp[i][j] << " ";
		// 	}
		// 	cout << endl;
		// }
	}
	int ans = 0;
	fr(i, 1, n){
		fr(j, i + 1, n){
			ans += dp[i][j];
			ans %= mod;
		}
	}
	cout << (ans * pwr(2, q)) % mod;
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

Measured memory_bytes: 71936
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;
#define MAX_V 50000
struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

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

void bfs(int s) {
	memset(level, -1LL, sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (int i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f) {
	if (v == t) return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0) return flow;
		memset(iter, 0, sizeof(iter));
		int f;
		while ((f = dfs(s, t, INF)) > 0) {
			flow += f;
		}
	}
}


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

	int H, W; cin >> H >> W;
	int A = 20001, B = 20002;
	int C = 10000;
	int dx[] = { 0,0,-1,1 };
	int dy[] = { -1,1,0,0 };
	VS S(H);
	REP(i, H)cin >> S[i];

	REP(i, H)if (S[i][0] == 'X' || S[i][W - 1] == 'X') {
		cout << -1 << endl;
		return 0;
	}
	REP(i, W)if (S[0][i] == 'X' || S[H - 1][i] == 'X') {
		cout << -1 << endl;
		return 0;
	}

	REP(i, H) {
		REP(j, W) {
			int k = i * W + j % W;
			int tmp = k;
			if (S[i][j] == 'X') {
				add_edge(k, k + C, INF);
				add_edge(A, k + C, INF);
			}
			else add_edge(k, k + C, 1);

			if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
				add_edge(k + C, B, INF);
			}

			REP(l, 4) {
				int nx = i + dx[l], ny = j + dy[l];
				if (nx < 0 || nx >= H || ny < 0 || ny >= W)continue;
				k = nx * W + ny % W;
				add_edge(tmp + C, k, INF);
			}
		}
	}

	cout << max_flow(A, B) << endl;

	return 0;
}



Measured memory_bytes: 8952
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  vll L(N+1,1);
  L[0]=2;
  for(int i=2;i<=N;i++){
    L[i]=L[i-1]+L[i-2];
  }
  cout << L[N] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<utility>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
using namespace std;

const double eps = 1e-8;
const double INF = 1e12;

int calc(double n,double tax){
	return (int)(n*(100.0+tax)/100.0);
}

int main(){
	double x,y;
	int s;
	while(1){
		cin>>x>>y>>s;
		if(x==0 && y==0 && s==0)break;
		vector<int> intax;
		for(int i=1;i<=s;i++){
			for(int j=1;j<=s;j++){
				double a=i,b=j;
				int sum=calc(a,x)+calc(b,x);
				if(sum==s){
					intax.push_back(calc(a,y)+calc(b,y));
				}
			}
		}
		sort(intax.begin(),intax.end());
		cout<<intax[intax.size()-1]<<endl;
	}
	return 0;
}

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

using namespace std;

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

    int a = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '(') a++;
        else if (a > 0 && s[i] == ')') a--;
    }

    string r = "";
    for (int i = 0; i < a; i++)
        r += ")";
    
    string cpy = s;
    for (int i = 0; i < n; i++) {
        if (s[n - 1 - i] == ')') cpy[i] = '(';
        else cpy[i] = ')';
    }

    a = 0;
    for (int i = 0; i < n; i++) {
        if (cpy[i] == '(') a++;
        else if (a > 0 && cpy[i] == ')') a--;
    }

    string l = "";
    for (int i = 0; i < a; i++)
        l += "(";
    
    cout << l + s + r << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String[]S = new String[N];
    ArrayList<String>hina = new ArrayList<>();
    
    for(int i=0; i<N-1; i++){
       S[i] = sc.next();
    if(!hina.contains(S[i])){
        hina.add(S[i]);
   } 
}
    if(hina.size()==4){
        System.out.println("Four");
    }else{
        System.out.println("Three");
    }
}
}

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

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

    char number[10];
    int sum = 0;
    strcpy(number, N.c_str());
    for(unsigned int i = 0; i < N.size(); i++){
        sum += number[i] - '0';
    }
    int nn = atoi((const char*) N.c_str());
    if (nn%sum==0) cout << "Yes" << endl;
    else cout << "No "  << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

if K == 0:
  print(N ** 2)
  exit()

ans = 0
for b in range(K+1, N+1): ## b in [K+1,N]
  var1 = b-1 - K + 1
  Nmodb = N // b
  if N < K + Nmodb * b:
    var2 = 0
  else:
    var2 = N - (K+Nmodb*b) + 1
  ans += var1 * Nmodb + var2
  #print(b, var1, Nmodb, var2, var1 * Nmodb + var2)
  
print(ans)

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    if n == 0:
        print(0)
        exit()
    bit = []
    i = 0
    base = 1
    while n != 0:
        if n % (base * 2) == 0:
            bit.append("0")
        else:
            bit.append("1")
            n -= base
        i += 1
        base *= -2
    print("".join(bit[::-1]))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 300000;
ll mod = INF;
ll H,W,M;
ll r[maxn],c[maxn];
ll R[maxn]={0},C[maxn]={0};
set<pair<int,int>> s;

int main(){

    cin >> H>>W>>M;
    for(int i=0;i<M;i++){
        cin >> r[i]>>c[i];
        r[i]--;c[i]--;
        R[r[i]]++;C[c[i]]++;
        s.insert(make_pair(r[i],c[i]));
    }

    ll rmax=0,cmax=0;
    for(int i=0;i<H;i++){
        rmax=max(rmax,R[i]);
    }
    for(int i=0;i<W;i++){
        cmax=max(cmax,C[i]);
    }
    vector<int> rnum,cnum;
    for(int i=0;i<H;i++){
        if(R[i]==rmax)rnum.push_back(i);
    }
    for(int i=0;i<W;i++){
        if(C[i]==cmax)cnum.push_back(i);
    }

    bool found=false;
    
    for(int i=0;i<rnum.size();i++){
        for(int j=0;j<cnum.size();j++){
            decltype(s)::iterator it =s.find(make_pair(rnum[i],cnum[j]));
            if(it==s.end()){
                found=true;
                break;
            }
        }
        if(found)break;
    }

    if(!found)cout << rmax+cmax-1<<endl;
    else cout << rmax+cmax<<endl;
    
    return 0;
}

Measured memory_bytes: 30836
/*
☭░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░☆
☭░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░☆
☭░░░░░░░░▓▓░▓▓▓▓▓▓▓▓░░▓▓▓░░░░░░░☆
☭░░░░░░░█▓▓░░░▓▓▓▓▓▓▓▓▓▓░▓░░░░░░☆
☭░░░░░░░█▓░░░░░░░░░░░░░▓▓▓▓░░░░░☆
☭░░░░░░▓█░░░░░░░░░░░░░░▓░▓▓░░░░░☆
☭░░░░░░▓▓░▀▀▀▀░░▀▀▓▓▓░░░▓▓▓░░░░░☆
☭░░░░░░░▓░██▓▓░░██▓░░░░░░▓▓░░░░░☆
☭░░░░░░▓░░░░░░░░░░░░░░░░░░▓░░░░░☆
☭░░░░░░▓░░░░░▓░░▓░░░░░░░░▓░░░░░░☆
☭░░░░░░▓▓░░▓▓░██░▓▓░░░░░░▓░░░░░░☆
☭░░░░░░░░▓███▀▀▀████░░░░▓▓▓░░░░░☆
☭░░░░░░░░▓░░░░░░░░░░░░░░▓▓▓▓░░░░☆
☭░░░░░░░░▓░░░░░░░░░░░░░▓▓▓▓▓░░░░☆
☭░░░░░░▓▓▓▓▓░▓▓▓▓▓░░░░▓▓▓▓▓░░░░░☆
☭░▓☆▓▓▓▓▓▓▓▓▓▓░░▓▓░░░▓▓▓▓▓▓▓▓░░░☆
▓▓▓▓▓▓▓▓▓█☆█▓▓▓▓▓░░░▓▓▓▓☆█▓▓▓▓☆▓▓
▓▓▓▓▓▓▓▓▓▓██
*/
#include <bits/stdc++.h>
using namespace std;

const int a[] = {0, 300000, 200000, 100000};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x <= 3) {
    ans += a[x];
  }
  if (y <= 3) {
    ans += a[y];
  }
  if (x == 1 && y == 1) {
    ans += 400000;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n;

  cin>>n;

  int a[100001];

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

  int t,cnt=0;
  cin>>t;

  int q;

  for(int i=0;i<t;i++){
    cin>>q;

    if(upper_bound(a,a+n,q)-lower_bound(a,a+n,q)){
      cnt++;
    }
  }
  
  cout<<cnt<<endl;
  
  return 0;
  
}



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


int main(){
	int i,j;
	int m,n;
	int a[200010],b[200010];
	map<int,int>mpa,mpb;
	scanf("%d",&m);
	rep(i,0,m){
		scanf("%d",&a[i]);
	}
	scanf("%d",&n);
	rep(j,0,n){
		scanf("%d",&b[j]);
	}
	rep(i,0,m){
		mpa[a[i]]++;
	}
	rep(j,0,n){
		mpb[b[j]]++;
	}
	rep(i,0,n){
		int x=b[i];
		if(mpb[x]>mpa[x]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}





Measured memory_bytes: 20608
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    vector<int> vecH(N);
    for (int i = 0; i < N; ++i)
    {
        int H;
        cin >> H;
        vecH[i] = H;
    }
    
    int start = 0;
    int startOfMaxCnt = 0;
    int cnt = 0;
    int maxCnt = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        if (vecH[i] >= vecH[i + 1])
        {
            ++cnt;
            if (cnt > maxCnt)
            {
                startOfMaxCnt = start;
                maxCnt = cnt;
            }
        }
        else
        {
            start = i + 1;
            cnt = 0;
        }
    }
    
    cout << maxCnt << endl;
    
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    if(s.size()+1==t.size())
    {

        t.erase(t.end()-1);
        if(t==s)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    else
        cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push
#define fi first
#define se second
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long int unsigned lliu;
typedef long long int lli;
typedef pair<lli,lli> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

int main(){__
    int n, a, b;
    cin>>n>>a>>b;
    if((a-b)%2)
        cout<<"Borys\n";
    else
        cout<<"Alice\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if(b<n*a)
        printf("%d",b);
    else
        printf("%d",n*a);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<climits>
#include<algorithm>
using namespace std;

#define MaxDistance 20000
#define None INT_MAX>>1

int n, m, c, s, g;
vector< vector<int> > cost;
vector< vector< vector<int> > > dist;
vector< vector< vector<int> > > fee;

int main() {
    while(cin>>n>>m>>c>>s>>g, n|m|c|s|g) {
        s--; g--;
        dist = vector< vector< vector<int> > >(c, vector< vector<int> >(n, vector<int>(n, None)));
        for(int i=0; i<m; i++) {
            int x, y, d, c;
            cin>>x>>y>>d>>c;
            x--; y--; c--;
            dist[c][x][y] = dist[c][y][x] = min(dist[c][x][y], d);
        }
        cost = vector< vector<int> >(c, vector<int>(MaxDistance+1));
        vector<int> p(c);
        for(int i=0; i<c; i++) cin>>p[i];
        for(int company=0; company<c; company++) {
            vector<int> q(p[company]+1);
            vector<int> r(p[company]);
            q[0] = 0;
            q[p[company]] = MaxDistance;
            for(int i=1; i<p[company]; i++) cin>>q[i];
            for(int i=0; i<p[company]; i++) cin>>r[i];
            cost[company][0] = 0;
            for(int i=0; i<p[company]; i++) {
                for(int j=q[i]+1; j<=q[i+1]; j++) {
                    cost[company][j] = cost[company][j-1] + r[i];
                }
            }
        }

        for(int company=0; company<c; company++)
            for(int k=0 ;k<n; k++)
                for(int i=0; i<n; i++)
                    for(int j=0; j<n; j++)
                        dist[company][i][j] = min(dist[company][i][j], dist[company][i][k]+dist[company][k][j]);
        fee = vector< vector< vector<int> > >(c, vector< vector<int> >(n, vector<int>(n, None)));
        for(int company=0; company<c; company++)
            for(int i=0; i<n; i++)
                for(int j=0; j<n; j++)
                    if(dist[company][i][j] != None) fee[company][i][j] = cost[company][dist[company][i][j]];
        vector< vector<int> > minFee(n, vector<int>(n, None));
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                for(int company=0; company<c; company++)
                    minFee[i][j] = min(minFee[i][j], fee[company][i][j]);
        for(int k=0 ;k<n; k++)
            for(int i=0; i<n; i++)
                for(int j=0; j<n; j++)
                    minFee[i][j] = min(minFee[i][j], minFee[i][k]+minFee[k][j]);
        cout<<(minFee[s][g] == None ? -1 : minFee[s][g])<<endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

const ll INF = 1e18;

pll dp[2005][2005];
string S;
pll dfs(int l, int r){
	pll ret;
	if( dp[l][r] != pll(-INF,-INF) ) return dp[l][r];
	if( r-l <= 0 ) return dp[l][r] = pll(0,1);
	if( S[l] == S[r] ){
		ret = dfs(l+1, r-1);
	}else{
		auto r1 = dfs(l+1, r);
		auto r2 = dfs(l, r-1);
		if( r1.first != r2.first ){
			ret = min( r1, r2 );
		}else{
			ret = pll( r1.first, min(INF, r1.second+r2.second) );
		}
		ret.first++;
	}
	return dp[l][r] = ret;
}

bool flag = false;
string dfs(int l, int r, ll k){
	if( r-l <= 0 && k > 0 ) flag = true;
	if( r-l <= 0 ) return S.substr(l,1+r-l);
	bool sw = true;
	if( S[l] == S[r] ){
		return S[l] + dfs(l+1, r-1, k) + S[l];
	}else{
		auto pl = dfs(l+1, r);
		auto pr = dfs(l, r-1);
		if( pl.first != pr.first ){
			sw = (pl.first < pr.first);
		}else{
			if( S[l] > S[r] ) swap(pl, pr);
			sw = ( S[l] > S[r] ) ^ ( k < pl.second );
			if( k >= pl.second ) k -= pl.second;
		}
	}
	if( sw ) return S[l] + dfs(l+1, r, k) + S[l];
	else     return S[r] + dfs(l, r-1, k) + S[r];
}

int main(){
	ll k;
	cin >> S >> k;
	rep(i,2005) rep(j,2005) dp[i][j] = pll(-INF, -INF);

	auto ans = dfs(0, S.length()-1, k-1);
	cout << (flag ? "NONE" : ans) << endl;

	return 0;
}

Measured memory_bytes: 66216