akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    char prev = s[0];
    if(s[0]=='R') ans++;
    for(int i=1; i< s.size(); i++){
        if(prev=='R' && s[i]=='R') ans++;
        if(prev=='R' && s[i]=='S') ans = ans;
        if(prev=='S' && s[i]=='R') ans=1;
        if(prev=='S' && s[i]=='S') ans = ans;
        prev = s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
<?php
/*
    Problem URL : http://abc060.contest.atcoder.jp/tasks/abc060_d

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('memory_limit', '256M');

// define('DEBUG', true);
define('DEBUG', false);

list($N, $W) = explode(" ", trim(fgets(STDIN)));

// $w = array_fill(0, $N, 0);
// $v = array_fill(0, $W, 0);

for ($i = 0; $i < $N; $i++) {
    list($w[$i], $v[$i]) = explode(" ", trim(fgets(STDIN)));
}
if (DEBUG) echo implode(" ", $w) . PHP_EOL;

$cnt1 = floor($W / $w[0]);
$cnt2 = floor($W / ($w[0] + 3));
if (DEBUG) echo "\$cnt: {$cnt1} {$cnt2}\n";

if ($cnt1 == $cnt2) {
    for ($i = 0; $i < $N; $i++) {
        $w[$i] = 1;
    }
    $W = $cnt1;
}
if ($cnt1 == $cnt2 + 1) {
    $avoid = $w[0];

    for ($i = 0; $i < $N; $i++) {
        $w[$i] = $w[$i] - $avoid + 100;
    }
    $W -= ($avoid - 100) * $cnt1;
}

if (DEBUG) echo implode(" ", $w) . PHP_EOL;
if (DEBUG) echo "\$W = {$W}\n";

$tmp1 = array_fill(0, $N + 1, 0);
$tmp2 = array_fill(0, $W + 1, 0);

$dp = array($tmp1, $tmp2);

for ($j = 0; $j <= $W; $j++) {
    $dp[$N][$j] = 0;
}

for ($i = $N - 1; $i >= 0; $i--) {
    for ($j = 0; $j <= $W; $j++) {
        // printf("%d < %d\n", $j, $w[$i]);
        if ($j < $w[$i]) {
            $dp[$i][$j] = $dp[$i + 1][$j];
        } else {
            $dp[$i][$j] = max($dp[$i + 1][$j], $dp[$i + 1][$j - $w[$i]] + $v[$i]);
        }
        // printf("%d %d %d\n", $i, $j, $dp[$i][$j]);
    }
}

echo $dp[0][$W]."\n";

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

template<typename T> class WeightedUnionFind{
    protected:
        vector<int> par;
        vector<T> w;
    public:
        WeightedUnionFind(int n);
        int root(int x);
        bool unite(int x, int y, T w);
        bool same(int x, int y);
        T weight(int x);
        T diff(int x, int y);
};

template<typename T> WeightedUnionFind<T>::WeightedUnionFind(int n){
    par = vector<int>(n + 1, -1);
    w = vector<T>(n + 1);
}

template<typename T> int WeightedUnionFind<T>::root(int x){
    if (par[x] < 0) return x;
    int r = root(par[x]);
    w[x] += w[par[x]];
    return par[x] = r;
}

template<typename T> bool WeightedUnionFind<T>::unite(int x, int y, T d){
    d += weight(x); d -= weight(y);
    x = root(x); y = root(y);
    if (x == y) return d == 0;
    if (par[x] > par[y]){
        swap(x, y);
        d = -d;
    }
    par[x] += par[y];
    par[y] = x;
    w[y] = d;
    return true;
}

template<typename T> bool WeightedUnionFind<T>::same(int x, int y){
    return root(x) == root(y);
}

template<typename T> T WeightedUnionFind<T>::weight(int x){
    root(x);
    return w[x];
}

template<typename T> T WeightedUnionFind<T>::diff(int x, int y){
    return weight(y) - weight(x);
}



int main(){
    int n, m;
    cin >> n >> m;
    WeightedUnionFind<ll> wuf(n);
    for (int i = 0; i < m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        if (!wuf.unite(l, r, d)){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll h(N);
        rep(i, 0, N) cin >> h[i];

        ll ans = 0;
        while (true) {
                if (all_of(all(h), [](auto x) {return x <= 0;})) break;
                rep(i, 0, N) {
                        if (h[i] != 0) {
                                do {
                                        h[i]--;
                                        ++i;
                                } while (h[i] > 0 and i <= N-1);
                                ++ans;
                        }
                }
        }

        cout << ans << endl;
}

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

using namespace std;

int r,n,L,R,h,i,x;

int main(){
	
	while(cin>>r>>n,r){

		
		int A[41]={},B[41]={};
		for(i=0;i<n;i++){
			cin>>L>>R>>h;
			for(x=L;x<=R;x++){
				if(x!=R)A[x+20]=max(A[x+20],h);
				if(x!=L)B[x+20]=max(B[x+20],h);
			}	
		}
		double res=99;
		for(i=-r;i<=r-1;i++){
			res=min(res,min(r-sqrt(r*r-i*i)+A[i+20],r-sqrt(r*r-(i+1)*(i+1))+B[i+1+20]));
		}
		cout<<res<<"\n";
		
	}
	
	return 0;
}

Measured memory_bytes: 1240
s=input()
c=0
if s[0]!='A' or s[0].isupper()==False:
  print("WA")
else:
  for i in range(2,len(s)-1):
    if s[i]=='C' and s[i].isupper()==True:
      c+=1
  if c==1 and s[1].isupper()==False and s[len(s)-1].isupper()==False:
    print("AC")
  else:
    print("WA")


Measured memory_bytes: 3060
a, b, c, d = [int(i) for i in input().split()]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

def count(a, b, c):
    d = a // b
    e = a // c
    f = a // lcm(b, c)
    return a - d - e + f
ans = count(b, c, d) - count(a, c, d)
if(a % c != 0 and a % d != 0):
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n,x,t;
  cin >> n >> x >> t;
  int p=(n+x-1)/x;
  cout << p*t;
}

Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, i, l, r;
	ll a[200003], ans, sa, xc;

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

	r = 0;
	ans = 0;
	sa = xc = a[0];
	for (l = 0; l < n; l++) {
		while (r < n && sa == xc) {
			r++;
			sa += a[r];
			xc ^= a[r];
		}
		ans += r - l;
		sa -= a[l];
		xc ^= a[l];
	}

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

	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#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));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


ll n;
vector<ll> v[100010];//木になる

ll f(int p){
	ll ans=0;
	priority_queue<ll> Q;
	rep(i,v[p].size()){
		Q.push(f(v[p][i]));
	}
	reg(i,1,v[p].size()){
		ll q=Q.top();Q.pop();
		ans=max(ans,i+q);
	}
	return ans;
}

int main(void){
	cin>>n;
	reg(i,2,n){
		ll a;
		cin>>a;
		v[a].push_back(i);//勝った方から負けた方に辺を伸ばす
	}
	cout<<f(1)<<endl;
	return 0;
}

Measured memory_bytes: 15104
#include <iostream>

using namespace std;

int mapping(string s) {
    if(s == "SUN") {
        return 0; 
    }else if(s == "MON") {
        return 1; 
    }else if(s == "TUE") {
        return 2; 
    }else if(s == "WED") {
        return 3; 
    }else if(s == "THU") {
        return 4; 
    }else if(s == "FRI") {
        return 5;    
    }else {
        return 6;
    }
}

int main()
{
    string s;
    cin >> s;
    
    int n = mapping(s); 
    
    cout << 7 - n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int N, i, a, b, c;
	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d %d %d", &a, &b, &c);
		if(a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n,y = nm()

for i in range(2001):
    for j in range(2001):
        k = n - i - j
        res = 10000*i + 5000*j + 1000*k
        if k >= 0 and res == y:
            print(i,j,k)
            sys.exit(0)
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include<vector>
#include<string>
    #include<algorithm>
using namespace std;



/// Info.
///****************************************************************************************************************************************///
/// author                : BAHAA El-DEEN OSAMA .
/// Problem name          : N - Phone Numbers
/// Method                : brute force
/// Online judge          : vjudge(Contest)
/// Date                  : 8/7/2020
///****************************************************************************************************************************************///

typedef long long ll ;
typedef unsigned long long ull ;

ll n;
string str = "";

int main()
{

    cin >> n;
	while (n)
    {
		int s = (n-1) % 26;
		str = (char)('a' + s) + str;
		n = (n-1)/ 26;
	}
	cout << str << endl;

	   return 0;
}


Measured memory_bytes: 3596
#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 <bitset>
#include <algorithm>
#include <complex>
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<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 304;
double dp[N][N][N];

int main() {
    int n;
    cin >> n;
    int c[3] = {};
    REP(i,n){
        c[in() - 1]++;
    }

    REP(k,N-1) REP(j,N-1) REP(i,N-1){
        if (i + j + k == 0) continue;
        double tmp = 1.0;
        if (i) tmp += dp[i - 1][j][k] * i / n;
        if (j) tmp += dp[i + 1][j - 1][k] * j / n;
        if (k) tmp += dp[i][j + 1][k - 1] * k / n;
        tmp *= n;
        tmp /= i + j + k;
        dp[i][j][k] = tmp;
    }
    printf("%.15f\n", dp[c[0]][c[1]][c[2]]);

    return 0;
}


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


int main(int argc, char const *argv[]) {
  int n,a,b,c;
  scanf("%d", &n);
  a = n / 100;
  b = (n-a*100)/10;
  c = n-a*100-b*10;
  if(a == 1){
    a = 9;
  }else if(a == 9){
    a = 1;
  }
  if(b == 1){
    b = 9;
  }else if(b == 9){
    b = 1;
  }
  if(c == 1){
    c = 9;
  }else if(c == 9){
    c = 1;
  }
  n = a*100+b*10+c;
  printf("%d",n);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

struct edge{int end;int cost;};
typedef pair<int,int> P;
int V,d[114514],f[114514];
vector<edge> G[114514];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    for(int i=0;i<114514;i++){d[i]=INF;}
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.end]>d[v]+e.cost){
                d[e.end] = d[v]+e.cost;
                que.push(P(d[e.end],e.end));
            }
        }
    }
}


