akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ld           long double
#define vi           vector<int>
#define pii          pair<int,int>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=(s);i<=(e);i++)
#define brep(i,s,e)  for(int i=(s);i>=(e);i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25); // less_equal
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());
#define int          long long
const int INF = 0x3F3F3F3F3F3F3F3F;
const int MOD = 1e9+7;
ld EPS = 1e-12;

const int N = 2e5 + 5;
int n, k, len = 0, st = 1;
vi adj[N];
bool vis[N];

void DFS(int v)
{
    vis[v] = true;
    for(auto i:adj[v])
    {
        if( vis[i] )
        {
            st = i;
            continue;
        }
        DFS( i );
    }
}

void DFS2(int v, int dep)
{
    vis[v] = true;
    len = max( len, dep );
    for(auto i:adj[v])
    {
        if( vis[i] )    
            continue;
        DFS2( i, dep+1 );
    }
}

int kaha = 1;
bool mila = false;

void DFS3(int v, int dep)
{
    if( v==st )
        return;
    
    if( k==0 )
    {
        mila = true;
        kaha = v;
        return;
    }

    if( mila )
        return;

    vis[v] = true;
    for(auto i:adj[v])
    {
        if( vis[i] )
            continue;
        k--;
        DFS3( i, dep+1 );
    }
}

void DFS4(int v, int dep)
{
    if( dep==k )
    {
        mila = true;
        kaha = v;
    }
    if( mila )
        return;
    vis[v] = true;
    for(auto i:adj[v])
    {
        if( vis[i] )
            continue;
        DFS4( i, dep+1 );
    }
}

short rain()
{
    // ifstream fin("ip.txt"); ofstream fout("op.txt");
    // int t;cin>>t;rep(test,1,t)
    {
        cin >> n >> k;
        vi a(n);
        for(auto &i:a)
            cin >> i;
        rep(i,1,n)
            adj[i].pb( a[i-1] );
        // mem( cyc, false );
        mem( vis, false );
        DFS( 1 );

        mem( vis, false );
        DFS2( st, 1 );

        mem( vis, false );
        DFS3( 1, 0 );
        if( mila )
        {
            cout << kaha << endl;
            return 0;
        }

        k %= len;
        mem( vis, false );
        DFS4( st, 0 );

        if( mila )
        {
            cout << kaha << endl;
            return 0;
        }
        assert( mila );
    }

    return 0;
}

signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int start = 1000*clock()/CLOCKS_PER_SEC;
    cout << fixed << setprecision(15);           rain();
    cerr << 1000*clock()/CLOCKS_PER_SEC-start << "ms\n";
}

Measured memory_bytes: 24532
#include <bits/stdc++.h> 
using namespace std; 
  
// function to determine the edge colors 
void colorEdges(int ptr, vector<vector<pair<int, int> > >& gra, 
                vector<int>& edgeColors, bool isVisited[]) 
{ 
    queue<int> q; 
    int c = 0; 
  
    set<int> colored; 
  
    // return if isVisited[ptr] is true 
    if (isVisited[ptr]) 
        return; 
  
    // Mark the current node visited 
    isVisited[ptr] = 1; 
  
    // Traverse all edges of current vertex 
    for (int i = 0; i < gra[ptr].size(); i++) { 
        // if already colored, insert it into the set 
        if (edgeColors[gra[ptr][i].second] != -1) 
            colored.insert(edgeColors[gra[ptr][i].second]); 
    } 
  
    for (int i = 0; i < gra[ptr].size(); i++) { 
        // if not visited, inset into the queue 
        if (!isVisited[gra[ptr][i].first]) 
            q.push(gra[ptr][i].first); 
  
        if (edgeColors[gra[ptr][i].second] == -1) { 
            // if col vector -> negative 
            while (colored.find(c) != colored.end()) 
  
                // increment the color 
                c++; 
  
            // copy it in the vector 
            edgeColors[gra[ptr][i].second] = c; 
  
            // then add it to the set 
            colored.insert(c); 
            c++; 
        } 
    } 
  
    // while queue's not empty 
    while (!q.empty()) { 
        int temp = q.front(); 
        q.pop(); 
  
        colorEdges(temp, gra, edgeColors, isVisited); 
    } 
  
    return; 
} 
  
