akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let (n, x, y): (usize, usize, usize) =
        (read::<usize>(), read::<usize>() - 1, read::<usize>() - 1);
    let mut adjl = vec![vec![]; n];
    adjl[x].push(Edge { node: y, cost: 1 });
    adjl[y].push(Edge { node: x, cost: 1 });
    for i in 0..n - 1 {
        adjl[i].push(Edge {
            node: (i + 1) % n,
            cost: 1,
        });
        adjl[(i + 1) % n].push(Edge { node: i, cost: 1 });
    }
    // println!("{:?}", adjl);
    let mut ansv = vec![0; n];
    for i in 0..n {
        let distimes = shortest_path(&adjl, i);

        for j in i + 1..n {
            ansv[distimes[j].0] += distimes[j].1;
        }
    }
    for i in 1..n {
        println!("{}", ansv[i]);
    }
}

#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    cost: usize,
    position: usize,
    times: usize,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> std::cmp::Ordering {
        other.cost.cmp(&self.cost)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

#[derive(Debug, Copy, Clone)]
struct Edge {
    node: usize,
    cost: usize,
}

fn shortest_path(adjl: &Vec<Vec<Edge>>, start: usize) -> Vec<(usize, usize)> {
    let mut distimes: Vec<(usize, usize)> = (0..adjl.len()).map(|_| (std::usize::MAX, 0)).collect();

    let mut heap = std::collections::BinaryHeap::new();

    distimes[start] = (0, 1);
    heap.push(State {
        cost: 0,
        position: start,
        times: 1,
    });

    while let Some(State {
        cost,
        position,
        times,
    }) = heap.pop()
    {
        if cost > distimes[position].0 {
            continue;
        }

        for edge in &adjl[position] {
            let next = State {
                cost: cost + edge.cost,
                position: edge.node,
                times: times,
            };
            // 次に行けるところがdistに書いたのより早く行ける
            if next.cost < distimes[next.position].0 {
                heap.push(next);
                distimes[next.position].0 = next.cost;
                distimes[next.position].1 = next.times;
            } else if next.cost == distimes[next.position].0 {
                heap.push(State {
                    cost: cost + edge.cost,
                    position: edge.node,
                    times: times + 1,
                });
            }
        }
    }
    distimes
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main() {
    string s; cin >> s;
    int tmp = s.length()-1;
    bool flag = true;
    bool flag2;
    vector<string> cand(4);
    cand[0] = "dream"; cand[1] = "dreamer"; cand[2] = "erase"; cand[3] = "eraser";
    while (tmp >= 0) {
        flag2 = false;
        for (int j = 0; j < 4; j++) {
            flag = true;
            for (int i = 0; i < cand[j].length(); i++) {
                if (tmp - i >= 0) {
                    if (s[tmp-i] != cand[j][cand[j].length()-1-i]) flag = false;
                }
            }
            if (flag) {
                tmp -= cand[j].length();
                flag2 = true;
                continue;
            }
        }
        if (flag2) continue;
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

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

int main() {
  // input
  int n {0};
  cin >> n;
  int tmp {0};
  cin >> tmp;
  int minv = tmp;
  int ans = -(1 << 30);

  for (int i = 1; i < n; i++) {
    cin >> tmp;
    if (ans <= tmp - minv) {
      ans = tmp - minv;
    }
    if (minv >= tmp) minv = tmp;
  }

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


Measured memory_bytes: 3128
#include<iostream>
using namespace std;
int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0&&W==0) break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((i+j)%2==0){
                    cout<<'#';
                }
                else{
                    cout<<'.';
                }
                
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,t,a,x=1,y=1,m;
  cin>>n;
  fr(i,n){
    cin>>t>>a;
    m=max((x-1)/t,(y-1)/a)+1;
    x=t*m;y=a*m;
  }
  cout<<x+y<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * (max(A) + 2)


for a in A:
    if a == 0:
        cnt[a] += 1
        cnt[a + 1] += 1
    else:
        cnt[a - 1] += 1
        cnt[a] += 1
        cnt[a+1] += 1

cnt.sort(reverse=True)
print(cnt[0])


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

using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;

int N, M, A, B, C, T;

mat mul(const mat &A, const mat &B) {
	mat C(A.size(), vec(B[0].size()));
	for (int i = 0; i < A.size(); i++)
		for (int k = 0; k < B.size(); k++)
			for (int j = 0; j < B[0].size(); j++)
				C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
	return C;
}

mat powMat(mat A, int n) {
	mat B(A.size(), vec(A.size()));
	for (int i = 0; i < A.size(); i++)
		B[i][i] = 1;
	while (n > 0) {
		if (n & 1) B = mul(B, A);
		A = mul(A, A);
		n >>= 1;
	}
	return B;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> N >> M >> A >> B >> C >> T, N || M || A || B || C || T) {
		vec s(N);
		for (int i = 0; i < N; i++)
			cin >> s[i];

		mat a(N, vec(N));
		a[0][0] = B;	a[0][1] = C;
		a[N - 1][N - 2] = A; a[N - 1][N - 1] = B;
		for (int i = 1; i < N - 1; i++)
			a[i][i - 1] = A, a[i][i] = B, a[i][i + 1] = C;
		a = powMat(a, T);
		vec ans(N);
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				ans[i] += a[i][j] * s[j];
		for (int i = 0; i < N - 1; i++)
			cout << ans[i] % M << " ";
		cout << ans[N - 1] % M << endl;
	}
}

Measured memory_bytes: 1292
import string
def resolve():
    N = int(input())-1
    lst = []
    while True:
        lst.append(N%26)
        N //= 26
        N-=1
        if N == -1:
            break
    lst.reverse()

    
    st = [string.ascii_lowercase[i] for i in lst]
    print("".join(st))
resolve()

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

// #undef DEBUG
//#define DEBUG
/// {{{ DEBUG --- ///
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; }
#ifdef DEBUG
#define dump(...) cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n";
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
#else
#define dump(...)
#endif
/// }}}--- ///

#define uniq(v) {sort(begin(v), end(v)); (v).erase(unique(begin(v), end(v)), end(v)); }

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  string s;
  cin >> s;
  int k; cin >> k;
  int n = s.size();
  vector<string> v;
  for(int i = 0; i < n; i++) {
    for(int j = 1; j <= 5; j++){
      v.emplace_back(s.substr(i, j));
    }
  }
  uniq(v);
  dump(v);
  cout << v[k - 1] << endl;
}


Measured memory_bytes: 1660
# coding: utf-8

def getMBinary(N):
    S = ""
    
    while N != 0:
        if N % -2 == 0:
            S = "0" + S
        if N % -2 != 0:
            S = "1" + S
            N = N - 1
        N = N // -2
    
    if S == "":
        S = "0"
    
    return S
if __name__ == "__main__":
    N = int(input())
    print(getMBinary(N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
 
int main() {
    int n;
    string s;
    cin >> s;
    n = s.length();
    for(int i = 0;i<s.length()/2;i++) {
        if(s.substr(i,1) != s.substr(s.length() - i -1, 1)) {
            cout << "No" << '\n';
            return 0;
        }
    }

    for(int i = 0;i < (n-1)/(2*2); i++) {
        if(s.substr(i,1) != s.substr((n-1)/2 - i - 1,1)) {
            cout << "No" << '\n';
            return 0;
        }
    }

    int k = 0;
    for(int i = (n+3)/(2);i< n/(2*2); i++) {
        if(s.substr(i - 1,1) != s.substr(n-1-k,1)) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                                
def I(): return list(map(int,inp().split()))
m=10**9+7

n,k=I()
ans=1 ;a=[]
for i in range(k,n+1):
    ans+=i*(n-i+1)+1
    ans%=m
    a.append(k*(n-i+1)+1)
print(ans)
    
    



Measured memory_bytes: 78528
#include<bits/stdc++.h>
using namespace std;
int x,y,z,med;

int main()
{
	scanf("%d%d%d",&x,&y,&z);
	med=y,y=x,x=med;
	med=z,z=x,x=med;
	
	printf("%d %d %d",x,y,z);
	return 0;
}

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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> vh(n),vv(n);
  for(int i=0;i<n;i++){
    cin >> vh[i].first;
  	cin >> vv[i].first;
    vh[i].second = i;
    vv[i].second = i;
  }
  sort(vh.begin(),vh.end());
  sort(vv.begin(),vv.end());
  priority_queue<pair<int,pair<int,int>>, vector<pair<int,pair<int,int>>>, std::greater<pair<int,pair<int,int>>> > q;
  for(int i=0;i<n-1;i++){
    int costh,costv;
    costh = vh[i+1].first-vh[i].first;
    costv = vv[i+1].first-vv[i].first;
    q.push(make_pair(costh, make_pair(vh[i].second,vh[i+1].second)));
    q.push(make_pair(costv, make_pair(vv[i].second,vv[i+1].second)));
  }
  
  struct UnionFind uf(n);
  long long int ans = 0;
  while(uf.size(0)!=n){
  	int cost = q.top().first, r = q.top().second.first, l = q.top().second.second;
    q.pop();
    if(uf.findSet(r,l)) continue;
    else{
      ans += cost;
      uf.unionSet(r,l);
    }
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 6132
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) {cout<<n<<"\n" ; return ;}
#define po(n) cout << n <<"\n " 
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#ifndef ONLINE_JUDGE
//#ifndef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#else
//#define debug(x...)
//#endif
//#define int ll 
long const M=1e9+7;
const long mxN =2e5+2 ;
const long mxA=1e6+2 ;
const ll INF =1e18;
int n ,a[mxN],cnt[mxA];
bool c[mxA];

void solve(){ 
  mems(c,1);mems(cnt,0) ;
  cin >> n ;
  int maxi =-1 ;
  For(i,n){
    cin >> a[i] ;cnt[a[i]]++ ;
    maxi = max(maxi,a[i]) ;
  } 
  For(i,n){
    for(int j=2*a[i];j<=maxi;j+=a[i])
      c[j]=0 ;
  }
  int ans =0 ;
  For(i,n){
    if(cnt[a[i]]>1)
      continue;
    if(c[a[i]])
      ++ans ;
  }
  pf(ans) ;
  
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  // ll t ; cin >> t ; while(t--)solve() ;
	return 0;
}


Measured memory_bytes: 9272
n,m=map(int,input().split())
gate=[list(map(int,input().split())) for i in range(m)]
small=[]
tall=[]
for i in range(m):
    small+=[gate[i][0]]
    tall+=[gate[i][1]]
smallmax=(max(small))
tallmin=(min(tall))
if tallmin-smallmax>=0:
    print(tallmin-smallmax+1)
else:
    print(0)

Measured memory_bytes: 28792
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}
using ll=long long ;

int main() {
	ios::sync_with_stdio(false);
	// int a,b,c,d;cin>>a>>b>>c>>d;
	// cout<<(int(b>d))<<endl;

	// int N;cin>>N;
	// int answer=-1;
	// for(int i=1;i<50000;++i){
	// 	int j=i*108;
	// 	j/=100;
	// 	if(j==N){
	// 		answer=i;
	// 		break;
	// 	}
	// }
	// if(answer==-1)cout<<":("<<endl;
	// else cout<<answer<<endl;

	// int N;cin>>N;
	// string st;cin>>st;
	// //vector<vector<int>>dp(4,vector<int>(30001));
	// int answer=0;
	// for(int i=0;i<1000;++i){
	// 	vector<int>v;
	// 	int k=i;
	// 	for(int j=0;j<3;++j){
	// 		v.push_back(k%10);
	// 		k/=10;
	// 	}
		
	// 	int now=0;
	// 	for(auto c:st){
	// 		if(now<3&&v[now]==c-'0'){
	// 			now++;
	// 		}
	// 	}
	// 	if(now==3)answer++;
	// }

	// cout<<answer<<endl;
	// return 0;

	// ll answer=1;
	// int N;cin>>N;
	// vector<int>v(3);
	// while(N--){
	// 	int a;cin>>a;
	// 	ll val=0;
	// 	int place=-1;
	// 	for(int i=0;i<3;++i){
	// 		if(a==v[i]){
	// 			val++;
	// 			place=i;
	// 		}
	// 	}
	// 	if(place!=-1){
	// 		answer*=val;
	// 		v[place]++;
	// 	}else{
	// 		break;
	// 	}
	// 	//WHATS(v)
	// 	answer%=ll(1e9+7);
	// }
	// cout<<answer<<endl;

	ll T1,T2;cin>>T1>>T2;
	ll A1,A2,B1,B2;cin>>A1>>A2>>B1>>B2;
	A1*=T1;
	A2*=T2;
	B1*=T1;
	B2*=T2;

	if(A1>B1){
		swap(A1,B1);
		swap(A2,B2);
	}
	assert(A1<B1);
	//WHATS(A1)
	if(A1+A2==B1+B2){
		
		cout<<"infinity"<<endl;
	}else{
		{
			ll dis=A1+A2-B1-B2;
			
			if(dis<0){
				cout<<0<<endl;
			}else{
				ll kk=B1-A1;
				ll answer=1;
				answer+=2*(kk/dis);
				if(kk%dis==0){
					answer--;
				}
				cout<<answer<<endl;
			}
		}
	}
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> A(N, 0);
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    A[a - 1]++;
    A[b - 1]++;
  }
  for(int i = 0; i < N; i++) {
    cout << A[i] << endl;
  }

  return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int n;
int a[22][22];
ll dp[22][1<<21];
vector<int> bs[22];

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

  cin>>n;
  rep(i,n)rep(j,n)cin>>a[i][j];

  rep(S,1<<n){
    bs[bcnt(S)].push_back(S);
  }

  dp[0][0]=1;
  rep(i,n){
    for(ll b : bs[i]){
      rep(j,n){
        if(((b>>j)&1)||a[i][j]==0)continue;
        (dp[i+1][b|(1<<j)]+=dp[i][b])%=mod;
      }
    }
  }
  cout<<dp[n][(1<<n)-1]<<endl;

  return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;
    //code
    int n , k;
    cin >> n >> k;
    int ans = 0;
    int cnt = 0;
    for(int i = 0 ; i <= n ; ++i){
    	for(int j = 0 ; j <= n ; ++j){
    		if(i + j <= k && ( 0 <= (k - i - j) and (k - i - j ) <= n)){
    			cnt++;
    		}
    	}
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a+b+c>=22)
    {
        printf("bust\n");
    }
    else
    {
        printf("win\n");
    }
    return 0;
}


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


int main()
{
    int x,y ;
    cin>>x>>y;
    if((x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12 ) && (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12 ))
        cout<<"Yes"<<endl;
    else if((x==4 || x==9 || x==6 || x==11) && (y==4 ||y==9 || y==6 || y==11))
        cout<<"Yes"<<endl;
    else if((x==2)&& (y==2))
        cout<<"Yes"<<endl;

    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3548
mod = 998244353
N, A, B, K = map(int, input().split())
def make_fact(n):#0~nの階乗を求める
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i%mod
    return fact
fact = make_fact(N) #＠
def make_fact_inv(n):#0~nの階乗のmodに関する逆元を求める
    fact_inv = [1]*(n+1)
    fact_inv[n] = pow(fact[n], mod-2, mod)#フェルマーの小定理
    for i in range(n, 0, -1):
        fact_inv[i-1] = fact_inv[i]*i%mod
    return fact_inv
fact_inv = make_fact_inv(N)#＠
def comb(n, k):#nCk
    return fact[n]*fact_inv[k]*fact_inv[n-k]%mod
ans = 0
for k in range(N+1):
    r = K-k*A
    if r<0 or r%B != 0 or r//B>N:
        continue
    l = r//B
    ans+=comb(N, k)*comb(N, l)
    ans%=mod
print(ans)



Measured memory_bytes: 46060
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	
	string s;
	int cnt = 0;
	cin >> s;
	sort(s.begin(), s.end());
	for (int i = 0; i < s.length()-1; i++)
		if (s[i] == s[i + 1])
			cnt++;
	if (cnt == 2)
		cout << "Yes";
	else
		cout << "No";
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x,k,d; cin >> x >> k >> d;


	if(x > 0){
		ll necesito = x/d;
		necesito = min(necesito,k);
		
		k -= necesito;
		x -= necesito*d;
		
	}else if(x < 0){
		ll necesito = -x/d;
		necesito = min(necesito,k);
		
		k -= necesito;
		x += necesito*d;
	}

	if(!k){
		cout << abs(x) << '\n';
		return 0;
	}
	
	if(k%2 == 0){
		cout << abs(x) << '\n';
		return 0;
	}
	cout << min(abs(x+d),abs(x-d)) << '\n';
	

	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


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

int main() {
  int n;
  cin >> n;
  string taro, hanako;
  int pt_taro = 0, pt_hanako = 0;
  for (int i = 0; i < n; ++i) {
    cin >> taro >> hanako;
    if (taro == hanako) {
      pt_taro++;
      pt_hanako++;
    } else if (taro > hanako) {
      pt_taro += 3;
    } else {
      pt_hanako += 3;
    }
  }
  cout << pt_taro << " " << pt_hanako << endl;

  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    
    int input, ans = 0;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        while(input % 2 == 0){
            ans++;
            input /= 2;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007

int main() {
    ll n, m;
    cin >> n >> m;
    if(n==4 && m==1)cout<<"1 2"<<endl;
    else if (n % 2 == 0&& m>=n/4) {
        for (ll i = 0; i < n/4; ++i) {
            cout << i + 1 << " " << n - i << endl;
        }
        for (int j = 0; j < m-(n/4); ++j) {
            cout<<n/4+j+1<<" "<<n-1-(n/4+j)<<endl;
        }
    } else {
        for (ll i = 0; i < m; ++i) {
            cout << i + 1 << " " << n - i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
#include <set>
#include <cstdio>

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

using namespace std;

int main(){
	int n,q; scanf("%d%d",&n,&q);
	static int num[1000001];
	set< pair<int,int> > S; S.insert(make_pair(0,1));
	rep(_,q){
		int a,v; scanf("%d%d",&a,&v);
		if(num[a]>0) S.erase(S.find(make_pair(-num[a],a)));
		num[a]+=v;
		if(num[a]>0) S.insert(make_pair(-num[a],a));
		printf("%d %d\n",S.begin()->second,-S.begin()->first);
	}

	return 0;
}

Measured memory_bytes: 9388
package main

import "fmt"

const MAX = 10000
const NIL = -1

type Node struct {
	parent int
	left   int
	right  int
}

var T [MAX]Node
var n int
var D [MAX]int
var H [MAX]int

func setDepth(u int, d int) {
	if u == NIL {
		return
	}
	D[u] = d
	setDepth(T[u].left, d+1)
	setDepth(T[u].right, d+1)
}

func setHeight(u int) int {
	var h1, h2 int
	if T[u].left != NIL {
		h1 = setHeight(T[u].left) + 1
	}
	if T[u].right != NIL {
		h2 = setHeight(T[u].right) + 1
	}
	if h1 > h2 {
		H[u] = h1
		return h1
	} else {
		H[u] = h2
		return h2
	}
}

func getSibling(u int) int {
	if T[u].parent == NIL {
		return NIL
	}
	if T[T[u].parent].left != u && T[T[u].parent].left != NIL {
		return T[T[u].parent].left
	}
	if T[T[u].parent].right != u && T[T[u].parent].right != NIL {
		return T[T[u].parent].right
	}
	return NIL
}

func printNodes(u int) {
	fmt.Printf("node %d: ", u)
	fmt.Printf("parent = %d, ", T[u].parent)
	fmt.Printf("sibling = %d, ", getSibling(u))
	deg := 0
	if T[u].left != NIL {
		deg++
	}
	if T[u].right != NIL {
		deg++
	}
	fmt.Printf("degree = %d, ", deg)
	fmt.Printf("depth = %d, ", D[u])
	fmt.Printf("height = %d, ", H[u])
	if T[u].parent == NIL {
		fmt.Printf("root\n")
	} else if T[u].left == NIL && T[u].right == NIL {
		fmt.Printf("leaf\n")
	} else {
		fmt.Printf("internal node\n")
	}
}

func main() {
	var v, l, r, root int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		T[i].parent = NIL
	}
	for i:= 0; i < n; i++ {
		fmt.Scan(&v, &l, &r)
		T[v].left = l
		T[v].right = r
		if l != NIL {
			T[l].parent = v
		}
		if r != NIL {
			T[r].parent = v
		}
	}
	for i := 0;i < n; i++ {
		if T[i].parent == NIL {
			root = i
		}
	}
	setDepth(root, 0)
	setHeight(root)
	for i := 0; i < n; i++ {
		printNodes(i)
	} 
}



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

using namespace std;
int i,n,m,x,y,d[100005],maxim,b[100005],k;
vector<int>v[100005];
bool viz[100005];
void dfs(int nod)
{
    viz[nod]=1;
    for(auto i:v[nod])
        if(!viz[i])
        dfs(i);
    b[++k]=nod;
}
int main()
{
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(i=1;i<=n;i++)
        if(!viz[i])
        dfs(i);
    reverse(b+1,b+n+1);
    for(i=1;i<=n;i++)
    {
        x=b[i];
        for(auto j:v[x])
            d[j]=max(d[x]+1,d[j]);
    }
    for(i=1;i<=n;i++)
    maxim=max(maxim,d[i]);
    cout<<maxim;
    return 0;
}


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

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

  


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  
  int a[200002] = {0};
  for(int i=2; i<=n; i++) cin >> a[i];
  
  int b[200002] = {0};
  for(int i=2; i<=n; i++) b[a[i]]++;
  for(int i=1; i<=n; i++) cout << b[i] << endl;

  return 0;
}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int n; cin>>n;
    int ans=0;
    for(int i=1; i<n; ++i){
        ans+=n/i;
        if(n%i==0){
            ans--;
        }
    }
    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
  string s;
  
  cin >> s;
  
  if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
	cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map { |i| i.to_i - 1 }
counts = Array.new(n, 0)
arr.each { |i| counts[i] += 1 }
total = counts.inject(0) { |acc, i| acc + i * (i - 1) / 2 }
arr.each do |i|
  puts total - counts[i] * (counts[i] - 1) / 2 + (counts[i] - 1) * (counts[i] - 2) / 2
end

Measured memory_bytes: 25116
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n;
  int i,j;
  cin>>n>>s;
  for(i=0;i<s.size();++i){
    s.at(i)+=n;
    if(s.at(i)>90)s.at(i)-=26;
  }
  cout<<s<<endl;
}

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

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)

template<typename T>
istream& operator >> (istream &is , vector<T> &v){
    rep(i,v.size()) is >> v[i]; return is;
}

bool solve(){
    int W, H; cin >> W >> H;
    int N; cin >> N;
    vector<int> P(N); cin >> P;

    int x[2] = {0, 0}, y[2] = {0, 1};
    int dx[2] = {1, 1}, dy[2] = {};

    int ans = 0;
    for(int p : P){
        x[p] += dx[p];
        y[p] += dy[p];
        if(y[p] == p and x[p] == W-1-p) dx[p] =  0, dy[p] = 1;
        if(x[p] == W-1-p and y[p] == H-1-p) dx[p] = -1, dy[p] = 0;

        if(x[0] == x[1] and abs(y[0] - y[1]) == 1) ans++;
        if(y[0] == y[1] and abs(x[0] - x[1]) == 1) ans++;
    }
    
    cout << ans << endl;
        
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	int f[n][5][2];
	int f2[n][10];
	ll p[n][11];

	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			f2[i][j]=-1;
		}
	}
	bool flag=false;
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<5;j++){
			for(int k=0;k<2;k++){
				cin>>f[i][j][k];
				f2[i][cnt]=f[i][j][k];
				cnt++;
				if(cnt==10)cnt=0;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<11;j++){
			cin>>p[i][j];
		}
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			//cout<<f2[i][j];
		}
		//cout<<endl;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<11;j++){
			//cout<<p[i][j];
		}
		//cout<<endl;
	}

	ll res=-(1<<30),tmp=0;
	ll m[n];

	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			if(f2[i][j]==1)tmp++;
		}
		m[i]=tmp;
		tmp=0;
	}


	for(int i=1;i<(1<<10);i++){
		tmp = 0;
		for(int j=0;j<n;j++){
			int c = 0;
			for(int k=0;k<10;k++){
				if((i>>k&1)&&f2[j][k])c++;
			}
			tmp += p[j][c];
		}
		if(res < tmp)res=tmp;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N = input()
A = [0, 0, 0, 0, 0]
for i in range(N):
    S = raw_input()
    if S[0] in 'MARCH':
        A['MARCH'.find(S[0])] += 1

ans = 0

for a, b, c in it.combinations(A, 3):
    ans += a * b * c

print ans

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

using namespace std;

using int64 = long long;

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

  int n;
  int64 cap;
  cin >> n >> cap;
  vector<int64> weights(n);
  vector<int64> values(n);
  int64 value_sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> weights[i];
    cin >> values[i];
    value_sum += values[i];
  }

  vector<vector<int64>> dp(n + 1, vector<int64>(value_sum + 1, INT64_MAX));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= value_sum; j++) {
      if (dp[i][j] == INT64_MAX) continue;
      dp[i + 1][j + values[i]] =
          min(dp[i + 1][j + values[i]], dp[i][j] + weights[i]);
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    }
  }
  int64 ans = 0;
  for (int j = 0; j <= value_sum; j++) {
    if (dp[n][j] <= cap) {
      ans = j;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define dump(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1000000007;
/* テンプレートここまで */

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

  vector<string> S(N);
  vector<int> P(N);

  REP(i,N){
    cin >> S[i] >> P[i];
  }

  vector<int> order(N);
  iota(ALL(order), 0);

  auto comp = [=](int x, int y){
    if(S[x] == S[y]) return P[x] > P[y];
    return S[x] < S[y];
  };

  sort(ALL(order), comp);
 
  FOREACH(x,order) cout << x + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i)
    {
        if (i % k == 0)
        {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000
#define MOD 1000000007

int dfs(vector<vector<int>> &G,int v,int p,vector<int> &number,vector<int> &parent,vector<int> &depth){
  int ans=1;
  parent.at(v)=p;
  for(auto nv:G.at(v)){
    if(nv==p){
      continue;
    }
    depth.at(nv)=depth.at(v)+1;
    ans+=dfs(G,nv,v,number,parent,depth);
  }
  return number.at(v)=ans;
}

int main(){
  int N;
  cin>>N;
  vector<vector<int>> G(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }

  vector<int> number(N),parent(N),depth(N,0);
  dfs(G,0,-1,number,parent,depth);

  int x=N-1;
  for(int i=0;i<(depth.at(N-1)-1)/2;i++){
    x=parent.at(x);
  }

  int Fennec=number.at(0)-number.at(x);
  int Snuke=number.at(x);
  if(Fennec>Snuke){
    cout<<"Fennec"<<endl;
  }else{
    cout<<"Snuke"<<endl;
  }

}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define pf		 push_front
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
#define N 11
int n;
vector<vi> mul(vector<vi> a, vector<vi> b)
{
	vector<vi> vl(n, vi(n, 0));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
			{	vl[i][j] += a[i][k] * b[k][j];
				vl[i][j] %= MOD;
			}
	return vl;
}

vector<vi> p(vector<vi> rs, int k)
{	vector<vi> as(n, vi(n, 0));
	as = rs;
	while (k > 0)
	{	if (k & 1)
			as = mul(as, rs);
		k = k >> 1;
		rs = mul(rs, rs);
	}
	return as;
}


int32_t main()
{	pre();
//case
	{	int k;
		cin >> n >> k;
		vector<vi> al;
		for (int i = 0; i < n; i++)
		{	vi v;
			int x;
			for (int j = 0; j < n; j++)
			{	cin >> x;
				v.pb(x);
			}
			al.pb(v);
		}

		al = p(al, k - 1);
		int as = 0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{	as += al[i][j] ;
				as %= MOD;
			}
		cout << as;
	}
	return 0;
}

Measured memory_bytes: 384
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	c := nextInt()
	s := next()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		if s[i] == 'o' {
			a[i] = 1
		}
	}
	ans := make([]string, 0, n)
	m := make([]int, k)
	var cc int
	for i := 0; i < n; i++ {
		if a[i] == 1 {
			m[cc] = i
			cc++
			if cc >= k {
				break
			}
			i += c
		}
	}
	m2 := make([]int, k)
	cc = 0
	for i := 0; i < n; i++ {
		if a[n-1-i] == 1 {
			m2[k-cc-1] = n - 1 - i
			cc++
			if cc >= k {
				break
			}
			i += c
		}
	}
	// fmt.Println(m, m2)
	for i := range m {
		if m[i] == m2[i] {
			ans = append(ans, strconv.Itoa(m[i]+1))
		}
	}
	if len(ans) > 0 {
		fmt.Println(strings.Join(ans, "\n"))
	}
}


Measured memory_bytes: 12928
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

int main(){
    double x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double ans = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    printf("%.5f\n",ans);
    return 0;
}

Measured memory_bytes: 1240
/*
#include "stdafx.h"
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<complex>
*/

#include<bits/stdc++.h>

#define X real()
#define Y imag()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define FastF freopen("in.txt","r",stdin); freopen("out.txt","w",stdout)
#define Fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0)
using ll = long long;
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vi::iterator vii;
typedef vector<ll> vl;
typedef vl::iterator vli;
typedef long double C;
typedef complex<C> P;
const int INF = 1e9 + 5;
const ll INFF = 1e18 + 5;
const int M = 1e9 + 7;
const double pi = acos(-1);

int main()
{
	//FastF;
	Fast;
	int n, k; cin >> n >> k;
	vi h(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> h[i];
	}
	vi dp(n + 1,INF);
	dp[1] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= i + k; ++j) {
			if (j > n) continue;
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n] << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>

#define ll long long
#define DIV 1000000007

using namespace std;

ll lower_bound(ll K){
  return ((K-1)*K/2);
}

ll upper_bound(ll N, ll K){
  return ((N+N-K+1)*K/2);
}

int main(){
  ll N, K;
  cin >> N >> K;
  ll ans =1;
  ll lb, ub;
  for(ll i=K;i<N+1;i++){
    //cout << "here"<<endl;
    lb = lower_bound(i);
    ub = upper_bound(N,i);
    //if(!(i%10000)) cout << "i=" << i << ", lb:" << lb << ", ub:" << ub << endl;
    ans = (ans + ub - lb +1)%DIV;
    //if(ans<0) cout << "OVERFLOW!!!"<<endl;
    //ans = ans % DIV;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 3632
n=int(input())
a=input().split()
b=[]
for i in a:
    b.append(int(i))
max=-1000000
min=1000000
sum=0
for i in b:
    if (i<min):
        min=i
    if (i>max):
        max=i
    sum+=i
print("{0} {1} {2}".format(min,max,sum))

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

int main() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    int i;
    for(i=0;i<s.size();++i)
    {
        if(s[i]=='7')
        {
            cout<<"Yes"<<endl;
            break;
        }
    }
    if(i==s.size())
    {
        cout<<"No"<<endl;
    }
  	
   // cout<<ans<<endl;
	return 0;
}

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

int main() {
    long long K, A, B; cin >> K >> A >> B;
    if (B-A <= 2 || K < A-1) cout << K+1 << endl;
    else {
        long long res = A;
        K -= A-1;//ビスケットがA枚になるまで1枚ずつ増やし続ける(K回中A-1回の操作をここで消費)
        if (K % 2 == 1) ++res, --K;//残り回数が奇数だったら、あと1枚増やしておく
        res += (B-A) * (K/2);//最後に残った回数で目一杯、2手一組でB-Aを増やし続ける
        cout << res << endl;
    }
}

Measured memory_bytes: 256
N, X = map(int,input().split(' '))

m = 0
min_m = 1001
for n in range(N):
  _ = int(input())
  m += _
  min_m = min(min_m, _)

cnt_plus_donut = (X-m) // min_m

print(N+cnt_plus_donut)

Measured memory_bytes: 3060
x, y = map(int, input().split())
mylist1=[1,3,5,7,8,10,12]
mylist2=[4,6,9,11]
if x in mylist1 and y in mylist1:
    print("Yes")
elif x in mylist2 and y in mylist2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[200005];
int tag[200005];
bool incircle[200005];
bool vis[200005];
int val[200005];
struct edge
{
    int y;
    edge * next;
};
edge * li[200005];
edge * new_edge()
{
    static edge a[200005];
    static int top=0;
    return &a[top++];
}
void insert_edge(int x,int y)
{
    edge * t=new_edge();
    t->y=y;
    t->next=li[x];
    li[x]=t;
}
bool tags[200005];
void dfs(int x)
{
    if (vis[x]) return;
    vis[x]=true;
    edge * t;
    for (t=li[x];t!=0;t=t->next)
    {
        if (incircle[t->y]) continue;
        dfs(t->y);
    }
    if (incircle[x]) return;
    for (t=li[x];t!=0;t=t->next)
    {
        if (incircle[t->y]) continue;
        tags[val[t->y]]=true;
    }
    int i;
    for (i=0;;i++)
    {
        if (tags[i]) continue;
        break;
    }
    val[x]=i;
    for (t=li[x];t!=0;t=t->next)
    {
        if (incircle[t->y]) continue;
        tags[val[t->y]]=false;
    }
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        a[i]--;
        insert_edge(a[i],i);
    }
    int now=0;
    for (i=0;i<n;i++)
    {
        now=a[now];
    }
    for (i=0;i<n;i++)
    {
        incircle[now]=true;
        now=a[now];
    }
    for (i=0;i<n;i++)
    {
        if (vis[now]) break;
        dfs(now);
        now=a[now];
    }
    int j;
    for (j=0;j<=25;j++)
    {
        edge * t;
        for (t=li[now];t!=0;t=t->next)
        {
            if (incircle[t->y])
            {
                continue;
            }
            if (val[t->y]==j)
            {
                //Error!
                break;
            }
        }
        if (t!=0) continue;
        val[now]=j;
        int x;
        for (x=a[now];x!=now;x=a[x])
        {
            for (t=li[x];t!=0;t=t->next)
            {
                tags[val[t->y]]=true;
            }
            int i;
            for (i=0;;i++)
            {
                if (tags[i]) continue;
                break;
            }
            val[x]=i;
            for (t=li[x];t!=0;t=t->next)
            {
                tags[val[t->y]]=false;
            }
        }
        for (t=li[x];t!=0;t=t->next)
        {
            tags[val[t->y]]=true;
        }
        int i;
        for (i=0;;i++)
        {
            if (tags[i]) continue;
            break;
        }
        if (i==val[now])
        {
            puts("POSSIBLE");
            return 0;
        }
        for (t=li[x];t!=0;t=t->next)
        {
            tags[val[t->y]]=false;
        }
    }
    puts("IMPOSSIBLE");
    return 0;
} 


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    char s[15];
    cin>>a;
    cin>>s;
    int f = 1;

        if(a<3200)
        {
            cout<<"red"<<endl;
        }
   else cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, ans1, ans2;
string str;

int main(){
	cin >> str;
	n = str.size();
	
	ans1 = -1;
	ans2 = -1;
	if(n == 2){
		if(str[0] == str[1]){
			ans1 = 1;
			ans2 = 2;
		}
	}
	else{
		for(ll i = 0; i <= n-3; i++){
			if(str[i] == str[i+1] || str[i+1] == str[i+2] || str[i+2] == str[i]){
				ans1 = i+1;
				ans2 = i+3;
				break;
			}
		}
	}
	
	cout << ans1 << " " << ans2 << endl;
	return 0;
}

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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n,k;
	string s;
	cin >> n >> k >> s;
	LL res = 0;	
	for (LL i = 1; i < n; i++)
		if (s[i] == s[i-1])
			res++;
	res = min(n-1,res+2*k);
	cout << res << "\n";
}


Measured memory_bytes: 512
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }      
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
signed main()
{   jaldi
    int n,i,a=1e13,b=1e13,c,d;
    cin>>n;
    for(i=1;i<=sqrt(n);i++)
    {   if(n%i==0)
        {   if(n/i==i)
            {   a=i;
                b=n/i;
                break;
            }
            else 
            {   c=i;
                d=n/i;
                if((a+b)>=(c+d))
                {   a=c;
                    b=d;
                }
            }
        }
    }
    cout<<abs(a-1)+abs(b-1);
}

Measured memory_bytes: 256
import java.util.*;
 interface aisatu{
	final String str="こんにちは";
	void mesod();
}

public class Main {
	static public void main(String args[]){
		Scanner sc=new Scanner(System.in);
		
		long a=sc.nextLong();
		int b=(int)(sc.nextDouble()*100+0.01);
		
		System.out.print((a*b)/100);
	}

}



Measured memory_bytes: 37460