akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    char a,b,c;
    cin >> a >> b >> c;
    if(a!=b||b!=c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

// UnionFind
class UnionFind {
  private:
  std::vector<long long> uni;
  long long num;

  public:
  UnionFind(long long s) : uni(s, -1), num(s) {}

  //頂点aが所属するグループ
  long long root(long long a) {
    if (uni[a] < 0) {
      return a;
    }
    return uni[a] = root(uni[a]);
  }

  // a,bをつなげる
  bool connect(long long a, long long b) {
    a = root(a);
    b = root(b);
    if (a == b) {
      return false;
    }

    if (uni[a] > uni[b]) {
      std::swap(a, b);
    }

    uni[a] += uni[b];
    uni[b] = a;
    return true;
  }

  // a,bが同グループか確認
  bool isConnect(long long a, long long b) { return root(a) == root(b); }

  // aが属するグループの要素数
  long long size(long long a) { return -uni[root(a)]; }

  //グループ数を返す
  long long groups() {
    std::set<long long> b;
    for (long long i = 0; i < num; i++) {
      b.insert(root(i));
    }
    return b.size();
  }
};
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  ll w,h;
  std::cin>>w>>h;

  std::vector<P> edge(w+h);

  rep(i,0,h+w){
    ll p;
    std::cin>>p;
    edge[i]={p,i};
  }

  std::sort(all(edge));

  ll x=w+1,y=h+1;
  ll ans=0;

  rep(i,0,h+w){
    if(edge[i].second>=w){
      ans+=x*edge[i].first;
      y--;
    }else{
      ans+=y*edge[i].first;
      x--;
    }
  }

  std::cout<<ans;

  return 0;
}

Measured memory_bytes: 3328
# include<iostream>
using namespace std;
void insertion_sort(int A[], int n){
    for(int i=1; i<n; i++){
        for(int j=0; j<n-1; j++) cout << A[j] <<" ";
        cout << A[n-1] <<"\n";
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
    }
}
int main(){
    int A[1000];
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    insertion_sort(A,n);
    for(int j=0; j<n-1; j++) cout << A[j] <<" ";
    cout << A[n-1] <<"\n";
    return 0;
}


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

int main() {
	int t,z,s,y,h;
	cin>>t>>z>>s>>y>>h;
	if(t<40){
		t=40;
	}
	if(z<40){
			z=40;
		}
	if(s<40){
			s=40;
		}
	if(y<40){
			y=40;
		}
	if(h<40){
			h=40;
		}
	cout<<(t+z+s+y+h)/5<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

void solve(int N, int D, vector<vector<int>> X) {
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int tmp = 0;
      for (int k = 0; k < D; k++) {
        tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      float r = sqrt(float(tmp));
      if ((int)r * (int)r == tmp) {
        ans += 1;
      }
    }
  }

  printf("%d\n", ans);
}

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      int x;
      cin >> x;
      X[i].push_back(x);
    }
  }
  solve(N, D, X);
  return 0;
}

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

int n;
vector<vector<int>> item_map(15);

void out_honests(vector<int> honests){
    rep(i,n) cout << honests[i] << " ";
    cout << endl;
}

// 
int bfs(vector<int> honests, int i) {
    // 最後までできたらカウントして返す
    if(i==n){
        // out_honests(honests);
        int cnt = 0;
        rep(j,n){
            if(honests.at(j) == 1) cnt++;
        }
        return cnt;
    }

    int cnt1 = -1;
    if(honests.at(i) != 1){
        vector<int> honests2(n);
        rep(j,n) honests2.at(j) = honests.at(j);
        honests2.at(i) = 0;
        // cout << "(0)";
        // out_honests(honests2);
        cnt1 = bfs(honests2, i+1);
    }

    int cnt2 = -1;
    if(honests.at(i) != 0){
        // 要素コピー
        vector<int> honests3(n);
        rep(j,n) honests3.at(j) = honests.at(j);
        honests3.at(i) = 1;
        bool ok_fl = true;
        rep(j,n){
            if((honests3.at(j) != -1) && (item_map.at(i).at(j) != -1) && (honests3.at(j) != item_map.at(i).at(j))){
                ok_fl = false;
                break;
            }else {
                honests3.at(j) = max(honests3.at(j),item_map.at(i).at(j));
            }
        }
        // cout << "(1)";
        // out_honests(honests3);
        if(ok_fl){
            cnt2 = bfs(honests3, i+1);
        }
    }
    
    return max(cnt1,cnt2);
}