signed main(){
    int N;
    int a[114514],b[114514];
    cin >> N;
    REP(i,N-1){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    edge h;
    REP(i,N-1){
        h.cost=1;
        h.end=b[i];
        G[a[i]].push_back(h);
        h.end=a[i];
        G[b[i]].push_back(h);
    }
    dijkstra(N-1);
    REP(i,N){
        f[i]=d[i];
    }
    dijkstra(0);
    int Fennec=0,Snuke=0;
    REP(i,N){
        if(d[i]<=f[i]){
            Fennec++;
        }else{
            Snuke++;
        }
    }
    out(Fennec>Snuke,"Fennec","Snuke");
    return 0;
}   


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

int main() {
  int a, b;
  double c, d;
  cin >> a >> b;
  c = a;
  d = b;
  if((a+b)/2 == (c+d)/2){
    cout << (a+b)/2;
  }
  else{
    cout << (a+b)/2 + 1;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
int A, B;
int n, m;
char tu[110][110];

void paint(int x, int y)
{
	for (int i = 0; i < 4; i++) tu[x][y + i] = '#';
	for (int i = 0; i < 4; i++) tu[x - i][y + 3] = '#';
}

int main()
{
	//freopen("test.out", "w", stdout);
	int i, j;
	scanf("%d%d", &A, &B);
	n = 100;
	m = 100;
	for (i = 0; i < 100; i++)
	{
		for (j = 0; j < 100; j++) tu[i][j] = '.';
	}
	int now_x = 3, now_y = 0;
	A--;
	bool flag = 0;
	while (A > 0)
	{
		flag = 1;
		paint(now_x, now_y);
		A--;
		now_x += 4;
		if (now_x >= 100)
		{
			now_x = 3;
			now_y += 4;
		}
	}
	now_x = 1, now_y = 1;
	if(flag==1)B--;
	while (B > 0)
	{
		tu[now_x][now_y] = '#';
		B--;
		now_x += 4;
		if (now_x >= 100)
		{
			now_x = 1;
			now_y += 4;
		}
	}
	printf("%d %d\n", n, m);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++) printf("%c", tu[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 2000005
#define MOD  998244353 //1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define sort(v) sort(v.begin(), v.end())
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}
ll ceil(ll a, ll b){ return (a+ b-1)/b; }
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}

ll mn= 1000005,k=0;
bool prime[1000005];
vector<ll>vec;
ll seive(){
    ll i, j;
    memset(prime,  true, sizeof(prime));
    prime[0]= prime[1]= false;
    for(i=2; i*i<=mn;i++){
        if(prime[i]){
            //
            for(j = i*i;j<=mn; j+= i){
                prime[j] = false;
            }
        }
    }
    for(i=0; i<mn;i++){
        if(prime[i]) {vec.push_back(i); }
    }
}

void solve(){

    ll x;
    cin >> x;
    seive();
    for(auto y : vec){
        if(y >= x) {
            cout << y ; return; }
    }
}

int main()
{
    fast();
    ll t = 1;//cin >> t;
    while(t--){
        solve();
    }
}


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

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif

const int MOD = 1000000007;

int main(){
    IOS;
    int l, r;
    cin >> l >> r;
    set<int> values;

    for (int i = l; i <= r; i++){
        int x = i % 2019;
        if (values.count(x)){
            break;
        }
        //trace(x);
        values.insert(x);
    }

    int mn = 3000;
    //cout << (*values.begin() * (*(++values.begin()))) % 2019 << endl;

    //auto it = values.begin();
    vector<int> vecvalues;
    for (auto x: values){
        vecvalues.pb(x);
    }

    for (int i = 0; i < vecvalues.size(); i++){
        for (int j = i + 1; j < vecvalues.size(); j++){
            int x = (vecvalues[i] * vecvalues[j]) % 2019;
            mn = min(x, mn);
        }
    }

    cout << mn << endl;

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

typedef struct {
	vector<pair<ll, int>> edge;
	bool vi;
	ll cost = 0;
	int deg = 0;
}node_t;
vector<node_t> node;

int main() {
	int N, M; cin >> N >> M;
	node = vector<node_t>(N + 1);
	for (int i = 0; i < M; i++) {
		int L, R, D; cin >> L >> R >> D;
		node[L].edge.push_back(make_pair(D, R));
		node[R].deg++;
	}

	if (M == 0)cout << "Yes" << endl;
	else {
		bool fl = true, cir = false;
		for (int i = 1; i <= N && fl; i++) {
			if (node[i].deg != 0) continue;
			if (node[i].edge.size() != 0)cir = true;
			priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
			vector<ll> dis(N + 1, 1e16);
			pq.emplace(0, i);
			while (!pq.empty()) {
				int x = pq.top().second;
				pq.pop();
				if (node[x].vi)continue;
				node[x].vi = true;
				for (auto ed : node[x].edge) {
					int to = ed.second;
					ll co = ed.first;
					if (dis[to] == 1e16) {
						dis[to] = dis[x] + ed.first;
						pq.emplace(dis[to], to);
					}
					else if (dis[to] != dis[x] + ed.first) {
						fl = false;
						break;
					}

				}

				if (!fl)break;
			}

		}

		if (fl && cir) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 15796
package main

import(
	"fmt"
	"bufio"
	"os"
)
func main(){
	stdin := bufio.NewReader(os.Stdin)
	var r float64
	fmt.Fscan(stdin,&r)
	//fmt.Printf("%v\n",r)
	s := r*r*3.14159265358979
	syu := r*2.0*3.14159265358979
	fmt.Printf("%.6f %.6f\n",s,syu)
}


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

using namespace std;

typedef long long ll;

const int nax = 1e7+7;
const int MOD = 1e9+7;

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

    int v[n];

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

    vector<int> f(n), r(n);

    f[0] = v[0];
    r[n-1] = v[n-1];

    for(int i=1; i<n; i++){
        f[i] = __gcd(f[i-1], v[i]);
    }

    for(int i=n-2; i>=0; i--){
        r[i] = __gcd(r[i+1], v[i]);
    }

    int ans = max(f[n-2], r[1]);
    for(int i=1; i<n-1; i++){
        ans = max(ans, __gcd(f[i-1], r[i+1]));
    }

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

Measured memory_bytes: 4568
// Code by ajcxsu
// Problem: river correction

#include<bits/stdc++.h>
#define MOD (1000000007)
using namespace std;

const int N=5e5+10;
int h[N], l[N], r[N];
vector<int> L[N];
int x[N], v[N], a[N];
bool cmp(const int &a, const int &b) { return v[a]<v[b]; }
int f[N], S[N];

int main() {
    // freopen("river.in","r",stdin);
    // freopen("river.out","w",stdout);
    ios::sync_with_stdio(false), cin.tie(0);
    int n, m;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>x[i]>>v[i], a[i]=i;
    sort(a+1, a+1+n, cmp);
    int stk[N], p[N], t=0;
    for(int i=1; i<=n; i++) {
        if(!t || stk[t]<x[a[i]]) stk[++t]=x[a[i]], p[t]=i;
        int l=1, r=t, mid;
        while(l<r) {
            mid=(l+r)>>1;
            if(stk[mid]<x[a[i]]) l=mid+1;
            else r=mid;
        }
        ::l[i]=p[r];
    }
    t=0;
    for(int i=n; i>=1; i--) {
        if(!t || stk[t]>x[a[i]]) stk[++t]=x[a[i]], p[t]=i;
        int l=1, r=t, mid;
        while(l<r) {
            mid=(l+r)>>1;  
            if(stk[mid]>x[a[i]]) l=mid+1;
            else r=mid;
        }
        ::r[i]=p[r];
    }
    // cin>>m;
    // for(int i=1; i<=n; i++) cin>>l[i]>>r[i];
    for(int i=1; i<=n; i++) L[r[i]].push_back(l[i]);
    f[0]=S[0]=1;
    for(int i=1; i<=n; i++) {
        S[i]=S[i-1];
        sort(L[i].begin(), L[i].end());
        for(int j:L[i]) {
            f[i]=(1ll*f[i]+S[i]-(j-2>=0?S[j-2]:0)+MOD)%MOD;
            S[i]=(f[i]+S[i-1])%MOD;
        }
        // cout<<f[i]<<" \n"[i==n];
    }
    cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 32768
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n, p[10], q[10],a=0,b=0;
	cin >> n;
	for (int i = 1; i <= n;i++) {
		cin >> p[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> q[i];
	}
	for (int i = 1; i < n;i++) {
		int c = p[i] - 1,m=1;
		for (int j = 1; j < i;j++) {
			if (p[i]>p[j]) {
				c--;
			}
		}
		for (int j = 1; j <=n-i ;j++) {
			m *= j;
		}
		a += c*m;
	}
	for (int i = 1; i < n; i++) {
		int c = q[i] - 1, m = 1;
		for (int j = 1; j < i; j++) {
			if (q[i] > q[j]) {
				c--;
			}
		}
		for (int j = 1; j <= n - i; j++) {
			m *= j;
		}
		b += c*m;
	}
	cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
import math

def comb(n, r):
  if n < r:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
a = [input() for _ in range(N)]

d = dict()
for x in a:
  s = ''.join(sorted(x))
  if s not in d.keys():
    d[s] = 1
  else:
    d[s] += 1

print(sum([comb(i, 2) for i in d.values()]))

Measured memory_bytes: 29108
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define step(n) rep(_, n)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define Unique(a) a.erase(unique(Range(a)), a.end())
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr Type Square(Type x) { return x * x; }
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << ""; Print(forward<Tail>(tail)...); }
template <class T> void Print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void Print(vector<vector<T>> &df) { for (auto& vec : df) { Print(vec); } }

int main()
{
    int N, K; cin >> N >> K;
    set<int> s;
    rep (i, K)
    {
        int d; cin >> d;
        rep (m, d)
        {
            int a; cin >> a;
            s.insert(a);
        }
    }

    Print(N - s.size());

    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int count=0;
  int i;
  for(i=0;i<3;i++){
    if(s.at(i)==t.at(i)){
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int s[100010], t[100010], c[100010];
bool use[40][100010];
int main()
{
	int N, C;
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		cin >> s[i] >> t[i] >> c[i];
		c[i]--;
		for (int j = s[i]; j <= t[i]; j++) {
			use[c[i]][j] = true;
		}
	}
	int ans = 0;
	int sum = 0;
	for (int i = 0; i <= 100010; i++) {
		sum = 0;
		for (int j = 0; j < C; j++) {
			if (use[j][i]) sum++;
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main() {
    string s;
    int ans = 0;
    int tmp = 0;
    int cur = 0;
    cin >> s;
    rep(i,s.size()){
       if(s[i] != '0'+cur) tmp++;
       cur = 1 - cur;
    }
    ans = tmp;
    tmp = 0;
    cur = 1;
    rep(i,s.size()){
        if(s[i] != '0'+cur) tmp++;
        cur = 1 - cur;
    }
    cout << min(ans, tmp) << endl;
}



Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep_one(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;


int main(){
    int n,x,t;
    cin >> n >> x >> t;
    cout << ((n+x-1)/x)*t << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "YES" << endl;}                                               
void no() {cout << "NO" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 8e18 + 8;
const double EPS = 1e-9;
const long long MOD = 998244353;
const double PI = acos(-1);

void solve() {
    int n; cin >> n;
    int lg = 0;
    while ((1 << lg) <= n) lg++;
    vector<long long> a(n + 1);
    vector<vector<long long> > b(n + 1, vector<long long>(lg + 1));
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    long long L; cin >> L;
    int last = 1;
    for (int i = 1; i <= n; i++) {
        while (last <= n and a[last] - a[i] <= L) last++;
        b[i][0] = last - 1;
    }
    for (int i = 1; i <= lg; i++) {
        for (int j = 1; j <= n; j++) {
            b[j][i] = b[b[j][i - 1]][i - 1];
        }
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int l, r; cin >> l >> r;
        if (l > r) swap(l, r);
        int res = 0;
        for (int j = lg; j >= 0; j--) {
            if (b[l][j] < r) {
                l = b[l][j];
                res += (1 << j);
            }
        }
        cout << res + 1 << endl;
    }
} 

int main() {
    jonathan; 
    livingston;
    solve();
    return 0;
}

Measured memory_bytes: 21884
#include<stdio.h>
int main(){
  char s[20];
  int i;
  scanf("%s",s);
  for(i=0;i<=4;i++)
    printf("%c",s[i]);
  printf(" ");
  for(i=6;i<=12;i++)
    printf("%c",s[i]);
  printf(" ");
  for(i=14;i<=18;i++)
    printf("%c",s[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll field[510][510];
ll H,W;

int main(){
    cin >> H >> W;
    rep(i,H) rep(j,W) cin >> field[i][j];
    ll n = 0;
    vector<ll> y,x,y1,x1;
    rep(i,H){
        if(i % 2 == 0){
            rep(j,W){
                if(j != W-1){
                    if(field[i][j] % 2 == 1){
                        field[i][j]--;
                        field[i][j+1]++;
                        n++;
                        y.push_back(i);
                        x.push_back(j);
                        y1.push_back(i);
                        x1.push_back(j+1);
                    }
                }else{
                    if(field[i][j] % 2 == 1 && i != H-1){
                        field[i][j]--;
                        field[i+1][j]++;
                        n++;
                        y.push_back(i);
                        x.push_back(j);
                        y1.push_back(i+1);
                        x1.push_back(j);
                    }
                }
            }
        }else{
            rrep(j,W){
                if(j != 0){
                    if(field[i][j] % 2 == 1){
                        field[i][j]--;
                        field[i][j-1]++;
                        n++;
                        y.push_back(i);
                        x.push_back(j);
                        y1.push_back(i);
                        x1.push_back(j-1);
                    }
                }else{
                    if(field[i][j] % 2 == 1 && i != H-1){
                        field[i][j]--;
                        field[i+1][j]++;
                        n++;
                        y.push_back(i);
                        x.push_back(j);
                        y1.push_back(i+1);
                        x1.push_back(j);
                    }
                }
            }
        }
    }
    cout << n << endl;
    rep(i,n){
        cout << y[i]+1 << ' ' << x[i]+1 << ' ' << y1[i]+1 << ' ' << x1[i]+1 << endl;
    }
}


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

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    for (int i=0; i<m; i++) cin >> b[i];
    int ans = 0;
    for (int i=0; i<n; i++) {
        int sum = c;
        for (int j=0; j<m; j++) {
            int num; cin >> num;
            sum += b[j] * num;
        }
        if (sum > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
list_ = [False for _ in range(n)]
for _ in range(k):
  d = int(input())
  a = [int(i) for i in input().split()]
  for i in a:
    list_[i-1] = True
count = 0
for i in list_:
  if not i:
    count += 1
print(count)

Measured memory_bytes: 67964
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

ll dp[100001] = {};

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int tmp;
    cin >> tmp;
    dp[tmp] = -1;  // hole
  }

  dp[0] = 1;
  if (dp[1] == -1) {
    dp[1] = 0;
  } else {
    dp[1] = 1;
  }

  for (int ith = 2; ith < N + 1; ++ith) {
    if (dp[ith] == -1) continue;

    if (dp[ith - 1] == -1) {
      if (dp[ith - 2] == -1) {
        dp[ith] = 0;
      } else {
        // ith-2のみ穴なし
        dp[ith] = dp[ith - 2] % MOD;
      }
    } else if (dp[ith - 2] == -1) {
      // ith-1のみ穴なし
      dp[ith] = dp[ith - 1] % MOD;
    } else {
      // ともに穴なし
      dp[ith] = dp[ith - 1] % MOD + dp[ith - 2] % MOD;
    }
  }

  cout << dp[N] % MOD << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
int gcd(int a, int b){
  if(a > b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  if(b % a == 0) return a;
  else return gcd(a, b % a);
}
    
int main(void)
{
  int n, a, ans;
  std::cin >> n;
  for(int i = 0; i != n; i++){
    std::cin >> a;
    if(i == 0) ans = a;
    else ans = gcd(ans, a);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  stdin.getLines.foreach { s=>
    var j=0;var i=0

    for(k <- 0 until s.length-2) {
      if(s(k) == 'J' && s(k+1) == 'O' && s(k+2) == 'I') j += 1
      if(s(k) == 'I' && s(k+1) == 'O' && s(k+2) == 'I') i += 1
    }
    println(j)
    println(i)
  }
}

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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const int VS = 1<<8;
const int W = 1e5;
void cmax(int& lhs,int rhs){
    lhs=max(lhs,rhs);
}
vector<int> v,w;
vector<vector<int>> dp(VS,vector<int>(W+1));

ll dfs(int ver,int y,int vsum,int wsum){
    if(ver<VS){
        return wsum<=y ? dp[ver][y-wsum]+vsum : 0;
    }
    int par = (ver-1)/2;
    return max(dfs(par,y,vsum,wsum),dfs(par,y,vsum+v[ver],wsum+w[ver]));
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    v.resize(n),w.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }

    int sz = min(VS,n);
    for(int i=0;i<sz;i++){
        if(i!=0){
            int par = (i-1)/2;
            dp[i] = dp[par];
            for(int j=0;j<=W-w[i];j++){
                cmax(dp[i][j+w[i]],dp[par][j]+v[i]);
            }
        }
        else{
            for(int i=w[0];i<=W;i++){
                dp[0][i] = v[0];
            }
        }
    }
    
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        x--;
        cout<<dfs(x,y,0,0)<<"\n";
    }
     return 0;
}


Measured memory_bytes: 105492
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

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

/* エラトステネスのふるいによる素数リスト */
class PrimeList {
  private:
    i64 max;
    Vec<i64> vals;
    Vec<bool> is_prime;
  public:
    PrimeList(i64 val): max(val), is_prime(val + 1, true) {
        is_prime[0] = false; is_prime[1] = false;
        for(i64 i = 4; i <= max; i += 2) is_prime[i] = false;
        for(i64 i = 3; i * i <= max; i += 2) {
            if(!is_prime[i]) continue;
            for(i64 j = 3; i * j <= max; j += 2)
                if(is_prime[i * j]) is_prime[i * j] = false;
        }
        for (i64 i = 0; i <= max; i++) if (is_prime[i]) vals.push_back(i);
    }
    bool exists(i64 x) const { return is_prime[x]; }
    i64 size() const noexcept { return (i64)vals.size(); }
    i64 range_max() const noexcept { return max; }
    i64 operator[](i64 index) const { return vals[index]; }
    decltype(vals)::const_iterator begin() const noexcept { return vals.cbegin(); }
    decltype(vals)::const_iterator end() const noexcept { return vals.cend(); }
};

/* 素因数分解 */
Vec<pair<i64, i32>> prime_factorization(i64 num) {
    i64 n = sqrt(num);
    PrimeList p(n);
    Vec<pair<i64, i32>> res;
    for (auto it = p.begin(); it != p.end(); it++) {
        i32 sum = 0;
        i64 i = *it;
        while (num % i == 0) {
            sum++;
            num /= i;
        }
        if (sum > 0) res.push_back(make_pair(i, sum));
    }
    if (num > n) res.push_back(make_pair(num, 1));
    return res;
}

void Main() {
    i64 A, B, C, D;
    cin >> A >> B >> C >> D;
    A--;
    i64 ans1 = A - A / C - A / D + A / LCM(C, D);
    i64 ans2 = B - B / C - B / D + B / LCM(C, D);
    cout << ans2 - ans1 << endl;
}


Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    double r;
    cin >> r;
    cout << fixed << setprecision(10) << r * r * PI << ' ';
    cout << fixed << setprecision(10) << 2 * r * PI << endl;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// #define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int mod = 998244353;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 300 + 10;

#define int long long
int power(int a, int b, int m = mod){if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

int n, a[N], s = 0;
int dp[N][N*N];

int solve(int idx, int sum){
   if(idx >= n){
      return (sum >= s-sum);
   }
   int &ans = dp[idx][sum];
   if(~ans)
      return ans;
   ans = 0;
   ans += solve(idx+1, sum+a[idx]);
   ans %= mod;
   ans += 2LL*solve(idx+1, sum)%mod;
   ans %= mod;
   return ans;
}

int solve2(int idx, int sum){
   if(idx >= n){
      return (2*sum == s);
   }
   int &ans = dp[idx][sum];
   if(~ans)
      return ans;
   ans = 0;
   ans += solve2(idx+1, sum+a[idx]);
   ans %= mod;
   ans += solve2(idx+1, sum);
   ans %= mod;
   return ans;
}

int32_t main(){_

   cin>>n;

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

   int tot = 0;
   memset(dp, -1, sizeof dp);
   tot = solve(0, 0) % mod;

   if(s % 2 == 0){
      memset(dp, -1, sizeof dp);   
      int ans2 = solve2(0, 0) % mod;
      tot -= ans2;
      tot += mod;
      tot %= mod;
   }

   tot = 3*tot;
   tot %= mod;

   tot = power(3, n) - tot + mod;
   tot %= mod;
   cout<<tot;
   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 232960
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<iomanip>
#include<algorithm>

using namespace std;

#define debug(x) cout<< #x <<" : "<< x << endl;
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n);
#define int long long

const int INF = (1<<30);
const int MOD = (int)1e9 + 7;

const int NUM = 9;

bool check(vector<int> &a, vector<int> &b){
    int A = 0, B = 0;
    for(int i = 0; i < a.size(); i++){
        if(a[i] > b[i]) A += a[i] + b[i];
        else B += a[i] + b[i];
    }

    return A > B;
}

signed main(){
    cout<<fixed<<setprecision(7);
    int n;

    cin>>n;


    for(int i = 0; i < n; i++){
        vector<int> a(NUM),b(NUM);
        int con = 0;
        int k = 1;

        for(int j = 0; j < NUM; j++){
            cin>>a[j];
            k *= (j+1);
        }

        for(int j = 0; j < NUM; j++){
            cin>>b[j];
        }

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

        while(true){

            bool flag = next_permutation(a.begin(), a.end());

            con += check(a, b);

            if(flag ==  false) break;
        }

        cout<<((double)con/k)<<" "<<((double)(k-con)/k)<<endl;
    }

    return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+5;
const int mod=1e9+7;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,n;
	cin>>a>>b>>n;
	if(n>=b-1)
    {
        cout<<floor(a*(b-1)/(double)b-a*floor((b-1)/(double)b))<<'\n';
    }
    else
    {
        cout<<floor(a*n/(double)b)-a*floor(n/(double)b)<<'\n';
    }

}


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

using namespace std;
using ll = long long;


int main()
{
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for(int i = 0; i < n; i++)cin >> w[i] >> v[i];
    vector<ll> dp(300000);

    for(int i = 0; i < n; i++) {
        vector<ll> DP = dp;
        for(int j = 0; j <= 100010; j++){
            DP[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
        }
        dp = DP;
    }
    cout << *max_element(dp.begin(), dp.begin() + W + 1) << endl;;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a)&-(a))
#define clean(a,b) memset(a,b,sizeof(a))
const int mod = 1e9 + 7;
// const int inf=0x3f3f3f3f;
const int maxn = 2e5+9;

inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}

int _;

//////////////////////////////////////////////////////////////////////////
ll a[maxn];
//////////////////////////////////////////////////////////////////////////
int main()
{
    int n;
    scanf("%d",&n);
    ll inf=1e18,ans=1,flag=0,flag_=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        if(a[i]<=inf/ans&&flag==0) ans*=a[i];
        else flag=1;
        if(a[i]==0) flag_=1;
    }
    if(flag_==1) puts("0");
    else if(flag) puts("-1");
    else printf("%lld\n",ans);
    return 0;
}


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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << ' ' << max(0, A + B - N) << endl;
}


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

int main() {
  int n;
  cin >> n;
  int b, f, r, v;
  int a[4][3][10] = {};
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    a[b-1][f-1][r-1] += v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << a[i][j][k];
      }
      cout << endl;
    }
      if(i!=3) cout << "####################" << endl;
  }
}

Measured memory_bytes: 1164