akhauriyash/Code-Regression huggingface dataset:
#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;}

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};
struct edge{ int u, v, cost;};
bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}
int nv, ne;
vector<edge> es;

int kruskal() {
    sort(es.begin(), es.end(), comp);
    UnionFind uf(nv);
    int res = 0;
    for (int i = 0; i < ne; ++i) {
        edge e = es[i];
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<pair<P, int>> town(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        town[i] = pair<P, int>(P(x, y), i);
    }
    auto comp = [](pair<P, int> a, pair<P, int> b) { return a.fi.se < b.fi.se;};
    sort(all(town));
    rep(i, n-1) {
        es.pb(edge{town[i].se, town[i+1].se, abs(town[i].fi.fi - town[i+1].fi.fi)});
    }
    sort(all(town), comp);
    rep(i, n-1) {
        es.pb(edge{town[i].se, town[i+1].se, abs(town[i].fi.se - town[i+1].fi.se)});
    }
    nv = n;
    ne = sz(es);
    cout << kruskal() << endl;
}

Measured memory_bytes: 6132
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iterator>
#include <random>
#include <cassert>
#include <iomanip>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<char> vc;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;
typedef vector<vector<char>> vcc;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}
const double EPS = 1e-10;
const double PI = acos(-1);

class ADDCCFinals {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int X, Y;
        in>>X>>Y;
        int ans = 0;
        if(X==1) ans += 300000;
        else if(X==2) ans += 200000;
        else if(X==3) ans += 100000;
        if(Y==1) ans += 300000;
        else if(Y==2) ans += 200000;
        else if(Y==3) ans += 100000;
        if(X==1 and Y==1) ans += 400000;
        out<<ans<<'\n';
    }
};


