akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

ll n,W;
ll w[100010],v[100010];
ll dp[100010];
int main(int argc,char** argv){
	cin>>n>>W;
	rep(i,n){
		cin>>w[i]>>v[i];
	}
	rep(i,100001){
		dp[i]=LLINF;
	}
	dp[0]=0;
	rep(i,n){
		repr(j,100001){
			if(j-v[i]>=0){
				dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			}
		}
	}
	int ans=0;
	repr(i,100001){
		if(dp[i]<=W){
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
//ll mod=1000000007;
ll mod=998244353;
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
int main() {
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    string s;
    cin>>n>>s;
    char si[26];
    forn(i,26)si[i]=65+i;
    //cout<<si[24];
    forn(i,s.size()){
        //cout<<(n+(s[i]-'a'%26)<<endl;
        int num=(n+(s[i]-'A'))%26;
        //cout<<num;
        s[i]=si[num];
    }
    cout<<s;

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, p) = get!(usize, usize);
    let a = util::gets::<usize>();

    let mut dp = vec![0u64, 0];


    for (i, &x) in (1..).zip(a.iter()) {
        if x % 2 == 0 {
            dp[0] *= 2;
            dp[1] *= 2;
            dp[0] += 1;
        } else {
            let prev = dp.clone();
            dp[0] += prev[1];
            dp[1] += prev[0];
            dp[1] += 1;
        }
        // debug!(dp);
    }
    dp[0] += 1;

    println!("{}", dp[p]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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 (a > b) { a = b; return 1; } return 0; }

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x <<" " << y << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans = (n - k + 1) * (n - k) / 2;
    if(k==0){
        ans = n * (n - 1) / 2;
    }
    repf(b,k+1,n+1){
        ans += (n / b - 1) * (b - k) + max(0ll, n % b + 1 - k);
    }
    cout << ans << endl;
}


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

int main() {
	int h, w;
	while (true) {
		cin >> h>> w;
		if (h == 0 && w == 0) break;
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if(x==0 || x ==w-1 || y==0 || y==h-1){
				    cout << "#";
				}else{
				    cout << ".";
				}
			}
			cout << endl;

		}
		cout << endl;
	}
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cassert>
#include <numeric>
#include <queue>
#include <unordered_set>

using namespace std;

struct P {
    int64_t x;
    int64_t y;
};

struct D {
    int idx;
    int next;
    int64_t d;

    bool operator>(const D& rhs) const {
        return d > rhs.d;
    }
};


using pq = priority_queue<D, vector<D>, greater<D>>;

void calc_d(const vector<int>& ss, const vector<int>& pos, const vector<int64_t>& c, int idx, pq* que) {
    auto pp = pos[idx];

    if (pp > 0) {
        que->push(D{idx, ss[pp - 1], abs(c[ss[pp - 1]] - c[idx])});
    }
    if (pp + 1 < ss.size()) {
        que->push(D{idx, ss[pp + 1], abs(c[ss[pp + 1]] - c[idx])});
    }
}

int64_t solve(const vector<int64_t>& x, const vector<int64_t>& y) {
    vector<int> xs(x.size());
    vector<int> ys(y.size());

    iota(xs.begin(), xs.end(), 0);
    sort(xs.begin(), xs.end(), [&x](int lhs, int rhs) {
        return x[lhs] < x[rhs];
    });

    iota(ys.begin(), ys.end(), 0);
    sort(ys.begin(), ys.end(), [&y](int lhs, int rhs) {
        return y[lhs] < y[rhs];
    });

    vector<int> xpos(x.size()), ypos(y.size());
    for (int i = 0; i < x.size(); ++i) {
        xpos[xs[i]] = i;
        ypos[ys[i]] = i;
    }

    priority_queue<D, vector<D>, greater<D>> qx;
    priority_queue<D, vector<D>, greater<D>> qy;

    calc_d(xs, xpos, x, 0, &qx);
    calc_d(ys, ypos, y, 0, &qy);

    unordered_set<int> selected;
    selected.insert(0);

    int64_t ans = 0;

    while(true) {
        // TODO: should check selected and empty
        bool has_x = false;
        bool has_y = false;
        D mdx, mdy;

        while (!qx.empty()) {
            mdx = qx.top();
            if (selected.count(mdx.next) > 0) {
                qx.pop();
                continue;
            }
            has_x = true;
            break;
        }

        while (!qy.empty()) {
            mdy = qy.top();
            if (selected.count(mdy.next) > 0) {
                qy.pop();
                continue;
            }
            has_y = true;
            break;
        }

        if (!has_x && !has_y) {
            break;
        }

        int next;
        if (has_x && mdx.d < mdy.d) {
            qx.pop();
            ans += mdx.d;
            next = mdx.next;
        } else {
            qy.pop();
            ans += mdy.d;
            next = mdy.next;
        }
        selected.insert(next);
        calc_d(xs, xpos, x, next, &qx);
        calc_d(ys, ypos, y, next, &qy);
    }

    return ans;
}

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

    vector<int64_t> x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }

    cout << solve(x, y) << endl;

    return 0;
}