int main() {
    cin >> n;
    rep(i,n){
        vector<int> p(n);
        rep(j,n){
            p.at(j) = -1;
        }
        int m;
        cin >> m;
        rep(j,m){
            int a,b;
            cin >> a >> b;
            p.at(a-1) = b;
        }
        item_map.at(i) = p;
    }
    
    // rep(i,n){
    //     rep(j,n){
    //         if(item_map[i][j] == -1) cout << '-';
    //         else cout << item_map[i][j];
    //         cout << " ";
    //     }
    //     cout << endl;
    // }
    vector<int> h(n);
    rep(i,n) {
        h.at(i) = -1;
    }
    int cnt = bfs(h,0);
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <ctime>
#include <fstream>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <utility>
#include <cctype>
#include <list>
#include <bitset>
#include <unordered_set>

using namespace std;

#define FORALL(i,a,b) for(int i=(a);i<=(b);++i)
#define FOR(i,n) for(int i=0;i<(n);++i)
#define FORB(i,a,b) for(int i=(a);i>=(b);--i)

typedef long long ll;
typedef long double ld;
typedef complex<ld> vec;

typedef pair<ll,int> plli;
typedef pair<int,int> pii;
typedef map<int,int> mii;

#define pb push_back
#define mp make_pair

#define MAXN 3005

int s[MAXN][MAXN];
int choose[MAXN][MAXN];
int two_to_x_mod_pm1[MAXN];
int two_to_two_to_n[MAXN];
int two_to_n[MAXN*MAXN];

int pw(int a, int p, int PRIME) {
  if (p==0) return 1%PRIME;
  int x = pw(a,p/2,PRIME);
  x = 1ll*x%PRIME*x%PRIME;
  if (p%2) x = 1ll*x%PRIME*a%PRIME;
  return x;
}

int main() {
  int N,PRIME;
  scanf("%d%d",&N,&PRIME);

  two_to_x_mod_pm1[0] = 1%(PRIME-1);
  FORALL(n,1,MAXN-1) {
    two_to_x_mod_pm1[n] = two_to_x_mod_pm1[n-1]*2%(PRIME-1);
  }

  // init choose[n][k]
  memset(choose,0,sizeof(choose));
  FORALL(n,0,MAXN-1) {
    choose[n][0] = 1;
    FORALL(k,1,n) choose[n][k] = (choose[n-1][k-1] + choose[n-1][k])%PRIME;
  }

  // init stirling[n][k]
  memset(s,0,sizeof(s));
  FORALL(n,0,MAXN-1) {
    s[n][0] = 1;
    FORALL(k,1,n) s[n][k] = (s[n-1][k-1] + 1ll*(k+1)*s[n-1][k])%PRIME;
  }

  // init two_to_two_to_n
  FORALL(n,0,MAXN-1) {
    two_to_two_to_n[n] = pw(2, two_to_x_mod_pm1[n], PRIME);
  }

  // init two_to_n
  two_to_n[0] = 1%PRIME;
  FORALL(n,1,MAXN*MAXN - 1) {
    two_to_n[n] = two_to_n[n-1]*2ll%PRIME;
  }

  int ans = 0;
  int mult = 1;
  FORALL(c,0,N) {
    FORALL(k,0,c) {

      ll here = 1ll * choose[N][c] % PRIME * s[c][k] % PRIME * two_to_two_to_n[N-c] % PRIME * two_to_n[k*(N-c)] % PRIME;
      ans = (1ll*ans + PRIME + 1ll*mult * here%PRIME)%PRIME;
    }

    mult = 1ll*mult*(PRIME-1)%PRIME;
  }

  cout << ans << endl;
}














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

int main(void)
{
	int length[12];

	int i, j;

	for (i = 0; i < 12; i++)
	{
		cin >> length[i];
	}

	sort(length, length + 12);

	int check = 0;
	for (i = 0; i < 12; i += 4)
	{
		if (length[i] == length[i + 1] && length[i] == length[i + 2] && length[i] == length[i + 3])
		{
			check++;
		}
	}

	if (check == 3)
	{
		cout << "yes\n";
	}
	else
	{
		cout << "no\n";
	}

	return 0;
}


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

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double deg = (h + m / 60) * 30 - m * 6;
  double rad = deg * acos(-1) / 180;
  double c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
  printf("%.10f\n", c);
  return 0;
}

Measured memory_bytes: 4136
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>
 
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
 
#include <math.h>
#include <complex>
 
