akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double dd;
    #define all(v) v.begin(),v.end()
    #define all(v) v.begin(),v.end()
    #define endl "\n"
    #define clr(n, r) memset(n,r,sizeof(n))
    typedef bitset<13> MASK;
    typedef pair<int, int> ii;
    typedef vector<ii> vii;
    typedef vector<int> vi;
    typedef pair<int, int> pi;
    typedef vector<vector<int>> vvi;

    //set iterator can be increamnted and decreamnted
    void fast() {
        cin.tie(0);
        cin.sync_with_stdio(0);
    }

    ll dp[(1 << 13) + 10][100], n;

    ll ans(MASK m, ll k) {
        if (m.count() == 0) {
            return !k;
        }
        ll &ret = dp[m.to_ulong()][k];
        if (~ret)return ret;

        ret = 0;
        for (int i = 1; i <= n; ++i) {
            if (m[i]) {
                ll cnt = 0;
                for (int j = i - 1; j >= 1; --j) {
                    if (!m[j])cnt++;
                }
                MASK tmp = m;
                tmp[i] = 0;
                ret += (ans(tmp, k - cnt));
            }
            //    cout<<ret<<" ";
        }
        return ret;
    }

    int main() {
        fast();
    //    freopen("input.txt","r",stdin);
    //    freopen("out.txt","w",stdout);
        int n, k;
        cin >> n >> k;
        vector<pi> s;
        for (int i = 0; i < k; ++i) {
            int a, b;
            cin >> a >> b;
            s.push_back({a, b});
        }
        ll dp[n + 1];
        clr(dp, 0);
        dp[0] = 1ll;
        dp[1] = -1ll;
        ll mod=998244353;
        for (int j = 0; j < n; ++j) {
            if (j)dp[j] += dp[j - 1]%mod;
            dp[j]%=mod;
            for (int i = 0; i < k; ++i) {
                int l = s[i].first;
                int r = s[i].second;
                if (j + r + 1 < n)dp[j + r + 1] =(dp[j + r + 1] - dp[j]+mod)%mod,dp[j+r+1]%=mod;
                if (j + l < n)dp[j + l] += dp[j]%mod,dp[j+l]%=mod;
            }
        }
        cout << dp[n - 1];
    }

Measured memory_bytes: 5168
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ld long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }
                                   
 
  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=2e18+18;
  const int N=2e6+25;
  const int M=2e4;
  
  vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

 void fft()           
 { 
    ld l; cin>>l;
    l=l/3;
                     
    cout<<setprecision(10)<<l*l*l;

 }     

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   
   
   int t=1;                         
//   cin>>t;

  rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<t)
   cout<<nl;
  }
  
 
 return 0; 
}

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

const int N=200005;

int n,a[N],f[N],ans;
bool vis[N];

void init()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(vis[a[i]-1]) f[a[i]]=f[a[i]-1]+1;
		vis[a[i]]=1;
		ans=max(ans,f[a[i]]);
	}
	cout<<n-ans-1<<endl;
}

int main()
{
	init();
	return 0;
}

Measured memory_bytes: 2048
from sys import stdin
import numpy as np
N=int(stdin.readline().rstrip())
A,B=[int(x) for x in stdin.readline().rstrip().split()]
data=[int(x) for x in stdin.readline().rstrip().split()]
data=np.array(data)
ako=len(data[data<=A])
bko=len(data[data>=B+1])
cko=len(data[data>=A+1])-len(data[data>B])
ans=min([ako,bko,cko])
print(ans)

Measured memory_bytes: 20684
#include<bits/stdc++.h>
using namespace std;
#define MAXN 1000+20
int a[MAXN][MAXN]={0};
bool cmp(string s1,string s2){
  return s1.length()<s2.length() ? true : false;
}
int main(){
  int n;
  cin>>n;
  double t,a;
  cin>>t>>a;
  double rst = 0x3f3f3f;
  int b = 1;
  for(int i =1;i<=n;i++){
    double x;
    cin>>x;
    x = t-x*0.006;
    if(fabs(a-x)<rst){
      rst = fabs(a-x);
      b= i;
    }
  }
  cout<<b<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        String op = in.next();
        int b = in.nextInt();
        
        if(op.equals("+"))   System.out.println(a + b);
        else            System.out.println(a - b);
    }
}


Measured memory_bytes: 21972
import sys

