akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        final int m = in.nextInt();
        final int q = in.nextInt();
        in.nextLine();
        final int[][] lines = new int[q][4];
        for (int i = 0; i < q; i++) {
            lines[i] = new int[] { in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt() };
            in.nextLine();
        }
        long res = 0;
        for (List<Integer> l : combine(m, n)) {
            long curr = 0;
            for (int[] query : lines) {
                if (l.get(query[1] - 1) - l.get(query[0] - 1) == query[2]) {
                    curr += query[3];
                }
            }
            res = Math.max(res, curr);
        }
        System.out.println(res);
    }

    public static List<List<Integer>> combine(int n, int k) {
        final List<List<Integer>> res = new ArrayList<>();
        recurse(1, n, k, new ArrayList<>(), res);
        return res;
    }

    public static void recurse(int start, int n, int k, List<Integer> curr, List<List<Integer>> res) {
        if (k == 0) {
            res.add(new ArrayList<>(curr));
            return;
        }

        for (int i = start; i <= n; i++) {
            curr.add(i);
            recurse(i, n, k - 1, curr, res);
            curr.remove(curr.size() - 1);
        }
    }
}


Measured memory_bytes: 47504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
    int N = 0;
    float tmp = 0;
    cin >> N;

    float result = 0.0e-6;

    if(N%2 == 0){
        result = 0.5;
    }else{
        tmp = (N-1)/2;
        result = (tmp + 1)/N;
    }

    cout << result << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;++i) cin >> p[i];
    sort(p.begin(),p.end(),greater<int>());
    int ans=0;
    p[0]/=2;
    for(int i=0;i<n;++i){
        ans+=p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    char s[5];
    cin >> s;
    int ret = 0;
    int a = (s[0] - '0') * 10 + s[1] - '0';
    if (a <= 12 && a > 0) ret++;
    a = (s[2] - '0') * 10 + s[3] - '0';
    if (a <= 12 && a > 0) ret += 2;
    if (ret == 0) puts("NA");
    if (ret == 1) puts("MMYY");
    if (ret == 2) puts("YYMM");
    if (ret == 3) puts("AMBIGUOUS");
    return 0;       
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int N;
  
  cin >> N;
  
  int a[N];
  int num[N+1];
  
  for(int i=0;i<=N;i++)
  {
    num[i] = 0;
  }
  
  for(int i=0;i<N;i++)
  {
    cin >> a[i];
    num[a[i]]++;
  }
  
  long long kumiawase[N+1];
  kumiawase[0]=0;
  kumiawase[1]=0;
  
  for(int i=2;i<=N;i++)
  {
    kumiawase[i] = kumiawase[i-1] + (i-1);
  }
  
  long long total = 0;
  for(int i=1;i<=N;i++)
  {
    total += kumiawase[num[i]];
  }
  
  for(int i=0;i<N;i++)
  {
    cout << total - num[a[i]] + 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5760
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

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

  vector<double> p(n);
  for (auto& e : p) cin >> e;

  vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
  dp[1][0] = 1.0 - p[0];
  dp[1][1] = p[0];

  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      double& ans = dp[i][j];
      ans = dp[i - 1][j] * (1.0 - p[i - 1]);
      if (j > 0) ans += dp[i - 1][j - 1] * p[i - 1];
    }
  }

  double ans = 0.0;
  int mid = n / 2 + n % 2;
  for (int i = mid; i <= n; i++) {
    ans += dp[n][i];
  }
  cout << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 70784
n = int(input())
a = list(map(int, input().split()))
pl = []
mi = []
for x in a:
  if x < 0:
    mi.append(x)
  else:
    pl.append(x)
a = 0
mi.sort()
pl.sort()
move = []
if mi == []:
  cur = pl[0]
  for i in range(n-2):
    move.append((cur,pl[i+1]))
    cur -= pl[i+1]
  move.append((pl[-1],cur))
  cur = pl[-1] - cur
elif pl == []:
  cur = mi[-1]
  for i in range(n-1):
    move.append((cur,mi[i]))
    cur -= mi[i]
else:
  pl1 = pl.pop()
  mi1 = mi.pop()
  for x in mi:
    move.append((pl1,x))
    pl1 -= x
  for y in pl:
    move.append((mi1,y))
    mi1 -= y
  move.append((pl1,mi1))
  cur = pl1-mi1
print(cur)
for x,y in move:
  print(x,y)

Measured memory_bytes: 19736
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

const int INF = (1 << 30) - 1;
const int MAX_V = 100001;

struct edge {
  int to, cost;
};
typedef pair<int, int> P; // firstは最短距離, secondは頂点の番号

int V, E;
vector<edge> G[MAX_V];
int du[MAX_V];