#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>
 
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
 
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
 
void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}
 
const int N = 1e5;
LL dp[N + 5];
vector<LL> vec[N + 5];
LL up[N + 5];
LL MOD;
 
LL ST[4 * N + 5];
 
void dfs(int idx,int pre) {
	dp[idx] = 1;
	for(int i = 0;i < vec[idx].size();i++) {
		int nx = vec[idx][i];
		if(nx == pre) continue;
		dfs(nx,idx);
		dp[idx] = dp[idx] * (dp[nx] + 1) % MOD;
	}
}
 
void build(int a, int idx,int l,int r) {
	if(l > r) return ;
	if(l == r){
		ST[idx] = (dp[vec[a][l]] + 1) % MOD;
		return ;
	}
	int mid = (l + r) / 2;
	build(a,2 * idx, l, mid), build(a,2 * idx + 1,mid + 1,r);
	ST[idx] = ST[2 * idx] * ST[2 * idx + 1] % MOD;
}
 
LL query(int idx,int l,int r,int tar) {
	if(r < tar || l > tar) return ST[idx];
	if(l == tar && r == tar) return 1;
	int mid = (l + r) / 2;
	return query(2 * idx,l,mid,tar) * query(2 * idx + 1,mid + 1,r,tar) % MOD;
}
 
void dfs2(int idx,int pre) {
	if(idx != pre) swap(up[idx], dp[pre]);
	build(idx,1,0,(int)vec[idx].size() - 1);
	for(int i = 0;i < vec[idx].size();i++) {
		int nx = vec[idx][i];
		if(nx == pre) continue;
//		cout<<"NX "<<nx<<" "<<(query(1,0,vec[idx].size() - 1, i) + 1)<<endl;
		up[nx] = (query(1,0,(int)vec[idx].size() - 1, i)) % MOD;
	}
	for(int i = 0;i < vec[idx].size();i++) {
		int nx = vec[idx][i];
		if(nx == pre) continue;
		dfs2(nx,idx);
	}
	if(idx != pre) swap(up[idx], dp[pre]);
}
 
void hora(int tc) {
	int n;
	cin>>n>>MOD;
	for(int i = 1;i < n;i++) {
		int x,y;
		cin>>x>>y;
		vec[x].PB(y);
		vec[y].PB(x);
	}
	dfs(1,1);
	up[1] = 0;
	dfs2(1,1);
	for(int i = 1;i <= n;i++) {
		cout<<dp[i] * (up[i] + 1) % MOD<<endl;
	}
}
 
int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}
 

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if (a==b)
		cout<<"1"<<endl;
	else
	{
		int ans=0;
		while(b>1)
		{
			ans++;
			b-=(a-1);
		}
		cout<<ans<<endl;
	} 
    return 0;
}


Measured memory_bytes: 256
N, x = [int(n) for n in input().split()]
a = [int(n) for n in input().split()]

res = 0
if a[0] > x:
    res += a[0] - x
    a[0] = x

for i in range(1, N):
    if a[i-1] + a[i] > x:
        res += a[i] - (x - a[i-1])
        a[i] = x - a[i-1]

print(res)


