akhauriyash/Code-Regression huggingface dataset:
N=int(input())
h=list(map(int,input().split()))
# N = 4
# h = [10, 30, 40, 20]
dp = [1000000]*N
#d[i]はカエルが足場iへと移動するのに必要な最小コスト
dp[0]=0
for i in range(1,N):
    if i == 1:
        dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
# print(dp)
# print("min cost=",dp[-1])
print(dp[-1])

Measured memory_bytes: 20380
#include <cstdio>
#include <string>
#include <list>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    
    list<int> l;
    while(n--){
        char cmdChar[64];
        scanf("%s", cmdChar);
        string command(cmdChar);
        if(command == "deleteFirst"){
            l.pop_front();
        }else if(command == "deleteLast"){
            l.pop_back();
        }else{
            int i;
            scanf("%d", &i);
            if(command == "insert"){
                l.push_front(i);
            }else if(command == "delete"){
                list<int>::iterator it = l.begin();
                while(it != l.end()){
                    if(i == *it){
                        l.erase(it);
                        break;
                    }
                    it++;
                }
            }
        }
    }
    list<int>::iterator it = l.begin();
    while(it != l.end()){
        printf("%d", *it);
        it++;
        printf("%c", it == l.end() ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 32272
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}

	vector<vector<int>> dp(n,vector<int>(k+1,0));
	vector<int> res(k+1,0);
	for(int i = 0; i < n; i++){
		if(i==0){
			for(int j = 0; j <= a[i]; j++){
				dp[i][j]=1;
			}
			continue;
		}
		res[0]=dp[i-1][0];
		for(int j = 1; j <= k; j++){
			res[j]=(res[j-1]+dp[i-1][j])%mod;
		}
		for(int j = 0; j <=k; j++){
			dp[i][j] =(j-a[i]<=0?res[j]:res[j]-res[j-a[i]-1]);
			dp[i][j]+=mod;
			dp[i][j]%=mod;
		}
	}

	cout<<dp[n-1][k]<<endl;

	return 0;
}

Measured memory_bytes: 39808
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    #endif
    ll N,year = 0;
    cin>>N;
    ll initial = 100;
    while(initial<N){
        ll tmp = initial*0.01;
        year++;
        initial +=tmp;
    }
    cout<<year;
    return 0;
}

Measured memory_bytes: 3668
from typing import List, Tuple


class RollingHash:
    """Rolling Hash"""

    __slots__ = ["_base", "_mod", "_hash", "_power"]

    def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7):
        self._base = base
        self._mod = mod
        self._hash, self._power = self._build(source)

    def _build(self, source: str) -> Tuple[List[int], List[int]]:
        """Compute "hash" and "mod of power of base" of interval [0, right)."""
        length = len(source)
        hash_, power = [0] * (length + 1), [0] * (length + 1)
        power[0] = 1
        for i, c in enumerate(source, 1):
            hash_[i] = (hash_[i - 1] * self._base + ord(c)) % self._mod
            power[i] = power[i - 1] * self._base % self._mod
        return hash_, power

    def get_hash(self, left: int, right: int):
        """Return hash of interval [left, right)."""
        return (
            self._hash[right] - self._hash[left] * self._power[right - left]
        ) % self._mod


def abc141_e():
    # https://atcoder.jp/contests/abc141/tasks/abc141_e
    N = int(input())
    S = input().rstrip()

    rh = RollingHash(S)
    ok, ng = 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        flg = False
        memo = set()
        for i in range(N - 2 * mid + 1):
            memo.add(rh.get_hash(i, i + mid))
            if rh.get_hash(i + mid, i + 2 * mid) in memo:
                flg = True
                break
        if flg:
            ok = mid  # next mid will be longer
        else:
            ng = mid  # next mid will be shorter

    print(ok)  # max length of substrings appeared twice or more


if __name__ == "__main__":
    abc141_e()


