akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}


ll dp[2001][2001][2];

void solve()
{
    const ll mod = 1000000007;
    ll N,M;
    cin >> N >> M;
    vll S(N);
    vll T(M);
    for1(i,N) {
        cin >> S[i];
    }
    for1(i,M) {
        cin >> T[i];
    }
    dp[0][0][0] = 1;
    for1(i,N+1) {
        for1(j,M+1) {
            if (i >= 1 && j >= 1) {
                if (S[i-1]==T[j-1]) {
                    dp[i][j][0] += dp[i-1][j-1][0];
                    dp[i][j][0] %= mod;
                    dp[i][j][0] += dp[i-1][j-1][1];
                    dp[i][j][0] %= mod;
                }
            }
            if (i >= 1) {
                dp[i][j][0] += dp[i-1][j][0];
                dp[i][j][0] %= mod;
            }
            if (j >= 1) {
                dp[i][j][1] += dp[i][j-1][0];
                dp[i][j][1] %= mod;
                dp[i][j][1] += dp[i][j-1][1];
                dp[i][j][1] %= mod;
            }
        }
    }
    cout << (dp[N][M][0]+dp[N][M][1]) % mod << endl;
}

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


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

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

ll pow_ans(ll x, int n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) { res *= x; }
        x *= x;
        n >>= 1;
    }
    return res;
}