Measured memory_bytes: 13168
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

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

using namespace std;

int main() {
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;
    return 0;
}

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

long long ara[2003][2003],tra[2003][2003],val[2003],tal[2003];
long long mod=1000000007;

int main()
{

    long long n,m,i,j,k,x,y,z,p,q,r,a,b=1;

    scanf("%lld %lld",&n,&m);

    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a); val[i]=a;
    }

    for(i=1;i<=m;i++)
    {
        scanf("%lld",&a);  tal[i]=a;
    }


    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {

            if(val[i]==tal[j])
            {

                if(i==1 || j==1)ara[i][j]=1;
                else
                {
                    p=i-1; q=j-1;
                    ara[i][j]=(tra[p][q]+1)%mod;
                }

            }


            b=(b+ara[i][j])%mod;

            x=(tra[i-1][j]+tra[i][j-1]+ara[i][j])%mod;
            y=tra[i-1][j-1];

            if(x>=y)z=x-y;
            else{  z=(mod-y)+x;  }

            tra[i][j]=z;

        }
    }

    printf("%lld\n",b);


    return 0;
}


Measured memory_bytes: 65856
n,q = gets.chomp.split.map(&:to_i)
s = gets.chomp
array = []
q.times do |i|
  l, r = gets.chomp.split.map(&:to_i)
  array.push([l-1, r-1])
end

ac_array = []
n.times do |i|
  if i == 0
    ac_array << 0
    next
  end

  if s[i-1, 2] == 'AC'
    ac_array << ac_array[i-1] + 1
  else
    ac_array << ac_array[i-1]
  end
end

q.times do |j|
  first, last = array[j]
  if first == 0
    puts ac_array[last]
    next
  end

  puts ac_array[last] - [ac_array[first-1], ac_array[first]].max
end



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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 単調減少のグループを、グループのサイズの最大値がbになるようにa個並べればok

int n, a, b, m;
vi res;