Measured memory_bytes: 76212
// c++ -std=c++14 atcoder.cpp
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int64_t a, b, c;
    cin >> a >> b >> c;

    if (c-a-b >= 0 && 4*a*b < (c-a-b)*(c-a-b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
//BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 all my suceesses are dedicated to my parents
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define ms(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))
#define II ( { int a ; read(a) ; a; } )
#define LL ( { Long a ; read(a) ; a; } )
#define DD ({double a; scanf("%lf", &a); a;})

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */

const int NX = 105 ;
const int MX = 10000 + 5 ;
pii inp[NX];
int dp[NX][MX] , vis[NX][MX] , cs , W , n ;

int DP( int idx , int w )
{
    if( idx == n ) return 0 ;
    int &v = vis[idx][w];
    int &ret = dp[idx][w];
    if( v == cs ) return ret ;
    v = cs ;
    ret = DP( idx + 1 , w ) ;
    if( w + inp[idx].ss <= W ) ret = max( ret , DP( idx + 1 , w + inp[idx].ss ) + inp[idx].ff );
    return ret ;
}
int main()
{
   // I will always use scanf and printf
   // May be i won't be a good programmer but i will be a good human being
   while( scanf("%d %d",&n,&W) == 2 )
   {
       rep( i , n )
       {
           int x = II , y = II ;
           inp[i] = mp( x , y );
       }
       cs++;
       printf("%d\n",DP(0,0));
   }


    return 0;
}

Measured memory_bytes: 9208
N = int(input())
aaa = []
for i in range(N):
  aaa.append(list(reversed(list(map(int, input().split())))))

cs = set(range(N))
for i in range(0, N*N+1):
  empty = True
  played = False
  ncs = set()
  for j in cs:
    aa = aaa[j]
    if len(aa) > 0:
      empty = False
      l = aa[-1]-1
      if j not in ncs and l not in ncs and len(aaa[l]) > 0 and aaa[l][-1] == j+1:
          aa.pop()
          aaa[l].pop()
          played = True
          ncs.add(j)
          ncs.add(l)
  cs = ncs
  if empty:
    print(i)
    break
  elif not played:
    print(-1)
    break

Measured memory_bytes: 60124
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N % 2 != 0:
    a = A[(N-1)//2]
    b = B[(N-1)//2]
    print(b - a + 1)
else:
    a = (A[N//2-1] + A[N//2]) / 2
    b = (B[N//2-1] + B[N//2]) / 2
    print(int((b-a)*2+1))


Measured memory_bytes: 25412
import sys


def main():
    input = sys.stdin.buffer.readline
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    print('YES' if v * t - w * t >= abs(a - b) else 'NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#define LOCAL
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define ll long long
#define sz(x) (int)(x).size()
#define endl '\n'
#define print_case() cout << "Case #" << test_case_number++ << ": "

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int test_case_number = 1;

void solve(){
    print_case();
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int d = n % 10;
    if(d == 3)
        cout << "bon" << endl;
    else if(d == 2 || d == 5 || d == 4 || d == 7 || d == 9)
        cout << "hon" << endl;
    else
        cout << "pon" << endl;
}


Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	string k;
	cin >> k;
	bool flag = false;
	int l = k.length();
	for(int i = 0;i < l;i++) {
		if(k[i] == 'C') flag = true;
		
		if(k[i] == 'F' && flag) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
} 

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

signed main() {
  int N, M;
  string S;
  cin >> N >> M >> S;

  vector<int> ans;

  for (int i = N; i > 0;) {
    bool flag = true;
    for (int j = max(0LL, i - M); j != i; j++) {
      if (S[j] == '0') {
        ans.push_back(i - j);
        i = j;
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << -1 << endl;
      return 0;
    }
  }

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

  for (int i = 0; i < ans.size(); i++) {
    if (i != 0) {
      cout << " ";
    }

    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1528
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
ll a[212345], b[212345];
//std::ios::sync_with_stdio(0); std::cin.tie(0);
int main() {
	ll n, m, k, i, ans = 0, cnt, mx = 0;
	cin >> n >> m >> k;
	for (i = 1; i <= n; ++i)cin >> a[i];
	for (i = 1; i <= m; ++i)cin >> b[i];
	for (i = 1; i <= n; ++i)a[i] += a[i - 1];
	for (i = 1; i <= m; ++i)b[i] += b[i - 1];
	for (i = n ; i >= 0; --i) {
		if (a[i] <= k)break;
	}
	cnt = i;
	mx = max(cnt, mx);
	for (i = 1; i <= m && b[i] <= k; ++i) {
		while (cnt > 0&&a[cnt]+b[i]>k) {
			--cnt;
		}
		mx = max(i + cnt, mx);
	}
	cout << mx << endl;
}

Measured memory_bytes: 6724
let N =
    stdin.ReadLine()
    |> int
let X =
    stdin.ReadLine().Split()
    |> Array.map int

let sortedX =
    Array.indexed X
    |> Array.sortBy (fun (_,v) -> v)

let (_,larger) = sortedX.[N/2]
let (_,smaller) = sortedX.[N/2-1]

sortedX
|> Array.indexed
|> Array.sortBy (fun (_,(i,_)) -> i)
|> Array.map (fun (l,_) ->
    if l<N/2 then stdout.WriteLine larger
    else stdout.WriteLine smaller)
|> ignore

Measured memory_bytes: 75552
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef vector<int> V;
void test() {
	constexpr int N = 21;
	V g(N, 1);
	for (int i : range(N)) {
		V l;
		for (int m : range(i+1)) {
			int sum = 0;
			for (int j : range(i - m, i)) {
				sum ^= g[j];
			}
			l.push_back(sum);
		}
		l.push_back(114514);
		sort(ALL(l));
		unique(ALL(l));
		for (int j : range(1, l.size())) {
			if (l[j - 1] + 1 != l[j]) {
				g[i] = l[j - 1] + 1;
				break;
			}
		}
		cout << i<<" "<<g[i] << endl;
	}
}
LL L;
namespace trie{
	constexpr int K = 2;
	constexpr int EMPTY = -1;
	constexpr char base = '0';
	struct node{
		int nxt[K];
		bool is_leaf() {
			for (int i : range(K)) {
				if (nxt[i] != EMPTY) {
					return false;
				}
			}
			return true;
		}
	}v[112345];
	
	namespace manager {
		int id = 0;
		int get() {
			for (int i : range(K))
				v[id].nxt[i] = EMPTY;
			return id++;
		}
		void reset(){
			id = 0;
		}
	}
	int root;
	void init() {
		manager::reset();
		root = manager::get();
	}
	void insert(string s) {
		int now = root;
		for (char c : s) {
			c -= base;
			int &nxt = v[now].nxt[c];
			if (nxt == EMPTY)nxt = manager::get();
			now = nxt;
		}
	}
	LL get_empty_tree_grundy(LL h) {
		LL ret = 1;
		h++;
		while ((h & 1) == 0) {
			ret <<= 1;
			h >>= 1;
		}
		return ret;
	}
	void dfs(int t,int d, LL &ret) {
		if (v[t].is_leaf()) {
			return;
		}
		else {
			for (int i : range(K)) {
				if (v[t].nxt[i] != EMPTY) {
					dfs(v[t].nxt[i], d + 1, ret);
				}
				else {
					ret ^= get_empty_tree_grundy(L - d - 1);
				}
			}
		}
	}
	LL solve() {
		LL ret = 0;
		dfs(root, 0, ret);
		return ret;
	}
}

int main() {
	int N;
	while (cin >> N >> L) {
		trie::init();
		for (int i : range(N)) {
			string s;
			cin >> s;
			trie::insert(s);
		}
		if (trie::solve()) {
			cout << "Alice" << endl;
		}
		else cout << "Bob" << endl;
	}
	return 0;
}


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

int main(){
  long long n, ans = 0, MAX, a;
  cin >> n >> MAX;
  for(int i=0;i<n-1;i++){
    cin >> a;
    if(a<MAX){
      ans += MAX - a;
    } else if(a>MAX){
      MAX = a;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

int main() {
    //vector<int> ans;
    string s, t = "Yes";
    cin>>s;

    rep(i, s.size()){
        if((i+1)%2 == 0){
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') t ="No";
        }
        else{
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') t ="No";
        }
    }
   
    
        
    cout<<t<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N,M,R;cin>>N>>M>>R;
    vl visit(R);
    rep(i,R){
        cin>>visit[i];
        visit[i]--;
    }
    vvl cost(N,vl(N,INF));
    rep(i,M){
        ll A,B,C;cin>>A>>B>>C;
        A--,B--;
        cost[A][B]=cost[B][A]=C;
    }
    rep(k,N)rep(i,N)rep(j,N){
        cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
    }
    sort(all(visit));
    ll ans=INF;
    do{
        ll now=0;
        rep(i,R-1){
            now+=cost[visit[i]][visit[i+1]];
        }
        ans=min(ans,now);
    }while(next_permutation(all(visit)));
    cout<<ans<<endl;
    return 0;
}

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

int main(void){

    int A,B,C,D,E;
    vector<int> a(5);
    for (int i = 0; i < 5; ++i) {
        cin>>a[i];
    }

    int min=10, min_index=0;
    for (int i = 0; i < 5; ++i) {
        if(min >= a[i]%10 && (a[i]%10 != 0)){
            min = a[i] % 10;
            min_index = i;
        }
    }
    int ans=0;
    for (int i = 0; i < 5; ++i) {
        if(i != min_index){
            if((10-a[i]%10) == 10) ans+= a[i];
            else ans += a[i]+(10-a[i]%10);
        }
        else ans += a[i];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 100
#define INF 1e8

int main(){
  int N,i,j,k,l,q,r[MAX_N],c[MAX_N],p[MAX_N+1];
  int dp[MAX_N+1][MAX_N+1];
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d%d",&r[i],&c[i]);
  }
  p[0] = r[0];
  for(i = 1 ; i <= N ; i++){
    p[i] = c[i-1];
  }
  N++;
  for(i = 0 ; i < N ; i++){
    dp[i][i] = 0;
  }
  for(l = 2 ; l < N ; l++){
    for(i = 1 ; i < N-l+1 ; i++){
      j = i + l - 1;
      dp[i][j] = INF;
      for(k = i ; k <= j-1 ; k++){
        q = dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j];
        if(q < dp[i][j]){
          dp[i][j] = q;
        }
      }
    }
  }
  printf("%d\n",dp[1][N-1]);
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
using namespace std;

int main()
{
    int n, a, b, ans, max;
    ans = 0;
    max = 0;
    cin >> n;
    vector<int> p(100004, 0);
    vector<int> s(100004, 0);
    for(int i=0; i<n; ++i){
        cin >> a >> b;
        p[a]++;
        p[b+1]--;
    }
    for(int i=1; i<=n+1; ++i){
        if(i == 1){
            s[i] = 1;
        }
        else {
            s[i] = s[i-1] + p[i];
        }
        // cout << i << ":" << s[i] << endl;
    }
    for(int i=2; i<=n+1; ++i){
        if(i <= s[i]){
            ans = i - 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll getMax(ll x){
  ll ans = 0;
  while(x%2 == 0){
    x = x/2;
    ans ++;
  }
  return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;

    ll n;
    cin >>n;
    ll a[n];
    ll sum = 0;
    F0R(i,n) {
        cin >> a[i];
        sum +=getMax(a[i]);
    }
    cout << sum << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;cin>>S;
  
  int count=0;
  
  for(int i=0;i<3;i++){
    if(S[i]=='o'){
      count++;
    }
  }
  
  cout<<700+count*100<<endl;
}

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

void solve(){
    ll n, q;
    cin >> n;
    ll a[n], cnt = 0;
    map<ll, ll> mp;
    for(ll i = 0; i < n; i++) cin >> a[i], cnt += a[i], mp[a[i]]++;
    cin >> q;
    while(q--){
        ll x, y;
        cin >> x >> y;
        cnt += (-x*mp[x] + y*mp[x]);
        mp[y] += mp[x];
        mp[x] = 0;
        cout << cnt << endl;
    }
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //int t;cin>>t;while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 10336
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
ll inf = 1e10;

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  map<int, int> a;
  rep(i, n){
    int tmp;
    cin >> tmp;
    a[tmp]++;
  }
  
  if(k >= a.size()){cout << 0 << "\n"; return 0;}
  int ans = 0;
  vector<int> cnt(n+1);
  cnt[0] = 1e6;
  for(int i = 1; i <= n; ++i) cnt[i] = a[i];
  sort(cnt.begin(), cnt.end());
  for(int i = 0; i < (a.size()-k); ++i) ans += cnt[i];
  cout << ans << "\n";
  return 0;
}  

Measured memory_bytes: 10368
N,Y=map(int,input().split())
Y//=1000
for z in range(N+1):
  x=round(-N+0.8*z+0.2*Y,5)
  y=round(-0.2*Y-1.8*z+2*N,5)
  if x.is_integer() and y.is_integer() and x+y+z==N:
    if x>=0 and y>=0:
      if 10*x+5*y+z==Y:
        print(int(x),int(y),int(z))
        exit()
print(-1,-1,-1)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;
#define int long long

signed main(){

   int N;
   cin>> N;
   int a[N+1];
   for(int i=0; i<N+1; i++) a[i]=0;
   for(int i=0; i<N; i++) cin>> a[i];

   int ans=0;
   for(int i=0; i<N; i++){
      ans+=(a[i]/2);
      a[i]%=2;
      if(a[i]>0&&a[i+1]>0){
         ans++;
         a[i]--; a[i+1]--;
      }
   }

   cout<< ans<< endl;

   return 0;
}


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

int main() {
 int n;
  cin>>n;
 int m;
  if(n==1){
    m=1;
  }
  else{
    for(int i=0;i<=n;i++){
	int squ=i*i;
    if(n<squ){
      m=i-1;
      break;
    }
  }
  }
  
    cout<<m*m<<endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;
 
template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}
 
struct edge {
    int from, to, cost;
    edge(int f, int t, int c) :from(f), to(t), cost(c) {}
};
 
bitset<200001> ans;
 
int main() {
    int n, m;
    while (cin >> n >> m and n) {
        ans.reset();
        vector< pair<int, pair<int, int>> > p;
        rep(i, m) {
            int t, s, d;
            cin >> t >> s >> d;
            s--;
            d--;
            p.push_back(make_pair(t, make_pair(s, d)));
        }
        sort(p.begin(), p.end());
        vector<edge> g[20001];
        ans[0] = 1;
        rep(i, m) {
            pair<int, int> tmp = p[i].second;
            int to = tmp.first, from = tmp.second;
            if (ans[to]) ans[from] = 1;
        }
        cout << ans.count() << endl;
    }
    return 0;
}


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

using namespace std;

int main(void) {
	int N,M;
	cin >> N >> M;
	vector<int> memo(M,0);
	for (int i = 0; i < N; ++i) {
		int K;
		cin >> K;
		for (int j = 0; j < K; ++j) {
			int temp;
			cin >> temp;
			++memo[temp-1];
		}
	}
	int res = 0;
	for (int i = 0; i < M; ++i) {
		if (memo[i] == N) {
			++res;
		}
	}
	cout << res << endl;
	return 0;
}



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

namespace CSharp_AtCoder
{
    
    class Person
    {
        public int n;
        public int[] x;
        public int[] y;
        public Person(int n, int[] x, int[] y)
        {
            this.n = n;
            this.x = x;
            this.y = y;
        }
    }

    class Program
    {

        static Person[] persons;

        static List<string> authenticity;
        static int N;

        static void SetBinaryList(string now, int length)
        {
            if (length >= N)
            {
                authenticity.Add(now);
                return;
            }

            SetBinaryList(now + "1", length + 1);
            SetBinaryList(now + "0", length + 1);
        }

        static int MaxNumber(string auth)
        {
            bool contradiction = false;
            int cnt_true = 0;

            for(int i = 0; i < N; i++)
            {
                if (auth[i] == '0') continue;

                for(int j = 0; j < persons[i].n; j++)
                {
                    int x = persons[i].x[j];
                    int y = persons[i].y[j];
                    if (int.Parse(auth[x].ToString()) != y)
                    {
                        contradiction = true;
                        break;
                    }
                }

                cnt_true++;

                if (contradiction) break;
            }


            if (contradiction) return 0;
            else return cnt_true;
        }

        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());

            persons = new Person[N];
            for(int i = 0; i < N; i++)
            { 
                int A = int.Parse(Console.ReadLine());
                int[] x = new int[A];
                int[] y = new int[A];
                for(int j = 0; j < A; j++)
                {
                    int[] xy = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                    x[j] = xy[0] - 1;
                    y[j] = xy[1];
                }
                persons[i] = new Person(A, x, y);
            }

            authenticity = new List<string>();
            SetBinaryList("", 0);

            int max = 0;
            foreach(var now_case in authenticity)
            {
                max = Math.Max(max, MaxNumber(now_case));
            }

            Console.WriteLine(max);
        }
    }
}


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

int main(){
  int a, b, d, r;
  double f;

  cin>>a>>b;
  d=a/b;
  r=a%b;
  f=1.0*a/b;

  printf("%d %d %f\n", d, r, f);
  return 0;
}

Measured memory_bytes: 3156
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	匹配括号 左减右>=0
	多组数据清空？
	dp优化用g？
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
const int MAXN=22;
int c[MAXN],v[MAXN],sum[MAXN],n,res=0;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	cin>>n;
	rb(i,1,n){
		cin>>v[i];
	}
	rb(i,1,n){
		cin>>c[i];
	}
	rb(i,1,n){
	sum[i]=v[i]-c[i];
	if(sum[i]>0) res+=sum[i];
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int a[10][10];

bool check(string &s){
    int t = a[0][s[0]-'0'];
    For(i, 1, 5){
        t = a[t][s[i]-'0'];
    }
    return t == 0;
}

bool f(int n){
    string s = to_string(n);
    int len = s.size();
    rep(i, 4-len) s = "0" + s;
    int tmp = a[0][s[0]-'0'];
    For(i, 1, 4) tmp = a[tmp][s[i]-'0'];
    s += to_string(tmp);
    string t = s;
    rep(i, 5)rep(j, 10)if(s[i]-'0' != j){
        t[i] = j+'0';
        if(check(t)) return true;
        t[i] = s[i];
    }
    rep(i, 4)if(s[i] != s[i+1]){
        swap(t[i], t[i+1]);
        if(check(t)) return true;
        swap(t[i], t[i+1]);
    }
    return false;
}

int main(){
    rep(i, 10)rep(j, 10) scanf("%d", &a[i][j]);
    int ans = 0;
    rep(i, 10000){
        ans += f(i);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 3336
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using PL = pair<ll , ll> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

string dfs(ll x){
    if(x == 0){
        return "" ;
    }
    x-- ;
    return dfs(x/26) + string(1, 'a' + x%26) ;
}


int main(){
    ll n ;
    cin >> n;
    cout << dfs(n) << endl ;
}



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

int main() {
  string num;
  cin >> num;

  int sum = 0;
  for(int i = 0; i < num.length(); i++){
    char ch = num[i];
    int tmp = ch - '0';
    //cout << tmp << endl;
    sum = sum + tmp;
  }

  if(sum%9 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }



  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }*/

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3708
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 

const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;


struct ext{
    int x, y, len; char common;
    ext() : x(-1), y(-1), len(0), common('\0') {}
    ext(int _x, int _y, int _len, char _common) : x(_x), y(_y), len(_len), common(_common) {}
};


string s, t;
ext dp[3005][3005];

int main(){ FAST
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

    cin >> s >> t;
    F0R(i,sz(s)){
        F0R(j,sz(t)){
            if (s[i] == t[j]){
                if (i == 0 || j == 0){
                    dp[i][j] = ext(-1,-1,1,s[i]);
                }
                else{
                    dp[i][j] = ext(i-1,j-1,dp[i-1][j-1].len + 1,s[i]);
                }
            }
            else{
                if (i == 0 && j > 0) dp[i][j] = ext(i,j-1,dp[i][j-1].len,'\0');
                if (i > 0 && j == 0) dp[i][j] = ext(i-1,j,dp[i-1][j].len,'\0');
                if (i > 0 && j > 0){
                    int xlen = dp[i-1][j].len, ylen = dp[i][j-1].len;
                    dp[i][j] = (xlen > ylen ? ext(i-1,j,xlen,'\0') : ext(i,j-1,ylen,'\0'));
                }
            }
        }
    }
    string ans = "";
    ext cur = dp[sz(s)-1][sz(t)-1];
    while(true){
        if (cur.common != '\0') ans += cur.common;
        if (cur.x == -1 && cur.y == -1) break;
        cur = dp[cur.x][cur.y];
    }
    reverse(ans.begin(),ans.end());
    finish(ans);














	return 0;
}


Measured memory_bytes: 141440
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int N; int K;
    cin >> N >> K;
    double p[210000];
    rep(i, N) {
        double now; cin >> now;
        p[i] = (now + 1)/2;
    }
    double sum = 0;
    double max = 0;
    queue<double> que;
    rep(i, K) {
        que.push(p[i]);
        max += p[i];
    }
    sum = max;
    for(int i = K; i < N; i++) {
        double front = que.front();
        que.pop();
        que.push(p[i]);
        sum += p[i] - front;
        if(sum > max) {
            max = sum;
        }
    }
    cout << fixed << setprecision(10) << max << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int A[2100000];

int NUM = 1 << 20;

long long int MOD = 998244353;

long long int sum[200005];

long long int INF = 9999999999999;

void update(int k, long long int val) {

	A[k + NUM] = val;

	int x = k + NUM;

	int p = x / 2;
	while (p > 0) {
		A[p] = max(A[p * 2], A[p * 2 + 1]);
		//A[p] %= MOD;
		p /= 2;
	}
}

long long int rmq(int p, int a, int b, int l, int r) {

	long long int ret = -INF;
	if (r < a || b < l) { return -INF; }

	if (a <= l && r <= b) { return A[p]; }
	else {
		ret =max(ret, rmq(p * 2, a, b, l, (r + l) / 2));
		ret =max(ret, rmq(p * 2 + 1, a, b, (r + l) / 2 + 1, r));
	}

	return ret;
}
int N;
long long int X[200005], D[200005];

vector<pair<long long int, int > >V;
vector<long long int> W;

long long int dp_used[200005],dp_unused[200005];

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> D[i];
		V.push_back(make_pair(X[i], i));
		W.push_back(X[i]);
	}

	sort(V.begin(), V.end());
	sort(W.begin(), W.end());

	dp_unused[N] = 1;

	for (int k = N - 1; k >= 0; k--) {
		int i = V[k].second;
		long long int d = X[i] + D[i];
		update(k, d);
		int pos = lower_bound(W.begin(), W.end(), d) - W.begin();
		
		long long int val = rmq(1, k, pos - 1, 0, NUM - 1);
		//cout << "val= " << val << endl;
		update(k, val);

		int p = lower_bound(W.begin(), W.end(), val) - W.begin();
		//cout << "p= " << p << endl;
		dp_used[k] = (dp_used[p] + dp_unused[p]) % MOD;
		dp_unused[k] = (dp_used[k + 1] + dp_unused[k + 1])%MOD;
	}

	long long int ans = 0;

	ans = (dp_used[0] + dp_unused[0]) % MOD;

	cout << ans << endl;

	/*for (int k = 0; k < N; k++) {
		cout << "dp_used[" << k << "]= " << dp_used[k]<<" dp_unused["<<k<<"]= " <<dp_unused[k] <<"  X= " <<V[k].first<<" D= " <<D[V[k].second]<< endl;
	}*/

	return 0;
}

Measured memory_bytes: 25964
n, q = map(int, input().split())
process = [input().split() for _ in range(n)]
time = 0
while process:
    p = process.pop(0)
    if int(p[1]) <= q:
        time += int(p[1])
        print(p[0], time)
    else:
        time += q
        process.append([p[0], int(p[1])-q])

Measured memory_bytes: 19628
#include<bits/stdc++.h>
using namespace std;
string s;
int sz, ans;
int main () {
    cin >> s;
    int sz = (int) s.size();
    ans = sz;
    for (int i = 0; i < sz - 1; i++) {
	if (s[i] != s[i + 1])
	    ans = min(ans, max(i + 1, sz - i - 1));
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    n = len(a)
    count_1 = a.count(1)
    count_2 = a.count(2)
    count_3 = a.count(3)

    # dp[count_1][count_2][count_3] = expectation of attempts for all dishes are cleared
    expectation_of_attempts = [[[0.0 for num_dishes_3 in range(n + 1)] for num_dishes_2 in range(n + 1)] for num_dishes_1 in range(n + 1)]

    for k in range(count_3 + 1):
        for j in range(count_2 + count_3 + 1):
            if j + k > n:
                continue
            for i in range(n + 1):
                if i + j + k > n:
                    continue
                if i == 0 and j == 0 and k == 0:
                    continue
                if expectation_of_attempts[i][j][k] > 0.0:
                    return expectation_of_attempts[i][j][k]
                a = 0.0 if i == 0 else expectation_of_attempts[i - 1][j][k]
                b = 0.0 if j == 0 else expectation_of_attempts[i + 1][j - 1][k]
                c = 0.0 if k == 0 else expectation_of_attempts[i][j + 1][k - 1]

                expectation_of_attempts[i][j][k] = (i * a + j * b + k * c + n) / (i + j + k)

    return expectation_of_attempts[count_1][count_2][count_3]


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    ll x;
    cin >> x;

    ll ans = 0;
    ans += (x / 11) * 2;
    int rem = x % 11;
    if(rem > 0) {
        if(rem <=6) ans++;
        else ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,M;
bool graph[9][9]={};
bool visited[9]={};

int dfs(int v){
	bool all_visited=true;
	for(int i=1;i<=N;i++){
		if(visited[i]==false){
			all_visited=false;
		}
	}
	
	if(all_visited){
		return 1;
	}
	
	int ret=0;
	
	for(int i=1;i<=N;i++){
		if(graph[v][i]==false) continue;
		if(visited[i]) continue;
		
		visited[i]=true;
		ret+=dfs(i);
		visited[i]=false;
		
	}
	
	return ret;
	
}

int main(){
	for(int i=0;i<9;i++){
		visited[i]=false;
		for(int k=0;k<9;k++){
			graph[i][k]=false;
		}
	}
	
	cin >> N >> M;
	int input_1,input_2;
	
	for(int i=1;i<=M;i++){
		cin >> input_1 >> input_2;
		graph[input_1][input_2]=true;
		graph[input_2][input_1]=true;
	}
	
	visited[1]=true;
	cout << dfs(1) << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int m,n;
  std::cin >> n >> m;

  if(abs(m-n)>=2){
    std::cout << "0" << '\n';
  }

  else if(abs(m-n)==1){
    ll  ans=1;
    for(ll i=1; i<=m; i++){
      ans*=i;
      ans%=mod;
    }
    for(ll i=1; i<=n; i++){
      ans*=i;
      ans%=mod;
    }
    std::cout << ans << '\n';
}

  else{
    ll  ans=1;
    for(ll i=1; i<=m; i++){
      ans*=i;
      ans%=mod;
    }
    for(ll i=1; i<=n; i++){
      ans*=i;
      ans%=mod;
    }
    std::cout << ans*2%mod << '\n';
}

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<iostream>
#include<vector>
#include<bitset>
#include<ctime>
#include<cmath>
#include<queue>

using namespace std;

#define bomb exit(1)
#define INF 1061109567
#define LINF 4557430888798830399ll
#define pprint(x) print(x),putchar(' ')
#define fprint(x) print(x),putchar('\n')
#define EE(x); struct edge { int nxt,to,w; }e[M << 1]; int head[N],ecnt = 1;\
	void add(int u,int v,ll w = 0) { e[++ecnt].w = w,e[ecnt].to = v,e[ecnt].nxt = head[u];head[u] = ecnt; }\
	void add_edge(int u,int v,ll w = 0) { add(u,v,w),add(v,u,w * x); }
#define ll long long
const double pi = acos(-1);
int mod = 1000000007;
ll Mod(ll x) { return x >= mod ? x - mod : x; }
#define eps 0.0000000001
#define sqr(x) ((x) * (x))
#define iter iterator
#define fi first
#define se second
//#define getchar() (SS == TT && (TT = (SS = BB) + fread(BB,1,1 << 15,stdin),TT == SS) ? EOF : *SS++)
//char BB[1 << 15],*SS = BB,*TT = BB;
ll read()
{
	ll x = 0;int f = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = -1;
	for(;isdigit(ch);ch = getchar()) x = x * 10 + (ch ^ 48);
	return x * f;
}
void print(ll x)
{
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);putchar(x % 10 + '0');
}

const int N = 200010;
struct tree
{
	int l,r;
	ll lz,min1,min2;
}t[N << 2];
#define ls now << 1
#define rs now << 1 | 1
void pushup(int now)
{
	t[now].min1 = min(t[ls].min1,t[rs].min1);
	t[now].min2 = min(t[ls].min2,t[rs].min2);
}
void build(int now,int l,int r)
{
	t[now].l = l,t[now].r = r,t[now].lz = 0;
	if(l == r) { t[now].min1 = t[now].min2 = LINF;return; }
	int mid = l + r >> 1;build(ls,l,mid),build(rs,mid + 1,r);
	pushup(now);
}
void pushlz(int now,ll l) { t[now].lz += l,t[now].min1 += l,t[now].min2 += l; }
void pushdown(int now) { if(t[now].lz) pushlz(ls,t[now].lz),pushlz(rs,t[now].lz),t[now].lz = 0; }
void update(int now,int pos,ll num)
{
	if(t[now].l == t[now].r)
	{
		t[now].min1 = min(t[now].min1,num - t[now].l);
		t[now].min2 = min(t[now].min2,num + t[now].l);
		return;
	}pushdown(now);int mid = t[now].l + t[now].r >> 1;
	if(pos <= mid) update(ls,pos,num); else update(rs,pos,num);
	pushup(now);
}
ll query1(int now,int l,int r)
{
	if(t[now].l == l && t[now].r == r) return t[now].min1;
	pushdown(now);int mid = t[now].l + t[now].r >> 1;
	if(r <= mid) return query1(ls,l,r);
	if(l > mid) return query1(rs,l,r);
	return min(query1(ls,l,mid),query1(rs,mid + 1,r));
}
ll query2(int now,int l,int r)
{
	if(t[now].l == l && t[now].r == r) return t[now].min2;
	pushdown(now);int mid = t[now].l + t[now].r >> 1;
	if(r <= mid) return query2(ls,l,r);
	if(l > mid) return query2(rs,l,r);
	return min(query2(ls,l,mid),query2(rs,mid + 1,r));
}
ll query(int now)
{
	if(t[now].l == t[now].r) return t[now].min1 + t[now].l;
	pushdown(now);
	return min(query(ls),query(rs));
}

int n,q,a,b,x[N];

int main()
{
	n = read(),q = read(),a = read(),b = read();
	build(1,1,n);x[0] = a,update(1,b,0);
	for(int i = 1;i <= q;i++)
	{
		x[i] = read();
		ll res = min(query1(1,1,x[i]) + x[i],query2(1,x[i],n) - x[i]);
		pushlz(1,abs(x[i] - x[i - 1]));
		update(1,x[i - 1],res);
	}fprint(query(1));
	return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
#define M 3005
int C[M][M],a[M],p;
int pw(int x,int w){
	int ans=1;
	while(w){
		if(w&1)ans=ans*x%p;
		x=x*x%p;w>>=1;
	}
	return ans;
}
int main(){
	scanf("%d",&p);
	for(int i=0;i<=p;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%p;
	}
	for(int i=0,x;i<p;++i){
		scanf("%d",&x);
		if(x==1){
			a[0]++;
			for(int j=0;j<p;++j)a[j]=(a[j]-pw(-i,p-1-j)*C[p-1][j])%p;
		}
	}
	for(int i=0;i<p;++i)printf("%d ",(a[i]%p+p)%p);
}

Measured memory_bytes: 34304
N = gets.to_i

def shichigosan(s="")
  return 0 if N < s.to_i
  c = '357'.chars.all? {|n| s.include?(n) } ? 1 : 0
  '357'.chars {|n| c += shichigosan(n+s) }
  return c
end
puts shichigosan

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

int Max(int *array,int Q){
  int M=0,res;
  for(int i=0;i<101;i++){
    if (array[i]>M){
      M=array[i];
      res=i;
    }
  }
  if (M<Q) res=0;
  return res;
}

int main(){
  int N,Q,M,d;
  int Dates[101];
  for(int i=0;i<100;i++) Dates[i]=0;
  for(;;){
    cin >> N >> Q;
    if (N==0 && Q==0)break;
    for(int i=0;i<100;i++) Dates[i]=0;
    for(int i=0;i<N;i++){
      cin >>M;
      for(int j=0;j<M;j++){
	cin >> d;
	Dates[d]++;
      }
    }
    cout << Max(Dates,Q) << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

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

string s, t;
char ch[10];
int n, a, b, c, d, x, m[5];

int main() {
	cin >> s;
	cout << (s[0] == s[2] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

int A, B;

int main()
{
  scanf( "%d%d", &A, &B );

  int ans = int(std::min( (double)A/0.08, (double)B/0.1 )-100.0);

  for( ; ans*0.08 <= A+1 && ans*0.1 <= B+1; ++ans )
  {
    if( int(ans*0.08) == A && int(ans*0.1) == B )
    {
      printf( "%d\n", ans );

      return 0;
    }
  }

  puts("-1");

  return 0;
}

Measured memory_bytes: 128
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    X = kwargs["X"]
    res = 0

    for i, x in enumerate(X):
        if x == 0:
            res = i + 1

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["X"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 30864
#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
    int Q;
    cin >> Q;

    for (int i = 0; i < Q; i++) {
        long A, B;
        cin >> A >> B;
        if (A > B) {
            long t;
            t = A; A = B; B = t;
        }
        long score = A * B;
        long ans = 0;
        
        if (A == B) ans = 2 * A - 2;
        else if (A + 1 == B) ans = 2 * A - 2;
        else {
            long C = sqrt(score);
            if (C * C == score) C--;
            if (C * (C + 1) >= score) ans = 2 * C - 2;
            else if (C * C < score) ans = 2 * C - 1;
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256