// Driver Function 
int main() 
{ 
    set<int> empty; 
  
    // declaring vector of vector of pairs, to define Graph 
    vector<vector<pair<int, int> > > gra; 
  
    vector<int> edgeColors; 
  
    bool isVisited[1000000] = { 0 }; 
  
    // Enter the Number of Vertices 
    // and the number of edges 
    int ver;
    cin >> ver;
    int edge = ver - 1;
  
    gra.resize(ver); 
    edgeColors.resize(edge, -1); 
  
    // Enter edge & vertices of edge 
    // x--; y--; 
    // Since graph is undirected, push both pairs 
    // (x, y) and (y, x) 
    // graph[x].push_back(make_pair(y, i)); 
    // graph[y].push_back(make_pair(x, i)); 
    // gra[0].push_back(make_pair(1, 0)); 
    // gra[1].push_back(make_pair(0, 0)); 
  
    // gra[1].push_back(make_pair(2, 1)); 
    // gra[2].push_back(make_pair(1, 1)); 
  
    // gra[2].push_back(make_pair(3, 2)); 
    // gra[3].push_back(make_pair(2, 2)); 
  
    // gra[0].push_back(make_pair(3, 3)); 
    // gra[3].push_back(make_pair(0, 3)); 

    for (int i = 0; i < edge; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        gra[a].push_back(make_pair(b, i));
        gra[b].push_back(make_pair(a, i));
    }
  
    colorEdges(0, gra, edgeColors, isVisited); 
  
    // printing all the edge colors 
    int ans = -1;
    for (int i = 0; i < edge; i++) {
        ans = max(ans, edgeColors[i] + 1);
    }

    cout << ans << endl;
    for (int i = 0; i < edge; i++) 
        cout << edgeColors[i] + 1 << endl;
  
    return 0; 
} 

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

int count_bits(int n) {
    n=(n&0x55555555)+(n>>1&0x55555555);
    n=(n&0x33333333)+(n>>2&0x33333333);
    n=(n&0x0f0f0f0f)+(n>>4&0x0f0f0f0f);
    n=(n&0x00ff00ff)+(n>>8&0x00ff00ff);
    n=(n&0x0000ffff)+(n>>16&0x0000ffff);
    return n;
}