int main() {
	ADDCCFinals solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
    int i,j,n;
    int arr[1000];

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

    sort(arr,arr+n);
    //x = abs(arr[0])
    cout<<abs(arr[0] - arr[n-1]);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef pair<double, pdd> pddd;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int dp[505][505];

int main() {
    int n, m, q;
    scanf("%d%d%d", &n, &m, &q);
    while(m--) {
        int a, b;
        scanf("%d%d", &a, &b);
        dp[a][b]++;
    }
    for(int s = 0; s <= n; s++) {
        for(int i = 0; i + s <= n; i++) {
            dp[i][i+s] += dp[i+1][i+s] + dp[i][i+s-1] - dp[i+1][i+s-1];
        }
    }
    while(q--) {
        int a, b;
        scanf("%d%d", &a, &b);
        printf("%d\n", dp[a][b]);
    }
}


Measured memory_bytes: 1920
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(void)
{
	int r, g, b, n;
	int m, count = 0;
	scanf("%d %d %d %d", &r, &g, &b, &n);

	for (int red = 0; red <= n / r; red++) {
		for (int green = 0; green <= n / g; green++) {
			if ((n - r * red - g * green) >= 0 && (n - r * red - g * green) % b == 0) {
				m = (n - r * red - g * green) / b;
				if (r * red + g * green + m * b == n) ++count;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

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

    cin >> S;
    int a = 0, b = 0;
    REP(i, 3) {
        if (S[i] == 'A') {
            a++;
        } else if (S[i] == 'B') {
            b++;
        }
    }
    if (a > 0 && b > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//median time 31min
//time
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N, M;
    cin >> N >> M;
    map<ll, ll> AB;
    repi(i, N, 0)
    {
        ll tmA, tmB;
        cin >> tmA >> tmB;
        if (AB.count(tmA) == 0)
        {
            AB.insert(make_pair(tmA,tmB));
        }
        else
        {
            AB[tmA] += tmB;
        }
    }
    ll num = 0, sum = 0;
    repm(i, AB)
    {
        if (num + i->second <= M)
        {
            sum += i->first * i->second;
            num += i->second;
        }else{
            ll exchange = M - num;
            sum += i->first * exchange;
            num += exchange;
        }
        if(num == M){
            cout << sum << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <set>

using namespace std;

int main() {
  int n;
  cin >> n;
  set<int> st;
  for (int i=0; i<n; i++) {
    int t;
    cin >> t;
    st.insert(t);
  }
  printf("%d\n", st.size());
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int n,m;
char a[1001][1001];
long long f[1001][1001];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		getchar();
		for(int j=1;j<=m;j++)
			scanf("%c",&a[i][j]);
	}
	f[1][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(a[i][j]!='#')
				f[i][j]=(f[i-1][j]+f[i][j-1]+f[i][j])%1000000007;
	printf("%lld",f[n][m]);
}

Measured memory_bytes: 9088
N = int(input())
A = list(map(int, input().split()))
X = [0 for i in range(8)]
cnt = 0
for a in A:
  if a >= 3200:
    cnt += 1
  else:
    X[a // 400] = 1
s = sum(X)
if s == 0:
  print(str(1) + " " + str(cnt))
else:
  print(str(s) + " " + str(s + cnt))

Measured memory_bytes: 61928
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, q, m, now;

struct LazySegmentTree {
private:
    ll n;
    vector<ll> node, lazy;
    vector<bool> lazyFlag;

public:
    LazySegmentTree(ll sz) {
        n = 1; while (n < sz) n *= 2;
        node.resize(2 * n - 1);
        lazy.resize(2 * n - 1, 0);
        lazyFlag.resize(2 * n - 1);
    }

    void eval(ll k, ll l, ll r) {
        if (lazyFlag[k]) {
            node[k] += lazy[k];
            if (r - l > 1) {
                lazy[2 * k + 1] += lazy[k] / 2;
                lazy[2 * k + 2] += lazy[k] / 2;
                lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
            }
            lazy[k] = 0;
        }
    }

    void add(ll a, ll b, ll x, ll k = 0, ll l = 0, ll r = -1) {
        if (r < 0) r = n; 
        eval(k, l, r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            lazyFlag[k] = true;
            eval(k, l, r);
           
        }
        else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }

    ll getsum(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

int main() {
    ll n, q;
    cin >> n >> q;
    LazySegmentTree s(n);
    REP(i, q) {
        ll t;
        cin >> t;
        if (t == 0) {
            ll a, b, c;
            cin >> a >> b >> c;
            a--;
            s.add(a, b, c);
        }
        else {
            ll a, b;
            cin >> a >> b;
            a--;
            cout << s.getsum(a, b) << endl;
        }
    }
}



Measured memory_bytes: 7076
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let c: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let d: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = if ((a - c).abs() <= d) || ((a - b).abs() <= d && (b - c).abs() <= d) {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main(){
//ll tc; cin>>tc; while(tc--){
ll n,m,mn=INT_MAX,i,x,j,a=0,t,k,b=-1,mx=-1,cnt=0,c=0; 
 st s,str; char strn;
cin>>n; //a=n; n-=1; 
ll ara[n+1],bra[n+1],taj[n+1];
memset(ara,0,sizeof(ara));
//for(i=1;i<=n;i++) cin>>ara[i]; 
  for(i=1;i<=n;i++)
   {  
     for(j=i;j<=n;j+=i)
      {
        ara[j]++;
      }
      
   }      
   for(i=1;i<=n;i++) 
        a+=(i*ara[i]);  

        
     cout<<a<<endl;
    
 
    rt;
}

Measured memory_bytes: 81700
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

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

    VII primes;
    vector<bool> vis(1e6, false);
    int l = 1e6;
    for (int i = 2; i <= l;++i)
    {
        if(vis[i])
            continue;

        primes.pb(i);
        for (int j = i + i; j <= l;j+=i)
            vis[j] = true;
    }

    int n;
    cin >> n;
    cout<<*lower_bound(all(primes), n);
    return 0;
}


Measured memory_bytes: 3936
#include<bits/stdc++.h>
using namespace std;
typedef  long double ll;
typedef pair<ll,ll> mp;
typedef pair<ll,bool> mlb;
#define inf 1e9
struct point{
    double x,y;
    point(double x, double y): x(x),y(y){};
    point() {};
    point operator - (point &p){ return point(x-p.x,y-p.y); }
    void make(){cin>>x>>y; }
    double norm(){ return x*x+y*y; }
    double abs() { return sqrt( norm() ); }
    double arg(){//原点からの角度
        //comp c(x.y);
        //return c.arg();
        return atan2(y,x);
    }   
    double arg2(){
        point tmp = point(-1,0);
        double pi = tmp.arg();
        return arg()/ pi * 180.0; 
    }
    void print(){ cout<<x<<' '<<y<<endl; }
};
 
int main(){
    point tmp = point(-1,0);
    double pi = tmp.arg();
    int n;
    cin>>n;
    double r,theta;
    cin>>r>>theta;
    vector<point> p(n);
    for(int i=0;i<n;i++)p[i].make();
    vector<vector<vector<mlb> > > g(n,vector<vector<mlb> >(n,vector<mlb> (n,mlb(inf,false) ) ) );
    for(int i=0;i<n;i++)//prev
        for(int j=0;j<n;j++)//now
            for(int k=0;k<n;k++){//next
                if(i==j||j==k||k==i)continue;
                point d1 = p[j]-p[i];
                point d2 = p[k]-p[j];
                point dire = point( d1.x*d2.x + d1.y*d2.y , d1.y*d2.x - d1.x*d2.y );
                if( abs( dire.arg() ) <= theta/180.0*pi   ){
                    g[i][j][k] = mlb(d2.abs(),true);
                }
            }
    int M = 1e4+2;
    //vector<vector<vector<double> > > dp(n,vector<vector<double> >(n,vector<double>(M,-1) ) );
    vector<vector<double> > dp(n,vector<double>(n,-1) );
    int ans = 0;
    for(int i=1;i<n;i++){
        dp[0][i] = r - (p[i]-p[0]).abs();
        if(dp[0][i] >= 0) ans = 1;
    }
if(ans == 1)
    for(int i=1;i<M-1;i++){
        vector<vector<double> > ndp(n,vector<double>(n,-1) );
        for(int j = 0;j<n;j++){
            for(int k = 0;k<n;k++){
                if(dp[j][k] > 0){
                    for(int l=0;l<n;l++){
                        if(g[j][k][l].second){
                            double next = dp[j][k] - g[j][k][l].first;
                            if(next>=0){
                                ans = i+1;
                                ndp[k][l] = max(ndp[k][l],next );
                                //cout<<i+1<<' '<<j<<' '<<k<<' '<<l<<' '<<next<<endl;
                            }
                        }
                    }
                }
            }
        }
        dp = ndp;
        if(ans == i) break;
    }
    cout<<ans<<endl;
 
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);


int main(){
  ll n,m;
  cin>>n>>m;
  if(n==1||m==1){
    cout<<max((n*m)-2,1)<<"\n";
  }else{
    cout<<((n-2)*(m-2))<<"\n";
  }
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;

void main() {
  char c;
  scanln(c);
  writeln((c + 1).to!char);
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


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

int n, a[1000], b[1000], c[1000];

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) cin >> a[i] >> b[i] >> c[i];
	for (int i = 0; i < n; i++) {
		int tm = 0;
		for (int j = i; j < n - 1; j++) {
			if (tm < b[j])tm = b[j];
			else tm = ((tm + c[j] - 1) / c[j])*c[j];
			tm += a[j];
		}
		cout << tm << endl;
	}
	return 0;
}

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

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	long long x;

	cin >> x;

	int num = 0,i;

	for (i = 1; num < x; i++) {
		num += i;
	}

	cout << --i << endl;

	return 0;

}

Measured memory_bytes: 256
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#include <atcoder/all>

using namespace __gnu_pbds;
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) begin(x),end(x)
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7;
constexpr int mod2 = 998244353;
 
template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}
 
    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};
 
template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
template <class T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class K, class V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
 
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

//}}}
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n, m;
    cin >> n >> m;

    atcoder::dsu uf(n);

    rep(i,m){
        int a, b;
        cin >> a >> b;
        --a, --b;
        uf.merge(a, b);
    }

    cout << uf.groups().size() - 1 << '\n';

    return 0;
}

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



int main() {
    int n, x, t;
    cin >> n >> x >> t;
    
    int cnt;
    if(n%x == 0)
        cnt = n / x;
    else
        cnt = n / x + 1;
    
    cout << cnt * t << endl;
    
    
    return 0;
}




Measured memory_bytes: 3632
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        double a[105];
        double s=0;
        for(int i=1;i<=n;i++)
        {
        	cin>>a[i];
        	s+=1/a[i];
        }
        cout<<setprecision(10)<<(1/s);
    }
    return 0;
}

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

int main() {

  unsigned long int n,a,b,rem;
  long long int ans;
  cin >> n >> a >> b;
  ans=a*(n/(a+b));
  rem=n%(a+b);
  //cout << rem << endl;
  ans+=min(rem,a);
  cout << ans << endl;

}


Measured memory_bytes: 256
// Hint: Don't look, No need

#pragma optimize("O2")
#include <bits/stdc++.h>
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#ifndef bhupixb
  #define var(...)
  #define stl(...)
#endif

signed main() {
  fast;
  int n;
  cin >> n;
  map<int,int> mp;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i) continue;
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1) mp[n]++;
  int ans = 0;
  for (auto it: mp) {
    var(it.second);
    if (it.second == 1) {
      ++ans;
    }
    else {
      int lo = 1, hi = 100;
      while (lo <= hi) {
        int mid = lo + hi >> 1LL;
        if (mid * (mid + 1) / 2 <= it.second) {
          lo = mid + 1;
        }
        else{
          hi = mid - 1;
        }
      }
      ans += lo - 1;
      // cout << it.second << ' ' << cnt << '\n';

      // if (c > cnt * (cnt + 1) / 2) --ans;
    }
  }
  cout << ans << '\n';


  return 0;
}

Measured memory_bytes: 3660
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto K = s[1].to!long;
    auto A = readln.split.map!(to!long).array;
    A.sort();

    auto B = A.filter!(a => a < 0).array;
    auto C = A.filter!(a => a >= 0).array;

    long cnt(long tar, long a) {
        if (a == 0) {
            return tar >= 0 ? N - 1 : 0;
        } else if (a > 0) {
            int hi = N;
            int lo = -1;
            while (hi - lo > 1) {
                int mid = (hi + lo) / 2;
                if (A[mid] * a <= tar) lo = mid;
                else hi = mid;
            }
            return lo  + 1 - (a * a <= tar);
        } else {
            int hi = N;
            int lo = -1;
            while (hi - lo > 1) {
                int mid = (hi + lo) / 2;
                if (A[mid] * a <= tar) hi = mid;
                else lo = mid;
            }
            return (N - hi) - (a * a <= tar);
        }
    }

    long hi = 10L^^18 + 1;
    long lo = -(10L^^18) - 1;
    while (hi - lo > 1) {
        long mid = (hi + lo) / 2;
        long count = 0;
        foreach (a; A) {
            count += cnt(mid, a);
        }
        count /= 2;
        if (count >= K) hi = mid;
        else lo = mid;
    }

    hi.writeln;
}


Measured memory_bytes: 11608
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> k >> s;
	s[k-1] = s[k-1]-'A'+'a';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
// int is too small for this calcuration
// so i used long.
// have a nice hhk!!

int main()
{
    unsigned long n;
    unsigned long ans = 1;
    cin >> n;
    for(int c = n; c > 1; c--)
    {
        ans *=c;
    }
    cout << ans << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1156
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = map(int, sys.stdin.readline().split())
    lines = list(map(int, sys.stdin.readline().split()))
    lines.sort()

    cost = {}
    for i in range(len(lines) - 1):
        tmp = lines[i + 1] - lines[i]
        cost[i] = tmp

    sortedCost = sorted(cost.items(), key=lambda x: x[1], reverse=True)
    ret = 0
    for i, c in sortedCost[N - 1:]:
        ret += c

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24652
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  if(a<b)
    cout<<"a < b"<<'\n';
  if(a>b)
    cout<<"a > b"<<'\n';
  if(a==b)
    cout<<"a == b"<<'\n';
  return(0);
}
  



Measured memory_bytes: 3024
// 
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


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

    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    sort(all(p));
    int ans=0;
    rep(i,k) ans+=p[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int H, W, h, w;
	cin >> H >> W >> h >> w;

	cout << (H - h)*(W - w) << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, C, K;
  cin>>N>>C>>K;
  vector<ll> T(N);
  for(int i=0;i<N;++i) cin>>T[i];
  sort(T.begin(), T.end());
  int index = 0;
  int time;
  int num;
  int ans = 0;
  while(true) {
    ans++;
    time = T[index] + K;
    num = 0;
    for(int i=index;i<N;++i) {
      if(T[i]>time || num+1>C) {
        index = i;
        break;
      }
      num++;
      index++;
    }
    if(index==N) break;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4052
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
//    static final long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};
    static long pl,mi;

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int h=sc.nextInt();
        int w=sc.nextInt();
        char c[][]=new char[h][w];
        
        for (int i = 0; i < c.length; i++) {
			c[i]=sc.nextString().toCharArray();
		}
        int m[][]=new int[h][w];
        int k=0;
        long ans=0;
        for (int i = 0; i < m.length; i++) {
			for (int t = 0; t < m[0].length; t++) {
				if(c[i][t]=='#' && m[i][t]==0) {
					pl=0;
					mi=0;
					rep(c,m,i,t,++k);
					ans+=pl*mi;
				}
			}
		}



        
        

        out.println(ans);
        out.flush();
    }
    
    static void rep(char c[][],int mark[][] ,int x, int y, int k) {
    	for (int i = 0; i < 4; i++) {
			int xx=x+dx[i],yy=y+dy[i];
			if(validpos(xx, yy, c.length, c[0].length) && mark[xx][yy]==0) {
				if(c[xx][yy]=='.' && c[x][y]=='#') {
					mark[xx][yy]=-k;mi++;
					rep(c,mark,xx,yy,k);
				}
				if(c[xx][yy]=='#' && c[x][y]=='.') {
					mark[xx][yy]=k;pl++;
					rep(c,mark,xx,yy,k);
				}
			}
		}
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int main(void){
    int a[1000000];
    cin>>a[0];
    int i;
    for(i=0;i<1000000;i++){
        if(a[i]%2==1){
            a[i+1]=a[i]*3+1;
        }else if(a[i]%2==0){
            a[i+1]=a[i]/2;
        }
        for(int t=0;t<=i;t++){
            if(a[i+1]==a[t]){
                cout<<(i+2)<<endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define N 200005
using namespace std;

int n, m, c[N][2], vt[N];
string s;
vector<int> gr[N];
queue<int> qu;

int main() {
	int i, u, v;
	cin >> n >> m >> s;
	s = '.' + s;
	while(m--) {
		scanf("%d%d", &u, &v);
		gr[u].push_back(v);
		gr[v].push_back(u);
		c[u][s[v]-'A']++;
		c[v][s[u]-'A']++;
	}
	for(i=1; i<=n; i++) if(!c[i][0] || !c[i][1]) {
		vt[i] = 1;
		qu.push(i);
	}
	while(!qu.empty()) {
		u = qu.front(); qu.pop();
		for(int v:gr[u]) {
			c[v][s[u]-'A']--;
			if(!vt[v] && !c[v][s[u]-'A']) {
				vt[v] = 1;
				qu.push(v);
			}
		}
	}
	for(i=1; i<=n && vt[i]; i++);
	puts(i>n ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 13128
local n = io.read("*n")
local h = {}
for i = 1, n do
  h[i] = io.read("*n")
end
local curlen = 0
local maxlen = 0
for i = 2, n do
  if h[i - 1] >= h[i] then
    curlen = curlen + 1
  else
    maxlen = math.max(maxlen, curlen)
    curlen = 0
  end
end
maxlen = math.max(maxlen, curlen)
print(maxlen)


Measured memory_bytes: 2424
#include <iostream>
#include <map>
#include <vector>
#include <array>
#include <string>
#include <cstdint>
using namespace std;

int main() {
    int n; cin >> n;
    vector<string> sv(n);
    for (auto &e : sv) cin >> e;

    constexpr size_t alphabet = 'z' - 'a' + 1;

    auto count = [](const string &s) {
        array<int, alphabet> counter = { 0 };
        for (auto c : s) {
            ++counter[c - 'a'];
        }
        return counter;
    };

    int64_t ans = 0;

    map<array<int, alphabet>, int> anagram;
    for (auto &s : sv) {
        ++anagram[count(s)];
    }

    for (auto &s : sv) {
        ans += --anagram[count(s)];
    }

    cout << ans << endl;
}



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

int main(){
	int w;
	int n;
	cin>>w>>n;
	vector<int> x(w);
	for(int i=0;i<w;i++)x[i]=i+1;

	for(int i=0;i<n;i++){
		int a,b;
		(cin>>a).ignore()>>b;
		a--;
		b--;
		int tmp=x[a];
		x[a]=x[b];
		x[b]=tmp;
	}
	for(int i=0;i<w;i++)cout<<x[i]<<endl;
	return 0;
}

Measured memory_bytes: 3064
#include <algorithm>
#include <chrono>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>

using namespace std;

int n;
vector<vector<int>> g;

vector<vector<int>> TryGetLayersFrom(int start)
{
    vector<bool> used(n, false);
    vector<int> dist(n);
    queue<int> q;
    q.push(start);
    used[start] = true;
    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (auto u : g[v]) {
            if (!used[u]) {
                used[u] = true;
                dist[u] = dist[v] + 1;
                q.push(u);
            }
        }
    }
    for (int v = 0; v < n; ++v) {
        for (auto u : g[v]) {
            if (dist[v] == dist[u]) {
                return {};
            }
        }
    }
    vector<vector<int>> result;
    for (int v = 0; v < n; ++v) {
        while (result.size() <= dist[v]) {
            result.push_back({});
        }
        result[dist[v]].push_back(v);
    }
    return result;
}

void Solve()
{
    vector<vector<int>> result;
    for (int v = 0; v < n; ++v) {
        auto currentResult = TryGetLayersFrom(v);
        if (currentResult.size() > result.size()) {
            result = std::move(currentResult);
        }
    }
    if (result.size() > 0) {
        cout << result.size() << endl;
    } else {
        cout << -1 << endl;
    }
}

bool Read()
{
    if (!(cin >> n)) {
        return false;
    }
    g.clear();
    g.resize(n);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < n; ++j) {
            if (s[j] == '1') {
                g[i].push_back(j);
            }
        }
    }
    return true;
}

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 3376
let () = Scanf.scanf "%d %d\n" @@ fun x n ->
  let ps = List.init n @@ fun _ -> Scanf.scanf "%d " Fun.id in
  Printf.printf "%d\n" @@
  List.fold_left (fun y y' ->
    if abs (y - x) <= abs (y' - x) then y else y') 0 @@
  List.filter (fun y -> List.for_all (( <> ) y) ps) @@
  List.init 102 Fun.id



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

int a, b;
int main()
{
	cin >> a >> b;
	if (b < 0) {
		if ((b - a + 1) % 2) cout << "Negative";
		else cout << "Positive";
	} else if (a > 0) cout << "Positive";
	else cout << "Zero";
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
  int a, b, k;
  scanf("%d%d%d", &a, &b, &k);
  int i;
  for(i = a; i - a < k && i <= b; i++)
    printf("%d\n", i);
  if(i < b - k + 1)
    i = b - k + 1;
  for(; i <= b; i++)
    printf("%d\n", i);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
    int a[5];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<i;j++)
        {
            if(a[i]>a[j])
                swap(a[i],a[j]);
        }
    }
    if(a[0]==a[1]&&a[0]==a[2])
        puts("0");
    else
    {
        int cnt=0;
        int x=a[0]-a[1];
        int y=a[0]-a[2];
        while(x!=0)
        {
            if(x>=2)
            {
                cnt++;
                x=x-2;
            }
            else if(y!=0)
            {
               x--;
               y--;
               cnt++;
            }
            else
                break;
        }
        while(y!=0)
        {
            if(y>=2)
            {
                cnt++;
                y=y-2;
            }
            else
                break;
        }
        if((x==0&&y==1)||(x==1&&y==0))
                cnt=cnt+2;
        printf("%d\n",cnt);
    }
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < int(s.size()); ++i) if (((i % 2) && (s.at(i) == 'R')) || (!(i % 2) && (s.at(i) == 'L'))) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}


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

int main(){
	vector<double> ans;
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		double a[n],sum=0;
		for(int i=0; i<n; i++){
			cin>>a[i];
			sum+=a[i];
		}
		double ave=sum/n;
		double sum2=0;
		for(int i=0; i<n; i++) sum2+=(a[i]-ave)*(a[i]-ave);
		ans.push_back(sqrt(sum2/n));
	}
	for(int i=0; i<ans.size(); i++){
		cout<<fixed<<setprecision(10)<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3276
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

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

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

     long long int n,k;

     cin>>n>>k;

     if(n>=k){
      	if(n%k==0){
      		cout<<0<<endl;
      	}else{
     	   cout<<k-(n%k)<<endl;
     	}
     }else{
     	if(n<=(k/2)){
     		cout<<n<<endl;
     	}else{
     		cout<<k-n<<endl;
     	}
     }

    return 0;
  }

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j,N,M,ans=0,x;
  cin>>N;
  vec a(N+1),b(N);
  rep(i,N+1)cin>>a[i];
  rep(i,N)cin>>b[i];
  rep(i,N){
    if(a[i]>=b[i]){
      a[i]-=b[i];
      ans+=b[i];
    }else{
      b[i]-=a[i];
      ans+=a[i];
      if(a[i+1]>=b[i]){
        a[i+1]-=b[i];
        ans+=b[i];
      }else{
        ans+=a[i+1];
        a[i+1]=0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int l[10];
int main()
{
	int N, A[3];
	cin >> N >> A[0] >> A[1] >> A[2];
	for (int i = 0; i < N; i++) cin >> l[i];
	int ans = mod;
	for (int bit = 0; bit < (1 << 2 * N); bit++) {
		int tmp = bit;
		int cnt = 0;
		int c[10] = { 0 };
		int sum[10] = { 0 };
		for (int i = 0; i < N; i++) {
			c[tmp % 4]++;
			sum[tmp % 4] += l[i];
			tmp /= 4;
		}
		for (int i = 0; i < 3; i++) {
			if (c[i] == 0) cnt = mod;
			cnt += 10 * (max(0,c[i] - 1));
			cnt += abs(sum[i] - A[i]);
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P= pair<ll,ll>;
 
int main() {
    string str;
    cin>>str;
    ll count=0;
    for(int i=0;i<str.size();i++)
    {
      //cout<<str[i]-'0';
      count+=str[i]-'0';
    }
    if(count%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3760