akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

ll ans = 0;
ll attack (ll h) {
	if(h == 1) {
		return 1;
	}
	else if (h > 1) {
		return 2 * attack(h/2) + 1;
	}
}
int main() {

	ll h;
	cin >> h;
	cout << attack(h) << endl;
	
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

int N, M, Q;
ll ans = 0;
int A[101], B[101], C[101], D[101];
void dfs(vector<int>v, int cnt, int las) {
	if (cnt == N) {
		int res = 0;
		REP(i, Q) {
			if (v[B[i]] - v[A[i]] == C[i])res += D[i];
		}
		ans = max(ans, res);
	}
	else {
		FOR(i, las, M + 1) {
			vector<int>nw = v;
			nw.push_back(i);
			dfs(nw, cnt + 1, i);
		}
	}

}
void solve() {
	cin >> N >> M >> Q;
	REP(i, Q) {
		cin >> A[i] >> B[i] >> C[i] >> D[i];
		A[i]--, B[i]--;
	}
	vector<int>v;
	dfs(v, 0, 1);
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



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

typedef long long ll;

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k%2 == 0){
        cout << a - b << endl;
    }else{
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, const char * argv[]) {
    string S; cin >> S;
    cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
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...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(ll i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
	ll l,r,ans = 0; cin >> l >> r;
	while(l%4!=0){
		ans ^= l, l++;
	}
	l = r - (r%4);
	while(l<=r){
		ans ^= l, l++;
	}
	cout << ans;
}

int main(){
    IOS;    
    solve();
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  cout << max({ (N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E }) + 5 << endl;

  return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int ans = 1;
    while(n>0){n/=2; ans*=2;}
    out(ans/2);

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
n = int(raw_input());
over = 10 ** 80;
for i in range(0, n):
    a = int(raw_input());
    b = int(raw_input());
    if a + b >= over:
        print "overflow"
    else:
        print a + b;

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N, L;

signed main()
{
  cin >> N >> L;
  int k = 1145141919;
  int v = 0;
  int sum = 0;
  REP(n,N) {
    k = min(k, abs(L+n));
    if(L+n < 0) {
      v = 1;
    } else {
      v = -1;
    }
    sum += L+n;
  }
  cout << sum+v*k << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
     int n;
     cin >> n;
     int a[n];
     rep(i,n){
          int tmp;
          cin >> tmp;
          tmp--;
          a[tmp] = i + 1;
     }
     rep(i,n){
          cout << a[i] << endl;
     }
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    cin >> s;
    ll n = 1000000000;
    ll x1 = n-s%n,x2 = s/n;
    if (s == n*n) cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 1000000000 << '\n';
    else cout << 0 << " " << 0 << " " << x2+1 << " " << 1 << " " << x1 << " " << 1000000000 << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt(),A=sc.nextInt(),B=sc.nextInt();
		String S=sc.next();
		int pass=0;
		int orderB=0;

		for(int i=0;i<S.length();i++) {
			char ch = S.charAt(i);

			if(ch=='a') {
				if(pass<A+B) {
					pass++;
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}else if(ch=='b') {
				orderB++;
				if(pass<A+B && orderB<=B) {
					pass++;
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 34652
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

lint N, X;
vector<lint> x;
constexpr lint Nmax = 200000;
constexpr lint INF = 10000000000000000;
inline lint calc(lint Y) // Y個のグループにわけるときの値を算出
{
    lint ans = X * (N + Y);
    REP(i, N)
    {
        if (ans >= INF) return INF;
        lint d = i / Y;
        if (d)
            ans += x[i] * (2 * d + 3);
        else
            ans += x[i] * 5;
        
    }
    return ans;
}

int main()
{
    cin >> N >> X;
    x.resize(N);
    REP(i, N) cin >> x[i];

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

    lint l = 0, r = N + 1;
    while (l + 2 < r)
    {
        lint left = (l * 2 + r) / 3;
        lint right = (l + r * 2) / 3;

        // cerr << l << " " << left << " " << right << " " << r << endl;
        if (calc(left) < calc(right)) r = right;
        else l = left;
    }
    cout << calc((l + r) / 2) << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,R; cin >> N >> R;

    cout << R + max(0,10-N)*100 << ln;
}

Measured memory_bytes: 892
def main():
    a, b, c = (int(i) for i in input().split())
    ans = 0
    get_week = a*7 + b
    ans = 0
    if c % get_week == 0:
        ans = (c//get_week) * 7
        return print(ans)
    else:
        ans = (c//get_week) * 7
        c = c % get_week
        cnt = 0
        while c > 0:
            c -= a
            ans += 1
            cnt += 1
            if cnt == 7:
                c -= b
                cnt = 0
        return print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n; cin >> n;
  int INF = 1000000000;
  vector<pair<int, int>> red, blue;
  for(int i=0; i<n;++i){
    int x,y;cin >> x >> y;
    red.push_back(make_pair(y,x));
  }
  for(int i=0; i<n;++i){
    int x,y;cin >> x >> y;
    blue.push_back(make_pair(x,y));
  }
  sort(all(blue));
  sort(all(red),greater<pair<int, int>>());
  int cnt=0;
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      if(blue[i].first > red[j].second && blue[i].second > red[j].first){
        ++cnt;
        red[j] = make_pair(INF, INF);
        break;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;

int cool (int l, int r, int cl, int cr) {
	re int ((r - l) % 2 != (cl + cr) % 2);
}

int ask (int x) {
	printf ("%d\n", x);
	fflush (stdout);
	char h[10];
	scanf (" %s", h);
	if (h[0] == 'M') re 0;
	if (h[0] == 'F') re 1;
	re 2;
}

int go (int l, int r, int cl, int cr) {
	int s = (l + r) / 2;
	int cs = ask (s);
	if (cs == 2) re 0;
	if (cool (l, s, cl, cs))
		re go (l, s, cl, cs);
	re go (s, r, cs, cr);
}

int main () {
	scanf ("%d", &n);
	int st = ask (0);
	go (0, n, st, st);
	return 0;
}

Measured memory_bytes: 852
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if x in a and y in a or x in b and y in b or x in c and y in c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
package main

import (
	"fmt"
	"strconv"
)

func mine(f, w int, maps []string) []string {
	dx := []int{-1, 0, 1, -1, 1, -1, 0, 1}
	dy := []int{1, 1, 1, 0, 0, -1, -1, -1}

	minemap := make([]string, f)
	for i := 0; i < f; i++ {
		for j := 0; j < w; j++ {
			if string(maps[i][j]) == "#" {
				minemap[i] += "#"
				continue
			}
			var mine int
			for d := 0; d < 8; d++ {
				posx := i + dx[d]
				posy := j + dy[d]
				if posx < 0 || f <= posx {
					continue
				}
				if posy < 0 || w <= posy {
					continue
				}
				if string(maps[posx][posy]) == "#" {
					mine++
				}
			}
			minemap[i] += strconv.Itoa(mine)
		}
	}
	return minemap
}

func main() {
	var f, w int
	fmt.Scan(&f, &w)
	maps := make([]string, f)
	for i := range maps {
		fmt.Scan(&maps[i])
	}
	for _, out := range mine(f, w, maps) {
		fmt.Println(out)
	}
}


Measured memory_bytes: 640
n=int(input());a=eval('list(input()),'*n);f=sum(n==t.count('#')for t in zip(*a));print(-all(t.count('#')<1for t in a)or min(n*2-f-b.count('#')+all(a[j][i]>'#'for j in range(n))for i,b in enumerate(a)))

Measured memory_bytes: 5676
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=200005;
const int mod=1e9+7;
int n,mxd,ans;
ll cnt[maxn],t2[maxn],sz[maxn];
vector<int>edge[maxn];
deque<ll>dp[maxn][3];
ll tmp[3];

ll quick_pow(ll x,ll power){
	ll res=1;
	while(power){
		if(power&1)res=res*x%mod;
		x=x*x%mod;
		power>>=1;
	}
	return res;
}

void dfs(int x,int dep){
	cnt[dep]++;
	mxd=max(mxd,dep);
	int mx=0;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		dfs(y,dep+1);
      	if(dp[x][0].size()<dp[y][0].size()){
          	swap(dp[x][0],dp[y][0]);
          	swap(dp[x][1],dp[y][1]);
          	swap(dp[x][2],dp[y][2]);
        }
        mx=max(mx,(int)dp[y][0].size());//important!
		rep(j,dp[y][0].size()){
			tmp[0]=dp[x][0][j]*dp[y][0][j]%mod;
			tmp[1]=dp[x][0][j]*dp[y][1][j]%mod+dp[x][1][j]*dp[y][0][j]%mod;
			tmp[1]%=mod;
			tmp[2]=((dp[x][0][j]+dp[x][1][j]+dp[x][2][j])%mod*(dp[y][0][j]+dp[y][1][j]+dp[y][2][j])%mod-tmp[0]-tmp[1]+mod)%mod;
			dp[x][0][j]=tmp[0];
			dp[x][1][j]=tmp[1];
			dp[x][2][j]=tmp[2];
		}
		dp[y][0].clear();
		dp[y][1].clear();
		dp[y][2].clear();
	}
	dp[x][0].push_front(1);
	dp[x][1].push_front(1);
	dp[x][2].push_front(0);
	rep(i,mx+1){
		dp[x][0][i]+=dp[x][2][i];
		dp[x][2][i]=0;
	}
}

int main(){
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout);
	scanf("%d",&n);
	REP(i,n){
		int p;
		scanf("%d",&p);
		edge[p].pb(i);
	}
	dfs(0,0);
	rep(i,mxd+1)ans=(ans+dp[0][1][i]*quick_pow(2,n+1-cnt[i])%mod)%mod;
	printf("%d\n",ans);
	return 0;
}
/*
Input:
31
0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 2 15 6 12 10 12 16 5 3 19 20 10 2 5 3 2
-----------------
*/

Measured memory_bytes: 495744
import sys
sys.setrecursionlimit(10**6)
from functools import lru_cache

def solve(n,a,b,c,d):
    
    @lru_cache(None)
    def f(n):
        if n==0: return 0
        elif n==1: return d
        ret=d*n
        q,r=n//2, n%2
        if r==0:
            ret=min(f(q)+a, ret)
        else:
            ret=min(ret, f(q)+a+d*r, f(q+1)+a+d*r)
        q,r=n//3, n%3
        if r==0:
            ret=min(f(q)+b, ret)
        else:
            ret=min(ret, f(q)+b+d*r, f(q+1)+b+d*(3-r))
        q,r=n//5, n%5
        if r==0:
            ret=min(f(q)+c, ret)
        else:
            ret=min(ret, f(q)+c+d*r, f(q+1)+c+d*(5-r))
        return ret
    
    return f(n)

if __name__=='__main__':
    t=int(input())
    for _ in range(t):
        n,a,b,c,d=map(int,input().split())
        print(solve(n,a,b,c,d))

Measured memory_bytes: 112640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vvi vector<vi>
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define pb push_back
#define umap(x,y) unordered_map<x,y>
static void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);}

int main()
{
fast();
ll d,t,s;
cin>>d>>t>>s;
ll dis = s*t;
if(dis>=d)
	cout<<"Yes\n";
else
	cout<<"No\n";

return 0;
}


Measured memory_bytes: 3648
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Reflection.Metadata;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        class inputdata
        {

            public int day;
            public int[] pt;
            

        }

        public static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            var downpoint = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var input = new inputdata[num];

            for (int i = 0; i < num; i++)
            {

                input[i] = new inputdata();
                input[i].day = i;
                input[i].pt = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            }
            
            

            for (int i = 0; i < num; i++)
            {

                var max = long.MinValue;
                var best = 0;

                for (int j = 0; j < 26; j++)
                {

                    if (max < input[i].pt[j])
                    {

                        max = input[i].pt[j];
                        best = j + 1;

                    }

                }

                Console.WriteLine(best);

            }    

        }
    }

}

Measured memory_bytes: 28888
import std.stdio;
import std.string, std.conv;
import std.array, std.algorithm;
import std.math;

void main() {
  int[] weight = [200, 300, 500, 200 * 5, 300 * 4, 500 * 3];
  int[] price = [380, 550, 850, 1520, 1870, 2244];
  int[5000+1] dp = cast(int)1e9;
  dp[0] = 0;
  foreach(i; 0 .. 6) {
    for(int j = weight[i]; j <= 5000; j++) {
      dp[j] = min(dp[j], dp[j - weight[i]] + price[i]);
    }
  }

  for(int N; (N = readln.chomp.to!int) != 0; ) {
    dp[N].writeln();
  }
}

Measured memory_bytes: 976
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
char mem[214514];
char t[214514];
char c[214514];
string s[214514];
int l[214514],r[214514];
int a[214514];
int sa[214514];
pair<int,int> b[214514];
signed main(){
	sc(s) 
	rep(0,i,s.size())cout<<'x';
}	

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll h;
    cin >> h;
    auto rec = [&](ll x, auto &&f) -> ll{
        if(x == 0) return 0;
        return 2*f(x/2, f)+1;
    };
    cout << rec(h, rec) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    char a[12],b[12];
    for(int i=0; i<s2.length()-1; i++){
        b[i]=s2[i];
    }
    int fl=1;
    for(int i=0; i<s1.length(); i++){
        if(b[i]!=s1[i]){
            puts("No");
            fl=0;
            break;
        }
    }
    if(fl) puts("Yes");

}


Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys
from bisect import bisect_left, bisect_right
import heapq

INF = float("inf")


class ErasableHeap(object):
    # https://qiita.com/Salmonize/items/638da118cd621d2628d1
    def __init__(self):
        self.data = []
        self.event = []

    def push(self, x):
        return heapq.heappush(self.data, x)

    def erase(self, x):
        return heapq.heappush(self.event, x)

    def _check(self):
        while self.event and\
                self.data[0] == self.event[0]:
            heapq.heappop(self.data)
            heapq.heappop(self.event)

    def front(self):
        self._check()
        return self.data[0]

    def pop(self):
        self.check()
        return heapq.heappop(self.data)

    def __len__(self):
        self._check()
        return len(self.data)


def main():

    N, Q = map(int, input().split())
    event = []
    for i in range(N):
        s, t, x = map(int, input().split())
        event.append((s-x, 1, x))
        event.append((t-x, -1, x))
    # 番兵用のeventを追加しておく
    event.append((INF, +1, INF))
    event.sort()

    D = [0]*Q
    for i in range(Q):
        D[i] = int(input())

    head = 0
    stack = ErasableHeap()
    for t, p, x in event:
        while head < Q and D[head] < t:
            if len(stack) == 0:
                print(-1)
            else:
                print(stack.front())
            head += 1
        if p == 1:
            stack.push(x)
        else:
            stack.erase(x)


if __name__ == '__main__':
    main()


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

int main()
{
    ll n;
    cin>>n;
    string s;
    map<string,ll> mp;
    for(ll i=0;i<n;++i)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size()<<'\n';
}


Measured memory_bytes: 19228
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);
 
using namespace std;
const int N = 1E5+7;
const long long INF = 1E18;
 
long long f[N][4];
long long a[N], b[N], c[N];
int n;
 
int main()
{
    fastIO;
    cin>>n;
    
    for (int i = 1;i <= n;++i) cin>>a[i]>>b[i]>>c[i];
    
    for (int i = 0;i <= n;++i)
        for (int j = 1;j <= 3;++j) f[i][j] = -INF;
    
    long long tmp = 0;
    int save = 0;
    if (tmp < a[1]) { tmp = a[1]; save = 1; }
    if (tmp < b[1]) { tmp = b[1]; save = 2; }
    if (tmp < c[1]) { tmp = c[1]; save = 3; }
    
    f[1][save] = tmp;
    
    for (int i = 2;i <= n;++i)
        for (int j = 1;j <= 3;++j)
        {
            if (j == 1) f[i][j] = max(f[i][j],max(f[i-1][j+1]+a[i],f[i-1][j+2]+a[i]));
            if (j == 2) f[i][j] = max(f[i][j],max(f[i-1][j-1]+b[i],f[i-1][j+1]+b[i]));
            if (j == 3) f[i][j] = max(f[i][j],max(f[i-1][j-1]+c[i],f[i-1][j-2]+c[i]));
        }
    
    long long res = 0;
    for (int i = 1;i <= 3;++i) res = max(res,f[n][i]);
    
    cout<<res;
}

Measured memory_bytes: 9108
import sys
N,Y=map(int,input().split())
ans=0
for x in range (N+1):
    for y in range(N+1-x):
        if 10000*x+5000*y+1000*(N-x-y)==Y:
            print(str(x)+' '+str(y)+' '+str(N-x-y))
            sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 9056
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define debug(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define debug(...) 
#define end_time()
#endif
 
 
#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
inline int gcd(int a, int b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); } 
inline int power(int x, int n, int m = LLONG_MAX)
    {  int res=1; x = (x%m + m)%m;
       while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
    }
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

void solve(){
	int n,w;
	cin>>n>>w;
	vi wt(n), vl(n);
	for(int i = 0; i<n; i++){
		cin>>wt[i]>>vl[i];
	}
	vector<vector<int>> dp(n,vector<int>(100005,mod));
	dp[0][vl[0]] = wt[0];
	dp[0][0] = 0;
	for(int i = 1; i<n; i++){
	 	for(int j = 0; j<vl[i]; j++){
	 		dp[i][j] = dp[i-1][j];
	 	}
	 	for(int j = vl[i]; j<100005; j++){
	 		dp[i][j] = min(dp[i-1][j],dp[i-1][j-vl[i]]+wt[i]);
	 	}
	}
	for(int i = 100000; i>=0; i--){
	 	if(dp[n-1][i]>w) continue;
	 	else{
	 		cout<<i<<"\n";
	 		break;
	 	}
	} 
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	end_time();
	return 0;
}


Measured memory_bytes: 82380
n=int(input())
l=[0]*n
for i in range(n):
    l[int(input())-1]=i
pre=-1
now=0
ans=n
for i in l:
    if pre<i:
        now+=1
    else:
        ans=min(ans,n-now)
        now=1
    pre=i

print(min(ans,n-now))

Measured memory_bytes: 16668
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

vector<int> G[200005];

int main() {
	int N, M;
	cin >> N >> M;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);//1-indexed
		G[b].push_back(a);
	}
	
	for (int i = 2;i < N;i++) {
		auto itr1 = find(G[i].begin(), G[i].end(), 1);
		auto itrN = find(G[i].begin(), G[i].end(), N);

		if (itr1 != G[i].end() && itrN != G[i].end()) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  vector<ll> B(0);
  vector<bool> C(N, 0);

  ll next = 1;
  bool j = 1;
  ll x;

  while(j){
    B.push_back(next);
    C[next-1] = 1;
    next = A[next-1];
    if(C[next-1] == 1){
        j = 0;
          rep(k, B.size()){
            if(B[k] == next) x = k;
          }
    }
  }

  ll r = B.size() - x;
  ll ans;
  if(K < x) ans = K;
  else{
    K -= x;
    K %= r;
    ans = K + x;
  }

  cout << B[ans]<< endl;
}


Measured memory_bytes: 6964
s = int(input())

if s == 1 or s == 2:
    print(0)
elif s == 3 or s == 4 or s == 5:
    print(1)
else:
    a = []
    a.append(0)
    a.append(0)
    a.append(1)
    a.append(1)
    a.append(1)

    for i in range(5, s):
        x = a[i-1] + a[i-3]
        a.append(x)
    
    z = a[s-1] % (10 ** 9 + 7)
    print(z)

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

#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'	

using namespace std;

const int MOD = 1e9+7;
const int N = 2e5;

int main() {
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cout.tie(0);
	ll n, m, k;
	cin >> n >> m >> k;
	n = abs(n);
	if ( n / k >= m)
		cout << n - m * k << endl;
	else {
		if ( n / k % 2 == m % 2)
			cout << n - (n / k * k) << endl;
		else
			cout << min(abs(n - (n / k * k) - k), n - (n / k * k) + k) << endl;
	}
}                         

Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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; }

using ll = long long;
const long long MOD = 1e9+7;

int main() { 
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < max(a, b); i++) {
        cout << min(a, b);
    }
    cout << endl;
}   

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