signed main() {
	cin >> n >> a >> b;
	if (a+b-1>n || (ll)a*b<n) return cout << -1 << ln, 0;
	rep(i,a) {
		int t = min(n-m - (a-i-1), b);
		rep(j,t) res.pb(m+t-j);
		m += t;
	}
	rep(i,n) cout << res[i] << bln(i,n);
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    ll a,b,MOD=2019;cin>>a>>b;

    ll ans=mod;

    if(b-a>=2019){
        cout<<0<<endl;
        return 0;
    }

    rep2(i,a,b){
        rep2(j,i+1,b+1){
            ans=min(ans,(i*j)%MOD);
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2016/09/24 20:07:53 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=100010;

char s[maxn];

int main()
{
	int k;
    scanf("%s%d",s,&k);
    int n=strlen(s);
    for (int j=0;j<n;++j)
    {
        if (s[j]=='a') continue;
        int cha='z'-s[j]+1;
        if (k>=cha)
        {
            k-=cha;
            s[j]='a';
        }
    }
    k%=26;
    if (k) s[n-1]+=k;
    if (s[n-1]>'z') s[n-1]-=26;
    printf("%s\n",s);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();

        int counter = 0;

        for (int i = a; i <= b; i++) {
            if (i != 0 && c%i == 0) {
                counter++;
            }
        }

        System.out.println(counter);
    }
}



Measured memory_bytes: 26372
import collections
def main():
    N, M = map(int, input().split())
    graph = collections.defaultdict(list)
    for _ in range(M):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)

    cur = [[1, set([1])]]
    for _ in range(N-1):
        temp = []
        for a, visited in cur:
            for b in graph[a]:
                if b not in visited:
                    temp.append([b, visited | {b}])
        cur = temp
    return len(cur)


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll powmod(ll base,ll exponent,ll mod){
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int dp[upperlimit][3];
int main() {
	int n,a1,a2,a3;
	sd(n);
	for(int i = 1; i <= n; i++){
		sd(a1);sd(a2);sd(a3);
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a1;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a2;
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a3;
	}
	pd(max(max(dp[n][1],dp[n][2]),dp[n][0]));
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;
    if(s.size()==a+b+1){
        for(int i=0;i<s.size();i++){
            if(s[i]=='-' && i!=a){
                cout << "No" << endl;
                return 0;
            }
            
        }
    }
    else{
        cout << "No" << endl;
    }
   if(s[a]=='-'){
        cout << "Yes" << endl;
        return 0;
   }
   cout << "No" << endl;
}


Measured memory_bytes: 256
let () =
    let mm = 1000000000 + 7 in
    let main () =
        let l = read_line () in
        let s = String.length l in
        let rec loop i k acc =
            if i = s then acc else
                if l.[i] = '1' then loop (i + 1) ((k * 2) mod mm) ((acc * 3) mod mm)
                    else loop (i + 1) k (((acc - k + mm) * 3 + k) mod mm)
        in
        let n = loop 1 2 3 in
        Printf.printf "%d\n" n
    in
    main ()

Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int na, nb, nc;
			na=sc.nextInt();
			nb=sc.nextInt();
			nc=sc.nextInt();
			if((na|nb|nc)==0){
				break;
			}

			int n=sc.nextInt();
			int[] as=new int[na];
			int[] bs=new int[nb];
			int[] cs=new int[nc];
			Arrays.fill(as, 2);
			Arrays.fill(bs, 2);
			Arrays.fill(cs, 2);

			R[] rs=new R[n];
			for(int i=0; i<n; i++){
				int a=sc.nextInt()-1;
				int b=sc.nextInt()-na-1;
				int c=sc.nextInt()-na-nb-1;
				int r=sc.nextInt();
				rs[i]=new R(a, b, c, r);
				if(r==1){
					as[a]=1;
					bs[b]=1;
					cs[c]=1;
				}
			}

			for(int i=0; i<n; i++){
				if(rs[i].r==0){
					int a=as[rs[i].a];
					int b=bs[rs[i].b];
					int c=cs[rs[i].c];
					if(a==1&&b==1){
						c=0;
					}else if(b==1&&c==1){
						a=0;
					}else if(c==1&&a==1){
						b=0;
					}
					as[rs[i].a]=a;
					bs[rs[i].b]=b;
					cs[rs[i].c]=c;
				}
			}
			for(int i=0; i<na; i++){
				println(as[i]+"");
			}
			for(int i=0; i<nb; i++){
				println(bs[i]+"");
			}
			for(int i=0; i<nc; i++){
				println(cs[i]+"");
			}
		}
	}

	class R{
		int a, b, c, r;

		R(int a, int b, int c, int r){
			this.a=a;
			this.b=b;
			this.c=c;
			this.r=r;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    REP(i,n) ans *= 3;
    ll tmp = 1;
    REP(i,n){
        int x;
        cin >> x;
        if (x % 2 == 0){
            tmp *= 2;
        }
    }
    cout << ans - tmp << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

int main(){
  string str;
  cin >> str;
  int length=str.size();
  int n=0,m;
  char hoge;
  int ans;
  if(length%2==0){
    m=length/2;
    hoge=str[m];
    for(int i=0;i<m;i++){
      if(str[m-i-1]==hoge && str[m+i]==hoge) n+=1;
      else break;
    }
  ans=m+n;
  } 
  else{
    m=(length-1)/2;
    hoge=str[m];
    for(int i=0;i<m+1;i++){
      if(str[m+i]==hoge && str[m-i]==hoge) n+=1;
      else break;
    }
    ans=m+n;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 512
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    H, W = map(int, input().rstrip().split())
    G = []
    for i in range(H):
        s = list(input())
        G.append(s)
    # print(G)
    cnt = [[0 for j in range(W)] for i in range(H)]

    for i in range(H):
        done = [0] * W
        for j in range(W):
            if G[i][j] == "#":
                continue
            if done[j]:
                continue
            length = 0
            while j + length < W:
                if G[i][j+length] == "#":
                    break
                length += 1
            for k in range(length):
                cnt[i][j + k] += length
                done[j + k] = 1

    for j in range(W):
        done = [0] * H
        for i in range(H):
            if G[i][j] == "#":
                continue
            if done[i]:
                continue
            length = 0
            while i + length < H:
                if G[i+length][j] == "#":
                    break
                length += 1
            for k in range(length):
                cnt[i + k][j] += length
                done[i + k] = 1
    ans = 0
    for i in range(H):
        ans = max(ans, max(cnt[i]) - 1)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 219272
n=int(input())
A=[0]*n
for i in range(3,int(n**0.5+150)):
  for j in range(1,i-1):
    for k in range(1,i-j):
      if (x:=i*i-j*k-k*(l:=i-j-k)-l*j)<=n:
        A[x-1]+=1
for a in A:
  print(a)

Measured memory_bytes: 9620
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

int main()
{
	// 入力
	ll a,p;
	cin>>a>>p;

	cout<<(a*3+p)/2<<endl;
}

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

int main(){
    int a, b, c; cin >> a >> b >> c;
    int d = max(a, b);
    int ans = 1;
    int e = d;
    while(1){
        if(c <= e){break;}
        e += d;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
(function(input) {
    var p = input.split('\n');
    var n = p.shift();
    var a = p.shift().split(' ', n).map(Number);
    sortSelection(a);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function sortSelection(a) {
    var count = 0;
    for (var i = 0; i < a.length; i++) {
        var min = i;
        for (var j = i; j < a.length; j++) {
            if (a[j] < a[min]) {
                min = j;
            }
        }
        if (min !== i) {
            var tmp = a[i];
            a[i] = a[min];
            a[min] = tmp;
            count++;
        }
    }
    console.log(a.join(' '));
    console.log(count);
}

Measured memory_bytes: 7648
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
from math import sqrt
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    N = int(input())
    xy = []
    for _ in range(N):
        x, y = map(int, input().split())
        xy.append([x, y])
    
    visit_perm = list(range(N))
    sum_dist = 0
    cnt = 0
    for v in permutations(visit_perm):
        cnt += 1
        prev = -1
        for i, p in enumerate(v):
            if i==0:
                prev = [xy[p][0], xy[p][1]]
            else:
                sum_dist += sqrt((xy[p][0]-prev[0])**2+(xy[p][1]-prev[1])**2)
    print(sum_dist/cnt)

Measured memory_bytes: 10572
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	char c[54][54];
	rep(i,54)
		rep(j,54) c[i][j]='.';
	rep(i,h)
		rep(j,w) cin>>c[i][j];
	rep(i,h)
		rep(j,w) if((c[i][j]=='#')and(c[i][j+1]=='.')and(c[i][j-1]=='.')and(c[i+1][j]=='.')and(c[i-1][j]=='.'))
				 {
				 	puts("No");
				 	rt0;
				 }
	puts("Yes");
    rt0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  int l_max = 0;
  int r_min = 1000000;
  for (int i = 0; i < m; i++) {
    int l,r;
    cin >> l >> r;
    l_max = max(l_max,l);
    r_min = min(r_min,r);
  }
  if (l_max > r_min) cout << 0 << endl;
  else cout << r_min - l_max + 1 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define MOD 1000000007

int main(void){
	int n; cin >> n;
	lli ans = 1;
	rep(i, n) ans = (ans * (i+1)) % MOD;
	cout << ans << endl;
	
	return 0;
}

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する
vector<int> D;
vector<bool> used;

bool nibu(int m) {
//    used = vector<bool>(D.size(), false);
//    vector<int> kouho;
//    rep(i,0,D.size()){
//        if(!used[i]){
//            kouho.push_back(D[i]);
//            kouho.push_back(24-D[i]);
//        }
//    }
//    int cur = 0;
//    int cnt = 0;
//    while(cnt < D.size()){
//
//    }
    int time[25] = {};
    rep(i,0,D.size()){
        time[D[i]]++;
        time[(24 - D[i]) % 24]++;
    }
    int cur = 0;
    int cnt = 0;
    int last = 24;
    while(cnt < D.size()){
        int e = -1;
        rep(i,cur+m,24){
            if(last - i >= m && i >= cur + m && time[i] > 0){
                e = i;
                break;
            }
        }
        if(e == -1) return false;
        time[e]--;
        time[(24-e)%24]--;
        cur = e;
//        last = 24 + e;
        cnt++;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    rep(i, 0, n) {
        int tmp;
        cin >> tmp;
        D.push_back(tmp);
    }
    sort(all(D));
    int ok = 0;
    int ng = 25;
    while(ng - ok > 1){
        int mid  = (ok + ng)/2;
        if(nibu(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    ll X, A, B;
    cin >> X >> A >> B;
    if(A - B >= 0){
        cout << "delicious" << endl;
        return 0;
    }
    if(A - B + X >= 0){
        cout << "safe" << endl;
        return 0;
    } else{
        cout << "dangerous" << endl;
    }
    return 0;
}

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++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

pair<int, int> E[200001];
int H[200001];
int kotae[100001];
int Vis[100001];
void sagasu(int P, int D, int C) {
	if (D == 0 && kotae[P] == 0) kotae[P] = C;
	else if (Vis[P] < D) {
		Vis[P] = D;
		if (kotae[P] == 0) kotae[P] = C;
		for (int p = H[P]; p; p = E[p].second) {
			sagasu(E[p].first, D - 1, C);
		}
	}
}

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


	int N, M, Q;
	cin >> N >> M;
	for (int i = 1; i < 2 * M; i += 2) {
		int a, b;
		cin >> a >> b;
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}
	cin >> Q;
	int v[100000], d[100000], c[100000];
	rep(i, Q) cin >> v[i] >> d[i] >> c[i];

	for (int i = Q - 1; i >= 0; i--) {
		sagasu(v[i], d[i], c[i]);
	}
	rep1(i, N) {
		co(kotae[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 4608
N = int(input())
p = [
    sum(N // (i**k) for k in range(1, 8))
    for i in range(2, 97 + 1)
    if all(i % j != 0 for j in range(2, i))
]
def f(m):
  return len([i for i in p if i >= m])
ans = f(74) + f(24) * (f(2) - 1) + f(14) * (f(4) - 1) + f(4) * (f(4) - 1) * (f(2) - 2) // 2
print(ans)


Measured memory_bytes: 3064
ctob={"A":"00000", "B":"00001", "C":"00010", "D":"00011", "E":"00100", "F":"00101", "G":"00110", "H":"00111", "I":"01000", "J":"01001", "K":"01010", "L":"01011", "M":"01100", "N":"01101", "O":"01110", "P":"01111", "Q":"10000", "R":"10001", "S":"10010", "T":"10011", "U":"10100", "V":"10101", "W":"10110", "X":"10111", "Y":"11000", "Z":"11001", " ":"11010", ".":"11011", ",":"11100", "-":"11101", "'":"11110", "?":"11111"}
btoc={'0110': 'K', '0111': 'I', '111': 'P', '110': 'E', '10011010': 'B', '10011011': 'G', '000011': ',', '000010': 'W', '10011111': 'Q', '10011110': 'N', '100101': 'A', '01001': 'F', '00111': 'T', '00110': 'S', '10010010': 'X', '0001': 'D', '0101': 'C', '10010000': 'Z', '10010001': '-', '101': ' ', '10011001': 'M', '10011000': 'J', '10011100': 'U', '10011101': 'V', '000000': "'", '000001': '?', '010001': '.', '010000': 'H', '10010011': 'Y', '00100': 'L', '00101': 'O', '1000': 'R'}

while 1:
	try:
		a=raw_input()
		b=""
		for w in a:
			b+=ctob[w]
		tmp,ans="",""
		for w in b:
			tmp+=w
			if tmp in btoc:
				ans+=btoc[tmp]
				tmp=""
		print ans
	except:
		break

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

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<pll> rec(M);
  for (ll i = 0; i < M; ++i) {
    cin >> rec.at(i).first >> rec.at(i).second;
  }
  sort(rec.begin(), rec.end(), [] (pll a, pll b) {
    return a.second < b.second;
  });
  ll last = -1;
  ll ans = 0;
  for (ll i = 0; i < M; ++i) {
    if (rec.at(i).first <= last) {
      continue;
    }
    ans += 1;
    last = rec.at(i).second -= 1;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1792
N = int(input())
A_list = list(map(int, input().split()))

D1 = 3
D2 = 5

ans = "APPROVED"

for A in A_list:
    if A%2 == 0:
        if (A%D1 != 0) & (A%D2 != 0):
            ans = "DENIED"
            break

print(ans)


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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 (a > b) { a = b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    bool fg = false;
    rep(i, n){
        int a; cin >> a;
        if(a%2 == 1) fg = true;
    }
    if(fg) cout << "first" << ln;
    else cout << "second" << ln;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
d,e,f = -1,-1,-1
for a in range(n+1):
    for b in range(n+1-a):
        c = n-(a+b)
        if y- (10000*a+5000*b) == c*1000:
            d,e,f =a,b,c
print(d,e,f)

Measured memory_bytes: 9192
s = int(input())

def f(n):
  if n%2 == 0:
    return n/2
  else:
    return 3 * n + 1
a = s
tmp =[]
count = 0
while True:
  tmp += [a]
  a = f(a)
  count += 1
  
  if a in tmp:
    print(count+1)
    exit()


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int data[10010];
int main()
{
	int n,q,x,ans = 0;
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> data[i];
	cin >> q;
	while(q--)
	{
		cin >> x;
		for(int i =1; i <= n; ++i)
		{
			if(data[i] == x)
			{
				++ans;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3120
import java.util.Scanner;

// https://atcoder.jp/contests/abc163/tasks/abc163_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		double ans = 2*n*Math.PI;

		System.out.println(ans);
	}
}


Measured memory_bytes: 27180
import math
def is_prime(n):
    if n==1:
        return False
    for k in range(2,int(math.sqrt(n))+1):
        if n%k==0:
            return False
    return True
n=int(input())
m=0
c=0
while True:
    if m==n:
        break
    a=int(input())
    
    if is_prime(a)==True:
        c=c+1
 
    m=m+1
print(c)



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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  
  int gosa = 100000000;
  int chiten = 0;
  
  for(int i=0;i<N;i++){
    int sa=0;
    sa=A*1000-(T*1000-H.at(i)*6);
    if(sa<0){ sa = sa*(-1);}
    
    if(sa<gosa){
      gosa = sa;
      chiten = i+1;
    }
  }
  
  cout << chiten << endl;
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


int w, h, n;
int seg[131072*2 - 1];
int N;


int p(int i){
	return (int)((i-1) / 2);
}


void update(int i){
	if(i == 0) return;
	if(seg[p(i)] >= seg[i]) return;
	seg[p(i)] = seg[i];
	update(p(i));
}


void init(){
	rep(i, N-1, h+N-1) update(i);
}


int qmax(int a, int b, int k = 0, int l = 0, int r = N){
	if(r <= a || b <= l) return -1;
	if(a <= l && r <= b) return seg[k];

	int vl = qmax(a, b, 2*k+1, l, (l+r)/2);
	int vr = qmax(a, b, 2*k+2, (l+r)/2, r);
	return max(vl, vr);
}


int solve(){
	int c = 999999999;
	rep(i, 0, h-1){
		c = min(c, i+qmax(i+1, h));
	}
	c = min(c, h-1);
	return c;
}


int main(){
	cin >> w >> h >> n;
	N = (int)pow(2, (int)ceil(log2(h)));
	
	rep(i, 0, n){
		int x, y;
		cin >> x >> y;
		seg[y+N-1] = max(seg[y+N-1], x);
	}
	
	init();
	
	cout << solve() << endl;
	
	return 0;
}


Measured memory_bytes: 4112
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w)
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    let n = s.len();

    let mut i = 0;
    let mut l = vec![0; n];
    while i < n {
        let c = s[i];
        let mut cnt = 1;
        while i < n && s[i] == c {
            l[i] = cnt;
            cnt += 1;
            i += 1;
        }
    }

    let mut i = n as i32 - 1;
    let mut r = vec![0; n];
    while i >= 0 {
        let c = s[i as usize];
        let mut cnt = 1;
        while i >= 0 && s[i as usize] == c {
            r[i as usize] = cnt;
            cnt += 1;
            i -= 1;
        }
    }

    let mut v = vec![0; n];
    for i in 0..n {
        if s[i] == 'R' {
            if r[i] % 2 == 0 {
                v[i + r[i]] += 1;
            } else {
                v[i + r[i] - 1] += 1;
            }
        } else {
            if l[i] % 2 == 0 {
                v[i - l[i]] += 1;
            } else {
                v[i - l[i] + 1] += 1;
            }
        }
    }

    with_stdout_lock(|mut w| {
        for v in v {
            write!(w, "{} ", v).unwrap();
        }
        writeln!(w, "").unwrap();
    });
}


Measured memory_bytes: 6524
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main()
{
    int w, n;
    cin >> w >> n;
    vector<int> num(w);
    for(int i=0; i<w; ++i)
        num[i] = i+1;
 
    for(int i=0; i<n; ++i){
        int a, b;
        char c;
        cin >> a >> c >> b;
        swap(num[a-1], num[b-1]);
    }
 
    for(int i=0; i<w; ++i)
        cout << num[i] << endl;
 
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int h,n;
   cin >>h>>n;
   vector<int> a(n);
   rep(i,n){
   cin>>a.at(i);
   h-=a.at(i);
   }
  if(h>0)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

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

    int ans = INF;
    for (int i = -100; i <= 100; i++) {
        int sum = 0;
        for (int j = 0; j < N; j++) {
            sum += pow(abs(i - a[j]), 2); 
        }
        if (ans > sum) {
            ans = sum;
        }
    }

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

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

int main() {
	int64_t a, b;
	while (cin >> a >> b) {
		int64_t GCD, LCM;
		int64_t n = a,
			m = b;
		while (1) {
			int64_t n = a % b;
			if (!n) {
				GCD = b;
				break;
			}
			else {
				a = b;
				b = n;
			}
		}

		LCM = n * m / GCD;
		cout << GCD << ' ' << LCM << endl;
	}
}


Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
int main(){
int d;
cin>>d;
if(d==25){
    cout<<"Christmas"<<endl;
}
if(d==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
}
if(d==24){
    cout<<"Christmas Eve"<<endl;
}
if(d==23){
    cout<<"Christmas Eve Eve"<<endl;
}
return 0;
}


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

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

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

constexpr long long mod = 1000000007;

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

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

    int n;
    cin >> n;

    vi l(n);
    rep(i, n) cin >> l[i];

    sort(l.begin(), l.end());

    int a, b, c;

    ll cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        for (int j = 0; j < i; j++) {
            a = l[j];
            b = l[i];

            auto itr = lower_bound(l.begin() + i, l.end(), a + b);

            cnt += itr - (l.begin()+i) - 1;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

void dfs(bool &found, vc &op, vl nums){
  if(op.size() == 3){
    ll ans = nums[0];

    rep(i, 3){
      if(op[i] == '+')
	ans += nums[i + 1];
      else
	ans -= nums[i + 1];
    }
    
    found = (ans == 7);
    return;
  }

  op.push_back('+');
  dfs(found, op, nums);
  if(found) return;
  op.pop_back();
  op.push_back('-');
  dfs(found, op, nums);
  if(found) return;
  op.pop_back();

  return;
}

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

  vl nums(4);
  rep(i, 4) nums[i] = (ll)(abcd[i] - '0');

  vc op;
  bool found = false;
  dfs(found, op, nums);

  rep(i, 3){
    cout << nums[i] << op[i];
  }
  cout << nums[3] << "=7" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b=sc.nextInt();
        int temp=0;
        for(int i=0;i<a;i++){
               int c=sc.nextInt();
               int d=sc.nextInt();
               double e=Math.sqrt(Math.pow(c,2)+Math.pow(d,2));
               if(b>=e){
                   temp++;
               }
        }
        System.out.println(temp);
    }
}


Measured memory_bytes: 59348
N, A, B, C, D = map(int, input().split())
S = input()

def max_stone(a, b):
  m = 0
  for j in range(a, b-1):
    if S[j] == S[j+1] == '#':
      return False
  
  return True
  
def reachable(b, d):
  n_sharp = 0
  n_dot = 0
  for j in range(b-1, d+1):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    elif n_sharp == 2:
      return False
    
  return False

def reachable2(b, d):
  for k in range(b-1,d):
    if S[k] == S[k+1] == S[k+2] == ".":
      return True
  return False
  
if C < B:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable2(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 3700
# coding: utf-8
# Your code here!

result = 0
AB = list(map(int, input().split()))

# AB.sort()

# print(AB)

sorted_list = sorted(AB, reverse=True)

# print(sorted_list)

result += sorted_list[0]

if sorted_list[0] - 1 > sorted_list[1]:
    result += sorted_list[0] - 1
else:
    result += sorted_list[1]
    
print(result)

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

const int modulo=1e9+7;
int main(){
   string inp;
   cin>>inp;
   int mod;
   cin>>mod;
   vector<vector<int>> dp(inp.size()+1,vector<int>(mod));
   
   for(int i=0;i<inp.size();i++){
   	for(int j=0;j<mod;j++)
   		dp[i][j]=0;
   }
   int eq_sum=0;
   eq_sum=(inp[0]-'0')%mod;
   for(int i=0;i<(inp[0]-'0');i++){
     dp[0][i%mod]++;
   }

   for(int i=1;i<inp.size();i++){
   	//count the ones that are less the given value
     for(int j=0;j<mod;j++){
      for(int k=0;k<=9;k++){
      	dp[i][(j+k)%mod]+=dp[i-1][j];
      	dp[i][(j+k)%mod]%=modulo;
      }
     }
    //Count the equal ones
     for(int k=0;k<(inp[i]-'0');k++){
     	dp[i][(eq_sum+k)%mod]++;
     	dp[i][(eq_sum+k)%mod]%=modulo;
     }
     eq_sum+=(inp[i]-'0')%mod;    
   }

   int eq_count=((eq_sum%mod) ==0);
   int val= (dp[inp.size()-1][0]-1+modulo)%modulo;
   cout<<(val+(eq_count)%(modulo))%modulo<<endl;
	return 0;	
}

Measured memory_bytes: 4608
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"math/big"
	"os"
	"strconv"
)

func main() {
	a := big.NewInt(readInt64())
	b := readFloat64()
	bTimes100 := big.NewInt(int64(math.Round(b * 100)))

	ans := big.NewInt(0)
	ans.Mul(a, bTimes100)
	ans.Div(ans, big.NewInt(100))
	fmt.Println(ans)

}

var (
	scanner *bufio.Scanner
)

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

func readInt64() int64 {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.ParseInt(t, 10, 64)
	if err != nil {
		log.Fatal(err)
	}

	return n

}

func readFloat64() float64 {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.ParseFloat(t, 64)
	if err != nil {
		log.Fatal(err)
	}

	return n
}


Measured memory_bytes: 1840