ll modpow(ll a, ll n, ll mod) {
    if (mod <= 0) return 0;
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int solve(int n) {
    if (n == 0) return 0;
    return solve(n % count_bits(n)) + 1;
}

int main() {
    int N;
    string X;
    cin >> N >> X;
    ll p = 0;
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') p++;
    }
    ll a1 = 0;
    ll a2 = 0;
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') {
            if (p == 1) {
                a1 = 0;
            } else {
                a1 = (a1 + modpow(2, N - i - 1, p - 1)) % (p - 1);
            }
            a2 = (a2 + modpow(2, N - i - 1, p + 1)) % (p + 1);
        }
    }
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') {
            if (p == 1) {
                cout << 0 << "\n";
            } else {
                cout << 1 + solve((a1 - modpow(2, N - i - 1, p - 1) + p - 1) % (p - 1)) << "\n";
            }
            
        } else {
            cout << 1 + solve((a2 + modpow(2, N - i - 1, p + 1)) % (p + 1)) << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3664
n = int(input())
a = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
    l = list(str(i))
    a[int(l[0])][int(l[len(l) - 1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += a[i][j] * a[j][i]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include <vector>
#include<string.h>
#include<cmath>
using namespace std;


int main(){
   int X1,X2,X3;
   cin>>X1>>X2>>X3;
   if(X1+X2+X3>21){
       cout<<"bust"<<endl;
   }
   else
   {
       cout<<"win"<<endl;
   }
   
   return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, a, b, c, d, tmp, m, h, w, x[10], y[10], sum, k, q;
ld ans;
int main(void) {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  rep(i, n) cin >> x[i] >> y[i];
  V p(n);
  rep(i, n) p[i] = i;

  do {
    ld cnt = 0.0;
    rep(i, n - 1) {
      cnt += sqrt((ld)(x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) +
                  (ld)(y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]]));
    }
    ans += cnt;
  } while (next_permutation(all(p)));
  ll waru = 1;
  rrep(i, 1, n + 1) waru *= i;
  ans /= (ld)waru;
  doublecout(ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
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
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATherefore solver = new ATherefore();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATherefore {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String a = in.next();
            int c = a.charAt(a.length() - 1) - '0';
            if (c == 0 || c == 1 || c == 6 || c == 8) {
                out.println("pon");
            } else if (c == 2 || c == 4 || c == 5 || c == 7 || c == 9) {
                out.println("hon");
            } else {
                out.println("bon");
            }


        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

    }
}



Measured memory_bytes: 32696
def main():
    height, width = map(int, input().split())
    color = int(input())
    limits = list(map(int, input().split()))
    answer = []
    for i in range(color):
        answer = answer + [i + 1] * limits[i]
    for i in range(height):
        if i % 2:
            print(" ".join(map(str, list(reversed(answer[i * width:(i + 1) * width:])))))
        else:
            print(" ".join(map(str, answer[i * width:(i + 1) * width])))


if __name__ == '__main__':
    main()



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

#define int long long
#define d7 1000000007


int32_t main(){
    
    
    int n;cin>>n;
    
    //dp[i] denote the i-heads so far;
    vector<double> dp(n+1);
    
    dp[0]=1;
    
    for(int i=0;i<n;i++){
        double ph;cin>>ph;
        for(int j=i+1;j>=0;j--){
            dp[j]=(j==0? 0: dp[j-1]*ph)+dp[j]*(1-ph);
        }
    }
    double ans=0;
    for(int i=n;i>n/2;i--){
        ans+=dp[i];
    }
    cout<<fixed<<setprecision(9)<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int k = in();
  int ans = 0;
  rrep(a,k)rrep(b,k)rrep(c,k) {
    ans += gcd(a,gcd(b,c));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
// B

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  string s,t;
  cin>>N>>s>>t;
  for (int i(0);i<N;i++){
    cout << s[i];
    cout << t[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
#define MOD 1000000007

long long add_mod(long long x,long long y){
	return (x+y)%MOD;
}

long long sub_mod(long long x,long long y){
	return (x-y+MOD)%MOD;
}

long long mul_mod(long long x,long long y){
	return x*y%MOD;
}

long long i,j,n,m;
string str;

int main(){
  cin >> n >> m;
  if(abs(n-m) > 1){
    cout << 0 << endl;
    return 0;
  }
  long long ans = 2;
  if(n > m){
    ans = n;
    n--;
  }
  if(m > n){
    ans = m;
    m--;
  }
  for(i = 2;i <= n;i++){
    ans = mul_mod(ans,i);
    ans = mul_mod(ans,i);
  }
  cout << ans << endl;
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define MOD 1000000007

template <class Monoid> struct SegmentTree{
	using Func = function<Monoid(Monoid, Monoid)>;

	int size;
	vector<Monoid> seg;
	const Func merge;
	const Monoid def;

	SegmentTree(int n, Monoid d, const Func f): merge(f), def(d){
		for(size = 1; size <= n; size <<= 1);
		seg.assign(size*2, def);
	}

	Monoid& operator[] (int i) { return seg[i+size]; };
	void build(){ for(int i = size-1;i >= 0;i--) seg[i] = merge(seg[i*2], seg[i*2+1]); }

	void update(int i, Monoid val){
		seg[i += size] = val;
		while(i >>= 1) seg[i] = merge(seg[i*2], seg[i*2+1]);
	}

	void add(int i, Monoid val){ update(i, val+seg[i+size]); }

	Monoid get(int a, int b){
		Monoid l = def, r = def;
		for(a += size, b += size; a < b; a >>= 1, b >>= 1){
			if(a & 1) l = merge(l, seg[a++]);
			if(b & 1) r = merge(seg[--b], r);
		}
		return merge(l, r);
	}
};

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

	SegmentTree<int> seg(2*n+10, 0, [](int a, int b){ return (a + b) % MOD;});

	for(int i = 0;i <= n+10;i++){
		seg[n+i] = 1;
	}

	seg[n-1] = n;
	seg.build();

	for(int i = n-2;i >= 0;i--){
		int num = seg.get(i+3, i+n+2);
		num = (num + seg[i+1]) % MOD;
		num = (num + (n-1)*(n-1) % MOD) % MOD;
		seg.update(i, num);
	}

	cout << seg[0] << endl;

	return 0;
}


Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353,iv=(mod+1)/2;
int n,x,y,dist[222222],pre[222222],rt,cnt,dp[222222][4][4],len,f[4][4],G[4][4];
vector<int> g[222222];
int bfs(int s)
{
	queue<int> q;
	q.push(s);
	memset(dist,-1,sizeof(dist));
	dist[s]=0;
	while(!q.empty())
	{
		int x=q.front();q.pop();
		for (int i=0;i<g[x].size();i++)
		{
			int to=g[x][i];
			if (!~dist[to])
			{
				dist[to]=dist[x]+1;
				pre[to]=x;
				q.push(to);
			}
		}
	}
	int mxi=1;
	for (int i=2;i<=n;i++)
	{
		if (dist[i]>dist[mxi]) mxi=i;
	}
	return mxi;
}
void add(int &x,int y)
{
	x+=y;
	if (x>=mod) x-=mod;
}
void dfs(int i,int fa,int dep)
{
	if (dep==len)
	{
		dp[i][0][0]=dp[i][1][0]=dp[i][0][1]=1;
		return;
	}
	for (int j=0;j<g[i].size();j++)
	{
		int to=g[i][j];
		if (to==fa) continue;
		dfs(to,i,dep+1);
	}
	memset(f,0,sizeof(f));
	f[0][0]=1;
	for (int j=0;j<g[i].size();j++)
	{
		int to=g[i][j];
		if (to==fa) continue;
		memset(G,0,sizeof(G));
		for (int k=0;k<3;k++)
		{
			for (int h=0;h<3;h++)
			{
				for (int s=0;s<3;s++)
				{
					for (int t=0;t<3;t++)
					{
						add(G[min(k+s,2)][min(h+t,2)],1ll*f[k][h]*dp[to][s][t]%mod);
					}
				}
			}
		}
		memcpy(f,G,sizeof(G));
	}
	for (int j=0;j<3;j++)
	{
		for (int k=0;k<3;k++)
		{
			if (i!=rt)
			{
				add(dp[i][0][0],f[j][k]);
				add(dp[i][0][k],f[j][k]);
				add(dp[i][j][0],f[j][k]);
			}
			else 
			{
				add(dp[i][j][k],f[j][k]);
			}
		}
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	x=bfs(1);
	y=bfs(x);
	if (dist[y]&1)
	{
		for (int i=y;i!=x;i=pre[i])
		{
			cnt++;
			if (cnt==(dist[y]+1)/2)
			{
				++n;
				rt=n;
				g[rt].push_back(i);
				g[rt].push_back(pre[i]);
				g[i].push_back(rt);
				g[pre[i]].push_back(rt);
				for (int j=0;j<g[i].size();j++)
				{
					if (g[i][j]==pre[i])
					{
						g[i].erase(g[i].begin()+j);
						break;
					}
				}
				for (int j=0;j<g[pre[i]].size();j++)
				{
					if (g[pre[i]][j]==i)
					{
						g[pre[i]].erase(g[pre[i]].begin()+j);
						break;
					}
				}
				len=(dist[y]+1)/2;
				break;
			}
		}
	}
	else
	{
		for (int i=y;i!=x;i=pre[i])
		{
			cnt++;
			if (cnt==dist[y]/2+1)
			{
				rt=i;
				len=dist[y]/2;
				break;
			}
		}
	}
	dfs(rt,0,0);
	printf("%d\n",1ll*dp[rt][1][1]*iv%mod);
	return 0;
}

Measured memory_bytes: 35328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    int a[n][d];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
        cin>>a[i][j];
    }
    int cnt=0;
    float x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            x=0;
            for(int k=0;k<d;k++)
            {
                x+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            y=sqrt(x);
            if(ceil(y)==floor(y))
            cnt++;
        }
    }
    cout<<cnt;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<map>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 110000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main(){
    ll N;
    cin>>N;
    
    cout<<(N-1)/2<<endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	S := sc.nextRuneSlice()
	R := make([]int, N+1)
	G := make([]int, N+1)
	B := make([]int, N+1)
	for i := 0; i < N; i++ {
		if S[i] == 'R' {
			R[i+1] = 1
		} else if S[i] == 'G' {
			G[i+1] = 1
		} else {
			B[i+1] = 1
		}
	}
	for i := 1; i <= N; i++ {
		R[i] += R[i-1]
		G[i] += G[i-1]
		B[i] += B[i-1]
	}
	ans := 0
	for i := 0; i < N; i++ {
		s1 := S[i]
		for j := i + 1; j < N; j++ {
			s2 := S[j]
			if s1 == s2 {
				continue
			}
			diff := j - i
			if s1 != 'R' && s2 != 'R' {
				ans += R[min(j+diff, N)] - R[min(j+1, N)]
				ans += R[N] - R[min(j+diff+1, N)]
			} else if s1 != 'G' && s2 != 'G' {
				ans += G[min(j+diff, N)] - G[min(j+1, N)]
				ans += G[N] - G[min(j+diff+1, N)]
			} else {
				ans += B[min(j+diff, N)] - B[min(j+1, N)]
				ans += B[N] - B[min(j+diff+1, N)]
			}
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 1900
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void swapp(int *,int *);
int main(){
  while(1){
    int M,T,P,R;
    cin >> M >> T >> P >> R;
    if(M==0&&T==0&&P==0&&R==0)break;
    int te[51];
    int tr[51];
    int tp[51]={};
    int tt[51]={};
    vector<vector<int> >ts(T+1,vector<int>(P+1,0));
    for(int i=0;i<R;i++){
      int m,t,p,j;
      cin >> m >> t >> p >> j;
      if(j==0){
	tt[t]+=ts[t][p]+m;
	tp[t]++;
      }
      else{
	ts[t][p]+=20;
      }
    }
    for(int i=1;i<=T;i++){
      //
      // cout << i<<" "<<tp[i]<< " "<< tt[i]<<endl;
      //
      tr[i]=i;
      te[i]=0;
    }
    //sort
    for(int i=1;i<=T;i++){
      for(int j=1;j<T;j++){
	if(tp[j]<tp[j+1]){
	  //  cout << tr[j]<<" "<<tr[j+1]<<endl;
	  swapp(tr+j,tr+j+1);
	  swapp(te+j,te+j+1);
	  swapp(tt+j,tt+j+1);
	  swapp(tp+j,tp+j+1);
	  //  cout << tr[j]<<" "<<tr[j+1]<<endl;
	}
	else if(tp[j]==tp[j+1]){
	  if(tt[j]>tt[j+1]){
	    swapp(tr+j,tr+j+1);
	    swapp(te+j,te+j+1);
	    swapp(tt+j,tt+j+1);
	    swapp(tp+j,tp+j+1);
	  }
	  else if(tt[j]==tt[j+1]){
	    if(tr[j]<tr[j+1]){
	      swapp(tr+j,tr+j+1);
	      swapp(te+j,te+j+1);
	      swapp(tt+j,tt+j+1);
	      swapp(tp+j,tp+j+1);
	    }
	    te[j]=1;
	    
	  }
	}
      }
    }
    // for(int i=1;i<=T;i++)  cout << i<<" "<<tp[i]<< " "<< tt[i]<<endl;
    for(int i=1;i<=T;i++){

      cout << tr[i];
      if(i<T){
	if(te[i]==1){
	  cout << '=';
	}
	else cout << ',';
      }
    }
    cout << endl;
  }
  return 0;
}
void swapp(int *m,int *a){
  int b;
  b=*m;
  *m=*a;
  *a=b;
  return;
}

Measured memory_bytes: 3128
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,r;
    cin>>r;
    ans=3*r*r;


    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;
const double PI = acos(-1.0);

double Q(double X){return X*X;}

int main(){
	double a,b,c,d;
	while(cin>>a>>b>>c>>d,a!=-1&&b!=-1&&c!=-1&&d!=-1){
		a = a / 180 * PI;
		b = b / 180 * PI;
		c = c / 180 * PI;
		d = d / 180 * PI;
		double ax,ay,az;
		az = sin(a);
		ax = sqrt(1-az*az) * cos(b);
		ay = sqrt(1-az*az) * sin(b);
		double bx,by,bz;
		bz = sin(c);
		bx = sqrt(1-bz*bz) * cos(d);
		by = sqrt(1-bz*bz) * sin(d);
		double dis = sqrt(Q(ax-bx)+Q(ay-by)+Q(az-bz));
		double arc = asin(dis/2);
		double ans = 2 * 6378.1 * arc;
		int i_ans = (int)floor(ans + 0.5);
		cout << i_ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1312
// Problem: E - Logs
// Contest: AtCoder - AtCoder Beginner Contest 174
// URL: https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n , k;
           cin >> n >> k;
           
           vector<int> a(n);
           for(auto &x : a)
           {
               cin >> x;
           }
           
           int l = 0 , r = *max_element(a.begin() , a.end());
           
           while(l < r - 1)
           {
               int mid = (l + r) / 2 ;
               int c = 0;
               
               for(auto x : a)
               {
                   c += (x - 1) / mid;
               }
               
               if(c <= k)
               {
                   r = mid;
               }
               else l = mid;
           }
           
           cout << r << endl;
        }
    }



Measured memory_bytes: 3956
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e18;
const ll MAXN=1e6;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll k;
cin>>k;
ll p=7;
for(ll i=1;i<=1e7;i++)
{
    if(p%k==0)
    {
        cout<<i;return 0;
    }
    p=p%k;
    p*=10;
    p+=7;
}
cout<<-1;
return 0;
}


Measured memory_bytes: 3652
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  VI a(n);
  REP(i, n) cin >> a[i];

  int suma = 0, sumb = 0;
  bool flaga = true, flagb = true;
  REP(i, n) {
    if(i%2==0 && a[i]>=0) suma += a[i], flaga = false;
    if(i%2 && a[i]>=0) sumb += a[i], flagb = false;
  }
  if(flaga && flagb) {
    int ma = -LLINF, idx = -1;
    REP(i, n) {
      if(ma < a[i]) {
        ma = a[i];
        idx = i;
      }
    }
    cout << ma << endl;
    cout << n-1 << endl;
    REP(i, idx) cout << 1 << endl;
    for(int i=n-idx; i>1; --i) cout << i << endl;
    return 0;
  }

  if(suma > sumb) {
    cout << suma << endl;
    bool flag = true;
    int num1 = 0, num2 = 0;
    VI ans;
    // 偶数番目でマイナスのやつを消す
    REP(i, n) {
      if(i%2==0 && a[i]<0) {
        ans.PB(i-num1);
        if(i==0||i==n-1) {
          num1++;
          if(flag) num2++;
        } else {
          num1+=2;
          if(flag) num2+=2;
        }
      }
      if(i%2==0 && a[i]>=0) {
        flag = false;
      }
    }
    // いらないのを消す
    // 偶奇反転で偶数番目を消す
    if(num2%2) {
      ans.PB(0);
      REP(i, n-num1) {
        if(i%2==0) ans.PB(1);
      }
      ans.pop_back();
    } else {
      REP(i, n-num1) {
        if(i%2) ans.PB(1);
      }
    }
    cout << ans.size() << endl;
    REP(i, ans.size()) cout << ans[i]+1 << endl;
  } else {
    // cout << "b" << endl;
    cout << sumb << endl;
    bool flag = true;
    int num1 = 0, num2 = 0;
    VI ans;
    // 偶数番目でマイナスのやつを消す
    REP(i, n) {
      if(i%2 && a[i]<0) {
        ans.PB(i-num1);
        if(i==0 || i==n-1) {
          num1++;
          if(flag) num2++;
        } else {
          num1+=2;
          if(flag) num2+=2;
        }
      }
      if(i%2 && a[i]>=0) flag = false;
    }
    // いらないのを消す
    // 偶奇反転で偶数番目を消す
    if(num2%2) {
      REP(i, n-num1) {
        if(i%2) ans.PB(1);
      }
    } else {
      ans.PB(0);
      REP(i, n-num1) {
        if(i%2==0) ans.PB(1);
      }
      ans.pop_back();
    }
    cout << ans.size() << endl;
    REP(i, ans.size()) cout << ans[i]+1 << endl;
  }

  return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int func(long long n, long long k, std::vector<long long> h) {
    // cout << fixed << setprecision(8);
    sort(all(h));

    ll ans = INF;
    for (int i = 0; i < n - (k - 1); i++) {
        ans = min(ans, h[i + (k - 1)] - h[i]);
    }

    cout << ans << endl;

    return 0;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &h[i]);
    }

    func(N, K, std::move(h));

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define MOD (1000000007)
/*AGC,GAC,ACG,AG-C,A-GC=>023,203,032,02-3,0-23*/
/*
[2][3][-]は[0][2][3]
[0][3][-]は[2][0][3]
[3][2][-]は[0][3][2]
[2][-][3]は[0][2][-]
[-][2][3]は[0][-][2]からの寄与を受けない*/
int main(){
  int n;
  long dp[98][4][4][4],ans=0;/*dp[i]=>n=i+3までの並べ方*/
  scanf("%d",&n);
  for (int i=0;i<98;i++){
    for (int j=0;j<4;j++){
      for (int k=0;k<4;k++){
        for (int l=0;l<4;l++){/*初期化*/
          dp[i][j][k][l]=1;
        }
      }
    }
  }
  dp[0][0][2][3]=0;
  dp[0][2][0][3]=0;
  dp[0][0][3][2]=0;
  for (int i=0;i<n-3;i++){
    for (int j=0;j<4;j++){
      for (int k=0;k<4;k++){
        for (int l=0;l<4;l++){/*dp[i][j][k][l]の処理*/
          if (j==0 && k==2 && l==3) dp[i+1][j][k][l]=0;
          else if (j==2 && k==0 && l==3) dp[i+1][j][k][l]=0;
          else if (j==0 && k==3 && l==2) dp[i+1][j][k][l]=0;
          else if (j==2 && l==3) 
            dp[i+1][j][k][l]
            =(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
          else if (k==2 && l==3) 
            dp[i+1][j][k][l]
            =(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
          else dp[i+1][j][k][l]
            =(dp[i][0][j][k]+dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
        }
      }
    }
  }
  for (int j=0;j<4;j++){
    for (int k=0;k<4;k++){
      for (int l=0;l<4;l++){
        ans+=dp[n-3][j][k][l];
        ans%=MOD;
      }
    }
  }
  printf("%ld",ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------


string S;
void _main() {
	cin >> S;
	string ans = "No";
	int count = 0;
	map<char, int> num;
	rep(i, 0, 4) {
		if (num[S[i]] == 2) break;
		num[S[i]]++;
		if (num[S[i]] == 2) count++;
	}
	if (count == 2) ans = "Yes";
	cout << ans << endl;
}

Measured memory_bytes: 256
/*    _                     _     
  __| | _____   _____  ___| |__  
 / _` |/ _ \ \ / / _ \/ __| '_ \ 
| (_| |  __/\ V /  __/\__ \ | | |
 \__,_|\___| \_/ \___||___/_| |_|
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define faster       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define  endl    '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define F           first
#define S           second
#define rep(i,j,k)  for(int i=j;i<k;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define what_is(x)  cout << #x << " is " << x << endl;
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


using namespace std;
using namespace __gnu_pbds;
 
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
#define N  100005

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
 
int main(){
  faster
  	int n,m;
  	cin>>n>>m;
  	int a[n][m];
  	int dp[n][m];
  	memset(dp,0,sizeof(dp));
  	rep(i,0,n){
  		rep(j,0,m){
  		char x;
  		cin>>x;
  		if(x=='.')a[i][j]=1;
  		else a[i][j]=0;
  		}
  	}
  	dp[0][0]=1;
  	rep(i,0,n){
  		rep(j,0,m){
  			if(i==0 && j==0)continue;
  			if(a[i][j]==0){
  				dp[i][j]=0;
  				continue;
  			}
  			if(i>0 && a[i][j]==1){
  				dp[i][j]+=dp[i-1][j];
  				dp[i][j]%=hell;
  			}
  			if(j>0 && a[i][j]==1){
  				dp[i][j]+=dp[i][j-1];
  				dp[i][j]%=hell;
  			}

  		}
  	}
  
  cout<<dp[n-1][m-1]<<endl;
}


 

Measured memory_bytes: 11372
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;

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

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 2e5;
ll N, T;
ll t[MAX_N + 1];
int main(){
  cin >> N >> T;
  ll ans = 0;
  REP(i, N){
    cin >> t[i];
  }
  t[N] = INF;
  REP(i, N){
    ans += min(t[i + 1] - t[i], T);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int x;
  cin >> x;
  cout << (1 - x) << nl;
  return 0;
}


Measured memory_bytes: 3640
import math

n,d = map(int,input().split())
x = [0]*n
y = [0]*n
for i in range(n):
    x[i],y[i] = list(map(int,input().split()))

cnt = 0

for i in range(n):
    D = math.sqrt(x[i]**2 + y[i]**2)
    if D <= d:
        cnt += 1

print(cnt)

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

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    int price = 0;
    int waribiki = vec.at(0) / 2;
    for(int i = 0; i < n; i++){
        price = price + vec.at(i);
    }
    cout << price - waribiki << endl;
}


Measured memory_bytes: 256
import math
x,y=map(int,input().split())
if x==1 or y==1:
    print(1)
else:    
    a=math.ceil(x/2)
    b=math.floor(x/2)
    if(y%2==0):
        print((a+b)*y//2)
    else:
        print(a*(y//2+1)+b*(y//2))


Measured memory_bytes: 38512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;cin>>q;
  FOR(i,0,q){
    string x, y;
    cin >> x >> y;
    int n = x.length();
    int m = y.length();
    int dp[n+1][m+1];
    CLR(dp);
    FOR(i,0,n){
      FOR(j,0,m){
        if(x[i]==y[j]){
          dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
        }
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
      }
    }
    cout<<dp[n][m]<<endl;
  }
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

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

  vector<int> votes(M,0);

  int K,A;
  for (auto i = 0; i != N; ++i) {
    cin >> K;
    for (auto j = 0; j != K; ++j) {
      cin >> A;
      ++votes[A-1];
    }
  }

  int ans{};
  for (auto i = 0; i != M; ++i) {
    if (votes[i]==N) {
      ++ans;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e9+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t,n;
	cin>>n;
	ll a[n],s=0;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
	    for(int j=i+1;j<n;j++) s+=a[i]*a[j];
	}
	cout<<s;
    return 0;
}

Measured memory_bytes: 256
sub f{my($u,$t,$p)=@_;push@$t,$u;$_-$p&&f($_,$t^R,$u)for@$u}@n=1..<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f 1,b;map{$s=++$x-3;$s+3>$.or$a[$_]||=$s+=3for@$_}@b>$./3&@0>$./3?(0,b):(@b>@0?b:0)x2,n;print"@a"

Measured memory_bytes: 282752
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let x = read::<i128>();
    let mut stock = 100i128;
    let mut ans = 0;
    while stock < x {
        stock *= 101;
        stock /= 100;
        ans += 1;
    }
    println!("{}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2128
// B - Popular Vote
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int N,M; cin>>N>>M;
	vector<int> A(N);
	int tot = 0;
	rep(i, N){
		cin>>A[i];
		tot += A[i];
	}
	sort(A.rbegin(), A.rend());
	puts(tot <= A[M-1]*4*M? "Yes":"No");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int *A,i,j,N,minv,maxv=-6000000000,count=0;
  scanf("%d\n",&N);
  A=(int *)malloc(N*sizeof(int));
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  minv=A[0];
  for(j=1;j<=N-1;j++){
    if(maxv<A[j]-minv) maxv=A[j]-minv;
    if(minv>A[j]) minv=A[j];
  }
  printf("%d\n",maxv);
  return 0;
}



Measured memory_bytes: 2588
N,L=gets.split.map(&:to_i)

A=gets.split.map(&:to_i)

last=-1
(N-1).times do |i|
  last=i if A[i]+A[i+1]>=L
end

if last==-1
  puts "Impossible"
else
  puts "Possible"
  (N-1).times do |i|
    break if i==last
    puts i+1
  end
  (N-1).times.reverse_each do |i|
    break if i==last
    puts i+1
  end
  puts last+1
end

Measured memory_bytes: 12560
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	double a, b, c, d, e, f;
	cout << setprecision(3);
	cout << fixed;
	while (cin >> a >> b >> c >> d >> e >> f){
		double x = (c * e - b * f) / (a * e - b * d);
		double y = (c * d - a * f) / (b * d - a * e);
		if (x < 0.0005 && x > -0.0005)
			x = 0;
		if (y < 0.0005 && y > -0.0005)
			y = 0;
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1280