akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
    }
    if n == 1 {
        puts!("1\n1\n");
        return;
    }
    if n == 2 {
        puts!("2\n0\n11\n");
        return;
    }
    let mut ans = vec![];
    for i in 2..n + 1 {
        let mut c = vec!['1'];
        for _ in 1..i - 1 {
            c.push('0');
        }
        c.push('1');
        ans.push(c.into_iter().collect::<String>());
    }
    puts!("{}\n", ans.len());
    for a in ans {
        puts!("{}\n", a);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;

int judge(int x){
    if(x <=0) return 1000;
    int ans=0;
    while(1){
        ans += x%10;
        x /=10;
        if(x==0) break;
    }
    return ans;
}



int main(){
    int n;
    cin >> n;
    int ans=9999;
    int i=1;
    while(1){
        int tmp;
        tmp = judge(i) + judge(n-i);
        ans=min(ans,tmp);
        i+=1;
        if(i >= n/2 +1) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    vector<vector<int>> c(3,vector<int>(3));
    rep(i,3){
        rep(j,3){
            cin>>c[i][j];
        }
    }
    bool whether=true;
    if(c[0][0]+c[1][1]!=c[0][1]+c[1][0]) whether=false;
    if(c[0][0]+c[2][2]!=c[0][2]+c[2][0]) whether=false;
    if(c[2][2]+c[1][1]!=c[2][1]+c[1][2]) whether=false;
    if(whether){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int r = 0;
    int now = 0;
    ll ans = 0;
    for (int l = 0; l < n; ++l) {
        while (r < n && (now ^ a[r]) == (now + a[r])) {
            now ^= a[r];
            r++;
        }
        ans += r - l;
        now ^= a[l];
        if (l == r) r++;
    }
    cout << ans << endl;
}

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

int main()
{
	int n = 0, a = 0, b = 0, c = 0;

	cin >> n >> a >> b;

	for (int i = 1; i <= n; i++) {
		int k = i, s = 0;
		for (int j = 0; j < 5; j++) {
			s += k % 10;
			k /= 10;
		}
		if (s >= a && s <= b)
			c += i;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int, input().split()))
    C.append(l[0])
    A.append(l[1:])
 
ans = -1
for i in range((1<<N)):
    u = [0] * M
    p = 0
    for j in range(N):
        if i & (1 << j):
            p += C[j]
            for k in range(M):
                u[k] += A[j][k]
    if min(u) >= X:
        if ans == -1 or ans > p:
            ans = p
print(ans)

Measured memory_bytes: 9212
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()
    val AB = rd.readListLongCols(N)

    var sum = 0L
    AB.reversed().forEach {
        val A = it[0]; val B = it[1]
        val C = B * ((A + sum + B - 1)/B)
        val press = C - (A + sum)
        sum += press
    }

    val ans = sum
    println(ans)
}


//val rd = debug.Reader("agc", "009", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 67544
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,a,c) for(auto it=c.begin()+a;it!=c.end();it++)
#define fr(i,a,n)	for(int i=a;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;


int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a > b); 
}

bool comp1(pi a, pi b)
{
	if(a.first==b.first)return a.second<b.second;
	else return a.first>b.first;
}

template<typename T> 
istream& operator>>(istream& in, vector<T>& v)
{
	for (T& x : v) in >> x; return in;
}

template<typename T> 
ostream& operator<<(ostream& out, vector<T>& v)
{
	for (T& x : v) out << x; return out;
}