void dijkstra_u(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(du, du + V, INF);
  du[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (du[v] < p.first) {
      continue;
    }

    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (du[e.to] > du[v] + e.cost) {
        du[e.to] = du[v] + e.cost;
        que.push(P(du[e.to], e.to));
      }
    }
  }
}

int dv[MAX_V];

void dijkstra_v(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(dv, dv + V, INF);
  dv[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (dv[v] < p.first) {
      continue;
    }

    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (dv[e.to] > dv[v] + e.cost) {
        dv[e.to] = dv[v] + e.cost;
        que.push(P(dv[e.to], e.to));
      }
    }
  }
}

int u, v;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> V >> u >> v;
  u--;
  v--;
  E = V - 1;
  for (int i = 0; i < E; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(edge{b, 1});
    G[b].push_back(edge{a, 1});
  }

  dijkstra_u(u);
  dijkstra_v(v);
  int ans = 0;
  for (int i = 0; i < V; i++) {
    if (du[i] < dv[i]) {
      ans = max(ans, dv[i] - 1);
    }
  }

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

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

using namespace std;

using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> per(n), cp(m);
    for (int i = 0; i < n; i++)
        cin >> per[i].first >> per[i].second;
    for (int i = 0; i < m; i++)
        cin >> cp[i].first >> cp[i].second;
    for (int i = 0; i < n; i++)
    {
        int mx = 1e9, ans = -1;
        for (int j = 0; j < m; j++)
        {
            int x = abs(per[i].first - cp[j].first);
            int y = abs(per[i].second - cp[j].second);
            if (mx > x + y)
            {
                ans = j + 1;
                mx = x + y;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;


int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    bool f = 0;
    for (int i = 0; i < n; ++i)
    {
        ll tmp;
        cin >> tmp;
        tmp %= 2ll;
        if (tmp)
        {
            f = 1;
        }
    }
    if (f)
    {
        cout << "first" <<endl;
    }
    else
    {
        cout << "second" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n;
    while(scanf("%lld", &n)) {
        if(n == 0) break;
        int board[30][30] = {};
        int r, c;
        rep(i,0,n) {
            scanf("%lld%lld", &c, &r);
            r = 20 - r;
            board[r][c] = 1;
        }

        int m; scanf("%lld", &m);
        string st = "SNEW";
        char d; int t;
        int rr = 10, cc = 10;
        int cnt = 0;
        rep(i,0,m) {
            scanf(" %c %lld", &d, &t);
            // printf("debug: m = %lld, input = (%c, %lld)\n", m, d, t);
            int p = st.find(d);
            rep(j,0,t) {
                rr += dx[p], cc += dy[p];
                if(board[rr][cc]) cnt++;
                board[rr][cc] = 0;
            }
        }
        if(cnt == n) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

typedef long long ll; 

int main(){
        int n,t; cin>>n>>t; 
        ll a[n+1]; 
        for(int i=1;i<=n;i++) cin>>a[i]; 
        ll d[n+1]; 
        d[1]=0; 
        for(int i=2;i<=n;i++) d[i]=a[i]-a[i-1]; 
        ll ms=d[2]; 
        ll temp=0; 
        for(int i=2;i<=n;i++){ 
                temp+=d[i]; 
                if(ms<temp) ms=temp; 
                if(temp<=0) temp=0; 
        }
        temp=0; 
        set<int> si,sj; 
        int left=1; 
        for(int i=2;i<=n;i++){
                temp+=d[i];
                if(temp==ms) { sj.insert(i); si.insert(left); }
                if(temp<=0) { temp=0; left=i+1; }
        }
                
        cout<<min(si.size(),sj.size());          

	return 0; 
}



Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define NUL -1
using namespace std;
struct Node{
	int par,lef,rig,dep,sib,deg;
};
Node T[26];
bool flg[26]={0};
void func(int node,int parent,int depth);
int  heigth(int NODE);
int main(void){
	int n; 
	int i,j;
	int u,l,r;
	int cnt;
	cin>>n;
	for(i=0;i<n;i++)	T[i].par=T[i].lef=T[i].rig=T[i].dep=T[i].sib=T[i].deg=NUL;
	for(i=0;i<n;i++){
		cin>>u>>l>>r;
		T[u].lef=l;
		T[u].rig=r;
		flg[l]=1;
		flg[r]=1;
		cnt=0;
		if(l!=-1)	{
			T[l].sib=r;
			cnt++;
		}
		if(r!=-1){
			T[r].sib=l;
			cnt++;
		}
		T[u].deg=cnt;
	}
	for(i=0;i<n;i++){
		if(!flg[i]){
			func(i,-1,0);
		}
	}
	
	for(i=0;i<n;i++){
		//cout<<"Check"<<endl;
		cout<<"node "<<i<<": parent = "<<T[i].par<<", sibling = "<<T[i].sib<<", degree = ";
		cout<<T[i].deg<<", depth = "<<T[i].dep<<", ";
		cout<<"height = "<<heigth(i)<<", ";
		if(T[i].deg==0){
			if(T[i].par==NUL){
				cout<<"root"<<endl;
			}
			else{
				cout<<"leaf"<<endl;
			}
		}
		else{
			if(T[i].par==NUL){
				cout<<"root"<<endl;
			}
			else{
				cout<<"internal node"<<endl;
			}
		}
	}	
	return 0;
}
void func(int node,int parent,int depth){
	int i,j;
	//cout<<parent<<endl;
	T[node].dep=depth;
	T[node].par=parent;
	if(T[node].lef!=NUL){
		func(T[node].lef,node,depth+1);
	}
	if(T[node].rig!=NUL){
		func(T[node].rig,node,depth+1);
	}
}
int  heigth(int NODE){
	int hr=0,hl=0;
	//cout<<T[NODE].lef<<endl;
	//cout<<T[NODE].rig<<endl;
	//cout<<"Check1"<<endl;
	if(T[NODE].lef!=-1)	hl=heigth(T[NODE].lef)+1;
	if(T[NODE].rig!=-1)	hr=heigth(T[NODE].rig)+1;
	//cout<<hr<<endl;
	//cout<<hl<<endl;
	return max(hr,hl);
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	


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

typedef long long ll;
const int MAX=210000;
const int MOD=1e9+7;

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans;
}

int main(){
    int N; cin >> N;
    ll c[N];
    for(int i=0;i<N;i++) cin >> c[i];
    sort(c,c+N,greater<ll>());
    if(N==1){
        cout << c[0]*2%MOD << endl;
        return 0;
    }
    ll ans=0;
    ll tmp;
    for(int i=0;i<N;i++){
        tmp=mod_pow(2,N+MOD-1)+i*mod_pow(2,N+MOD-2);
        tmp%=MOD;
        //cout << tmp << endl;
        ans+=tmp*c[i];
        ans%=MOD;
    }
    ans*=mod_pow(2,N-1);
    ans%=MOD;
    cout << ans << endl;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>

using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

int n;
vector<int> g[200000], gr[200000], gd[200000];
vector<int> vs;
bool used[200000];
vector<int> cmp[200000];
bool nuee;

void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
	vs.push_back(x);
}

void rdfs(int x, int k){
	used[x]=1;
	cmp[k].push_back(x);
	for(auto y:gr[x]){
		if(!used[y]){
			nuee=1;
			rdfs(y, k);
		}
	}
}

int scc(){
	for(int x=0; x<n; x++){
		if(!used[x]) dfs(x);
	}
	fill(used, used+n, 0);
	int k=0;
	for(int i=vs.size()-1; i>=0; i--){
		if(!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}

int main()
{
	cin>>n;
	for(int i=0; i<n; i++){
		int p; cin>>p; p--;
		g[p].push_back(i);
		gr[i].push_back(p);
	}

	int k=scc();
	if(!nuee){
		cout<<"POSSIBLE"<<endl;
		return 0;
	}
	int a[200000], a2[200000];
	fill(a, a+n, -1);
	fill(a2, a2+n, -1);
	for(int i=k-1; i>=0; i--){
		if(cmp[i].size()==1){
			set<int> st;
			for(auto y:g[cmp[i][0]]){
				st.insert(a[y]);
			}
			if(st.empty()){
				a[cmp[i][0]]=0;
				a2[cmp[i][0]]=0;
			}else{
				for(int t=0; ; t++){
					if(st.find(t)==st.end()){
						a[cmp[i][0]]=t;
						a2[cmp[i][0]]=t;
						break;
					}
				}
			}
		}else{
			set<int> st;
			for(auto y:g[cmp[i][0]]){
				st.insert(a[y]);
			}
			bool e=0;
			for(int t=0; ; t++){
				if(st.find(t)==st.end()){
					if(!e){
						e=1;
						a[cmp[i][0]]=t;
					}else{
						a2[cmp[i][0]]=t;
						break;
					}
				}
			}
			for(int j=1; j<cmp[i].size(); j++){
				set<int> st1, st2;
				for(auto y:g[cmp[i][j]]){
					st1.insert(a[y]);
					st2.insert(a2[y]);
				}
				for(int t=0; ; t++){
					if(st1.find(t)==st1.end()){
						a[cmp[i][j]]=t;
						break;
					}
				}
				for(int t=0; ; t++){
					if(st2.find(t)==st2.end()){
						a2[cmp[i][j]]=t;
						break;
					}
				}
			}
			if(a[cmp[i][0]]!=a[cmp[i][cmp[i].size()-1]]){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}else{
				set<int> st;
				for(auto y:g[cmp[i][0]]){
					st.insert(a2[y]);
				}
				for(int t=0; ; t++){
					if(st.find(t)==st.end()){
						if(a2[cmp[i][0]]==t){
							cout<<"POSSIBLE"<<endl;
						}else{
							cout<<"IMPOSSIBLE"<<endl;
						}
						return 0;
					}
				}
			}
		}
	}
    return 0;
}

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

int main(){
  long long N,K;
  cin >> N >> K;
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  long long right=0;
  long long all=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A.at(i) > A.at(j)) all++;
    }
    for(int j=i+1;j<N;j++){
      if(A.at(i) > A.at(j)) right++;
    }
  }
 
  long long ans =0;
  long long tmp =0;
  long long div = pow(10,9) + 7;

  ans += right * K % div;
  ans += K * (K-1) / 2 % div * all % div;
//  ans += all % div * K * (K-1) / 2 % div; // This is wrong. Why?
  ans %= div;
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

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

    int ans = r;
    if(n < 10)ans += 100*(10-n);

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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



ll K,N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N;
 
 ll val = N%10;

 if(val == 2 || val == 4 || val == 5 || val == 7 || val == 9)
  cout<<"hon"<<'\n';


else if(val == 0 || val == 1 || val == 6 || val == 8)
  cout<<"pon"<<'\n';


else
  cout<<"bon"<<'\n';



   

}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int n,p[100],ans=0;
    cin >> n;
    rep(i,n) cin >> p[i];
    rep(i,n-2) {
        if(p[i] < p[i+1] && p[i+1] < p[i+2]) ans++;
        else if(p[i] > p[i+1] && p[i+1] > p[i+2]) ans++;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	string s;
    cin >> s;
    ll ans;
    if(s=="SSS"){
        ans = 0;
    }
    if(s=="SSR"){
        ans = 1;
    }
    if(s=="SRS"){
        ans = 1;
    }
    if(s=="SRR"){
        ans = 2;
    }
    if(s=="RSS"){
        ans = 1;
    }
    if(s=="RSR"){
        ans = 1;
    }
    if(s=="RRS"){
        ans = 2;
    }
    if(s=="RRR"){
        ans = 3;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
 long  long int n,k[200000],sum=0;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>k[i];
    sum+=k[i];
  }
  
  long long int mon=2000000000,ss,snuke=0;
  for(int i=0;i<n-1;++i){
    snuke+=k[i];
    ss=sum-snuke*2;
    if(ss<0) ss*=-1;
    if(mon>ss) mon=ss;
  }
  cout<<mon<<endl;
}


Measured memory_bytes: 1792
# include <iostream>
using namespace std;
int main(){
int n,count=0;
cin>>n;
char  s[n];

for(int i=0;i<n;i++){
cin>>s[i];
}
for(int i=0;i<n;i++){
    if(s[i]=='A'&& s[i+1]=='B'&& s[i+2]=='C'){
        count++;
        i=i+2;
    }

}
cout<<count;




}


Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a*b%2) cout<<"Odd"<<endl;
	else cout<<"Even"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
#-------------------------------------
import collections

n = int(input())
p = list(map(int,input().split()))

counter = 0
for i in range(1,n-1):
        tmp = [p[i-1], p[i], p[i+1]]
        tmp = collections.Counter(tmp)
        tmp = sorted(tmp)
        if len(tmp) > 1 and tmp[0] < tmp[1] and tmp[1] == p[i]:
                counter += 1
print(counter)

Measured memory_bytes: 38256
#include<stdio.h>
#include<iostream>
using namespace std;
int a[100];


int main(){
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	int sum = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i+1; j <= n; j++) sum += a[i] * a[j];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}


func main() {
  NL := NextIntVec()
  N, L := NL[0], NL[1]
  A := NextIntVec()
  ans := "Impossible"
  last := -1
  for i := 0; i < N - 1; i++ {
    if L <= A[i] + A[i + 1] {
      last = i
      ans = "Possible"
      break
    }
  }
  Write(ans)
  if last >= 0 {
    S := make([]string, 0)
    for i := 0; i < last; i++ {
      S = append(S, strconv.Itoa(i + 1))
    }
    for i := N - 1; last < i; i-- {
      S = append(S, strconv.Itoa(i))
    }
    Write(strings.Join(S, "\n"))
  }
  Output()
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
vector<int> v[100010];
int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    int ans = 0;
    priority_queue<int> que;
    for (int i = 1; i <= m; i++)
    {
        for (auto j : v[i])
        {
            que.push(j);
        }
        if (!que.empty())
        {
            int t = que.top();
            que.pop();
            ans += t;
        }
    }
    cout << ans << endl;
}

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

int N;
vector<vector<int>> v(100010);
int visited[100010] = {0},dp[100010] = {0};

bool ok(int n,int m){
	visited[n] = 1;
	bool judge = true;
	vector<int> children;
	for(int i=0;i<v[n].size();i++){
		int s = v[n][i];
		if(visited[s]==0){
			judge = (judge && ok(s,m));
			children.push_back(dp[s]);
		}
	}
	int len = children.size();
	sort(children.begin(),children.end());
	if(len%2==0){
		bool j = true;
		for(int i=0;i<len/2;i++){
			if(children[i]+children[len-i-1]>m) j = false;
		}
		if(j) return judge;
		else if(n==1) return false;
		children.pop_back(); len--;
	}
	int l = -1,r = len;
	while(l+1<r){
		int mid = (l+r)/2;
		int a = 0,b = len-1;
		bool j = true;
		while(a<b){
			if(a==mid) a++;
			if(b==mid) b--;
			if(children[a]+children[b]>m) j = false;
			a++; b--;
		}
		if(j && children[mid]+dp[n]<=m) r = mid;
		else l = mid;
	}
	if(r==len) judge = false;
	else dp[n] += children[r];
	if(n==1 && dp[n]>m) judge = false;
	return judge;
}

int main(){
	cin >> N;
	int a,b;
	for(int i=0;i<N-1;i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int A = 0,cnt = 0;
	for(int i=1;i<=N;i++){
		if(v[i].size()%2==1) cnt++;
	}
	A = cnt/2;
	int l = 0,r = N;
	while(l+1<r){
		dp[1] = 0;
		for(int i=2;i<=N;i++){
			visited[i] = 0; dp[i] = 1;
		}
		int m = (l+r)/2;
		if(ok(1,m)) r = m;
		else l = m;
	}
	cout << A << " " << r << endl;
}

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

typedef long long ll;

 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans = a + b;
  if(ans>b+c) ans = b+c;
  if(ans>a+c) ans = a+c;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int C[100][100];

int main()
{
  int H, W, N, a, n = 1, x = 0, y = 0;
  int l = 0, r, u = 0, d;
  int k = 0;
  cin >> H >> W >> N;
  r = W - 1;
  d = H - 1;

  for(int i = 0; i < N; i++) {
    cin >> a;
    for(; a > 0; a--) {
      C[x][y] = n;
      switch(k) {
        l1:
        case 0:
          if(x != r) { x++; break; }
          else { u = y + 1; k = 1; a++; continue; }
        case 1:
          if(y != d) { y++; break; }
          else { r = x - 1; k = 2; a++; continue; }
        case 2:
          if(x != l) { x--; break; }
          else { d = y - 1; k = 3; a++; continue; }
        case 3:
          if(y != u) { y--; break; }
          else { l = x + 1; k = 0; a++; continue; }
      }
    }
    n++;
  }

  for(y = 0; y < H; y++) {
    for(x = 0; x < W; x++) {
      cout << C[x][y] << (x == W - 1 ? '\n' : ' ');
    }
  }

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main()
{
	char str[100001];
	gets(str);
	int len=strlen(str),ans=0,i;
	for(i=0;i<len-1;i++)
		if(str[i]!=str[i+1])
			ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef vector<int > vecint;
typedef vector<ll > vecll;
typedef vector<vector<int > > vec2int;
typedef vector<bool > vecbool;
typedef vector<string > vecstr;
////////////////////////////////////////////////
int main()
{
  int n;
  cin >> n;
  string s; cin >> s;
  vecint x(n + 1,0); // num of 'W' 
  vecint y(n + 1,0);
  REP(i,n){
    x[i + 1] = x[i] + (int)(s[i] == 'W');
    y[i + 1] = i + 1 - x[i + 1];
  }
  // REP(i,n + 1){
  //   y[i] = i - x[i];
  // }

  int ans = 1e9;
  int tmp = 0;
  // REP(i,n + 1){
  //   cout << i;
  // }
  // cout << endl;
  // REP(i,n + 1){
  //   cout << x[i];
  // }
  // cout << endl;
  // REP(i,n + 1){
  //   cout << y[i];
  // }
  // cout << endl;
  REP(i,n){
    tmp = x[i];
    tmp += y[n] - y[i + 1];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


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

int main() {
  int X;
  cin >> X;
  for (int A = -1000; A <= 1000; A++) {
    for (int B = -1000; B <= 1000; B++) {
      if (pow(A, 5) - pow(B, 5) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	K--;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int ans = INT_MAX;
	sort(h.begin(), h.end());
	for (int i = 0; i + K < N; i++) {
		ans = min(ans, h[i+K] - h[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
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();

		Long[] HP = new Long[N];

		for (int i = 0; i < N; i++) {
			HP[i] = sc.nextLong();
		}

		Arrays.sort(HP);

		long cnt = 0;
		if (N > K) {
			for (int i = 0; i < (N - K); i++) {
				cnt += HP[i];
			}
		}

		System.out.print(cnt);

		sc.close();

	}

}

Measured memory_bytes: 95672
N = gets.to_i
a = gets.split.map(&:to_i)
c = 0
d = 0
for i in 0..N-1
    for j in i..N-1
        if a[i] > a[j]
            b = a[j]
            a[j] = a[i]
            a[i] = b
        end
    end
    # puts a[i]
end

# for k in (N-1)..0
#     if k % 2 == 1
#         c += a[k]
       
#     else
#         d += a[k]
#     end
# end

# for k in 0..N-1
#     if k % 2 == 1
#         B += a[N-k-1]
#     else
#         A += a[N-k-1]
#     end
# end

k = 1
while k < N
    c += a[N-k]
    d += a[N-k-1]
    k += 2
end 
if N % 2 == 1
    c += a[0]
end
print c-d

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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 300005
int n,m;
int a[MN],t[MN],c[MN];lg res;
int LtL[MN],RtR[MN];
int main(){
	read(n);read(m);
	for(int i=1;i<=n;++i)read(a[i]);
	for(int i=1;i<=n;++i)read(t[i]);
	for(int i=1;i<=n;++i){
		int G=t[i]%(m*2);res+=t[i]/(m*2);
		if(G==0)c[i]=1;
		if(G<=a[i]*2)RtR[i]=1;
		if(G<=m*2-a[i]*2)LtL[i]=1;
	}
	res+=2-LtL[n];int remLtL=0,rem=0;
	for(int i=n-1;i;--i)if(!c[i]){
		if(RtR[i]){
			if(remLtL){
				--remLtL;if(LtL[i])++rem;
			}else{
				++res;if(LtL[i])++remLtL;else if(rem)--rem,++remLtL;
			}
		}else{
			++res;if(LtL[i])++remLtL;
		}
	}
	cout<<res*2*m;
	return 0;
}


Measured memory_bytes: 6144
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def main():
    n = int(input())

    connect = [[] for _ in range(n+1)]
    color = [None]*(n+1)
    color[1] = 0

    for _ in range(n-1):
        u, v, length = map(int, input().split())
        w = length % 2
        connect[u].append((v, w))
        connect[v].append((u, w))

    def dfs(now=1, prev=-1):
        kids = connect[now]
        for kid in kids:
            if kid[0] == prev:
                continue
            if kid[1] == 0:
                color[kid[0]] = (0, 1)[color[now]]
            else:
                color[kid[0]] = (1, 0)[color[now]]
            dfs(kid[0], now)

    dfs()
    for i in range(1, n+1):
        print(color[i])


if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

ll ngcd(vector<ll> a)
{
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size() && res != 1; i++)
  {
    res = gcd(a[i], res);
  }
  return res;
}

//実行部
void Main()
{
  ll n; cin >> n;
  vll a(n); rep(i, n) cin >> a[i];
  fin(ngcd(a));
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  int dx[] = {1, 0, -1, 0};
  int dy[] = {0, 1, 0, -1};
  char c;
  queue<pair<int, int>> q;
  cin >> h >> w;
  vector<vector<int>> v(h+2, vector<int>(w+2, 0));
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <=w; ++j) {
      cin >> c;
      if (c == '.') v[i][j] = -1;
      else q.emplace(i, j);
    }
  }
  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();
    for (int i = 0; i < 4; ++i) {
      if (v[y + dy[i]][x + dx[i]] == -1) {
        v[y + dy[i]][x + dx[i]] = v[y][x] + 1;
        q.emplace(y + dy[i], x + dx[i]);
      }
    }
  }
  int mx = 0;
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      mx = max(mx, v[i][j]);
    }
  }
  cout << mx << endl;
}

Measured memory_bytes: 12432
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, a, b; cin >> n >> a >> b;
    cout << (n * a < b ? n * a : b) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int a[N];
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
  bool q[110];
  f(i,110)q[i]=false;
  f(i,9){
f(j,9){
  q[(i+1)*(j+1)]=true;
}
  }
	scanf("%d", &n);
	if(q[n])printf("Yes\n");
  else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
from collections import Counter
n=int(input())
string_list = [input() for i in range(n)]
str_count = Counter(string_list).most_common()
max = []
for i in str_count:
    if i[1] == str_count[0][1]:
        max.append(i[0])
    else:
        break
max.sort()
for w in max:
    print(w)


Measured memory_bytes: 45040
#include<iostream>
using namespace std;
int main(void)
{
    int t,n;
    for(int i=0;i<4;i++){
        cin>>t>>n;
        if(t==1)cout<<n*6000<<"\n";
        else if(t==2)cout<<n*4000<<"\n";
        else if(t==3)cout<<n*3000<<"\n";
        else cout<<n*2000<<"\n";
        }
}

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

E = []
for p in P:
  E.append((p+1)*p/2/p)
csum = [0]
for i in range(N):
  csum.append(csum[-1]+E[i])
mx = 0
for i in range(N-K+1):
  mx = max(csum[K+i]-csum[i],mx)
print(mx)


Measured memory_bytes: 78984
#include <iostream>
#include <vector>
#include <string>

using ll = long long;

void print(){ std::cout << std::endl; }
template< typename H > void print(H head){std::cout << head << std::endl;}
template< typename H, typename... T > void print(H head, T... tail) {std::cout << head << " ", print(tail...); }

int main()
{
  ll N;
  std::cin >> N;

  ll ans = (N + 1) / 2;
  print(ans);
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var ans = 0;

            for (int i = 0; i < 5; i++)
            {
                if (cin.ReadInt == 0) ans = i + 1;
            }

            WriteLine(ans);
            
        }

        public void Display(int[] array)
        {
            var txt = "";
            foreach (var item in array)
            {
                txt += " " + item.ToString();
            }
            WriteLine("{0}", txt);
        }

        public void Display(int index,int[] array)
        {
            var txt = "";
            foreach (var item in array)
            {
                txt += " " + item.ToString();
            }
            WriteLine("{0} : {1}", index,txt);
        }

        public void Display(List<int>[] list) 
        {
            for (int i = 0; i < list.Length; i++)
            {
                Display(i, list[i].ToArray());
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 27796
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;



Int maxdeg[108];

Int n, a, b;
vector<Int> edge[108];
Int color = INF, leaf = LINF;

void dfs(Int x, Int last = -1, Int dep = 0){
  if(last == -1 && dep == 0)maxdeg[dep] = max(maxdeg[dep], (Int)edge[x].size());
  else maxdeg[dep] = max(maxdeg[dep], (Int)edge[x].size() - 1);
  for(Int to:edge[x]){
    if(to == last)continue;
    dfs(to, x, dep+1);
  }
}

void go(Int l){
  Int c = 0;
  while(maxdeg[c] != 0)c++;
  for(Int i = 0;i < c;i++){
    l *= maxdeg[i];
  }
  if(c < color){
    leaf =l;
    color = c;
  }
  if(c == color){
    leaf = min(l, leaf);
  }
}

int main(){
  cin >> n;
  for(Int i = 0;i < n-1;i++){
    cin >> a >> b;a--,b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  for(Int i = 0;i < n;i++){
    for(Int to:edge[i]){
      fill(maxdeg, maxdeg + 108, 0);
      dfs(i, to);
      dfs(to, i);
      go(2);
    }
    fill(maxdeg, maxdeg + 108, 0);
    dfs(i);
    go(1);
  }
  cout << color + 1 << " " << leaf << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int x,y;
	cin >> x >> y;
	cout << (abs(x-y)) << endl;
	return 0;
}



Measured memory_bytes: 3092
n = int(input())
s = input()
l = [[False]*10 for i in range(n)]
r = [[False] * 10 for i in range(n)]
total = set()
for i in range(1, n):
    l[i] = l[i - 1][:]
    l[i][int(s[i-1])] = True
for i in range(n-2, -1, -1):
    r[i] = r[i + 1][:]
    r[i][int(s[i+1])] = True
for i in range(1, n - 1):
    for j in range(10):
        if not l[i][j]:
            continue
        for k in range(10):
            if not r[i][k]:
                continue
            total.add((j, int(s[i]), k))
print(len(total))


Measured memory_bytes: 15092
<?php
  
$n = trim(fgets(STDIN));
$nn = $n;

$c = 0;
while($n>=1){
  if ($n/10 < 1) break;
  $n = $n/10;
  $c++;
}

$ans = 0;
for($i=1; $i<=$c; $i++){
  if ($i%2==1) $ans += 10**$i - 10**($i-1);
}

if ($c%2==0){
  $ans += $nn - 10**$c + 1;
} 

echo $ans;
  
?>

Measured memory_bytes: 4604
N = int(input())
a = [0] * N
b = [[] for _ in range(N)]
for _ in range(N-1):
    x,y,z = map(int, input().split())
    x -= 1
    y -= 1
    b[x].append((y, z))
    b[y].append((x, z))


l = [(0, -1, 0)]
while l:
    x, s, t = l.pop()
    if t % 2 == 0:
        a[x] = 0
    else:
        a[x] = 1
    for v, w in b[x]:
        if v == s:
            continue
        l.append((v, x, t + w))

for x in a:
    print(x)

Measured memory_bytes: 38828
a,b=map(str,input().split())
List = ["A","B","C","D","E","F"]
if a == b:
  print("=")
c = 0
d = 0
for i in range(6):
  if a == List[i]:
    c = i
  if b == List[i]:
    d = i
if c < d:
  print("<")
elif d < c:
  print(">")

Measured memory_bytes: 8896
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    // K = N
    ans++;
    // K^2 <= N
    for (ll K = 2; K*K <= N; K++) {
        ll n = N;
        while (n % K == 0) {
            n /= K;
        }
        if (n % K == 1) {
            ans++;
        }
    }
    ll K0 = 1;
    while (K0 * K0 <= N) {
        K0++;
    }
    // N-1の約数、K^2 > N
    for (ll L = 1; L*L <= N-1; L++) {
        if ((N-1) % L != 0) {
            continue;
        }
        ll K = (N-1) / L;
        if (K >= K0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 504
#include<iostream>
#include<cmath>
#include<iomanip>
#include <complex>
using namespace std;
 
int main(){
	long long a, b, h, m;
	double r,rad,c;

	cin >> a >> b >> h >> m;

	r = fabs(static_cast<double>(6.0 * m - 0.5 * (h * 60.0 + m)));

	if(r == 0.0) {
		c = fabs(b - a);
		cout << c;
		return 0;
	}else if(r == 180.0){
		c = b + a;
		cout << c;
		return 0;
	}else if(r > 180.0){
		r = 360.0 - r;
	}

	rad = static_cast<double>(r * M_PI / 180.0);

	c = static_cast<double>(sqrt(a*a + b*b - 2*a*b*cos(static_cast<double>(rad))));

	cout << fixed << setprecision(20) << c << endl;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int a,b,c,d;

  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);

  if(abs(a-c)<=d)printf("Yes");
  else if(abs(a-b)<=d&&abs(c-b)<=d)printf("Yes");
  else printf("No");

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int d;
    std::string result;
    cin >> d;
    if (d == 25)
        result = "Christmas";
    else if (d == 24)
        result = "Christmas Eve";
    else if (d == 23)
        result = "Christmas Eve Eve";
    else if (d == 22)
        result = "Christmas Eve Eve Eve";

    cout << result << endl;
    return 0;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

bool in_num(int a, int b, int c)
{
  if (b <= a && a <= c)
    return true;
  else
    return false;
}

int rate(int a)
{
  if (in_num(a, 1, 399))
    return 0;
  else if (in_num(a, 400, 799))
    return 1;
  else if (in_num(a, 800, 1199))
    return 2;
  else if (in_num(a, 1200, 1599))
    return 3;
  else if (in_num(a, 1600, 1999))
    return 4;
  else if (in_num(a, 2000, 2399))
    return 5;
  else if (in_num(a, 2400, 2799))
    return 6;
  else if (in_num(a, 2800, 3199))
    return 7;
  else
    return 8;
}

int main()
{
  int n, a, count_f = 0, tmp, ans = 0;
  vector<bool> flag(8, false);

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    tmp = rate(a);
    if (tmp == 8)
      count_f++;
    else
    {
      if (!flag[tmp])
      {
        flag[tmp] = true;
        ans++;
      }
    }
  }
  cout << max(1, ans) << ' ' << ans + count_f << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void){
  long double W,H,x,y;
  scanf("%Le%Le%Le%Le",&W,&H,&x,&y);

  printf("%Lf ",W*H/2);

  if(W/2==x){
    if(H/2==y){
      printf("1\n");
      return 0;
    }
  }
  printf("0");
  return 0;
 }


Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std ;
using ll = long long ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using pll = pair<ll,ll> ;
const int INF = 1e9 ;
void chmin(int &a,int b){if(a>b) a = b ;}
void chmax(ll &a,ll b){if(a<b) a = b ;}
void YorN(bool a){cout << (a?"YES":"NO") << "\n" ;}

int main(){
	int n ; cin >> n ;
	while(n%2==0) n /= 2 ;
	while(n%5==0) n /= 5 ;
	vll a(n,INF) ;
	priority_queue<pll> q ;
	q.emplace(-1,1) ;
	while(!q.empty()){
		ll p = q.top().second%n ;
		ll cost = -q.top().first ;
		q.pop() ;
		if(a[p]!=INF) continue ;
		a[p] = cost ;
		q.emplace(-cost,p*10) ;
		if(p%10!=9) q.emplace(-cost-1,p+1) ;
	}
	cout << a[0] << endl ;
	// for(auto i:a) cout << i << " " ; cout << endl ;
}

Measured memory_bytes: 5968
N = int(input())
grid = [list(map(int, input().split())) for _ in range(N)]

t = [0] + [col[0] for col in grid]
xs = [0] + [col[1] for col in grid]
ys = [0] + [col[2] for col in grid]

res = 'Yes'
for i in range(N):
    interval = t[i+1] - t[i]
    x_dist = xs[i+1] - xs[i]
    y_dist = ys[i+1] - ys[i]
    dist = x_dist + y_dist
    if dist == 0 and interval % 2 == 1:
        res = 'No'
        break
    if dist > interval or dist % 2 != interval % 2:
        res = 'No'
        break

print(res)

Measured memory_bytes: 30440