Measured memory_bytes: 14052
import java.io.*;
import java.util.*;
import java.math.*;

 
 public class Main	{
   static class Pair implements Comparable<Pair>{
   int a;
   int b;
   public Pair(int x,int y){a=x;b=y;}
   public Pair(){}
   public int compareTo(Pair p){
      return Integer.compare(a, p.a);
   }
 }
static class TrieNode{
  TrieNode[]child;
  int w;
  boolean term;
  TrieNode(){
    child = new TrieNode[26];  
  }
}
  public static int gcd(int a,int b)
  {
    if(a<b)

      return gcd(b,a);
    if(b==0)
      return a;
    return gcd(b,a%b);
    
  }
  //static long ans = 0;
  static long mod =(long)(1e9+7); //998244353;//
   
    public static void main(String[] args) throws Exception {
       new Thread(null, null, "Anshum Gupta", 99999999) {
            public void run() {
                try {
                    solve();
                } catch(Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }

static long pow(long x,long y){
    if(y == 0)return 1;
    if(y==1)return x;
    long a = pow(x,y/2);
    a = (a*a)%mod;
    if(y%2==0){
        return a;
    }
    return (a*x)%mod;
}

static long mxx;
static int mxN = (int)(1e5+5);
static long[]fact,inv_fact;
static long my_inv(long a) {
	return pow(a,mod-2);
}
static long bin(int a,int b) {
    return ((fact[a]*inv_fact[a-b])%mod * inv_fact[b])%mod;
}

static ArrayList<ArrayList<Integer>>adj ;

 public static void solve() throws Exception {
   // solve the problem here
   MyScanner s = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int t = 1;//s.nextInt();
        mxx = (long)(1e18+5);
 
        while(t-->0){
        	long r = s.nextInt();
        	out.println(3*r*r);
        }
           
        out.flush();
}
 
     
 
 
 
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
 
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
         
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}


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

using namespace std;

const int N = 1e5 + 5, mod = 1e9 + 7;

int x[N];

long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", x+i);
  }
  for (int i = 0; i + 1 < n; ++i) {
    x[i] = x[i+1] - x[i];
  }
  long long fact = 1;
  --n;
  for (int i = 1; i <= n; ++i)
    fact = fact * i % mod;
  long long now = 0, ans = 0;
  for (int i = 0; i < n; ++i) {
    now = (now + fact * powmod(i+1, mod-2)) % mod;
    ans = (ans + now * x[i]) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> A(N + 2);
  A[0] = A[N + 1] = 0;
  REP1(i, N)
  cin >> A[i];
  int S = 0;
  REP(i, N + 1)
  S += abs(A[i] - A[i + 1]);
  REP1(i, N)
  cout << S - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1])) + abs(A[i - 1] - A[i + 1]) << endl;
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

const ll INF = 1LL << 60;
const int MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl


int main() {
    int r, D, x0;
    cin >> r >> D >> x0;

    int tmp = x0;
    REPR(i, 1, 10) {
        tmp = r * tmp - D;
        cout << tmp << endl;
    }

    return 0;
}


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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;

//--------------------------- Solve ---------------------------//

using Graph = vector<vector<int>>;
Graph g;

mint dp[100005][2];
bool flag[100005][2];

mint rec(int v, int c, int p) {
    if (flag[v][c]) return dp[v][c];
    flag[v][c] = true;

    mint res = 1;
    for (auto e : g[v]) {
        if (e == p) continue;
        
        if (c == 0) res *= rec(e, 0, v) + rec(e, 1, v);
        else res *= rec(e, 0, v);
    }

    return dp[v][c] += res;
}