N, K = map(int, sys.stdin.readline().split())
ans = 0
for i in range(1, N+1):
    if K <= i:
        ans += 1 / N
    else:
        count = 0
        while i < K:
            count += 1
            i *= 2
        ans += (1 / N) * 0.5 ** count

print(ans)

Measured memory_bytes: 9332
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; ++i)
    cin >> X[i] >> Y[i];

  int ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    int dX = X[i + 1] - X[i], dY = Y[i + 1] - Y[i], d = min(abs(dX), abs(dY));
    if (dX > 0 && dY > 0)
      ans += d, dX -= d, dY -= d;
    if (dX < 0 && dY < 0)
      ans += d, dX += d, dY += d;
    ans += abs(dX) + abs(dY);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3100
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

int main(){
  int a,b;
  cin>>a>>b;
  int n=a+b;
  if(n==3)cout<<"3"<<endl;
  else if(n==4)cout<<"2"<<endl;
  else cout<<"1"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a,b,c;
	scanf("%c%c%c",&a,&b,&c);
	char g;scanf("%c",&g);
	char a1,b1,c1;
	scanf("%c%c%c",&a1,&b1,&c1);
	if(a==c1&&c==a1&&b==b1)printf("YES\n");
	else printf("NO\n");
}

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

namespace AtCoder_2019_04_27_B
{
	class Program
	{
		static void Main(string[] args)
		{
			int N;
			string [] V;
			string [] C;

			N = int.Parse(Console.ReadLine());
			V = Console.ReadLine().Split(' ');
			C = Console.ReadLine().Split(' ');

			int count = V.Length;
			int total = 0;

			for(int i = 0; i < count; i++)
			{
				int diff = int.Parse(V[i]) - int.Parse(C[i]);
				if(diff > 0)
				{
					total += diff;
				}
			}

			Console.WriteLine(total);
		}
	}
}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	ll n;
	cin >> n;

	string ans = "";

	while(n){
		int digit = (n - 1) % 26;
		n = (n - 1) / 26;
		ans += static_cast<char>(digit + 'a');
	}

	reverse(ans.begin(), ans.end());

	cout << ans << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
    double x,y,x2,y2;
    long double ans;
    cin>>x>>y>>x2>>y2;
    ans=sqrt(pow((x2-x),2)+pow((y2-y),2));
    cout<<fixed<<setprecision(20)<<ans;
}


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

using namespace std;
int main()
{
    vector<int>v;
    vector<int>v1;
    vector<int>v2;
    set <char>s;
    //int t,coun1=0,a,ans3,coun2=0,x,y=0,ans1=0,b,sum=0,flag=0,ans2;




    long long ai,t,n,a,b,sum=0,c=0,k,e,f,g;
    /*string str;
    string str1;

    getline(cin,str);
    getline(cin,str1);*/

    cin >> a >>b >>c >> k;








    if( a == k || a>k)
    {


     cout << k << endl;


    }
    else
    {
        sum=a;

        f=k-a;
        if(f >b )
        {
            sum=sum+b*0;
        }
        else
        {
            sum+=f*0;
        }

        g=k-a-b;

        if(g >0 && g !=0)
        {
            sum+=g*(-1);
        }

        cout << sum;



    }



return 0;
}





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

const int MAXN = 1<<17;
const int UNSET = -1;


vector<vector<int>> g;
int vis[MAXN];
int dp[MAXN];



vector<int> topo;

void dfs(int u) {
  if (vis[u]) return;
  vis[u] = true;
  for (int v : g[u]) {
    dfs(v);
  }
  topo.push_back(u);
}


int main () {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M; cin >> N >> M;
  g.resize(N);

  for (int i = 0; i < M; ++i) {
    int u, v; cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
  }

  for (int i = 0; i < N; ++i) dfs(i);
  reverse(topo.begin(), topo.end());

  for (int i = N - 1; i >= 0; --i) {
    int u = topo[i];
    for (auto v : g[u]) {
      dp[u] = max(dp[v] + 1, dp[u]);
    }
  }


  cout << *max_element(dp, dp + N) << '\n';



}