if __name__ == '__main__':

    n = int(input())
    M = [[0 for i in range(n)] for j in range(n)]
    for _ in range(n):
        l = list(map(int, input().split(" ")))
        u = l[0]
        k = l[1]
        if k != 0:
            for v in l[2:]:
                M[u-1][v-1] = 1
        
    for r in M:
        print(" ".join(map(str, r)))


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

ll solve(int n, int m, vector<int> a, vector<vector<int> > const & g) {
    // decompose to connected components
    vector<vector<int> > forest; {
        vector<bool> used(n);
        function<void (int)> go = [&](int i) {
            used[i] = true;
            forest.back().push_back(i);
            for (int j : g[i]) if (not used[j]) {
                go(j);
            }
        };
        REP (i, n) if (not used[i]) {
            forest.emplace_back();
            go(i);
        }
    }
    if (forest.size() == 1) return 0;

    // check the possibility
    vector<int> size;
    for (auto && tree : forest) {
        size.push_back(tree.size());
    }
    sort(ALL(size));
    while (size.size() >= 2) {
        int it = size.back();
        size.pop_back();
        if (it == 0) return -1;
        if (size.back() == 0) return -1;
        size.back() += it - 2;
    }

    // compute the cost
    ll acc = 0;
    vector<int> indices;
    for (auto && tree : forest) {
        int i = *min_element(ALL(tree), [&](int i, int j) { return a[i] < a[j]; });
        acc += a[i];
        a[i] = INT_MAX;  // remove it
    }
    sort(ALL(a));
    int k = forest.size() - 2;
    acc += accumulate(a.begin(), a.begin() + k, 0ll);
    return acc;
}

