akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n,m;
    while(cin>>n>>m){
        if(n==0 && m==0)break;
        
        vi data;
        
        rep(i,n){
            int a;
            cin>>a;
            data.pb(a);
        }
        
        sort(all(data));
        reverse(all(data));
        

        rep(i,n){
            if((i+1)%m==0){
                data[i]=0;
            }
        }
        int sum=0;
        rep(i,n){
            sum+=data[i];
        }
        cout<<sum<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1224
#include <iostream>

int main() {
  int A, B;
  std::cin >> A >> B;
  if (A <=5 )
    std::cout << 0 << std::endl;
  else if (A <= 12)
    std::cout << B/2 << std::endl;
  else
    std::cout << B << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void)
{
	vector< vector<int> > p( 10000,vector<int>(3) );
	vector<char> ans(10000);
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin >> p[i][0] >> p[i][1] >> p[i][2];
			if(p[i][0]==100||p[i][1]==100||p[i][2]==100) ans[i]='A';
			else if(90*2<=p[i][0]+p[i][1]) ans[i]='A';
			else if(80*3<=p[i][0]+p[i][1]+p[i][2]) ans[i]='A';
			else if(70*3<=p[i][0]+p[i][1]+p[i][2]) ans[i]='B';
			else if(50*3<=p[i][0]+p[i][1]+p[i][2]&&(80<=p[i][0]||80<=p[i][1])) ans[i]='B';
			else ans[i]='C';
		}
		for(int i=0;i<n;i++) cout << ans[i] << endl; 
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>

using namespace std;
using ll = long long;

#define Rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for (int i = s; i < (int)(n); ++i)

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

  ll answer = 0;
  For(i, 1, N + 1) {
    answer += ll(i) * (N - i + 1);
  }

  Rep(i, N - 1) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    answer -= ll(u) * (N - v + 1);
  }

  cout << answer << endl;
  return 0;
}


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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    llin(a);
    llin(b);
    llin(c);
    sal(b+min(a+b+1,c));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


/*const int MOD = ;

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}*/

using namespace std;



int main() {
    //ifstream cin("B.in");
    //ofstream cout("B.out");
    int i, n, x;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;
    multiset <int> s;
    for(i = 0; i < (1 << n); i++) {
        cin >> x;
        s.insert(x);
    }

    multiset <int> sol;
    sol.insert(*prev(s.end()));
    s.erase(prev(s.end()));

    for(i = 0; i < n; i++) {
        vector <int> aux;
        for(auto it : sol) {
            auto cur = s.lower_bound(it);
            if(cur == s.end()) {
                cur = prev(cur);
            }
            while(cur != s.begin() && *cur >= it) {
                cur = prev(cur);
            }
            if(*cur >= it) {
                cout << "No";
                return 0;
            }
            aux.push_back(*cur);
            s.erase(cur);
        }
        for(auto it : aux) {
            sol.insert(it);
        }
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 13304
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let a: Vec<Vec<char>> = {
        let mut a = vec![];
        for _ in 0..H {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            a.push(line.trim().chars().collect());
        }
        a
    };

    let wall = (0..(W + 2)).map(|_| "#").collect::<String>();
    let ans = format!(
        "{}\n{}\n{}",
        wall,
        a.iter()
            .map(|r| format!(
                "#{}#",
                r.iter()
                    .map(std::string::ToString::to_string)
                    .collect::<String>()
            ))
            .collect::<Vec<_>>()
            .join("\n"),
        wall
    );

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,m;
    while(cin >> n >> m,n){
        int ans=0;
        vector<int> a(n);
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                int s;cin >> s;
                a[j]+=s;
            }
        }
        for (int i = 0; i < n; i++) {
            ans=max(ans,a[i]);
        }
        cout << ans << endl;
    }
    return 0;
}



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

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  A = (A == 1 ? 14 : A);
  B = (B == 1 ? 14 : B);
  cout << (A == B ? "Draw" : (A > B ? "Alice" : "Bob")) << endl;
  return 0;
}


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