Measured memory_bytes: 9080
/*author @dhanush*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first
ll solve(ll x, ll k, ll d)
{

  if (k == 0)
    return abs(x);
  if (d == 0)
    return abs(x);
  if (x > 0)
  {
    if (d > x)
    {
      if (k & 1)
      {
        return abs(x - d);
      }
      else
      {
        return x;
      }
    }
    else if (d == x)
    {
      if (k & 1)
      {
        return 0;
      }
      else
        return x;
    }
    else
    {
      ll xx = x / d;
      if (xx >= k)
      {
        return x - k * d;
      }
      else
      {
        ll yy = k - xx;
        x = x - xx * d;
        // if (d > x)
        // {
        //   if (yy & 1)
        //   {
        //     return x - d;
        //   }
        //   else
        //   {
        //     return x;
        //   }
        // }
        return solve(x, yy, d);
        // else
        // {

        // }
      }



    }

  }
  else
  {
    if (k & 1)
      return x + d;
    else
      return x;
  }
}
int main()
{


  ll x, k, d;
  cin >> x >> k >> d;
  cout << solve(abs(x), k, d);

}





Measured memory_bytes: 3632
def problem_c():
    N, K = map(int, input().split())
    D = list(map(str, input().split()))
    numbers = {str(i) for i in range(10)}
    availables = set(numbers) - set(D)

    for i in range(N, 100000):
        nums = set(str(i))
        if nums <= availables:
            print(i)
            return

##########
problem_c()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void fnInput(int& rnStair, vector<int>& rvnFine)
{
  int nFineSiz;
  cin >> rnStair >> nFineSiz;
  rvnFine.resize(rnStair + 1, true);

  for (int i = 0; i < nFineSiz; i++)
  {
    int nFine;
    cin >> nFine;
    rvnFine[ nFine ] = false;
  }
}

llong fnNumOfWays(int nStair, const vector<int>& cnrvnFine)
{
  const llong cnnMod = 1000000007;
  vector<llong> vnDPWays(nStair + 1);
  vnDPWays[0] = 1;

  for (int i = 1; i < vnDPWays.size(); i++)
  {
    if (cnrvnFine[i])
    {
      vnDPWays[i] += vnDPWays[i - 1];
      if (i > 1)
        vnDPWays[i] += vnDPWays[i - 2];

      vnDPWays[i] %= cnnMod;
    }
  }
  return vnDPWays[vnDPWays.size() - 1];
}
  
int main()
{
  int nStair;
  vector<int> vnFine;

  fnInput(nStair, vnFine);
  cout << fnNumOfWays(nStair, vnFine) << endl;

  return 0;
}

Measured memory_bytes: 4172
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int x,y;
    cin >> x >> y;
    int ans = 0;
    ans += max(0, 400000 - x * 100000);
    ans += max(0, 400000 - y * 100000);
    if (x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
}

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

Measured memory_bytes: 256
from math import factorial

def comb(n, k, p):
    '''(nCk) mod oを求める'''
    if n<0 or k<0 or n<k:
        return 0
    if n == 0 or k == 0:
        return 1
    
    #n!, k!, (n-k)!をそれぞれ求める
    a = factorial(n)%p
    b = factorial(k)%p
    c = factorial(n-k)%p
    return (a*pow(b, p-2, p)*pow(c, p-2, p))%p


N, K = map(int, input().split())

mod = 10**9+7

for i in range(1, K+1):
    print(comb(N-K+1, i, mod)*comb(K-1, i-1, mod)%mod)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


ll nCr(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll nHr(ll n, ll r) { if (n == 0 && r == 0) return 1; else return nCr(n + r - 1, r); }
ll nPr(ll n, ll r) { if (r < 0 || n < r) return 0; else return (fac[n] * finv[n-r]) % MOD; }


int main(){
    ll n, m; cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    ll ans = fac[n]*fac[m] % MOD;
    if(n == m) MUL(ans, 2);
    cout << ans << endl;
}


Measured memory_bytes: 15580
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

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

    vector<vector<long long> > c(10, vector<long long> (10, 0));

    for(long long i = 1; i <= n; i++){
        string s;
        s = to_string(i);
        long long up = s[0] - '0';
        long long low = s[s.size()-1] - '0';

        c[up][low]++;
    }

    long long count = 0;

    for(long long i = 0; i < 10; i++){
        for(long long j = 0; j < 10; j++){
            count += c[i][j]*c[j][i];
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3684
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;


template <class T>
T gcd(T a, T b) {
    if (a < b) {
        swap(a, b);
    }

    T r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

template <class T>
T lcm(const T& a, const T& b) {
    return (a * b) / gcd<T>(a, b);
}

long long numOfMultiple(long long A, long long B, long long n) {
    return (B / n) - ((A - 1) / n);
}

int main() {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;

    long long lcmOfCD = lcm(C, D);

    long long cm = numOfMultiple(A, B, C);
    long long dm = numOfMultiple(A, B, D);
    long long cdm = numOfMultiple(A, B, lcmOfCD);

    // cout << "cm: " << cm << ", dm: " << dm << ", cdm: " << cdm << endl;

    cout << (B - A + 1) - (cm + dm - cdm) << endl;
    return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[100010], T[100010];
int A, B, C, D, Q, lenS, lenT, sum1[100010], sum2[100010];
int main(){
  rd(S);
  rd(T);
  rd(Q);
  lenS = strlen(S);
  lenT = strlen(T);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW= 0;Lj4PdHRW< (lenS-1) + 1;Lj4PdHRW++){
      S[Lj4PdHRW] = (S[Lj4PdHRW]=='A')?2:1;
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY= 0;KL2GvlyY< (lenT-1) + 1;KL2GvlyY++){
      T[KL2GvlyY] = (T[KL2GvlyY]=='A')?2:1;
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS= 1;Q5VJL1cS< (lenS) + 1;Q5VJL1cS++){
      sum1[Q5VJL1cS] = sum1[Q5VJL1cS - (1) + (0)] + S[Q5VJL1cS - (1) + (0)];
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY= 1;e98WHCEY< (lenT) + 1;e98WHCEY++){
      sum2[e98WHCEY] = sum2[e98WHCEY - (1) + (0)] + T[e98WHCEY - (1) + (0)];
    }
  }
  while(Q--){
    rd(A);
    rd(B);
    rd(C);
    rd(D);
    if( (sum1[B]-sum1[A-1])%3 == (sum2[D]-sum2[C-1])%3 ){
      wt_L("YES");
      putchar_unlocked('\n');
    }
    else{
      wt_L("NO");
      putchar_unlocked('\n');
    }
  }
  return 0;
}
// cLay varsion 20170408-3 [beta]

// --- original code ---
// char S[100010], T[100010];
// int lenS, lenT;
// int Q, A, B, C, D;
// 
// int sum1[100010], sum2[100010];
// {
//   rd(S,T,Q);
//   lenS = strlen(S);
//   lenT = strlen(T);
// 
//   S[0..lenS-1] = (S[0..lenS-1]=='A')?2:1;
//   T[0..lenT-1] = (T[0..lenT-1]=='A')?2:1;
//   sum1[1..lenS] = sum1[0..] + S[0..];
//   sum2[1..lenT] = sum2[0..] + T[0..];
//   
//   while(Q--){
//     rd(A,B,C,D);
//     if( (sum1[B]-sum1[A-1])%3 == (sum2[D]-sum2[C-1])%3 ) wt("YES"); else wt("NO");
//   }
// }


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string A,B,C;
cin >> A >> B >> C;
if (A.at(A.size()-1) == B.at(0) && B.at(B.size()-1) == C.at(0)) {
    cout << "YES" << endl;
} else cout << "NO" << endl;




return 0;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<double> a(n);
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    double ret = 0;
    ret = a[0] + a[1];
    ret /= 2.0;
    for(i=2;i<n;i++){
        ret += a[i];
        ret/=2.0;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    array=input[0].split(" ");
    const N=parseInt(array[0],10),M=parseInt(array[1],10);
    var l=Array(M), r=Array(M),i, lmax=1, rmin=N;
    for (i=0; i<M; i++) {
        var value=input[i+1].split(" ");
        l[i]=parseInt(value[0], 10);
        r[i]=parseInt(value[1], 10);
        lmax=Math.max(lmax,l[i]);
        rmin=Math.min(rmin,r[i]);
    } 
    console.log(rmin-lmax+1>0?rmin-lmax+1:0);    
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 30640
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool same(int a, int b){
    return root(a) == root(b);
  }
};

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

int main(){
  int n,m,k; cin >> n >> m >> k;
  UnionFind uni(n);
  vi deg(n,1);
  rep(i,m) {
    int a,b; cin >> a >> b; a--; b--;
    uni.merge(a,b);
    deg[a]++; deg[b]++;
  }
  rep(i,k) {
    int a,b; cin >> a >> b; a--; b--;
    if(uni.same(a,b)){
     deg[a]++; deg[b]++;
    }
  }

  rep(i,n) cout << uni.size(i) - deg[i] << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

vector<vector<long long>> dp(60, vector<long long>(5, -1));

long long solve(const int index, const bool is_top, const vector<long long> &v, const long long k) {
  if (index == -1) {
    return 0;
  }

  long long &ret = dp[index][is_top];
  if (ret == -1) {
    ret = 0;
    int limit = is_top ? (k >> index & 1) : 1;
    for (int d = 0; d <= limit; ++d) {
      long long cnt = count_if(v.begin(), v.end(), [index, d](long long x) {
                                                     return ((x >> index) & 1) ^ d;
                                                   });

      long long value = (1LL << index) * cnt + solve(index - 1, is_top and (d == limit), v, k);
      ret = max(ret, value);
      // D(index); D(d); D(cnt); D(ret); D((1LL << index));
    }
  }

  return ret;
}

int main() { IO;
  int n;
  long long k;
  cin >> n >> k;

  vector<long long> v(n);
  for (auto &x : v) cin >> x;

  long long ans = solve(50, true, v, k);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
using namespace std;
typedef long long LL;
const LL INF = 999999999999;

void Warshall_floyd(vector<vector<LL>> &G){
    int V = G.size();
    rep(k, V)rep(i, V)rep(j, V){
        if(G[i][k] == INF || G[k][j] == INF) continue;
        G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
    }
    // G[i][i] < 0が存在 <=> 負閉路が存在
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<LL>> G(n, vector<LL>(n, INF));
    rep(i, n) G[i][i] = 0;
    rep(i, m){
        int s,t,d;
        cin >> s >> t >> d;
        G[s][t] = d;
    }
    Warshall_floyd(G);
    rep(i, n){
        if(G[i][i] < 0){
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    rep(i, n){
        rep(j, n){
            if(G[i][j] == INF) cout << "INF";
            else cout << G[i][j];
            cout << (j==n-1 ? "\n":" ");
        }
    }

}





Measured memory_bytes: 3228
n = int(input())
a = [int(i) for i in input().split()]
c = [0 for i in range(n+1)]
b = sorted(a)
cnt = 1
for i in range(n-1):
  if b[i]==b[i+1]:
    cnt += 1
  else:
    c[b[i]] = cnt
    cnt = 1
  if i==n-2:
    c[b[n-1]] = cnt
ans = 0
for i in range(n+1):
  ans += int(c[i]*(c[i]-1)/2)
for i in range(n):
  print(ans-(c[a[i]]-1))

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

const ll FAC_MAX = 510000;

ll fac[FAC_MAX]; //階乗
ll finv[FAC_MAX]; //階乗の逆元

//繰り返し二乗法
//x^n mod
ll mod_pow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) { //奇数
        return mod_pow(x, n - 1) * x % MOD; //偶数の再帰にできるように変形
    } else { //偶数
        ll t = mod_pow(x, n / 2); //半分のものを求めて、2乗する
        return t * t % MOD;
    }
}

void init() {
    fac[0] = 1;
    for (ll i = 1; i < FAC_MAX; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD; //階乗を計算
    }

    for (ll i = 0; i < FAC_MAX; ++i) {
        finv[i] = mod_pow(fac[i], MOD - 2); //フェルマーの小定理を使い、階乗の逆元を計算
    }
}

//nCr
ll comb(ll n, ll r) {
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return (((fac[n] * finv[r]) % MOD) * finv[n - r]) % MOD;
}

int main() {

    ll n, k; cin >> n >> k;
    ll b = k;
    ll r = n - k;

    init();

    for (ll i = 1; i <= k; ++i) {
        //赤の組み合わせ
        //i+1Hr-i+1
        ll ans = comb(r + 1, r - i + 1);

        //青の組み合わせ
        //iHb-i
        ans *= comb(b - 1, b - i);
        ans %= MOD;

        cout << ans << endl;
    }
}

Measured memory_bytes: 8192
#include <iostream>
using namespace std;
#define MAX 100
void print(int A[],int n){
		for(int i=0;i<n;i++){
			if(i>0)
				cout<<" ";
			cout<<A[i];	
		}
		cout<<endl;	
}
int main(){
	int n,A[MAX],k=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	int flag=1,i=0;
	while(flag){
		flag=0;
		for(int j=0;j<n-1-i;j++){
			if(A[j]>A[j+1]){
				flag=1;
				k++;
				int temp=A[j];
				A[j]=A[j+1];
				A[j+1]=temp;
			}
		}
		i++;
	}
	print(A,n);
	cout<<k<<endl;
	return 0;
}


Measured memory_bytes: 3100
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize,
      mut aa: [usize; n]
    };

    aa.sort();
    aa.reverse();

    // 最初の1つは1回のみ
    let mut ans = aa[0];

    // 1~(n / 2 - 1)までの要素は2つ取れる
    let sum: usize = aa[1..n / 2].iter().map(|&a| a * 2).sum();

    ans += sum;

    // nが奇数個の場合は追加で1つピックできる ex) [5, 4, 3, 2, 1] ->  1, 2, 1
    if n % 2 != 0 {
        ans += aa[n / 2];
    }

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


Measured memory_bytes: 6216
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		int x=input.nextInt();
		int flag=0;
		while(x!=0)
		{
			int rem=x%10;
			if(rem==7)
			{
				flag=1;
				break;
			}
			x=x/10;
				
		}
		if(flag==1)
			System.out.println("Yes");
		else
			System.out.println("No");
		input.close();
	}
	

}


Measured memory_bytes: 35716
S = list(input())
S.append('fuck')
lis = ['A','T','C','G']
count = 1 if S[0] in lis else 0
ans = 1 if S[0] in lis else 0
for i in range(1,len(S)):
  if S[i] in lis:
    count += 1
  else:
    ans = max(ans,count)
    count = 0
print(ans)
    


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

int main(){
	int n,ans = 0,c = 0;
	char t;
	
	cin >> n;
	while(n--){
		cin >> t;
		if(t=='I') c++;
		else c--;
		
		if(c>ans) ans = c;
	}
	cout << ans;
}


Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L, R = [0] * (n1 + 1), [0] * (n2 + 1)
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]

    L[n1] = float('INF')
    R[n2] = float('INF')

    i, j = 0, 0
    compare_cnt = 0
    for k in range(left, right):
        compare_cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return compare_cnt


def merge_sort(A, left, right):
    cnt = 0
    if left + 1 < right:
        mid = (left + right) // 2
        cnt += merge_sort(A, left, mid)
        cnt += merge_sort(A, mid, right)
        cnt += merge(A, left, mid, right)
    return cnt


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    cnt = merge_sort(A, 0, N)
    print(*A)
    print(cnt)


if __name__ == '__main__':
    main()



Measured memory_bytes: 56188
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
long long dp[101][100001] = {};

int main()
{
    long long n, k;
    cin >> n >> k;
    long long w[100], v[100];
    for (long long i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (long long i = 0; i <= k; i++)
        dp[0][i] = 0;
    for (long long i = 0; i < n; i++)
    {
        for (long long W = 0; W <= k; W++)
        {
            if (W >= w[i])
            {
                dp[i + 1][W] = max(dp[i][W - w[i]] + v[i], dp[i][W]);
            }
            else
            {
                dp[i + 1][W] = dp[i][W];
            }
        }
    }
    cout << dp[n][k] << endl;
    return 0;
}

Measured memory_bytes: 79104
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

H, W = map(int,input().split())

INF = -1
Gmap = [list(input()) for _ in range(H)]
next_q = deque([])

def dfs_settings():
    #複数
    for h in range(H):
        for w in range(W):
            if Gmap[h][w]=='#':
                next_q.append([h,w])
                Gmap[h][w]=0

def dfs():
    ret = 0
    while len(next_q)!=0:
        #スタック取り出し(先頭)幅優先
        h,w = next_q.popleft()
        lv=Gmap[h][w]+1
        hs, ws = h + 0 , w + 1
        if ws<W and Gmap[hs][ws]=='.':
            next_q.append([hs,ws])
            Gmap[hs][ws] = lv
            ret = max(ret, Gmap[hs][ws])
        hs, ws = h + 1 , w + 0
        if hs<H and Gmap[hs][ws]=='.':
            next_q.append([hs,ws])
            Gmap[hs][ws] = lv
            ret = max(ret, Gmap[hs][ws])
        hs, ws = h + 0 , w - 1
        if ws>=0 and Gmap[hs][ws]=='.':
            next_q.append([hs,ws])
            Gmap[hs][ws] = lv
            ret = max(ret, Gmap[hs][ws])
        hs, ws = h - 1 , w + 0
        if hs>=0 and Gmap[hs][ws]=='.':
            next_q.append([hs,ws])
            Gmap[hs][ws] = lv
            ret = max(ret, Gmap[hs][ws])
    return ret

def main():
    dfs_settings()
    ret = dfs()
    print(ret)

if __name__ == '__main__':
    main()


Measured memory_bytes: 237372
#include<bits/stdc++.h>
using namespace std;
long long n,k;
long long p[10005],c[10005];
long long sum[10005];
const long long inf=1LL << 62LL ;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	long long maxnn=-inf;
	for(int i=1;i<=n;i++){
		cin>>c[i]; 
		maxnn=max(maxnn,c[i]);
	}
	long long now;
	long long msum=0;
	for(int i=1;i<=n;i++){
		long long sum=0;
		now=p[i];
		long long lp=1;
		long long start=i;
		for(int j=1;j<=n;j++){
			if(now==start)break;
			now=p[now];
			lp++;
		}
		now=i;
		long long summ=0;
		for(int j=1;j<=lp;j++){
			summ=summ+c[now];
			now=p[now];
		}
		now=i;
		for(int j=1;j<=min(k,lp);j++){
			sum+=c[now];
			msum=max(msum,max(sum,sum+(k-j)/lp*summ));
			now=p[now];
		}
	}
	if(maxnn<=0){
		cout<<maxnn;
		return 0;
	}
	cout<<msum;
	return 0;
} 


Measured memory_bytes: 3720
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	int x, a, b;
	while (scanf("%d%d%d",&x,&a,&b)==3)
	{
		if (abs(x - a) < abs(x - b)) printf("A\n");
		else
		{
			printf("B\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{int a,b,p;
 char s[1001];
 while(~scanf("%s",s))
 {a=0;
  p=strlen(s);
  for(b=0;b<p;b++)
  {if(s[b]=='+')
   a++;
   if(s[b]=='-')
   a--;
  }
  printf("%d\n",a);
 }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const long long mod = 1000000007;
int N, two[200001], stsize[200000];
long long ans = 0;
vector<int> adjlist[200000];
int dfs(int v, int p) {
	stsize[v] = 1;
	ans = (ans + two[N - 1]) % mod;
	ans = (ans + adjlist[v].size() - 1) % mod;
	for (int i: adjlist[v]) {
		if (i == p) continue;
		stsize[v] += dfs(i, v);
		ans = (ans - two[stsize[i]] + mod) % mod;
	}
	if (stsize[v] != N) ans = (ans - two[N - stsize[v]] + mod) % mod;
	return stsize[v];
}
long long modpow(long long X, long long Y) {
	if (Y == 0) return 1;
	long long ans = modpow(X, Y / 2);
	ans = ans * ans % mod;
	if (Y % 2) ans = ans * X % mod;
	return ans;
}
int main() {
	scanf("%d", &N);
	int A, B;
	for (int i = 1; i < N; ++i) {
		scanf("%d %d", &A, &B);
		adjlist[A - 1].push_back(B - 1);
		adjlist[B - 1].push_back(A - 1);
	}
	two[0] = 1;
	for (int i = 1; i <= N; ++i) two[i] = two[i - 1] * 2 % mod;
	dfs(0, -1);
	ans = ans * modpow(2, N * (mod - 2)) % mod;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 23808
#include<stdio.h>
#include<string.h>
// Kaibun -> Yes +1 / No. -1
int kaibun (char *S, int N)
{
	for (int i = 0; i < (int)(N/2); i++)
      if (S [i] != S [N - 1 - i])
        return -1;
   	return 1;
}
int strongKaibun (char *S, int N)
{
  int Nprime = (N - 1) / 2;
  if (kaibun (S, N) == 1)
    if (kaibun (S, Nprime) == 1)
      if (kaibun (S + Nprime + 1, Nprime) == 1)
        return 1;
  return 0;
}
int main (void)
{
  char S [100];
  int N;
  scanf("%s", S);
  N = strlen (S); // N: oddは前提として暗黙に仮定してチェックしない。
  if (strongKaibun (S, N) == 1)
    printf ("Yes\n");
  else
    printf ("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

using namespace std;

int main(){

	string str;
	getline(cin,str);
	string nstr="";

	for(int i = 0; i+4 < str.size(); i++){
		string cut=str.substr(i,5);
		if(cut=="apple"){
			cut="peach";
			for(int j = 0; j < cut.size(); j++){
				str[i+j]=cut[j];
			}
			i+=5;
		}
		else if(cut=="peach"){
			cut="apple";
			for(int j = 0; j < cut.size(); j++){
				str[i+j]=cut[j];
			}
			i+=5;
		}
	}

	//int head=0;
	//for(int i = 0; i < str.size(); i++){
	//	if(str[i]==' '||str[i]=='.'){
	//		string cut=str.substr(head,i-head);
	//		if(cut=="peach")
	//			cut="apple";
	//		else if(cut=="apple")
	//			cut="peach";
	//		head=i+1;
	//		nstr+=cut;
	//		if(str[i]=='.')
	//			nstr+='.';
	//		else
	//			nstr+=' ';
	//	}
	//}
	//if(str[str.size()-1]!='.'){
	//	string cut=str.substr(head,str.size()-head);
	//	if(cut=="peach"){
	//		cut="apple";
	//	}
	//	else if(cut=="apple"){
	//		cut="peach";
	//	}
	//	nstr+=cut;
	//}

	cout<<str<<endl;

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		Dice d = new Dice(scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt(),
				scan.nextInt());

		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			int upp = scan.nextInt();
			int sou = scan.nextInt();
			d.rotate(upp, sou);
			System.out.println(d.getEst());
		}

		scan.close();
		System.exit(0);
	}

}

class Dice {
	int Upp, Sou, Est, Wst, Nor, Bot;

	public Dice(int upp, int sou, int est, int wst, int nor, int bot) {
		Upp = upp;
		Sou = sou;
		Est = est;
		Wst = wst;
		Nor = nor;
		Bot = bot;
	}

	public void rotate(int upp, int sou) {
		if (sou == Wst || sou == Est)
			operate('E');
		for (int i = 0; i < 4; i++) {
			if (sou == Sou)
				break;
			operate('N');
		}
		for (int i = 0; i < 4; i++) {
			if (upp == Upp)
				break;
			operate('E');
		}
	}

	public int getEst() {
		return Est;
	}

	public void operate(char op) {
		int tmp;
		switch (op) {
		case 'S':
			tmp = Upp;
			Upp = Nor;
			Nor = Bot;
			Bot = Sou;
			Sou = tmp;
			break;
		case 'E':
			tmp = Upp;
			Upp = Wst;
			Wst = Bot;
			Bot = Est;
			Est = tmp;
			break;
		case 'W':
			tmp = Upp;
			Upp = Est;
			Est = Bot;
			Bot = Wst;
			Wst = tmp;
			break;
		case 'N':
			tmp = Upp;
			Upp = Sou;
			Sou = Bot;
			Bot = Nor;
			Nor = tmp;
			break;
		}
	}

	public int getUpp() {
		return Upp;
	}

}



Measured memory_bytes: 26204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A_PoisonousCookies solver = new A_PoisonousCookies();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_PoisonousCookies {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();
            out.println(b + Math.min(c, a + b + 1));
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 23252
import math
import collections
n = int(input())
a = [int(i) for i in input().split()]
dic = collections.defaultdict(int)
for i in range(n):
    dic[a[i]] += 1
a = [i for i in dic.keys() if dic[i] == 1]
b = [i for i in dic.keys() if dic[i] >= 1]

ls = [0] * (10**6)
for i in range(len(b)):
    tmp = b[i]
    cnt = 2
    while True:
        tmp = b[i] * cnt
        if tmp > 10**6:
            break
        ls[tmp-1] = 1
        cnt += 1

ans = 0
if len(a):
    for i in range(len(a)):
        if ls[a[i]-1] == 0:
            ans += 1
    print(ans)
else:
    print(0)


Measured memory_bytes: 151196
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    long long n;
    cin >> n;

    if(n % 2 == 0) cout << n << endl;
    else cout << n * 2 << endl;

    return 0;
}



Measured memory_bytes: 888
N = int(input())

n = 0
while True:
    if 2**n >= N:
        break
    n += 1

P = 2**n
graph = [[0]*P for _ in range(P)]
for i in range(1, n+1):
    k = 2**i
    for p in range(P):
        if p%k < k//2:
            offset = p//k*k + k//2
            for q in range(k//2):
                graph[p][q+offset] = i

for i in range(N-1):
    for j in range(i+1, N):
        print(graph[i][j], end=' ')
    print()

Measured memory_bytes: 6000