int main() {
    // input
    int n, m; cin >> n >> m;
    vector<int> a(n);
    REP (i, n) cin >> a[i];
    vector<vector<int> > g(n);
    REP (i, m) {
        int x, y; cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    // solve
    ll answer = solve(n, m, a, g);

    // output
    if (answer == -1) {
        cout << "Impossible" << endl;
    } else {
        cout << answer << endl;
    }
    return 0;
}


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

using namespace std;

const double EPS = 1e-8;
typedef vector<int> vec;
typedef vector<vec> mat;

bool gauss_jordan(const mat &A, const vec &b)
{
    int n = A.size();
    mat B(n, vec(n+1));
    for (int i = 0; i < n; i++) {
	for (int j = 0; j < n; j++) {
	    B[i][j] = A[i][j];
	}
    }
    
    for (int i = 0; i < n; i++) {
	B[i][n] = b[i];
    }
    
    for (int i = 0; i < n; i++) {
	int pivot = i;
	for (int j = i; j < n; j++) {
	    if (B[j][i] > B[pivot][i]) {
		pivot = j;
	    }
	}
        
	swap(B[i], B[pivot]);              
        
	for (int j = 0; j < n; j++) {
	    if (i != j && B[j][i] == 1) {
		for (int k = i; k <= n; k++) {
		    B[j][k] = (B[j][k] + B[i][k]) % 2;
		}
	    }
	}
    }

    for (int i = 0; i < n; i++) {
        bool non_zero = 0;
        for (int j = 0; j < n; j++) {
            if (B[i][j] != 0) non_zero = 1;
        }
        if (!non_zero && B[i][n] == 1) {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int W, H, D;
    while (cin >> W >> H >> D, W) {
        mat a(H, vec(W));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> a[i][j];
            }
        }
        
        mat A(H*W, vec(H*W, 0));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int n = i * W + j;
                A[n][n] = 1;
                for (int k = 0; k < H; k++) {
                    for (int l = 0; l < W; l++) {
                        int MD = abs(i - k) + abs(j - l);
                        int m = k * W + l;
                        if (D == MD) {
                            A[n][m] = 1;
                        }
                    }
                }
            }
        }

        vec b(H*W);
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (a[i][j] == 1) b[i*W+j] = 1;
            }
        }
        cout << (gauss_jordan(A, b) ? 1 : 0) << endl;
    }
    return 0;
}

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