using namespace std;


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

  vector<int> V;
  int i, l;
  for(i = 2; true; ++i) {
    vector<int>::iterator it;
    for(it = V.begin(); it != V.end(); ++it) {
      if(i % *it == 0) {
        break;
      }
    }

    if(it == V.end()) {
      V.push_back(i);
      if(i >= X) {
        cout << i;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 384
x,y = map(int,input().split())
maxx = y//2 +1
maxxx = max(x,maxx) + 1
count = 0
for i in range(maxxx):
  for j in range(maxxx):
    if i + j == x and i*2 + j*4 == y:
      count += 1
if count == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9188
#!/usr/bin/env python3
"""
Simple Version
Python TLE https://atcoder.jp/contests/dp/submissions/14906600
PyPy TLE https://atcoder.jp/contests/dp/submissions/14906630
"""
from collections import defaultdict
import sys

sys.setrecursionlimit(10**6)


def solve(N, M, edges):
    longest = {}

    stack = [v for v in edges]

    while stack:
        v = stack.pop()
        if v > 0:
            if v in longest:
                continue
            next_edges = edges.get(v)
            stack.append(-v)
            if next_edges:
                stack.extend(next_edges)
        else:
            next_edges = edges.get(-v)
            if not next_edges:
                ret = 0
            else:
                ret = max(longest[x] for x in next_edges) + 1
            longest[-v] = ret

    return max(longest[v] for v in edges)


def main():
    N, M = map(int, input().split())
    edges = defaultdict(set)
    for i in range(M):
        v1, v2 = map(int, input().split())
        edges[v1].add(v2)

    print(solve(N, M, edges))


T1 = """
4 5
1 2
1 3
3 2
2 4
3 4
"""

T2 = """
6 3
2 3
4 5
5 6
"""

T3 = """
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
"""


def _test():
    """
    # >>> as_input(T1)
    # >>> main()
    # 3

    # >>> as_input(T2)
    # >>> main()
    # 2

    >>> as_input(T3)
    >>> main()
    3
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


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

int main() {
	int n,m; cin>>n>>m;
	vector<int> x(m);
	vector<int> distances(m-1);
	for (int i=0; i<m; i++)
		cin>>x[i];
	sort(x.begin(),x.end());
	for (int i=0; i<m-1; i++)
		distances[i]=abs(x[i]-x[i+1]);

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

	int ans=0;
	for (int i=0; i<m-n; i++)
		ans+=distances[i];

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>A(n);
    
    REP(i,n){
        cin >> A[i];
    }
    ll p= A[0];
    ll cnt=1;
    FOR(i,1,n){
        p= min(p,A[i-1]);
        if(p>=A[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int A,B;
    cin >> A >> B;
    cout << max({B+(B-1),A+(A-1),A+B})<<endl;
    return 0;
}

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

int main() {
	long n, sum;
	int min, max;
	int a[9999] = {};
	cin >> n;
	for (int i=0;i<n;i++) {
		cin >> a[i];
	}
	min = a[0];
	max = a[0];
	sum = a[0];
	for (int k=1;k<n;k++) {
		if (max < a[k]) max = a[k];
		if (min > a[k]) min = a[k];
		sum += a[k];
	}
	cout << min << ' ' << max << ' ' << sum << endl;

}

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

int main() {
  int sum=0;
  rep(i,3) {
    int a;
    cin>>a;
    sum+=a;
  }
  if (sum>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int N, L;

int main() {
  while(cin >>N && N){
    vector<string> v(N);
    REP(i, N){
      cin >>v[i];
      L = max(L, (int)v[i].length());
    }
    REP(i, N) FOR(j, 1, v[i].length()) if(v[i][j - 1] == '.' && isalpha(v[i][j])) v[i][j - 1] = '+';
    REP(l, L){
      bool f = 0;
      for(int i = N - 1; i >= 0; --i){
        if(l >= v[i].length()) continue;
        if(!f){
          if(v[i][l] == '+') f = 1;
          else f = 0;
        } else{
          if(v[i][l] == '.') v[i][l] = '|';
          else if(v[i][l] != '+') f = 0;
        }
      }
    }
    REP(i, N){
      REP(j, v[i].length()) if(v[i][j] == '.') v[i][j] = ' ';
      cout <<v[i] <<endl;
    }
  }
  return 0;
}

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

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}

// no change 
const ll MOD = 1e9+7;  
const int mx = 1e5;
int n;
void Titan(){
	read(n);
	if(n>=30)
		cout << "Yes";
	else
	cout <<"No" ;
}
	

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        double sum = 0;
        int[] votes = new int[N];
        for (int i = 0; i < N; i++) {
            int vote = scanner.nextInt();
            sum += vote;
            votes[i] = vote;
        }

        int counter = 0;
        for (int i = 0; i < N; i++) {
            if ((double)votes[i] >= sum / (4.0 * (double)M)) {
                counter++;
            }
        }

        if (counter < M) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray();
        var a = vals[0];
        var b = vals[1];
        var c = vals[2];

        // √a + √b < √c
        // a + 2√ab + b < c
        // 2√ab < c -a - b
        // 4ab < (c-a-b)^2
        var r = c - a - b;
        if (r > 0 && 4 * a * b < r * r)
        {

            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

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

int main(){
  int n,k;
  int l[100];
  cin>>n>>k;
  for(int t=0;t<n;t++){
    cin>>l[t];
  }

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

  int sum=0;
  for(int t=0;t<k;t++){
    sum+=l[t];
  }

  cout<<sum<<"\n";
  return 0;
}


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

int main () {
  int N;
  cin >> N;
  vector <int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }

  bool a = false;
  
  for(int i = 0; i < N; i++){
    /*if(A.at(i) % 2 == 0 && A.at(i) % 3 != 0 || A.at(i) % 2 == 0 && A.at(i) % 5 != 0 || A.at(i) % 2 == 0 && A.at(i) % 3 == 0 && A.at(i) % 5 == 0){
      a = true;
    }*/
    if(A.at(i) % 2 == 0) {
      if (A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
        a = true;
      }
    }
  }

  if(a == true){
      cout << "DENIED" << endl;
  }

  else{
      cout << "APPROVED" << endl;
  }
  
}


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

int p, q, a, n;

int dfs(int depth, int si, int bo, int minBo) {
	int ret = 0;
	
	if (bo > a || depth > n) { return 0; }
	if (si * q == p * bo) { ret++; }
	if (depth == n) { return ret; }
	
	for (int x = minBo; x * bo <= a; x++) {
		//si /bo + 1 / x = (x * si + bo) / (bo * x)
		ret += dfs(depth + 1, x * si + bo, bo * x, x);
	}
	return ret;
}

int main() {
	while (cin >> p >> q >> a >> n) {
		if (!p) break;
		cout << dfs(0, 0, 1, 1) << endl;
	}
	return 0;
}


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

ll n;


int main()
{
    cin >> n;
    if(n % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    ll res = 0;
    for(ll i = 10; i <= n; i *= 5LL)
    {
        res += n / i;
    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#ABC160F

import sys
sys.setrecursionlimit(10**7)

def input():
	return sys.stdin.buffer.readline()[:-1]

MOD = 10**9+7
n = int(input())
con = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	con[a-1].append(b-1)
	con[b-1].append(a-1)
stair = [1] #階乗MOD
stairr = [1] #階乗逆数MOD
for i in range(n):
	stair.append((stair[i] * (i+1)) % MOD)
	stairr.append(pow((stair[i] * (i+1)) % MOD, MOD-2, MOD))
cnt = [1 for _ in range(n)]
des_size = [1 for _ in range(n)]
des_case = [1 for _ in range(n)]
def dfs1(v, u):
	totalsize = 1 #v自身も含んだsizeであることに注意
	totalcase = 1
	for w in con[v]:
		if w == u:
			continue
		dfs1(w, v)
		totalsize += des_size[w]
		totalcase = (totalcase * des_case[w] * stairr[des_size[w]]) % MOD
	totalcase = (totalcase * stair[totalsize-1]) % MOD
	des_size[v] = totalsize
	des_case[v] = totalcase
	#print(v, u, totalsize, totalcase)
	#print(des_size)
	#print(des_case)
	return

dfs1(0, -1)
#print(des_size) 
#print(des_case)
asc_size = [1 for _ in range(n)]
asc_case = [1 for _ in range(n)]
def dfs2(v, u):
	if u == -1:
		for w in con[v]:
			if w == u:
				continue 
			dfs2(w, v)
		return
	asc_size[v] = n - des_size[v] + 1
	x0 = des_size[u]
	y0 = des_case[u]
	x1 = des_size[v]
	y1 = des_case[v]
	x2 = asc_size[u]
	y2 = asc_case[u]
	p = (y0 * y2 * stair[x1] * stair[x0+x2-x1-2]) % MOD
	q = (stairr[x0-1] * stairr[x2-1] * pow(y1, MOD-2, MOD)) % MOD
	asc_case[v] = (p*q) % MOD
	#print(v, u, asc_size, asc_case, p, q)
	for w in con[v]:
		if w == u:
			continue 
		dfs2(w, v)
	return
dfs2(0, -1)
#print(asc_size) 
#print(asc_case)

for i in range(n):
	r = stair[des_size[i] + asc_size[i] -2]
	s = (stairr[des_size[i]-1] * stairr[asc_size[i]-1]) % MOD
	t = (des_case[i] * asc_case[i]) % MOD
	print((r * s * t) % MOD)

Measured memory_bytes: 87832
#include <iostream>

using namespace std;

#define EPS 1e-9

int main()
{
	int a,b,c,d,e,f;
	float x,y,dx,dy;
	while( cin >> a >> b >>c >>d >> e >> f ) {
		x = (c*e-b*f)/(float)(a*e-b*d);
		y = (c - a*x)/(float)b;
		

		printf("%.3f %.3f\n",x+EPS,y+EPS);
	}



	return 0;
}

Measured memory_bytes: 0
use std::io::*;

fn read<T: std::str::FromStr>(i: &mut StdinLock) -> T {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let input1: String = read(sin);
    let input2: String = read(sin);

    let rotates: String = vec![input1.as_str(), input1.as_str()].concat();
    let ans = if rotates.contains(input2.as_str()) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
(N, K) = list(map(int,input().split()))
P = list(map(int, input().split()))

def max_expected(L, K):
  length = len(L)
  if (length < K):
    return -1
  if (length == K):
    return (sum(L) + K) / 2
  mid = length // 2
  s_left = max_expected(L[0:mid], K)
  s_right = max_expected(L[mid:], K)
  offset = 0

  if (mid - K + 1 < 0):
    offset = - (mid - K + 1)
  end_offset = 0
  if (mid + K - 1 >= length):
    end_offset = mid + K - 1 - length
  max_p = sum(L[mid - K + 1 + offset:mid + 1 + offset])
  prev = max_p
  for i in range(mid - K + 1 + offset + 1, mid - end_offset):
    prev = prev - L[i - 1] + L[i + K - 1]
    if max_p < prev:
      max_p = prev
  
  return max((max_p + K) / 2, s_left, s_right)
print("{}".format(max_expected(P, K)))


Measured memory_bytes: 25308
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,y,a,b;
    cin>>x>>y;
    if(x%y==0){cout<<"-1\n"; return 0;}
    else{
            long long n=x*2;
            bool is=false;
        while(1)
        {
            if(n>=10e18) break;
            if(n%x==0&&n%y!=0)
            {
                is=true;
                break;
            }
            n+=x;

        }
        if(is) cout<<n<<endl;
        else cout<<"-1"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 998244353;
int N,X;
int dp[3005][6005],fac[6005],invfac[6005];
int f[3005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
int C(int n,int m) {
    if(n < m) return 0;
    return mul(fac[n],mul(invfac[m],invfac[n - m]));
}
void Solve() {
    read(N);read(X);
    dp[0][0] = 1;
    fac[0] = 1;
    for(int i = 1 ; i <= 2 * N ; ++i) fac[i] = mul(fac[i - 1],i);
    invfac[2 * N] = fpow(fac[2 * N],MOD - 2);
    for(int i = 2 * N - 1 ; i >= 0 ; --i) {
	invfac[i] = mul(invfac[i + 1],i + 1);
    }
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
	for(int j = 2 * i ; j >= 1 ; --j) {
	    if(j >= 2) update(dp[i][j],dp[i - 1][j - 2]);
	    if(j >= 1) update(dp[i][j],dp[i - 1][j - 1]);
	}
    }
    for(int i = 0 ; i <= N ; ++i) {
	for(int j = 0 ; j <= 2 * i ; ++j) {
	    if(j < X) update(ans,mul(dp[i][j],C(N,i)));
	}
    }
    for(int i = 1 ; i < N ; ++i) {
	int t = i * 2 + 1;
	if(t >= X) break;
	for(int j = 0 ; j <= N ; ++j) {
	    if(i + j + 2 <= N) {
		update(f[i + j + 2],dp[j][X - 1 - t]);
		if(i + j + i + 2 <= N) update(f[i + j + i + 2],MOD - dp[j][X - 1 - t]);
	    }
	}
    }
    for(int i = 1 ; i <= N ; ++i) f[i] = inc(f[i],f[i - 1]);
    for(int i = 1 ; i <= N ; ++i) {
	update(ans,mul(f[i],C(N,i)));
    }
    if(X & 1) {
	for(int i = 1 ; i <= N ; ++i) {
	    if(i * 2 > X) update(ans,C(N,i));
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 69120
N, P = map(int, input().split())
p_dict = {}
if N == 1:
  print(P)
  exit()
for num in range(2, int(P**0.5)+1):
  while P%num == 0:
    if num in p_dict:
      p_dict[num] += 1
    else:
      p_dict[num] = 1
    P //= num
ans = 1
for k, v in p_dict.items():
  ans *= k**(v//N)
print(ans)

Measured memory_bytes: 63256
n = input()
a_ar = list(map(int, input().split()))
total = 0
for i in range(len(a_ar) - 1):
    if a_ar[i] > a_ar[i+1]:
        total += a_ar[i] - a_ar[i+1]
        a_ar[i+1] = a_ar[i]
print(total)

Measured memory_bytes: 32020
#include <bits/stdc++.h>
using namespace std;
/* #pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
typedef long long ll;
const ll MAXN = 1e3 + 2;
const ll MAXD = 1e3 + 5;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}



int main(){

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

int n;
cin >> n;
map<string,int> mp;

string v[]={"AC","WA","TLE","RE"};

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

for(int i = 0 ; i < 4 ; i++)
 {
  string k = v[i];
  cout << k << " x " << mp[k] << '\n';
 }
 
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int a, b; cin >> a >> b;

    for(int i=1; i<=100000; ++i) {
        if(i*8/100 == a && i*10/100 == b) { cout << i << endl; return 0; }
    }

    cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define ull unsigned long long
using namespace std;

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

	ull max = 1000000000000000000;

	if (n % 2 == 0) {
		ull ret = 0;
		for (ull j = 10; j <= max; j *= 10) {
			ret += n / j;
		}
		for (ull k = 5; k <= max; k *= 5) {
			for (ull j = k * 10; j <= max; j *= 10) {
				ull t = n / j;
				ret += t / 2;
				ret += t % 2;
			}
		}
		cout << ret << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
const ll MOD = 1e9 + 7;
const long double PI = acos(-1);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    
    long double theta1 = 2 * (PI / (12 * 60)) * (60 * h + m), theta2 = (2 * PI / 60) * m;

    long double delta = abs(theta1 - theta2);
    delta = min(2 * PI - delta, delta);

    cout << setprecision(11) << sqrt(a * a + b * b - 2 * a * b * cos(delta)) << endl;
    
    return 0;
}

Measured memory_bytes: 4180
def main():
    n = int(input())
    if n == 1:
        print(1)
        return 
    a = [list(input().split()) for i in range(n)]
    s = sorted(a, key=lambda x:(x[0],-int(x[1])))
    for i in s:
        print(a.index(i)+1)

if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int arr[100001],n;

    cin>>n;

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

    sort(arr,arr+n);

    cout<<arr[n/2]-arr[n/2-1]<<endl;

}


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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<int> a(n);
    float sum = 0;
    for(int i=0;i<n;i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    int ave;
    if(sum>=0) ave = ((int)(sum / n + 0.5));
    else ave = ((int)(sum / n - 0.5));

    int ans = 0, tmp;
    for(int i=0;i<n;i++) {
        tmp = a.at(i) - ave;
        ans += tmp*tmp;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

ll powmod(ll a, ll p) {
	ll ans = 1;
	ll mul = a;
	for (; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
		if ((p & 1) == 1)ans = (ans * mul) % MOD;
	}
	return ans;
}

vll fact;//階乗
vll revFact;//階乗の逆元


void setFact(int N) {
	fact = vll(N);
	revFact = vll(N);
	fact[0] = 1;
	FOR(i, 1, N) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}
	revFact[N - 1] = powmod(fact[N - 1], MOD - 2);
	REPR(i, N - 1) {
		revFact[i] = revFact[i + 1] * (i + 1);
		revFact[i] %= MOD;
	}
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	map<int, int> M;
	setFact(10000);
	FOR(i, 2,N+1) {
		int t = 2;
		int n = i;
		while (t * t <= n) {
			while (n % t == 0) {
				M[t]++;
				n /= t;
			}
			t++;
		}
		if (n >= t)M[n]++;
	}
	int c75 = 0, c25 = 0, c15 = 0,c5 = 0, c3 = 0;
	for (auto m : M) {
		if (m.second + 1 >= 75) {
			c75++;
		}
		if (m.second + 1 >= 25) {
			c25++;
		}
		if (m.second + 1 >= 15) {
			c15++;
		}
		if (m.second + 1 >= 5) {
			c5++;
		}
		if (m.second + 1 >= 3) {
			c3++;
		}
	}

	int ans = c75;
	ans += c25 * (c3 - 1);
	ans += c15 * (c5 - 1);
	ll c5C2 = ((fact[c5] * revFact[2]) % MOD) * revFact[c5 - 2] % MOD;
	ans += c5C2 * (c3 - 2);
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>(0)?(a):-(a))
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    int n,i,buf1,h;
    cin>>n;
    cin>>buf1;
    buf1--;
    rep(i,1,n){
        cin>>h;
        if(buf1<h)h--;
        else if(buf1>h){
            cout<<"No"<<endl;
            return 0;
        }
        buf1=h;
    }
   cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long e = sc.nextLong();
		
		// find the bottle neck of each station
		long bottleNeckOfA = (long) Math.ceil((double)n / (double)a);
		long bottleNeckOfB = (long) Math.ceil((double)n / (double)b);
		long bottleNeckOfC = (long) Math.ceil((double)n / (double)c);
		long bottleNeckOfD = (long) Math.ceil((double)n / (double)d);
		long bottleNeckOfE = (long) Math.ceil((double)n / (double)e);
		
		// find max bottle neck
		long maxBottleNeck = Math.max(bottleNeckOfA, Math.max(bottleNeckOfB,
				Math.max(bottleNeckOfC, Math.max(bottleNeckOfD, bottleNeckOfE))));
		
		// calculate the final ans
		long ans = maxBottleNeck + 4;
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define endl '\n'
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvpi vector<vpi>
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,a,n) for(int i=a;i<n;i++)
#define pie =3.14159265358979323846264338327950;
const int mod= 1e9+7;

vector<int> graph[200005];
vector<bool> vis(200005,false);
int ans_g=0;

void dfs(int i){
	vis[i]=true;
	ans_g++;
	for(auto j:graph[i]){
		if(!vis[j]){
			dfs(j);
		}
	}
}


void solve(){
	fio;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	int ans=0; 	
	for(int i=0;i<n;i++){
		if(!vis[i]){
			ans_g=0;
			dfs(i);
			ans=max(ans,ans_g);
		}
	}
	cout<<ans<<endl;
}


int32_t main(){
	fio;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){ 
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 20840
w, h , x ,y ,r = map(int,input().split())

xLongLeft = x-r
xLongRight = x + r

yLongTop = y + r
yLongBot = y - r

if((xLongLeft >= 0 and yLongBot >= 0) and (xLongRight <= w and yLongTop <= h)):
   print('Yes')
else:
   print('No')



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int h, w;
    cin >> h >> w;
    char b[h + 2][w + 2];
    char a[h][w];
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> a[i][j];
        }
    }
    rep(i, h + 2)
    {
        rep(j, w + 2)
        {
            b[i][j] = '#';
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            b[i + 1][j + 1] = a[i][j];
        }
    }
    rep(i, h + 2)
    {
        rep(j, w + 2)
        {
            cout << b[i][j];
        }
        cout << endl;
    }
}

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

int main()
{
    int n;
    long long sum = 0;
    string s;
    vector<int> vr, vg, vb;
    cin >> n;
    cin >> s;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'R') {
            vr.push_back(i);
        }
        else if (s[i] == 'G') {
            vg.push_back(i);
        }
        else {
            vb.push_back(i);
        }
    }
    for(int i=0;i<(int)vr.size();i++)
        for (int j = 0; j < (int)vg.size(); j++) {
            int t = abs(vr[i] - vg[j]);
            if(max(vr[i], vg[j])+t<(int)s.size())
                if (s[max(vr[i], vg[j]) + t] == 'B') {
                    sum++;
                }
            if(min(vr[i], vg[j])- t>=0)
                if (s[min(vr[i], vg[j]) - t] == 'B') {
                    sum++;
                }
        }
    for (int i = 0; i < (int)vg.size(); i++)
        for (int j = 0; j < (int)vb.size(); j++) {
            int t = abs(vg[i] - vb[j]);
            if (max(vg[i], vb[j]) + t < (int)s.size())
                if (s[max(vg[i], vb[j]) + t] == 'R') {
                    sum++;
                }
            if (min(vg[i], vb[j]) - t >= 0)
                if (s[min(vg[i], vb[j]) - t] == 'R') {
                    sum++;
                }
        }
    for (int i = 0; i < (int)vr.size(); i++)
        for (int j = 0; j < (int)vb.size(); j++) {
            int t = abs(vr[i] - vb[j]);
            if (max(vr[i], vb[j]) + t < (int)s.size())
                if (s[max(vr[i], vb[j]) + t] == 'G') {
                    sum++;
                }
            if (min(vr[i], vb[j]) - t >= 0)
                if (s[min(vr[i], vb[j]) - t] == 'G') {
                    sum++;
                }
        }
    cout << vr.size() * vg.size() * vb.size() - (sum / 2) << endl;
    return 0;
}

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

long long int dp[2][200001];
int n;
long long int t;
vector <long long int> v;

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

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	fill(dp[0],dp[0]+200001,-1e18);
	fill(dp[1],dp[1]+200001,-1e18);
	if(n%2==0)
	{
		long long int res = -1e18;
		dp[0][0] = v[0];
		dp[0][1] = v[1];
		for(int i=0;i<n;i++)
		{
			if(i%2==0)
			{
				if(i + 2 < n)
				{
					dp[0][i+2] = max(dp[0][i+2],dp[0][i] + v[i+2]);
				}
				if(i + 3 < n)
				{
					dp[0][i+3] = max(dp[0][i+3],dp[0][i] + v[i+3]);
				}
			}
			else
			{
				if(i + 2 < n)
				{
					dp[0][i+2] = max(dp[0][i+2],dp[0][i] + v[i+2]);
				}
			}
		}
		res = max(dp[0][n-1],dp[0][n-2]);
		cout << res << '\n';
	}
	else
	{
		long long int res = -1e18;
		dp[0][0] = v[0];
		dp[0][1] = v[1];
		dp[0][2] = v[2];
		dp[1][0] = v[0];

		for(int i=0;i<n;i++)
		{
			if(i%2==1)
			{
				if(i + 2 < n)
				{
					dp[0][i+2] = max(dp[0][i+2],dp[0][i] + v[i+2]);
				}
				if(i + 3 < n)
				{
					dp[0][i+3] = max(dp[0][i+3],dp[0][i] + v[i+3]);
				}
			}
			else
			{
				if(i!=0)
				{
					if(i+2 < n)
					{
						dp[0][i+2] = max(dp[0][i+2],dp[0][i] + v[i+2]);
					}
					if(i!=n-3)
					{
						if(i+2 < n)
						{
							dp[1][i+2] = max(dp[1][i+2],dp[1][i] + v[i+2]);
						}
					}
					if(i+3 < n)
					{
						dp[0][i+3] = max(dp[0][i+3],dp[1][i] + v[i+3]);
					}
					if(i+4 < n)
					{
						dp[0][i+4] = max(dp[0][i+4],dp[1][i] + v[i+4]);
					}
				}
				else
				{
					if(i!=n-3)
					{
						if(i+2 < n)
						{
							dp[1][i+2] = max(dp[1][i+2],dp[1][i] + v[i+2]);
						}
					}
					if(i+3 < n)
					{
						dp[0][i+3] = max(dp[0][i+3],dp[1][i] + v[i+3]);
					}
					if(i+4 < n)
					{
						dp[0][i+4] = max(dp[0][i+4],dp[1][i] + v[i+4]);
					}
				}
			}
		}
		res = max(dp[1][n-3],max(dp[0][n-1],dp[0][n-2]));
		cout << res << '\n';

	}

	return 0;	
}


Measured memory_bytes: 7932
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 250005
#define in(x)  cin>>x
#define in4(w,x,y,z) cin>>w>>x>>y>>z
#define in3(x,y,z) cin>>x>>y>>z
#define o(x)  cout<<x
#define o2(x,y) cout<<x<<' '<<y;
#define o3(x,y,z) cout<<x<<' '<<y<<' '<<z
#define o4(w,x,y,z)cout<<w<<' '<<x<<' '<<y<<' '<<z
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],tem[AS];
int main()
{
    fast;
    in(n);
    fr(i,1,n)in(ar[i]),br[i]=(br[i-1]+ar[i])%mod;

    fr(i,1,n-1)
    {
        c=(c+(ar[i]*(br[n]-br[i]+mod)%mod)%mod)%mod;

    }
    o(c);
}



Measured memory_bytes: 6640
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int a[2010];
int main()
{	
	int n, w, z,i;
	scanf("%d%d%d",&n,&z,&w);
    for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
   	if(n==1)
   	printf("%d\n",abs(w-a[1]));	
    else 
    printf("%d\n",max(abs(a[n]-w),abs(a[n-1]-a[n])));
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

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

    vector<int> s(m);
    vector<int> c(m);
    rep(i, m)
    {
        cin >> s.at(i) >> c.at(i);
    }

    // 一桁のとき
    if (n == 1)
    {
        // m = 0 なら0が最小
        if (m == 0)
        {
            cout << 0 << endl;
            return 0;
        }

        // m個の条件を全て調べる
        rep(i, m)
        {
            // 最初の一つと比較し、一致しない場合は-1
            if (c.at(0) != c.at(i))
            {
                cout << -1 << endl;
                return 0;
            }
        }
        // 一致したのでその値を返す
        cout << c.at(0) << endl;
        return 0;
    }

    // 2桁または3桁のとき
    else if (n >= 2)
    {
        // 一桁目の条件としてs=1でc=0は不適
        rep(i, m)
        {
            if (s.at(i) == 1 && c.at(i) == 0)
            {
                cout << -1 << endl;
                return 0;
            }
        }

        // 桁数と値のmapを持つ
        map<int, int> digit;

        // m個の条件について調べる
        rep(i, m)
        {
            decltype(auto) itr = digit.find(s.at(i));
            // 同じものが既にある場合
            if (itr != digit.end())
            {
                // 一致していないなら不適
                if (itr->second != c.at(i))
                {
                    cout << -1 << endl;
                    return 0;
                }
            }
            // まだ存在しない場合は追加
            else
            {
                digit[s.at(i)] = c.at(i);
            }
        }

        // 最小となる値を構成
        string ans = "";
        for (int i = 1; i < n + 1; i++)
        {
            decltype(auto) itr = digit.find(i);

            // Keyが存在する
            if (itr != digit.end())
            {
                // その値を代入
                ans += to_string(digit[i]);
            }
            // Keyが存在しない
            else
            {
                if (i == 1)
                {
                    // 一桁目なら1で最小
                    ans += "1";
                }
                else
                {
                    // 他の桁なら0で最小
                    ans += "0";
                }
            }
        }
        // 構成したansを返す
        cout << stoi(ans) << endl;
        return 0;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
        int D = scan.nextInt();
        int T = scan.nextInt();
        int S = scan.nextInt();
        if(D<=T*S){
            System.out.println("Yes");}
        else{
            System.out.println("No");
        }
        }
        public static void main(String[]args){
            new Main().solve();
        }
    }

Measured memory_bytes: 35548
import numpy as np
U = 10**3
T = np.zeros(U,np.int32)
T[2]=1
T[3::2]=1
for i in range(U):
  if i*i>U:
    break
  if T[i]==1:
    T[i*i::2*i] = 0
pls = np.where(T)[0]
N = int(input())
MOD = 10**9+7
dic = {}
for i in range(2,N+1):
  for p in pls:
    if p>i:
      break
    while i%p==0:
      dic[p] = dic.get(p,0)+1
      i //= p
ans = 1
for v in dic.values():
  ans *= (v+1)
  ans %= MOD
print(ans)

Measured memory_bytes: 13336
#BinarySearchTree
class TreeNode():
    def __init__(self):
        self.key = None
        self.parent = None
        self.left = None
        self.right = None
    def inoder(self):
        r=[]
        if self.left:
            r += self.left.inoder()
        r += [self.key]
        if self.right:
            r += self.right.inoder()
        return r

    def preoder(self):
        r = [self.key]
        if self.left:
            r += self.left.preoder()
        if self.right:
            r += self.right.preoder()
        return r

class BinaryTree():
    def __init__(self):
        self.root = None

    def insert(self, z):
        y = None
        x = self.root
        while x != None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def show(self):
        x = self.root
        print(" " + " ".join(map(str, self.root.inoder())))
        print(" " + " ".join(map(str, self.root.preoder())))

    def find(self, key):
        currentNode = self.root
        while currentNode:
            if key == currentNode.key:
                return True
            else:
                if key < currentNode.key:
                    currentNode = currentNode.left
                else:
                    currentNode = currentNode.right
        return False


n = int(input())
Tree = BinaryTree()
for i in range(n):
    L = input().split()
    if L[0] == "insert":
        Node = TreeNode()
        Node.key = int(L[1])
        Tree.insert(Node)
    elif L[0] =="print":
        Tree.show()
    else:
        if Tree.find(int(L[1])):
            print("yes")
        else:
            print("no")

Measured memory_bytes: 156592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int a[] = new int[200010];
		int ans[] = new int[200010];
		int n  =scan.nextInt();

		for(int i = 2; i <= n; i++) {
			a[i] = scan.nextInt();
		}
		for(int i = 2; i <= n; i++) {
			ans[a[i]]++;
		}
		for(int i = 1; i <= n; i++) {
			System.out.println(ans[i]);
		}


	}
}

Measured memory_bytes: 62816