void solve() {
    int N; cin >> N;

    g.resize(N);

    for (int i = 0; i < N-1; i++) {
        int x, y; cin >> x >> y; x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    mint ans = rec(0, 0, -1) + rec(0, 1, -1);

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 18768
/*
  ID: ak260901
  TASK: a
  LANG: C++
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define foru(i, l, r) for(register ll i = l; i <= r; i++)
#define ford(i, r, l) for(register ll i = r; i >= l; i--)

typedef long long ll;
const ll inf = 1e14;
ll A, B, Q, X;
ll s[100005];
ll t[100005];

ll findt2(ll x) {
  ll l = 1, r = B + 2, res;
  while(l <= r) {
    ll mid = (l + r) >> 1;
    if(t[mid] < x) l = mid + 1;
    else r = mid - 1, res = mid;
  } return res;
}

ll finds2(ll x) {
  ll l = 1, r = A + 2, res;
  while(l <= r) {
    ll mid = (l + r) >> 1;
    if(s[mid] < x) l = mid + 1;
    else r = mid - 1, res = mid;
  } return res;
}

ll finds1(ll x) {
  ll l = 1, r = A + 2, res;
  while(l <= r) {
    ll mid = (l + r) >> 1;
    if(s[mid] > x) r = mid - 1;
    else l = mid + 1, res = mid;
  } return res;
}

ll findt1(ll x) {
  ll l = 1, r = B + 2, res;
  while(l <= r) {
    ll mid = (l + r) >> 1;
    if(t[mid] > x) r = mid - 1;
    else l = mid + 1, res = mid;
  } return res;
}

int main() {
  //freopen("a.in", "r", stdin);
  //freopen("a.out", "w", stdout);
  scanf("%lld%lld%lld", &A, &B, &Q);
  for(ll i = 2; i <= A + 1; i++) scanf("%lld", &s[i]);
  for(ll i = 2; i <= B + 1; i++) scanf("%lld", &t[i]);
  s[1] = -inf; s[A + 2] = inf; sort(s + 1, s + A + 1);
  t[1] = -inf; t[B + 2] = inf; sort(t + 1, t + B + 1);
  while(Q--) {
    scanf("%lld", &X);
    ll sum = inf;
    ll st_1 = finds1(X); st_1 = s[st_1];
    ll st_2 = finds2(X); st_2 = s[st_2];
    ll st_3 = findt1(X); st_3 = t[st_3];
    ll st_4 = findt2(X); st_4 = t[st_4];
    sum = min(sum, X - min(st_1, st_3));
    sum = min(sum, max(st_2, st_4) - X);
    sum = min(sum, (X - st_1) * 2 + st_4 - X);
    sum = min(sum, (st_4 - X) * 2 + X - st_1);
    sum = min(sum, (X - st_3) * 2 + st_2 - X);
    sum = min(sum, (st_2 - X) * 2 + X - st_3);
    printf("%lld\n", sum);
  }
  return 0;
}


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {

	static int N,T,H,L;
	static int[][] person;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		N=cin.nextInt();
		T=cin.nextInt();
		H=cin.nextInt();
		L=cin.nextInt();
		person=new int[N][2];
		for(int i=0;i<N;i++){
			person[i][0]=cin.nextInt();
			person[i][1]=cin.nextInt();
		}
		int p=0;
		int current=0;
		while(true){
//			System.out.println(p+" "+person[p][0]+" "+person[p][1]+" "+current);
			if(person[p][0]+person[p][1]==0){
				break;
			}			
			boolean pay=false;
			//10yen
			if(person[p][0]!=0){
				person[p][0]--;
				current+=10;
				T++;
				pay=true;
			}
			
			//is broken
			if(T>L){
				break;
			}
			
			//100yen
			if(!pay){
				if(current!=90&&person[p][1]!=0){
					current+=100;
					person[p][1]--;
					H++;
				}
				
			}
			
			//おつり
			if(current==90){
				current=0;
			}
			else if(current<90){
				
			}
			else{
				int oturi=(current-90)/10;
				current=0;
				if(oturi>=10){
					if(H==0)break;
					H--;
					oturi-=10;
					person[p][1]++;
					if(oturi > T)break;
					person[p][0]+=oturi;
					T-=oturi;
				}
				else{
					if(oturi > T)break;
					person[p][0]+=oturi;
					T-=oturi;
				}
			}
			p=(p+1)%N;
		}
		System.out.println(p+1);
	}

}

Measured memory_bytes: 20204
n = int(input())
a = [int(i) for i in input().split()]

if n == 1:
    print(0)
    exit()

val = []

for i in range(n):
    val.append(a[i]-i)

val.sort()
#print(val)

#idx = [(val[0],0)]
idx = []
cnt = 1
for i in range(n-1):
    if val[i] == val[i+1]:
        #cnt += 1
        if i == n-2:
            idx.append((val[i+1],i+2))
        continue
    else:
        if i == n-2:
            idx.append((val[i],i+1))
            idx.append((val[i+1],i+2))
        else:
           idx.append((val[i],i+1)) 
        #cnt = 1
        
ans_val = 0
ans2_val = 0
ans3_val = 0

flag2 = False
flag3 = False

for i in range(len(idx)):
    if idx[i][1] >= (n+1) // 2:
        ans_val = idx[i][0]
        """
        #print(i-1)
        if i-1 >= 0:
            flag2 = True
            ans2_val = idx[i-1][0]
        
        if i+1 <= len(idx)-1:
            flag3 = True
            ans3_val = idx[i+1][0]
        """
        break

#print(idx,ans_val,ans2_val)
#exit()
     
ans = 0
ans2 = 10**20
ans3 = 10**20
for i in range(n):
    ans += abs(a[i]-ans_val-i)
    if flag2 == True:
        ans2 += abs(a[i]-ans2_val-i)
    if flag3 == True:
        ans3 += abs(a[i]-ans3_val-i)
    


print(ans)

Measured memory_bytes: 39620
#include <iostream>
using namespace std;
int d, g, s, p[15], c[15], dp[1005];
int main() {
	int i, j, k;
	cin>>d>>g;
	for(i=1; i<=d; i++) cin>>p[i]>>c[i];
	for(i=1; i<=d; i++) {
		s += p[i];
		for(j=s; j>0; j--) for(k=1; k<=p[i] && k<=j; k++) {
			dp[j] = max(dp[j], dp[j-k] + k*100*i + (k==p[i])*c[i]);
		}
	}
	for(i=1; dp[i]<g; i++);
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Val>
struct BinaryIndexedTree {
    int n;
    vector<Val> t;
    BinaryIndexedTree() {}
    BinaryIndexedTree(int _n) :n(_n + 1), t(_n + 1) {}
    void add(int k, Val val) {
        k++;
        while (k < n) {
            t[k] += val;
            k += (k&-k);
        }
    }
    void set(int k, Val val) {
        add(k, -sum(k, k + 1));
        add(k, val);
    }
    Val sum(int k) {
        Val r = 0;
        while (k > 0) {
            r += t[k];
            k -= (k&-k);
        }
        return r;
    }
    Val sum(int l, int r) {
        return sum(r) - sum(l);
    }
};
typedef BinaryIndexedTree<int> BIT;

const ll INF = 1ll << 60;
ll dp[2001][2001];

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

    int N;
    cin >> N;
    vector<char> C(2*N);
    vi A(2*N), wk(N), bk(N);
    rep(i, 2*N) {
        cin >> C[i] >> A[i];
        --A[i];
        if (C[i] == 'W')wk[A[i]] = i;
        else bk[A[i]] = i;
    }


    rep(i, N + 1)rep(j, N + 1)dp[i][j] = INF;
    dp[0][0] = 0;
    BIT bit(2 * N);
    rep(i, 2 * N)bit.add(i, 1);

    rep(w, N+1) {
        rep(b, N+1) {
            if (w < N) {
                ll x = bit.sum(wk[w]);
                smin(dp[w + 1][b], dp[w][b] + x);
            }
            if (b < N) {
                ll x = bit.sum(bk[b]);
                
                smin(dp[w][b + 1], dp[w][b] + x);
            }

            if (b < N)bit.add(bk[b], -1);

        }
        rep(b, N)bit.add(bk[b], 1);


        if(w<N)bit.add(wk[w], -1);
    }

    cout << dp[N][N] << endl;
}

Measured memory_bytes: 31616
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら4321)
    return *((int*)b)- *((int*)a);
}

#define MIN(a,b)  ( ((a)>(b))?(b):(a) )

int main(){
    int A[100];
    int N;
    int bPermEnt=1;

    scanf("%d%*c", &N);
    InputIntAry(A,10,N);
    for(int i=0;i<N;i++){
        if((A[i]%2==0) && (A[i]%3!=0) && (A[i]%5!=0)){
            bPermEnt=0;
        }
    }
    puts((bPermEnt)?("APPROVED"):("DENIED"));

    return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;

		int* word = new int[N];
		for (int i = 0; i < N; i++) word[i] = i + 1; //まず0番目の単語を入れておく

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
			}
			else {
				bubblenum = bubblehist.rbegin()->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			bubblehist.insert(--it, p);
			for (map<int, int>::iterator it2 = bubblehist.upper_bound(word[i]); it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}

		delete[] word;
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << "\n";
	}

	delete[] factmodary;
	return 0;
}

Measured memory_bytes: 6860
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1e9 + 7)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  vector<int> WA(N, 0);
  vector<bool> AC(N, false);
  REP(i, M){
    int tmp1; cin >> tmp1;
    string tmp2; cin >> tmp2;
    tmp1--;
    if(tmp2 == "WA" && AC[tmp1] == false) WA[tmp1]++;
    if(tmp2 == "AC") AC[tmp1] = true;
  }
  int cnt1 = 0, cnt2 = 0;
  REP(i, N){
    if(AC[i]){
      cnt1++;
      cnt2 += WA[i];
    }
  }
  cout << cnt1 << " " << cnt2 << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int x = sc.nextInt();
  int a = sc.nextInt();
  int b = sc.nextInt();
  if(Math.abs(x-a) > Math.abs(x-b))
    System.out.println("B");
  else System.out.println("A");
}
}

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

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

  int ans = 1;
  int max_count = 0;
  for (int i = 1; i <= N; i++) {
    int j = i;
    int count = 0;
    while (j != 1) {
      if (j % 2 == 0) {
        count++;
        j = j / 2;
      } else {
        break;
      }
    }
    if (max_count < count) {
      max_count = count;
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int N, C, K, nt,np = 1, ans = 1, s[114514];
	cin >> N >> C >> K;
	REP(i, N) cin >> s[i];
	sort(s, s + N);
	nt = s[0];
	REPO(i, N - 1) {
		np++;
		if (np > C or s[i] - nt > K) {
			ans++;
			np = 1;
			nt = s[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <math.h>

int main(){
    long long int n;
    long long int ans=10;
    long long int diff1 = 9;
    long long int diff2 = 8;
    long long int diff;
    scanf("%lld",&n);

    for(int i=1; i<n; i++){
        ans *= 10;
        diff1 *= 9;
        diff2 *= 8;
        ans %=   (1000000000+7);
        diff1 %= (1000000000+7);
        diff2 %= (1000000000+7);
    }
    diff = (2*diff1 - diff2+1000000000+7)%(1000000000+7);
    ans = ans - diff + 1000000000+7;
    ans %= (1000000000+7);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1712
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramB
    {
        static void Main(string[] args)
        {

            //入力
            string[] s = Console.ReadLine().Split(' ');
            long a = long.Parse(s[0]);
            long b = long.Parse(s[1]);
            long c = long.Parse(s[2]);
            long d = long.Parse(s[3]);


            //答え出力
            while(a >= 1 && c >= 1)
            {
                c -= b;
                if (c < 1)
                    break;

                a -= d;

            }

            if (a > 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");


        }
    }

}


Measured memory_bytes: 27536
#include <stdio.h>
#include <stdlib.h>
int compareInt(const void* a, const void* b)
{
    int aNum = *(int*)a;
    int bNum = *(int*)b;

    return aNum - bNum;
}
int main(void){
  int n, x;
  int a[105];
  scanf("%d %d", &n,&x);
  
  //int sum = 0;
  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
    //sum+=a[i];
  }
  /*
  if(x>sum){
    printf("%d", n-1); 
    return 0;
  }
  */
  
  
  qsort(a, n, sizeof(int), compareInt);
  int i,s=0;int ans=0;
  for(i=0;i<n&&s<=x;i++){
    s+=a[i];
  }
    if(s==x && i==n){
      ans = n;     
    }else if(s!=x && i==n){
      ans = n-1;      
    }
  else if(i!=n){
    ans = i-1;
  }
  printf("%d", ans);
  return 0;
}
  

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

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

#define INF 0x3fffFFFF

signed main()
{
//    cout << fixed << setprecision(9);

    int N, M; cin >> N >> M;
    vector<int> L(M), R(M); rep(i, M) cin >> L[i] >> R[i];

    int maxL = -1;
    int minR = INF;
    rep(i, M){
        maxL = max(maxL, L[i]);
        minR = min(minR, R[i]);
    }
    if (maxL > minR){ puts("0"); return 0; }
    int ans = minR - maxL + 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin>>n;
map<string,int> s;
rep(i,n){
    string tmp_s;
    cin>>tmp_s;
    s[tmp_s]++;
}
cin>>m;
rep(i,m){
    string tmp_t;
    cin>>tmp_t;
    s[tmp_t]--;
}
int ans=0;
for(auto x :s){
    ans=max(ans,x.second);
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int a = n - n / 2;

    printf("%.10f\n", a / (double)n);

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int A = cin.NextInt();
        int B = cin.NextInt();
        int T = cin.NextInt();
        int count = T / A;
        int ans = count * B;

        Console.WriteLine(ans);
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> h(N, 0);

    for (size_t i = 0; i < h.size(); i++) {
        cin >> h[i];
    }

    vector<long> dp(N, __LONG_MAX__);
    dp[0] = 0;

    for (int i = 1; i < min(K, N); i++) {
        for (int j = 1; j < i + 1; j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    for (int i = K; i < N; i++) {
        dp[i] = __LONG_MAX__;
        for (int j = 1; j < K + 1; j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[N - 1] << '\n';

    return 0;
}


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

typedef long double ld;

ld rad(ld degree) {
	return degree * acos(-1) / 180.0;
}

int main() {

	ld a, b, h, m;
	cin >> a >> b >> h >> m;

	ld x = (30.0 * h + m / 2.0);

	m *= 6;
	if (m == 0) {
		x = min(x, 360-x);
	} else {
		if (x > m) {
			x = min(x-m, m+360-x);
			while (x >= 360) x-=360;
			while (x < 0) x+=360;
		} else {
			x = min(m-x, x+360-m);
			while (x >= 360) x-=360;
			while (x < 0) x+=360;
		}
	}
	
	ld angle = rad(x);
	
	cout << fixed << setprecision(10);
	cout << sqrt(a * a + b * b - 2 * a * b * cos(angle)) << "\n";
	
	return 0;
}


Measured memory_bytes: 4156
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    string s;
    cin>>s;
    vector<LL> nc(26,0);
    REP(i,SZ(s))
        nc[s[i]-'a']++;
    LL ans=0;
    LL nsum=0;
    REP(i,26)
        nsum+=nc[i];
    REP(i,26)
        ans += (nsum-nc[i]) * nc[i];
    cout<<1+ans/2<<endl;
    return 0;
}


Measured memory_bytes: 832
n = int(input())
arr = [int(x) for x in input().split()]
res=1
arr.sort()
if arr[0] == 0 :
  print('0')
  exit(0)
for i in range(n):
  res = res*arr[i]
  if res>1e18:
    print(-1)
    exit(0)
print(res)
  

Measured memory_bytes: 21652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;

const int INF = 2000000003;

int N,M;
ve<ve<pair<int,int>>> to;
ve<int> B;
bool ff = false;

void dfs(int u, int v){
    
    for(auto p : to[u]){
        if(p.fi == v) continue;
        if(B[p.fi] == INF){
            B[p.fi] = B[u] + p.se;
            dfs(p.fi, u);
        }
        else if(B[p.fi] ==  B[u] + p.se) continue;
        else{
            ff = true;
            return;
        }
    }
    
}



int main()
{

    
    cin>>N>>M;
    if(M==0){
        out("Yes");
        return 0;
    }
    to.res(N);
    rep(i,M) {
        int l,r,d;
        cin >> l >> r >> d;
        l--,r--;
        to[l].push_back({r,d});
        to[r].push_back({l,-d});
    }

    B.assign(N,INF);
    rep(i,N){
        if(B[i] == INF){
            B[i] = 0;
            dfs(i,-1);
            if(ff){
                out("No");
                return 0;
            }
        }
    }
    
    out("Yes");

    return 0;
}


Measured memory_bytes: 12032
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
using namespace std; 
int j(int x)
{
	int a = 1;
	for (int i = 0; i < x; i++)
	{
		a *= 10;


	}
	return a;


}


int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ans = 1000;
	for (int i = 0; i <= n - 3; i++)
	{
		int x = (s.at(i) - '0') * 100 + (s.at(i+1) - '0') * 10 + (s.at(i + 2) - '0');

		if (abs(753-x)< ans)
		{
			ans = abs(753 - x);

		}

		

	}
	cout << ans << endl;
	

}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int R;
  cin >> R;
  cout << setprecision(10) << 2 * R * 3.1415926535 << endl;

  return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    if (S[K - 1] == 'A')
    {
        S[K - 1] = 'a';
    }
    else if (S[K - 1] == 'B')
    {
        S[K - 1] = 'b';
    }
    else if (S[K - 1] == 'C')
    {
        S[K - 1] = 'c';
    }
    cout << S << endl;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 60;
const double eps = 1e-6;

int n, m;
char g[N][N];

bool check(int x, int y)
{
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};

    bool flag = false;
    for(int i = 0; i < 4; i++)
        if(g[x + dx[i]][y + dy[i]] == '#') flag = true;
    return flag;
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) scanf("%s", g[i] + 1);

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(g[i][j] == '#' && !check(i, j))
            {
                puts("No");
                return 0;
            }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <cstring>
#define maxn 101
#define INF 0x3f3f3f3f
using namespace std;

int m[maxn][maxn] = {}, d[maxn] = {}, color[maxn] = {};
int n;

void Dijkstra()
{
	for (int i = 1; i < n; i++)
		d[i] = INF;
	d[0] = 0;
	while (true)
	{
		int mincost = INF,u;
		for(int i=0;i<n;i++)
			if (d[i] < mincost&&color[i]==0)
			{
				mincost = d[i];
				u = i;
			}
		if (mincost == INF)break;
		color[u] = 1;
		for (int i = 0; i < n; i++)
			if (color[i] == 0 && m[u][i] != -1)
				if (d[i] > d[u] + m[u][i])
					d[i] = d[u] + m[u][i];
	}
}
int main()
{
	scanf("%d", &n);
	memset(m, -1, sizeof(m));
	for (int i = 0; i < n; i++)
	{
		int u, k;
		scanf("%d %d", &u, &k);
		for (int i = 0; i < k;i++)
		{
			int v, c;
			scanf("%d%d", &v, &c);
			m[u][v] = c;
		}
	}
	Dijkstra();
	for (int i = 0; i < n; i++)
	{
		printf("%d %d\n", i, d[i]);
	}
	return 0;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int func(int x){
  if(x%100!=0) return 0;
  return func(x/100)+1;
}

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  int ans=0;
  rep(i,n){
    if(i+1==a[a[i]-1]){
      ans++;
    }
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 3716