int main(){

  int A,B,C,X;
  int cnt;
  int tmp;

  cin >> A >> B >> C >> X;

  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        tmp = 500*i + 100*j + 50*k;
        if(X == tmp){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int a[1000000]={0};
int main(){
    int n;
    cin >>n;
    map<ll , ll,greater<ll> >mp;
    for(int i=0;i<n;i++){
        ll k=0;
        cin >>k;
        ll num = mp[k];
        mp[k]=num+1;
    }
    //cout<<mp.size()<<"jj"<<endl;
    ll sum=1;
    int flag=0,hhh=0;
    if(mp.begin()->second>=4){
        cout<<mp.begin()->first*mp.begin()->first<<endl;
        return 0;
    }
    else
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(flag==2)
            break;
        if(it->second>=2){
            sum*=it->first;
            hhh=1;
            flag++;
        }
    }
    if(hhh)cout<<sum<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MAX_N 5001
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;
typedef vector<ll> V;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;


double xa, ya, ra, xb, yb, rb, d;
ll n;

int main(){
	cin >> n;
	REP(i, n){
		cin >> xa >> ya >> ra >> xb >> yb >> rb;

		if (xa == xb&&ya == yb) d = 0;
		else d = sqrt((xa - xb)*(xa - xb) + (ya - yb)*(ya - yb));

		if (ra + rb < d)cout << 0 << endl;
		else if (d + ra < rb)cout << -2 << endl;
		else if (d + rb < ra)cout << 2 << endl;
		else cout << 1 << endl;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(void) {
	string s; cin >> s;
	int n = s.size();
	vector<vector<mint>> dp(n+1,vector<mint>(2,0)); //dp[i][j] - i:i桁目までの数 j:未満フラグ
	dp[0][0] = 1;
	rep(i,n){
		if(s[i]=='0'){ //s[i]=='0'
			//0
			dp[i+1][0] = dp[i][0];
			dp[i+1][1] = dp[i][1];
			//1
			dp[i+1][1] = dp[i+1][1] + dp[i][1]*2;
		}else{ //s[i]=='1'
			//0
			dp[i+1][1] = dp[i][0] + dp[i][1];
			//1
			dp[i+1][0] = dp[i][0]*2;
			dp[i+1][1] = dp[i+1][1] + dp[i][1]*2;		
		}
	}
	mint ans = dp[n][0] + dp[n][1];
	cout << ans.x << endl;
}




Measured memory_bytes: 5760
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	ll N;
	cin >> N;
	VI s(N);
	REP(i, N) cin >> s[i];
	SORT(s);
	int sum = SUM(s);
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	else
	REP(i, N) {
		if (s[i] % 10 != 0) {
			cout << sum - s[i] << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	int arr[5], x;
	for(int i = 0; i < 5; ++i) { cin >> arr[i];if(!arr[i]) x = i + 1;}
	cout << x << endl;
 }

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
	solve();
	return 0;
}
 
 
 
 
 
 


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

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

const int MAX = 110;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, K, x[MAX];

int main(){
    cin >> N >> K;
    rep(i, N) cin >> x[i];

    int ans = 0;
    rep(i, N){
        ans += min(x[i] * 2, (K - x[i]) * 2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

template<typename T>
struct Mat{
    vector<vector<T>> val;
    Mat(int n, int m, T x = 0) : val(n,vector<T>(m,x)){}
    void init(int n, int m, T x = 0){
        val.assign(n,vector<T>(m,x));
    }
    size_t size(){
        return val.size();
    }
    inline vector<T>& operator [](int i){
        return val[i];
    }
};

Mat<ll> operator *(Mat<ll> A, Mat<ll> B){
    Mat<ll> R(A.size(),B[0].size());
    for(int i = 0; i < A.size(); i++){
        for(int j = 0; j < B[0].size(); j++){
            for(int k = 0; k < B.size(); k++){
                R[i][j] += A[i][k]*B[k][j]+MOD;
                R[i][j] %= MOD;
            }
        }
    }
    return R;
}


Mat<ll> pow(Mat<ll> A, ll n){
    Mat<ll> R(A.size(),A.size());
    for(int i = 0; i < A.size(); i++) R[i][i] = 1;
    while(n > 0){
        if(n&1) R = R*A;
        A = A*A;
        n >>= 1;
    }
    return R;
}



int main(){
    int n; cin >> n;
    ll k; cin >> k;
    Mat<ll> a(n,n);
    rep(i,n)rep(j,n) cin >> a[i][j];
    Mat<ll> b = pow(a,k);
    ll ans = 0;
    rep(i,n)rep(j,n){
        ans += b[i][j];
        ans %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 384