// template<typename T>
int sum1(vector<int>& v)
{
	int sum=0;
	// for(auto x: v)sum+=x;
	fr(i,0,v.size())sum+=v[i];
	return sum;
}





 void solve()
{
	string s;
	cin>>s;
	int n= s.size();
	if(n==1)
	{
		if(s[0]=='R')cout<<1;
		else cout<<0;
		return;
	}
	else
	{
		if(s[1]=='S')
		{
			if(s[0]=='R'||(n==3&&s[2]=='R'))cout<<1;
			else cout<<0;
			return;
		}
		if(n==2)
		{
			if(s[0]=='R')cout<<2;
			else cout<<1;
			return;
		}
		if(n==3)
		{
			if(s[0]=='R')
			{
				if(s[2]=='R')
					cout<<3;
				else
					cout<<2;
			}
			else
			{
				if(s[2]=='R')cout<<2;
				else cout<<1;
			}
			return;
		}
	}



}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;	
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

struct edge{
	ll to,cost;
};

ll depth[100010];
vector<edge> tree[100010];

void dfs(int v,int p,ll d){
	depth[v]=d;
	for(edge e:tree[v]){
		if(e.to==p)
			continue;
		dfs(e.to,v,d+e.cost);
	}
}

int main(){
	int n;
	cin>>n;
	rep(i,n-1){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		tree[a].push_back({b,c});
		tree[b].push_back({a,c});
	}
	int q,k;
	cin>>q>>k;
	k--;
	dfs(k,-1,0);
	rep(i,q){
		int x,y;
		cin>>x>>y;
		x--;y--;
		cout<<depth[x]+depth[y]<<endl;
	}	
	return 0;
}


Measured memory_bytes: 14336
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define  nax 109
#define naxW 100009
typedef long long lld;