int main() {
    ll a,b;
    cin >>a>>b;
    ll res = 1;
    while (b > 0) {
        if (b & 1) {
            res *= a;
            res += 1000000007;
            res %= 1000000007;
        }
        a *= a;
        a += 1000000007;
        a %= 1000000007;
        b >>= 1;
    }
    cout << (1000000007+res)%1000000007<<endl;
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll a,b,n;
  cin>>a>>b>>n;
  auto f = [&](ll x){return a*x/b-a*(x/b);};
  cout<<f(min(b-1,n))<<endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a,b,c,d;

int main(void){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	bool flag=false;
	while(a>0 && c>0){
		if(!flag){
			c-=b;
		}else{
			a-=d;
		}
		flag=!flag;
	}
	printf("%s\n",a>0?"Yes":"No");
	return 0;
}


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int s, w;
    cin >> s >> w;
    if(s<=w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

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

  if(a > c && b < c)
    cout << "Yes" << endl;
  else if(a < c && b > c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

using namespace std;

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

int exi[10000];


int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	rep(i,n-2){
		int t=v[i]*100+v[i+1]*10+v[i+2];
		exi[t]=1;
	}
	//cout<<"A"<<endl;
	rep(i,n-1){
		int t=v[i]*10+v[i+1];
		exi[t]=1;
	}
	//cout<<"B"<<endl;
	rep(i,n){
		exi[v[i]]=1;
	}
	//cout<<"C"<<endl;
	rep(i,10000){
		if(exi[i]==0){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, n, idx = 0;
    cin >> x >> n;
    if (n == 0) {
      cout << x;
      return 0;
    }
    vector<int> banned(n);
    for (int i = 0; i < n; i++) {
        cin >> banned[i];
    }
    sort(banned.begin(), banned.end());
    while (idx < n && banned[idx] != x) {
        idx++;
    }
    if (banned[idx] != x) {
        cout << x;
        return 0;
    } else {
        //Find smallest lim
        int k = 0;
        while (idx - k >= 0 && banned[idx - k] == x - k) {
            k++;
        }
        int small_no = x - k;
        //Find biggest lim
        k = 0;
        while (idx + k < n && banned[idx + k] == x + k) {
            k++;
        }
        int big_no = x + k;
        if (big_no - x < x - small_no) {
            cout << big_no;
        }
        else {
            cout << small_no;
        }
    }
}

Measured memory_bytes: 3556
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> T(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &T[i]);
		int S = accumulate(all(T), 0);
		vector<vi> dp, ndp(S+1,vi(S+1,INF));
		ndp[0][0] = 0;
		int s = 0;
		rep(i, N) {
			dp.swap(ndp);
			ndp.assign(S+1,vi(S+1,INF));
			int t = T[i];
			rer(a, 0, s)rer(b, 0, s) {
				int x = dp[a][b];
				if(x == INF) continue;
				amin(ndp[a + t][b], x);
				amin(ndp[a][b + t], x);
				amin(ndp[a][b], x + t);
			}
			s += t;
		}
		int ans = INF;
		rer(a, 0, S)rer(b, 0, S) {
			amin(ans, max({ a, b, ndp[a][b] }));
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 45616
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define x first
#define y second
 
typedef long long ll;
 
const ll INF = 1e9+5;
const ll MOD = 1e9+7;
 
int main() {
	string s;
  	cin >>s;
  	int cnt = 0;
  	for (int i=0 ; i<s.size() ; i++) {
     	cnt += (s[i]-'0');
      	cnt %= 9;
    }
  	if (cnt) cout <<"No\n";
  	else cout <<"Yes\n";
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
int a, n;
int dfs(double x, double sum, int num, int limit, int step)
{
    if(abs(x - sum) <= EPS) return 1;
    if(limit == 0 || step == 0) return 0;
    int res = 0;
    for(int i = num; i <= limit; i++)
    {
        res += dfs(x, sum + 1.0 / i, i, limit / i, step - 1);
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q;
    while(cin >> p >> q >> a >> n, p | q | a | n)
    {
        cout << dfs((double)p / q, 0.0, 1, a, n) << endl;
    }
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    char latest_letter;
    bool flag = true;
    for (int i = 0; i< s.size(); i++){
        if (latest_letter == s[i]){
            flag = false;
            break;
        } else{
            latest_letter = s[i];
        }
    }
    if (flag){
        cout<<"Good";
    } else{
        cout<<"Bad";
    }
    return 0;
    
}


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

ans = ""
cnt = 0
for i in range(N):
  if cnt < K:
    ans += str(S) + " "
    cnt += 1
  else:
    if i == N-1:
      ans += str(min(S+1,10**9-1))
    else:
      ans += str(min(S+1,10**9-1)) + " "
    
print(ans)

Measured memory_bytes: 6292
let input = require("fs").readFileSync("/dev/stdin", "utf8")

function main() {
    const [N,M,K] = load(3)
    const A = load(N)
    const B = load(M)
 
    const Ad = [0], Bd = [0]
    for(let i = 0; i < N; i++) Ad.push(Ad[i]+A[i])
    for(let i = 0; i < M; i++) Bd.push(Bd[i]+B[i])
 
    let result = 0
    for(let i = 0, j = M; i <= N; i++) {
        if(Ad[i] > K) break
        while(Ad[i] + Bd[j] > K) j--
        result = Math.max(result, i + j)
    }
 
    return result
}


let inputs = input.split(/[\s\n]/)
console.log(main())


// 入力値を読み込む
function load(rows = 1, cols = 1, type = Number) {
    const length = rows * cols
    let result = inputs.splice(0, length)

    if(type !== String) result = result.map(type)
    if(cols > 1) {
        const arrays = new Array(cols)
        for(let col = 0; col < cols; col++) {
            arrays[col] = new Array()
            for(let row = 0; row < rows; row++) {
                arrays[col].push(result[row * cols + col])
            }
        }
        result = arrays
    }

    return result
}


Measured memory_bytes: 89460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = 1e18;
int n;
ll cst[26], sat[366][26], last[26], tmp[26];
ll tester(vector<int>v){
	ll res = 0ll;
	memset(last, 0ll, sizeof(last));
	for(int nw, i=0; i<n; i++){
		nw = v[i];
		res += sat[i][nw-1];
		last[nw-1] = i+1;
		for(int j=0; j<26; j++)
			res -= cst[j]*(i+1-last[j]);
	}
	return res;
}
bitset<370>vis;
int rand(int x){return rand()%x+1;}
vector<int>gen(int hm, int x){
	vector<int>res;
	for(int cr=rand()%x+1, times=0; times<hm; cr=rand(x)%x+1, times++)
		res.push_back(cr);
	return res;
}
int randlf(int l, int r){return rand()%(r-l+1)+l;}
vector<int>lgg={1, 2, 4, 8, 16, 32, 64, 128};
vector<int>best;
int main(){
	scanf("%d", &n);
	memset(last, 0ll, sizeof(last));
	for(int i=0; i<26; i++) scanf("%lld", &cst[i]);
	for(int i=0; i<n; i++) for(int j=0; j<26; j++)
		scanf("%lld", &sat[i][j]);
	ll res = 0ll;
	vector<int>base;
	for(int nw, i=0; i<n; i++){
		memset(tmp, 0ll, sizeof(tmp));
		for(nw=0; nw<26; nw++){
			tmp[nw] += sat[i][nw];
			for(int j=0; j<26; j++) if(j != nw)
				tmp[nw] -= cst[j] * (i+1-last[j]);
		}
		ll get = -inf; int id = -1;
		for(nw=0; nw<26; nw++) 
			if(get < tmp[nw]){
				get = tmp[nw]; id = nw;
			}else if(get == tmp[nw] && cst[nw] > cst[id]){
				get = tmp[nw]; id = nw;
			}
		base.push_back(id+1); 
		last[id] = i+1; res += tmp[nw];
	}
	best=base;
	for(int times=0; times<100; times++){
		for(int k=7; k>0; k--){
			vector<int>changeid, changeval;
			for(int tt=0; tt<100; tt++){
				int cv = randlf(lgg[k-1], lgg[k]);
				changeid = gen(cv, 365);
				changeval = gen(cv, 26);
				vector<int>cur = best;
				for(int i=0; i<cv; i++)
					cur[changeid[i]-1] = changeval[i];
				if(tester(best) < tester(cur))
					best = cur;
			}
		}
	}
	for(int i=0; i<n; i++) printf("%d\n", best[i]);
	return 0;
}

Measured memory_bytes: 3864
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;

    int odd = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 2 != 0) {
            odd += 1;
        }
    }

    cout << (double) odd / (double) N << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n, m;
    cin >> n >> m;
    int a, b;
    map<int, bool> start;
    vector<int> end;
    rep(i, m) {
        cin >> a >> b;
        if (a == 1) {
            start[b] = true;
        }

        if (b == n) {
            end.push_back(a);
        }
    }

    repv(v, end) {
        if (start.count(v) == 1) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 5368
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod (ll)1000000007
#define fast std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define input int t;cin>>t;while(t--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define f(i, a, b) for (int i = (a); i < (b); i++)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
int i,j,k;
int main()
{
	ll a,b;
	cin>>a>>b;
	ll arr[999+1]={0};
	ll sum=1;
	for(i=1; i<=999; i++)
	{
		arr[i]=arr[i-1]+sum;
		sum++;
	}
	for(i=1; i<999; i++)
	{
		if(arr[i]-a == arr[i+1]-b )
		{
			cout<<arr[i]-a;
			break;
		}
	}

}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    List<Integer> list = new ArrayList<>();
    int i = 1;
    while(true){
      int r = (a * i) % b;
      if(r == c){
        System.out.println("YES");
        System.exit(0);
      }
      if(list.contains(r)){
        System.out.println("NO");
        System.exit(0);
      }
      list.add(r);
      i++;
    }
  }
}

Measured memory_bytes: 23380
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

vector<long long> sep;

long long ary[1010];
int main(){
	int N;
	long long M,res;
	vector<long long>::iterator it,it2;
	while(1){
		sep.clear();
		cin>>N>>M;
		if(N==0&&M==0) break;
		for(int i=0;i<N;i++){
			cin>>ary[i];
		}
		ary[N]=0;
		for(int i=0;i<=N;i++){
			for(int j=i;j<=N;j++){
				if(ary[i]+ary[j]<=M){
					sep.push_back(ary[i]+ary[j]);
				}
			}
		}
		sort(sep.begin(),sep.end());
		res=0;
		it2=sep.end();
		it2--;
		for(it=sep.begin();it!=sep.end();it++){
			while((*it)+(*it2)>M)it2--;
			if((*it)>(*it2)) break;
			res=max(res,(*it)+(*it2));
		}
		cout<<res<<endl;

	}
	return 0;
}

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

const ll mod = 1000000007;
ll ubiq(ll x, ll y){
  ll res=1;
  for(ll i=0;i<y;i++) res = res*x%mod;
  return res;
}

int main(){
  ll n; cin >>n;
  ll ans = ubiq(10,n)-ubiq(9,n)-ubiq(9,n)+ubiq(8,n);
  ans%=mod;
  ans=(ans+mod)%mod;
  cout << ans << endl;
  return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

using pii = pair<int, int>;

int N;
vec<pii> G[111111];
vec<int> ans;

void rec(int from, int cur, int dist) {
  if (dist % 2 == 1) {
    ans[cur] = 1;
  }

  for (pii p : G[cur]) {
    int to = p.first;
    int tDist = p.second;
    if (to == from) continue;
    rec(cur, to, dist + tDist);
  }
}

signed main() {
  cin >> N;
  ans.resize(N);
  rep (i, N-1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }

  rec(-1, 0, 0);

  rep (i, N) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 10496
#include <iostream>

int main() {
  std::string a, b;
  std::cin >> a >> b;
  const int x = std::stoi(a + b);
  bool is_square = false;
  // sqrt(100100) = 316...)
  for( int i = 1; i <= 316; ++i ) {
    if( x == i*i ) {
      is_square = true;
      break;
    }
  }

  if( is_square ) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 3032
let h = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let extract (t : int array) =
  let ret = t.(1) in
  t.(1) <- t.(!h);
  decr h;
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !h && t.(l) > t.(i) then l else i in
    let m = if r <= !h && t.(r) > t.(m) then r else m in
    if m <> i then begin
      let tmp = t.(i) in t.(i) <- t.(m); t.(m) <- tmp;
      max_heapify m
    end in
  max_heapify 1;
  ret

let insert x (t : int array) =
  incr h;
  t.(!h) <- x;
  let rec doit i =
    if i > 1 && t.(parent i) < t.(i) then begin
      let tmp = t.(i) in t.(i) <- t.(parent i); t.(parent i) <- tmp;
      doit (parent i)
    end in
  doit !h

let () =
  let t = Array.make 2000001 0 in
  let rec doit () =
    let op = Scanf.scanf "%s " (fun i -> i) in
    if op = "extract" then (Printf.printf "%d\n" (extract t); doit ())
    else if op = "end" then ()
    else (insert (Scanf.scanf "%d " (fun i -> i)) t; doit ())
  in doit ()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

bool solve(){
    int n; cin >> n;
    map<int, int> p;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        p[b] += a;
    }
    
    int completed = 0;
    for(pair<int, int> ip: p){
        int a = ip.second, deadline = ip.first;
        completed += a;
        if(completed > deadline) return false;
    }
    return true;
}

signed main(){
    cout << (solve() ? "Yes" : "No") << endl;
}

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

using namespace std;

int main ()
{
	int N;
	cin >> N;
	vector<vector<int>>data ( N + 1 , vector<int> ( N + 1 ) );
	for( size_t i = 1; i < N + 1; i++ )
	{
		for( size_t j = 1; j < N + 1; j++ )
		{
			cin >> data[i][j];
		}
	}
	for( size_t i = 1; i < N + 1; i++ )
	{
		for( size_t j = 1; j < N + 1; j++ )
		{
			data[i][j] += data[i][j - 1];
		}
	}
	for( size_t i = 1; i < N + 1; i++ )
	{
		for( size_t j = 1; j < N + 1; j++ )
		{
			data[i][j] += data[i - 1][j];
		}
	}
	long long int ans = INT_MIN;
	for( size_t i = 0; i < N; i++ )
	{
		for( size_t j = 0; j < N; j++ )
		{
			for( size_t k = i + 1; k < N + 1; k++ )
			{
				for( size_t l = j + 1; l < N + 1; l++ )
				{
					long long int num = data[k][l] + data[i][j] - data[k][j] - data[i][l];
					if( num > ans )
					{
						ans = num;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1252
import Control.Monad
import Control.Applicative
import Data.List


dproduct :: Int -> [Int] -> [Int] -> Int
dproduct c [] []  = c
dproduct c (b:rt) (a:tl) = a*b + dproduct c rt tl



main :: IO ()
main = do
  [n,m,c] <- map read . words <$> getLine :: IO [Int]
  blist <- map read . words <$> getLine :: IO [Int]
  allist <- replicateM n (map read . words <$> getLine :: IO [Int])
  let a = length $ filter (>0) $ map (dproduct c blist) allist
  print a


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

#define int long long

signed main(){
  int n;
  cin >> n;
  
  int ans = 0;
  
  for(int i = 1;i<=n;i+=2){
    int cnt = 0;
    for(int j= 1;j*j<=i;j++){
      if(i%j==0)cnt+=2;
    }
    if(cnt==8)ans++;
  }
  
  cout<< ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,i=1,k;
  while(scanf("%d%d",&a,&b)!=EOF){
    k=a+b;    
    while(k>9){
      k=k/10;
      i++;
    }
    printf("%d\n",i);
    i=1;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		char[] c = s.toCharArray();

		for (int i = 0; i < n; i++) {
			if (i == k - 1) {
				if (c[i] == 'A') {
					c[i] = 'a';
				} else if (c[i] == 'B') {
					c[i] = 'b';
				} else {
					c[i] = 'c';
				}
			}
			System.out.print(c[i]);
		}

	}
}

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

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<bool>> C(H,vector<bool>(W,false));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char c;
      cin >> c;
      if(c=='#') C[i][j] = true;
    }
  }
  
  int ans=0;
  for(int a=0;a<(1<<H);a++){
    for(int b=0;b<(1<<W);b++){
      bitset<6> A(a),B(b);
      int count=0;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          if(C[i][j] && A.test(i) && B.test(j)){
            count++;
          }
        }
      }
      if(count==K) ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int A[2000010],H=0,keys[2000010];
char Command[2000010][10];
void MaxHeapify(int i)
{
	int t;
	int l=2*i;
	int largest;
	int r=2*i+1;
	if(l<=H && A[l]>A[i])
		largest=l;
	else
		largest=i;
	if(r<=H && A[r]>A[largest])
		largest=r;

	if(largest!=i)
	{
		t=A[i];
		A[i]=A[largest];
		A[largest]=t;

		MaxHeapify(largest);
	}
	return;
}
void heapincreasekey(int i, int key)
{
	int t;
	A[i]=key;
	while(i>1 && A[i/2]<A[i])
	{
		t=A[i];
		A[i]=A[i/2];
		A[i/2]=t;

		i=i/2;
	}
	return;
}
void insert(int key)
{
	H++;
	heapincreasekey(H,key);
}
int heapextractmax()
{
	int max=A[1];
	A[1]=A[H];
	H--;
	MaxHeapify(1);
	return max;
}
int main()
{
	int i=1,j;
	scanf("%s",Command[i]);
	if(Command[1][0]=='i')
		scanf("%d",&keys[i]);
	while(1>0)
	{
		i++;
		scanf("%s",Command[i]);
		if(Command[i][0]=='i')
		scanf("%d",&keys[i]);
		if(strcmp(Command[i],"end")==0)
			break;
	}
	for(j=1;j<=i-1;j++)
	{
		if(Command[j][0]=='i')
			insert(keys[j]);
		if(strcmp(Command[j],"extract")==0)
			printf("%d\n",heapextractmax());
	}


	return 0;
}


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

using namespace std;
typedef long long li;


li f(li current, li d) {
    return min(abs(current - d), current);
}

li g(li minv, li d) {
    if (minv < d) {
        return minv;
    } else {

    }
}

int main() {
    li n, d;
    cin >> n >> d;

    vector<li> ds(n), xs(1, d);
    for (int i = 0; i < n; ++i) {
        cin >> ds[i];
        xs.push_back(f(xs.back(), ds[i]));
    }

    vector<li> ans(n);
    li minv = 1;
    for (int i = n - 1; i >= 0; --i) {
        ans[i] = minv <= xs[i];
        const li dv = ds[i];
        if (dv < minv  *2) {
            minv += dv;
        }
    }

    li q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        li qv;
        cin >> qv;
        qv--;
        string astr = ans[qv] ? "YES" : "NO";
        cout << astr << endl;
    }

    return 0;
}

Measured memory_bytes: 14956
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;


signed main(){
    int N,M;cin>>N>>M;
    int sum=0;
    map<int,int>memo;
    memo[0]++;
    REP(i,N){
        int a;cin>>a;
        sum+=a;sum%=M;
        memo[sum]++;
    }
    int ans=0;
    for(auto v:memo){
        ans+=v.second*(v.second-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4224
while True:
    try:
        m = list(map(int,input().split()))
        if m[0] == 0 and m[1] == 0:
            break
    except EOFError:
        break

    m.sort(reverse=True)
    x = m[0]
    y = m[1]
    a = 0
    while y != 0:
        a += 1
        x = x % y
        x,y = y,x

    print(x,a)


Measured memory_bytes: 5612
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

idxA = S.find("A") + 1
idxB = len(S) - S[::-1].find("Z")

ans = idxB - idxA + 1
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

int main(){
  int n;
  cin >>n;
  set<int> a;
  rep(i,n){
    int z;
    cin >> z;
    a.insert(z);
  }
  if(n==(int)a.size()) cout << "YES" << endl;
  else cout<< "NO" << endl;
  return 0;
}


Measured memory_bytes: 12928
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * AtCoder Beginner Contest 130<br>
 * B - Bounding<br>
 * <br>
 * <a href=
 * "https://atcoder.jp/contests/abc130/tasks/abc130_b">AtCoderへのリンク</a><br>
 */
public class Main {

    /**
     * エントリポイント
     */
    public static void main(String[] args) {
        // 入力
        Model inputs = input(System.in);
        // 演算
        int count = proc(inputs);
        // 出力
        System.out.println(count);
    }

    /**
     * 入力モデル
     */
    static class Model {
        int N;
        int X;
        List<Integer> list = new ArrayList<Integer>();
    }

    /**
     * 入力値より入力モデルを作成する
     */
    static Model input(InputStream in) {
        Model m = new Model();

        try (Scanner sc = new Scanner(in)) {
            String[] input1 = sc.nextLine().split(" ");
            String[] input2 = sc.nextLine().split(" ");

            m.N = Integer.parseInt(input1[0]);
            m.X = Integer.parseInt(input1[1]);

            for (String str : input2) {
                m.list.add(Integer.parseInt(str));
            }
        }
        return m;
    }

    /**
     * 演算を行う
     */
    static int proc(Model m) {
        int answer = 0;
        int count = 1;
        for (int i = 0; i < m.N; i++) {
            answer = answer + m.list.get(i);
            if (m.X < answer) {
                break;
            }
            count++;
        }
        return count;
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector <int> mp(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	if (n % 2 == 1) {
		mp[0]++;
	}
	int val = (n % 2 == 0);
	for (int i = val; i <= n; i += 2) {
		if (mp[i] != 2) {
			cout << 0;
			return 0;
		}
	}
	int ans = 1;
	for (int i = 0; i < n / 2; i++) 
		ans = ans * 2 % MOD;
	cout << ans;
		
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1*1e5+5;

int32_t main() {
	map<int, int> mapa;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		mapa[x]++;
	}
	cout << (mapa.size() == n ? "YES" : "NO") << endl;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
ll fact[200005], infact[200005];
ll modex(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    }
    return ans;
}
ll ncr(ll n, ll r)
{
    if(n < 0 || r < 0 || r > n)
        return 0;
    ll ans = (fact[n] * infact[r]) % mod;
    ans = (ans * infact[n - r]) % mod;
    return ans;
}
ll f(ll a, ll b)
{
  return ncr(a + b - 2, max(a, b) - 1);
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll h, w, a, b, i;
    fact[0] = infact[0] = fact[1] = infact[1] = 1;
    for(i = 2; i < 200005; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
        infact[i] = modex(fact[i], mod - 2);
    }
  cin >> h >> w >> a >> b;
  ll ans = 0, prev = 0;
  for(i = 1; i + b <= w; i++)
  {
    ans = (ans % mod + ((f(h - a, b + i) - prev + mod) % mod * f(a + 1, w - b - i + 1) % mod) % mod) % mod;
  	prev = f(h - a, b + i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	ll dist = abs(a - b);
	ll vel = v - w;
	ll res = dist - vel * t;
	if (res > 0) {
		puts("NO");
	}
	else {
		puts("YES");
	}
	return 0;
}


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

#define rep(i,n) for(i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if


//int a,b,c,i,j,k,n,m,x,y,z;
//str s,t;
//vector<signed> v;

signed main(){
  int n,i,j,k;
  cin>>n;
  int a[n],mx=0;
  rep(i,n){
      cin>>a[i];
      mx=max(a[i],mx);
  }
  int ans=0;
  rep(i,mx*n){
        //for(auto k:a)cout<<k<<" ";
        //debg(ans);
        
        bool on=false;
            rep(j,n){
                if(a[j]!=0)on=true;
                else if(on&&a[j]==0){
                    on=false;
                    ans++;
                }
            }
            if(on)ans++;
        
        rep(j,n){
            if(a[j]!=0){
              a[j]--;
            }
        }
        bool brk=true;
        rep(k,n){
            if(a[k]!=0)brk=false;
        }
        if(brk)break;
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

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

    vector<vector<int>> inverse(n + 1);
    vector<int> out(n + 1);
    vector<int> pathcount(n + 1, 0);

    out[0] = -1;

    rep(i,m){
        int x,y;
        cin >> x >> y;

        inverse[y].pback(x);
        out[x]++;
    }

    queue<int> q;

    rep(i,n){
        if(out[i + 1] == 0) q.push(i + 1);
    }

    int ans = 0;

    while(!q.empty()){
        int v = q.front();
        out[v]--;

        //cerr << v << " " << pathcount[v] << endl;

        rep(i, inverse[v].size()){
            int u = inverse[v][i];
            out[u]--;

            if(out[u] == 0) q.push(u);

            pathcount[u] = max(pathcount[u], pathcount[v] + 1);
            ans = max(ans, pathcount[u]);
        }

        q.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
#include<string.h>
int main(void){
    char S[4];
    int cou=0,a=0;
    scanf("%s",S);
    for(int i=0;i<4;i++){
       for(int k=i+1;k<4;k++){
          if(S[i]==S[k]){
             cou++;
          }
       }
       
    }
    if(cou==2){
       printf("Yes");
    }else{
       printf("No");
    }
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  long double n, m, d; cin >> n >> m >> d;

  if(d == 0){
    cout << (m-1) / n << endl;
  }else{
    cout << (m-1) * 2 *(n-d) / n / n;
  }
  return 0;
}


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

typedef long long ll;

int main(void){
    int N;
    cin >> N;
    ll a[110000][3];
    ll dp[110000][3];
    
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 3 ; j++){
            cin >> a[i][j];
        }
    }
    
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 3 ; j++){
            for(int k = 0 ; k < 3 ; k++){
                if(j == k) continue;
                dp[i+1][k] = max(dp[i+1][k] , dp[i][j] + a[i][k]);
            }
        }
    }
    
    ll res = 0;
    for(int j = 0 ; j < 3 ; j++){
        res = max(res, dp[N][j]);
    }
    cout << res << endl;
}

Measured memory_bytes: 8296
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n= sc.nextInt();
      	String[] s=new String[n];
      for(int i=0;i<n;i++){
      		s[i]=sc.next();}
      	int ac=0;
      	int a=0;
      	int tle=0;
      	int re=0;
      	for (int i = 0; i < n; i++) {
			if(s[i].equals("AC")){ac++;}
			if(s[i].equals("WA")){a++;}
			if(s[i].equals("TLE")){tle++;}
			if(s[i].equals("RE")){re++;}
		}
      	System.out.println("AC x "+ac);
      	System.out.println("WA x "+a);
      	System.out.println("TLE x "+tle);
      	System.out.println("RE x "+re);
}
}

Measured memory_bytes: 63888
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;	

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

	if (a <= c) {
		if (b >= c) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
}


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

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

    sort(b, b+ n, greater<int>());

    for(int i = 0; i < n; i++){
        if(a[i] != b[0]){
            cout << b[0] << endl;
        }else{
            cout << b[1] << endl;
        }
    }
}

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

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
    {
        cout << s << endl;
    }
    else
    {
        cout << s.substr(0,k) << "..." << endl;
    }
    
}

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

using namespace std;

void col(int n,int m,bool p[][605]) {
  int d=0;
  while (m%(1<<(2*(d+1)))==0) d++;
  d=(1<<d);
  int v=(m/(d*d))%4;
  if (v==0||v==3) return;
  if (v==1) {
  	for(int i=0;i<n;i++)
  	  for(int j=0;j<n;j++) p[i][j]=(((i/d)+(j/d))&1);
  }
  else {
  	for(int i=0;i<n;i++)
  	  for(int j=0;j<n;j++) p[i][j]=((i/d)&1);
  }
}

bool f[605][605],g[605][605];

int main() {
  int n,D1,D2;
  scanf("%d%d%d",&n,&D1,&D2);
  col(n<<1,D1,f);
  col(n<<1,D2,g);
  int sz[2][2]={0};
  for(int i=0;i<(n<<1);i++)
    for(int j=0;j<(n<<1);j++) sz[f[i][j]][g[i][j]]++;
  int id1=0,id2=0;
  for(int i=0;i<2;i++)
    for(int j=0;j<2;j++)
      if (sz[i][j]>sz[id1][id2]) {
      	id1=i;
      	id2=j;
	  }
  int cnt=0;
  for(int i=0;i<(n<<1);i++) {
    for(int j=0;j<(n<<1);j++)
      if (f[i][j]==id1&&g[i][j]==id2) {
      	printf("%d %d\n",i,j);
      	cnt++;
      	if (cnt>=n*n) break;
	  }
	if (cnt>=n*n) break;
  }
  return 0;
}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

const int Nmax=114514;
const int inf=8101919;
vector<pii> graph[Nmax];
int cost[Nmax],qbuf[Nmax];
bool vis[Nmax],add[Nmax];

int main(){
	int n=read(),m=read();
	REP(i,m){
		int p=read()-1,q=read()-1,c=read()-1;
		graph[p].PB(MP(c,q));
		graph[q].PB(MP(c,p));
	}
	REP(i,n)
		sort(graph[i].begin(),graph[i].end());
	fill(cost,cost+n,inf);
	vi cur,nx;
	map<int,vi> sts;
	cost[0]=0;
	cur.PB(0);
	int w=0;
	while(cost[n-1]==inf&&!cur.empty()){
		w++;
		nx.clear();
		sts.clear();
		for(auto _:cur)
			for(auto edge:graph[_])if(cost[edge.second]>=w)
				sts[edge.first].PB(edge.second);
		for(auto kv:sts){
				int b=0,e=0,belong=kv.first;
				for(auto v:kv.second)
					if(!vis[v]){
						vis[v]=true;
						qbuf[e++]=v;
					}
				while(b<e){
					int v=qbuf[b++];
					cost[v]=w;
					auto itr=lower_bound(graph[v].begin(),graph[v].end(),MP(belong,-1));
					while(itr!=graph[v].end()&&itr->first==belong){
						if(!vis[itr->second]&&cost[itr->second]>=w){
							vis[itr->second]=true;
							qbuf[e++]=itr->second;
						}
						itr++;
					}
				}
				REP(i,e){
					if(!add[qbuf[i]]){
						nx.PB(qbuf[i]);
						add[qbuf[i]]=true;
					}
					vis[qbuf[i]]=false;
				}
			}
		swap(cur,nx);
	}
	if(cost[n-1]==inf)
		cout<<-1<<endl;
	else
		cout<<cost[n-1]<<endl;
}


Measured memory_bytes: 19956
#include <stdio.h>
#define swap(type, x, y) do{ type t = x; x = y; y = t; }while(0)

void quick(int a[], int left, int right, int b[], int c[]){
  int pl = left, pr = right, x = a[(left + right) / 2];
  do{
    while(a[pl] < x)  pl++;
    while(a[pr] > x)  pr--;
    if(pl <= pr){
      swap(int, a[pl], a[pr]);
      swap(int, b[pl], b[pr]);
      swap(int, c[pl], c[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(a, pl, right, b, c);
  if(pr > left)   quick(a, left, pr, b, c);
}

int main(){
  int n, m;  scanf("%d %d", &n, &m);
  int p[100005], y[100005], ad[100005];
  for(int i=1; i<=m; i++){
    scanf("%d %d", p+i, y+i);
    ad[i] = i;
  }
 
  quick(y, 1, m, p, ad);

  char ans[100005][14];
  int num[100005] = {0};
  
  for(int i=1; i<=m; i++){
    int pn = p[i], bn = ++num[p[i]];
    int d = 1;
    for(int j=0; j<6; j++){
      ans[ad[i]][5-j]  = (char)((int)'0'+(pn/d)%10);
      ans[ad[i]][11-j] = (char)((int)'0'+(bn/d)%10);
      d *= 10;
    }
  }

  for(int i=1; i<=m; i++){
    for(int j=0; j<12; j++)
      printf("%c", ans[i][j]);
    puts("");
  }

  return 0;
}


Measured memory_bytes: 4576