int main(){
	lld N;
	lld W;
	lld w[nax];
	lld v[nax];
	lld dp[nax][naxW];
	scanf("%lld",&N);
	scanf("%lld",&W);
	for(int i=0;i<N;i++){
		scanf("%lld",&w[i]);
		scanf("%lld",&v[i]);
	}
	for(int i=0;i<N;i++){
		dp[i][0] = 0; // dp[pos][peso]
	}
	for(int i=0;i<N;i++){
		for(int j=1;j<=W;j++){
			lld siSacas = 0;
			if (j >= w[i]){
				if(i!=0){
				siSacas = dp[i-1][j-w[i]] + v[i];
				}else{
					siSacas=v[i];
				}
			}
			lld NoSaco = 0;
				if(i!=0){
					NoSaco = dp[i-1][j];
				}
			dp[i][j] = siSacas > NoSaco ? siSacas:NoSaco;
		}
	}
	printf("%lld",dp[N-1][W]);
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string s;
    cin >> s;
    s = "0" + s;

    if(s == string(s.rbegin(), s.rend()) && s[1] == '1') {
        int r = 1;
        for(int i=2; i<s.size(); i++) {
            cout << r << ' ' << i << endl;
            if(s[i-1] == '1') r = i;
        }
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1660
H, W, K = gets.split.map(&:to_i)
arr = []
ans = 0
blk = 0
H.times do |i|
	tmp = gets.chomp.to_s
	tmp = tmp.split("")
	arr << tmp
end

tmp = Marshal.load(Marshal.dump(arr))
blk = 0


			h = []
			w = []
			[0, 1].repeated_permutation(H) do |bit|
				h << bit
			end
			[0, 1].repeated_permutation(W) do |bit|
				w << bit
			end
			#p h
			#p w
			(h.length).times do |m|
				(w.length).times do |n|
					(h[m].length).times do |s|
						if h[m][s] == 1
							tmp[s].fill("*")
						end
					end
					(w[n].length).times do |o|
						if w[n][o] == 1
							H.times do |p|
								#p tmp[p][o]
								tmp[p][o] = "*"
							end
						end
					end
					#p tmp
					H.times do |n|
						blk += tmp[n].count("#")
					end
					if blk == K
						#puts "ok"
						ans += 1
					end
					tmp = Marshal.load(Marshal.dump(arr))
					blk = 0
				end
			end


p ans

Measured memory_bytes: 14296
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
	int k;
	bool flag;
	
	cin >> k;
	
	for(int i=k;;i++){
		flag = false;
		for(int j=2;j<k;j++){
			if((i%j) == 0){
				flag = true;
				break;
			}
		}
		if(flag)	continue;
			
		
		cout << i << '\n';
		return; 
	}
}

int main(){
	int t = 1;

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





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <unordered_map>
#include <cmath>

int main() {
	int n, d;
	std::cin >> n >> d;
	
	std::vector<std::vector<int>> x;
	for (int i = 0; i < n; i++)
	{
		std::vector<int> v;
		for (int i = 0; i < d; i++)
		{
			int num;
			std::cin >> num;
			v.push_back(num);
		}
		x.push_back(v);
	}

	int counter = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			double sum = 0;
			for (int d_i = 0; d_i < d; d_i++)
			{
				sum += std::pow((double)(x[i][d_i] - x[j][d_i]), 2.0);
			}
			auto sq = sqrt(sum);
			if ((double)(int)sq == sq)
			{
				++counter;
			}	
		}
	}
	std::cout << counter << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 10
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
char st[MN+5];
int res1[MN+5],res2[MN+5];
int Solve(long long x)
{
    printf("? %lld\n",x);fflush(stdout);
    scanf("%s",st+1);return st[1]=='Y';
}
void Search(int l,int r)
{
    int mid,res;
    while(l<=r)
    {
        mid=l+r>>1;
        if(Solve(10LL*mid)) res=mid,r=mid-1;
        else l=mid+1;
    }
    printf("! %d\n",res);
}
int main()
{
  //  10^x  ->   > || 10^y(y<=x)
  //  10^x-1  ->  < || 10^y-1(y>=x)
    bool r1=1;
    for(int i=1,x=1;i<=9;++i)
    {
        x*=10;
        res1[i]=Solve(x);
        res2[i]=Solve(x-1);
        r1&=res1[i];
    }
    if(r1)
    {
        int l=1,r=1000000000;
      //  is 10^x  -> no-> > yes-><=
        for(int i=1,x=1;i<=9;++i)
        {
            x*=10;
            if(!res2[i]) l=x;
            else r=min(r,x-1);
        }
        Search(l,r);
    }
    else
    {
        int last=9,result=1000000000;
        for(;last&&!res1[last];--last,result/=10);++last;
        Search(result,result*10-1);
    }
    return 0;
}


Measured memory_bytes: 596
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

k,x = na()
a = []

for i in range(x-k+1,x+k):
    if i >= -1000000 and i <= 1000000:
        a.append(i)

print(' '.join([str(s) for s in a]))

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int i,x[9+1],wa;
	scanf("%d",&wa);
	while(wa!=0) {
		for(i=1;i<=9;i++) {
			scanf("%d",&x[i]);
			wa=wa-x[i];
		}
		printf("%d\n",wa);
	scanf("%d",&wa);
	}
	return 0;
}

Measured memory_bytes: 600
import sys
num_bills, total_yen = map(int, input().split())

for i in range(num_bills + 1):
    for j in range(num_bills + 1 - i):
        num_bills_left = num_bills - i - j
        if num_bills_left < 0:
            continue

        if (i * 10000 + j * 5000 + num_bills_left * 1000) == total_yen:
            print("{} {} {}".format(i, j, num_bills_left))
            sys.exit()

print("-1 -1 -1")





Measured memory_bytes: 41324
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    l=sort(parseMap(split(readline())))
    ans=0
    for i in 1:n
        for j in i+1:n
            n1=searchsortedlast(l,l[i]+l[j]-1)
            n2=searchsortedfirst(l,-l[i]+l[j]+1)
            n1,n2=min(n1,n2),max(n1,n2)
            n1,n2=max(n1,j),min(n2,n)
            ans+=max(n2-n1,0)
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 114324
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <utility>
#include <string>
#include <numeric>
#include <iterator>
using namespace std;


int main()
{
    long long int n, m, ans = 0;
    cin >> n >> m;
    vector<pair<long long int, long long int>> shop;
    long long int a, b;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        shop.push_back(make_pair(a, b));
    }
    sort(shop.begin(), shop.end());
    for(int i = 0; i < n; i++) {
        if(shop[i].second < m) {
            ans += shop[i].first*shop[i].second;
            m -= shop[i].second;
        } else {
            ans += m*shop[i].first;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
import math

n = int(input())

bi_factors = []

for i in range(1,int(math.sqrt(n)+1)):
    if n%i == 0:
        temp = (i,n//i)
        bi_factors.append(temp)

inf = float('INF')
ans = inf

for point in bi_factors:
    d = point[0] + point[1] - 2
    if ans > d:
        ans = d

print(ans)



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

int main()
{
  int64_t n, ans = 0;
  cin >> n;
  vector<int64_t> dp(n, -1);
  for (int64_t a = 1; a < n; a++)
  {
    int64_t maxb = (n - 1) / a;
    ans += maxb;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11168
#include <stdio.h>
int main(){
	int m,n;
	int i,j,k;
	refrain:
	scanf("%d",&m);
	if(m==0){
		return 0;
	}
	int seizax[m],seizay[m];
	for(i=0;i<m;i++){
		scanf("%d %d",&seizax[i],&seizay[i]);
	}
	scanf("%d",&n);
	int starx[n],stary[n];
	for(i=0;i<n;i++){
		scanf("%d %d",&starx[i],&stary[i]);
	}
	int diffx,diffy;
	int flag;
	for(i=0;i<n;i++){//すべての星を基準点(=seiza[0])として考える
		diffx=starx[i]-seizax[0];
		diffy=stary[i]-seizay[0];
		for(j=1;j<m;j++){
			flag=0;
			for(k=0;k<n;k++){//星があるか捜索
				if(seizax[j]+diffx==starx[k]&&seizay[j]+diffy==stary[k]){
					flag=1;
					break;
				}
			}
			if(flag==0){//星が存在しない場合
				flag=-1;
				break;
			}
		}
		if(flag!=-1){
			printf("%d %d\n",diffx,diffy);
			goto refrain;
		}
	}
	printf("ERROR!The star can't be found.\n");
	return 0;
}
		

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

typedef long long ll;
ll MOD = 1000000007;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> M;
  for(int i = 0;i < 10;i++){
    M.push_back(pow(9,i));
    M.push_back(pow(6,i));
  }
  sort(M.begin(),M.end());
  vector<ll> dp(N+1,10000000);

  dp[0] = 0;
  remove(M,0);
  ll n = M.size();
  for(ll i = 1;i < N + 1;i++){
    for(ll j = n - 1;j >= 0;j--){
      if(i >= M[j]){
        dp[i] = min(dp[i - M[j]] + 1,dp[i]);
      }
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, k, ans;
	cin >> n >> k;
	vector<lli> a(n);
	rep(i,n) cin >> a[i];
	if(n == k) ans = 1;
	else if(k == 2) ans = n-1;
	else if(n%(k-1) < 2) ans = n/(k-1);
	else ans = n/(k-1) + 1;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	fmt.Fprintln(writer, a+a*a+a*a*a)
}


Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main(){
	daman;
	
	char c;
	cin>>c;
	
	if(c >= 'A' && c <= 'Z')
		cout<<"A\n";
	else
		cout<<"a\n";
}

Measured memory_bytes: 3648
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]+=32;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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 pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main(){
    ll N;
  	ll ans = 0;
  	cin >> N;
  	vector<ll> A(N);
  	rep(i,N){
      cin >> A[i];
    }
  	rep(i,N){
      ans++;
      while(i+1<N&&A[i]==A[i+1]) i++;
      if(i==N-1) break;
      if(A[i]<A[i+1]){
      	while(i+1<N&&A[i]<=A[i+1]) i++;
    	}else{
     	 while(i+1<N&&A[i]>=A[i+1]) i++;
    	}
      
    }
  	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main (){
	int N,AC=0,WA=0,TLE=0,RE=0;
	scanf("%d", &N);
	char str[10];
	for (int i=0 ; i<N ; i++)
	{
		scanf("%s", str);
		
		if(strcmp(str,"AC")==0){ // "AC" - "AC" = 0
			AC++;}
		if(strcmp(str,"WA")==0){ // "AC" - "AC" = 0
			WA++;}
		if(strcmp(str,"TLE")==0){ // "AC" - "AC" = 0
			TLE++;}
		if(strcmp(str,"RE")==0){ // "AC" - "AC" = 0
			RE++;}
	}
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE);
return 0;
}


Measured memory_bytes: 1732
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	// ReadString returns a WORD string.
	ReadString func() string
)

func init() {
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
}

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	n, _ := strconv.Atoi(ReadString())
	return n
}

func readInt64() int64 {
	n, _ := strconv.ParseInt(ReadString(), 0, 64)
	return n
}

// 10 11 12 => [10, 11, 12]
func readIntSlice(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func fact(n, m int) int {
	res := 1
	for i := m + 1; i <= n; i++ {
		res *= i
	}
	return res
}

func perm(n, r int) int {
	if r > n {
		return 0
	}
	return fact(n, n-r)
}

func comb(n, m int) int {
	if m > n {
		return 0
	}
	return fact(n, n-m) / fact(m, 0)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func main() {
	N, M, Q := readInt(), readInt(), readInt()
	var A, B, C, D []int
	for i := 0; i < Q; i++ {
		A = append(A, readInt()-1)
		B = append(B, readInt()-1)
		C = append(C, readInt())
		D = append(D, readInt())
	}
	list := make([]int, N)
	for i := 0; i < N; i++ {
		list[i] = 1
	}
	max := 0
	for i := 0; i < 1000000; i++ {
		score := solve(Q, list, A, B, C, D)
		if max < score {
			max = score
		}
		if list[0] == M {
			break
		}
		increment(list, N, M)
	}
	fmt.Println(max)
}

func increment(list []int, n, m int) []int {
	l := []int{}
	for i := 0; i < n; i++ {
		if list[n-1-i] == m {
			l = append(l, n-1-i)
			continue
		}
		list[n-1-i]++
		for _, v := range l {
			list[v] = list[n-1-i]
		}
		break
	}
	return list
}

func solve(q int, list, a, b, c, d []int) int {
	sum := 0
	for i := 0; i < q; i++ {
		if list[b[i]]-list[a[i]] == c[i] {
			sum += d[i]
		}
	}
	return sum
}


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

int main(){
    int a,b;
    cin >> a >> b;

    int cnt = 0 ;
    vector<int> keta;
    for ( int i = a ; i <= b ; i++ ){
      	int j = i;
        while ( j > 0 ){
            keta.push_back( j % 10 );
            j /= 10;
        }
        if ( keta.at(0) == keta.at(4) && keta.at(1) == keta.at(3) )cnt++;
        keta.clear();
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n;
  cin >> n;
  deque<int> a;
  rep(i,n) {
    int b; cin >> b;
    if (i % 2 == 0) a.push_front(b);
    else a.push_back(b);
  }

  if (n % 2 == 1) {
    rep(i,n) cout << a[i] << ' ';
  } else {
    rep(i,n) cout << a[n-i-1] << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4444
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String s=sc.next();
String rev=new StringBuffer(s).reverse().toString();
int l=s.length();
int ctr=0;
int fA=0;
int fZ=0;
while(fA==0){
if(s.charAt(ctr)=='A'){fA=ctr;ctr=0;break;}
ctr++;
}
while(fZ==0){
if(rev.charAt(ctr)=='Z'){fZ=ctr;break;}
ctr++;
}
System.out.println(l-fZ-fA);
}
}

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

int main( )
{
  char X, Y;
  cin >> X >> Y;
  
  if(X < Y) cout << '<' << endl;
  if(X > Y) cout << '>' << endl;
  if(X == Y) cout << '=' << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() 
{
  int t, a, b, i, flag=0;
  cin >> t >> a >> b;
  for(i=a;i<=b;i++) 
  if(i%t==0)
  {
  	flag=1;
  	break;
  } 
  
  if(flag==1)
  cout << "OK" << endl;
  else
  cout << "NG" << endl;
  
  return 0;
} 

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int N,M,DP[100001],res=0;
bool visited[100001];
vector<int>to[100001];
int dfs(int now)
{
	if(to[now].empty())
	{
		return 0;
	}
	else if(DP[now]>-1)return DP[now];
	else
	{
		int best=0;
		for(int i=0;i<to[now].size();i++)
		{
			best=max(best,1+dfs(to[now][i]));
		}
		res=max(best,res);
		return DP[now]=best;
	}
}
int main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int x,y;
		cin>>x>>y;
		to[x].push_back(y);
	}
	for(int i=1;i<=N;i++)DP[i]=-1;
	for(int i=1;i<=N;i++)
	{
		if(DP[i]==-1)
		{
			res=max(res,dfs(i));
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 8192
S = list(input())

#1
count_1 = 0
count_2 = 0
for i in range(len(S)):
  #bwbw
  if i % 2 == 0:
    if S[i] == '1':
      count_1 += 1
  elif S[i] == '0':
    count_1 += 1
  
  #wbwb
  if i % 2 == 0:
    if S[i] == '0':
      count_2 += 1
  elif S[i] == '1':
    count_2 += 1
    
print(min(count_1, count_2))



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

using namespace std;

typedef long long ll;

signed main(){
    int n, m;
    cin >> n >> m;

    vector<int> x(m);
    vector<int> y(m);

    vector<vector<int>> edges(n);
    vector<int> count(n, 0);

    for(int i = 0; i < m; ++i){
        cin >> x[i] >> y[i];
        --x[i];
        --y[i];
        edges[x[i]].push_back(y[i]);
        ++count[y[i]];
    }
    queue<int> que;
    for(int i = 0; i < n; ++i){
        if(!count[i])
            que.push(i);
    }
    bool flag = false;
    vector<int> v;
    while(!que.empty()){

        int t = que.front();
        v.push_back(t);
        for(auto& x : edges[t]){
            if(!(--count[x]))
                que.push(x);
        }

        que.pop();

        if(que.size() >= 2)
            flag = true;
    }
    for(auto& x : v)
        cout << x + 1 << endl;
    cout << flag << endl;
}



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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int f(char c) {
	if(c == 'I') return 1;
	if(c == 'V') return 5;
	if(c == 'X') return 10;
	if(c == 'L') return 50;
	if(c == 'C') return 100;
	if(c == 'D') return 500;
	return 1000;
}

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

	for(string s; cin >> s; ) {
		int ans = 0;
		for(int i = 0; i < s.size(); i ++) {
			if(i + 1 < s.size() && f(s[i]) < f(s[i + 1]))
				ans -= f(s[i]);
			else
				ans += f(s[i]);
		}
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 3024
#include<iostream>
using namespace std;
int k, C[10], C2[10], ans, is;
char map[10][10];
void dfs(int cur){
	if(cur == 8){
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++)cout<<map[i][j];
			cout<<"\n";
		}
		is = 1;
	}
	else for(int i = 0; i < 8; i++){
		bool ok = true;
		for(int j = 0; j < cur; j++)
			if(C[j]==i || cur-i==j-C[j] || cur+i==j+C[j])
				{ok = false; break;}
		if(C2[cur]!=0 && C2[cur] != i)ok = false;
		if(ok && !is){
			map[cur][i] = 'Q';
			C[cur] = i;
			dfs(cur+1);
			map[cur][i] = '.';
		}
	}
}
int main(){
	for(int i = 0; i < 8; i++)
		for(int j = 0; j < 8; j++)
			map[i][j] = '.';
	cin>>k;
	for(int i = 0; i < k; i++){
		int a, b;
		cin>>a>>b;
		C2[a] = b;
		map[a][b] = 'Q';
	}
	dfs(0);
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 998244353
#define INF2 1000000000000000000
#define int long long
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, k;
    fact();
    cin >> n >> m >> k;
    int ans = 0;
    rep(i, k + 1) {
        ans = (ans + Mul(Mul(m, C(n - 1, i)),power(m - 1, n - 1 - i))) % mod;
    }
    cout << ans << endl;

    return 0;
}
//xxxx

Measured memory_bytes: 19984
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
char grid[55][55];
int n,m;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>grid[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(grid[i][j]=='#')
			{
				if(grid[i][j-1]=='.'&&grid[i][j+1]=='.')
				{
					if(grid[i-1][j]=='.'&&grid[i+1][j]=='.')
					{
						cout<<"No";
						return 0;
					}
				}
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}

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

int main()
{
	int N, L;
	cin >> N >> L;
	int total = 0;
	int v;
	int sabunmin=1000000;
	int sabun;
	int minvalue;
	for (int i = 0; i < N; i++) {
		v = L + i;
		sabun = abs(v);
		total += v;
		if (sabun < sabunmin) {
			minvalue = v;
			sabunmin = abs(v);
		}
	}
	
	cout << total - minvalue;
}


Measured memory_bytes: 384
#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
int n,m,d;
char h[1000]="RYGB";
int main()
{
//	freopen("data.in","r",stdin);
	
	int n=read(),m=read(),d=read();
	For(x,n) {
		For(y,m) {
			int px=x+y,py=x-y;
			px+=10000,py+=10000;
			px/=d,py/=d;
			px&=1,py&=1;
			putchar(h[px*2+py]);
		}puts("");
	}
	
	
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back

void solve(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v;
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        v.pb({b, a});
    }
    sort(v.begin(), v.end());

    ll tsum = 0;
    bool flag = true;
    REP(i, n){
        tsum += v[i].second;
        //cout << tsum << endl;
        //cout << v[i].second << endl;
        if(tsum > v[i].first) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;


}

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

Measured memory_bytes: 6128
N = int(input())
lst_A =list(map(int, input().split()))
neg_count = 0
zero_count = 0
total = 0

if lst_A[0] < 0:
    neg_count += 1
elif lst_A[0] == 0:
    zero_count +=1
total += abs(lst_A[0])
memo = abs(lst_A[0])
i = 1
while i < N:
    if lst_A[i] < 0:
        neg_count += 1
    elif lst_A[i] == 0:
        zero_count +=1
    total += abs(lst_A[i])
    memo = min(memo, abs(lst_A[i]))
    i += 1
if zero_count > 0:
    total = total
elif neg_count % 2 == 1:
    total = total - memo *2
else:
    total = total
print (total)

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

int main()
{
    int n;
    cin >> n;
    vector<ll> A(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int sta = 1, end = n-1;
    ll ans = 0;
    int flag = 1;
    ll pre = A[0];
    while(sta <= end) {
        if(sta == end) {
            if(flag == 1) {
                ans += max(A[end]-pre, A[end]-A[0]);
            }else {
                ans += max(pre-A[sta], A[sta]-A[0]);
            }
            break;
        }
        if(flag == 1) {
            ans += A[end] - pre;
            pre = A[end];
            --end;
        }else {
            ans += pre - A[sta];
            pre = A[sta];
            ++sta;
        }
        flag ^= 1;
    }

    sta = 0;
    end = n-2;
    flag = 1;
    pre = A[n-1];
    ll ans1 = 0;
    while(sta <= end) {
        if(sta == end) {
            if(flag == 1) {
                ans1 += max(pre-A[sta], A[n-1]-A[sta]);
            }else {
                ans1 += max(A[end]-pre, A[n-1]-A[end]);
            }
            break;
        }
        if(flag == 1) {
            ans1 += pre - A[sta];
            pre = A[sta];
            ++sta;
        }else {
            ans1 += A[end] - pre;
            pre = A[end];
            --end;
        }
        flag ^= 1;
    }
    ans = max(ans, ans1);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int dist[255555];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int k; cin>>k;
	for(int i=0;i<k;i++) dist[i]=int(1e9);
	dist[1]=1;
	deque<int> q; q.pb(1);
	while(!q.empty())
	{
		int u=q.front(); q.pop_front();
		if(dist[(10*u)%k]>dist[u]){dist[(10*u)%k]=dist[u]; q.push_front((10*u)%k);}
		if(dist[(u+1)%k]>dist[u]+1){dist[(u+1)%k]=dist[u]+1; q.push_back((u+1)%k);}
	}
	cout<<dist[0]<<'\n';
}


Measured memory_bytes: 896
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, K;
    cin >> N >> K;

    vector<ll> A(N + 1);
    FOR(i, 1, N)
    cin >> A[i];

    ll current = 1, count = 0;
    vector<bool> L(N + 1);
    vector<ll> M;
    REP(i, N)
    {
        //ループが検知されるまえにKに到達した場合
        if (count == K)
        {
            cout << current << endl;
            return 0;
        }

        //ループが検知された場合
        if (L[current] == true)
        {
            vector<ll>::iterator result = find(ALL(M), current);
            M = vector<ll>(result, M.end());
            ll R = (K - count) % SIZE(M);
            cout << M[R] << endl;
            return 0;
        }

        M.PB(current);
        L[current] = true;
        current = A[current];
        count++;
    }

    return 0;
}


Measured memory_bytes: 6424
N = int(input())
A = [[int(a) for a in input().split()] for _ in range(N)]

mod = 10**9+7

dp = [0]*(2**N)
dp[0] = 1

POPCOUNT_TABLE16 = [0] * 2**16
for index in range(len(POPCOUNT_TABLE16)):
    POPCOUNT_TABLE16[index] = (index & 1) + POPCOUNT_TABLE16[index >> 1]

def popcnt(v):
    return (POPCOUNT_TABLE16[ v        & 0xffff] +
            POPCOUNT_TABLE16[(v >> 16) & 0xffff] +
            POPCOUNT_TABLE16[(v >> 32) & 0xffff] +
            POPCOUNT_TABLE16[(v >> 48)         ])


for s in range(1, 2**N):
    i = popcnt(s)
    cnt = 0
    for j in range(N):
        if A[i-1][j] == 1 and s&(1<<j):
            cnt += dp[s^(1<<j)]%mod
    dp[s] = cnt%mod
            
print(dp[-1]%mod)

Measured memory_bytes: 59372
@A=glob<>;
printf sort{$a-$b}map{
	@v=//;
	$x=-30;
	$v[$t=$'>>2*$_&3]+=$t&&$l[$x+=10,$_]for 0..@l;
	$x+=abs$A[$_]-($v[$_]||1e9)for 1..3;
	$x
}1..1<<2*(@l=<>)


Measured memory_bytes: 9472
#include<bits/stdc++.h>
 using namespace std;
 int main(){
     int x,a,b,c,d;
     cin>>x>>a>>b;
     c=abs(x-a);
     d=abs(x-b);
     if(c<d){
        cout<<"A";
     }
     else{
        cout<<"B";
     }
     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 a = sc.nextInt();
        int b = sc.nextInt();

        if (a+b==15) {
            System.out.println('+');
            return;
        }

        if (a*b==15) {
            System.out.println('*');
            return;
        }

        System.out.println('x');
    }
}

Measured memory_bytes: 22868