akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		new Main().io();
	}
	
	void solve(long s){
		for(int i=0; i<10; ++i){
			s = (s*s)%100000000;
			int dig = s!=0 ? (int)(Math.log10(s)) + 1 : 0;
			
			String str = Long.toString(s);
			for(int j=dig; j<8; ++j){
				str = "0" + str;
			}
			
			String str_ = new String();
			for(int j=2; j<6; ++j){
				str_ = str_ + str.charAt(j);
			}
			
			s = Long.parseLong(str_);
			System.out.println(s);
		}
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for(int i=1; i<=n; ++i){
			System.out.println("Case " + i + ":");
			int s = sc.nextInt();
			solve(s);
		}
		
		sc.close();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
package main

import "fmt"

func main() {
	var L int
	fmt.Scanf("%d\n", &L)
	if L >= 3 {
		if L%3 == 0 {
			v := L / 3
			fmt.Println(v * v * v)
		} else {
			v := float64(L) / 3
			fmt.Println(v * v * v)
		}
	} else {
		v := float64(L) / 3
		fmt.Println(v * v * v)
	}

}


Measured memory_bytes: 512
// Date: 2020-02-25

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int cutL[N], cutR[N];
LL sum[N], a[N], b[4];

int main() {
    int n; scanf("%d", &n);
    rep(i, 1, n) scanf("%lld", &a[i]), sum[i] = sum[i-1] + a[i];
    int l = 1;
    cutL[2] = l;
    rep(i, 3, n) {
        LL x = sum[l], y = sum[i] - x;
        while(abs(y-x) > abs(x+a[l+1]-(y-a[l+1])) && l+1 < i) x += a[l+1], y -= a[l+1], ++l;
        cutL[i] = l;  
    }
    int r = n;
    cutR[n-1] = r;
    per(i, n-2, 1) {
        LL x = sum[n]-sum[r-1], y = sum[n]-sum[i-1]-x;
        while(abs(y-x) > abs(x+a[r-1]-(y-a[r-1])) && r-1 > i) x += a[r-1], y -= a[r-1], --r;
        cutR[i] = r;
    }
    LL ans = INF;
    rep(i, 2, n-2) {
        l = cutL[i], r = cutR[i+1];
        b[0] = sum[l], b[1] = sum[i]-b[0], b[2] = sum[n]-sum[r-1], b[3] = sum[n]-sum[i]-b[2];
        sort(b, b+4);
        ans = min(ans, b[3]-b[0]);
    }
    printf("%lld\n", ans);


    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
const int N = 90;
long long f[N];
void db(int n){
	f[0]=2;
	f[1]=1;
	for(int i=2; i<=n; i++){
		f[i]=f[i-1]+f[i-2];
	}
}
int main(){
	db(N);
	int n;
	cin >> n;
	cout <<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
    int n, m;
    long long tmp, ans;
    scanf("%d %d", &n, &m);
    tmp = 1900 * m + 100 * (n-m);
    ans = tmp * pow(2, m);
    printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  if(n*a<b)
    cout << n*a << endl;
  else
    cout << b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

const int MAX_DIGIT = 18;

long long check(int digits, long long d, bool first)
{
	if (digits == 0) return (d == 0 ? 1 : 0);
	if (digits == 1) return (d == 0 ? 10 : 0);
	if (abs(d) >= stoll(string(digits, '9'))) return 0;

	long long coe = stoll(string(digits - 1, '9'));

	long long ans = 0;

	for (long long cur = -9; cur <= 9; ++cur) {
        long long newD = d - cur * coe;
        if (newD % 10) continue;

        if (first) {
            if (cur >= 0) ans += check(digits - 2, newD / 10, 0) * (9 - cur);
        } else {
            ans += check(digits - 2, newD / 10, 0) * (10 - abs(cur));
        }
	}

    return ans;
}

int main()
{
    int d;
    cin >> d;
    long long ans = 0;
    for (int i = 1; i <= MAX_DIGIT; ++i) {
        ans += check(i, d, 1);
//        cerr << check(i, d, 1) << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int flag = 0;
	float max, min;
	float hill;

	while (scanf("%f", &hill) != EOF){
		if (flag == 0){
			max = min = hill;
			flag++;
		}
		
		if (max < hill){
			max = hill;
		}
		else if (min > hill){
			min = hill;
		}
	}

	printf("%f\n", max - min);

	return (0);
}

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

using namespace std;

int gcd(int a,int b)
{
	if(b==0)
	{
		return a;
	}
	return gcd(b,a%b);
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	vector <int> v;
	int n,x,t;

	cin >> n >> x;

	for(int i=0;i<n;i++)
	{
			cin >> t;
			v.push_back(t);
	}
		v.push_back(x);
	
	sort(v.begin(),v.end());
	int res = v[1]-v[0];
	for(int i=2;i<v.size();i++)
	{
		res = gcd(res,v[i]-v[i-1]);
	}

	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 892
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

constexpr int Offset = 10;
char grid[1024][1024];

using PosDistance = tuple<int, int, int>;
enum Flag {
    None = 0,
    Queued0 = 1,
    Queued1 = 2,
    Closed = 4,
};

PosDistance q0[1024 * 1024];
PosDistance q1[1024 * 1024];
int flag[1024][1024];

constexpr array<pair<int, int>, 4> adjacent = {{
    {-1, 0}, {1, 0}, {0, -1}, {0, 1},
}};

large solve(const int ys, const int xs, const int yg, const int xg) {
    int push0 = 0, pop0 = 0;
    int push1 = 0, pop1 = 0;

    const auto empty = [&]() { return (pop0 == push0) && (pop1 == push1); };
    const auto pop = [&]() {
        if (pop0 < push0)
            return q0[pop0++];
        return q1[pop1++];
    };

    q0[push0++] = make_tuple(ys, xs, 0);
    flag[ys][xs] = Queued0;

    while (!empty()) {
        const auto [y, x, d] = pop();
        if (y == yg && x == xg) return d;

        if (flag[y][x] & Closed) continue;
        flag[y][x] |= Closed;

        for (auto [dy, dx] : adjacent) {
            auto ny = y + dy;
            auto nx = x + dx;
            if (grid[ny][nx] != '.') continue;
            if (flag[ny][nx] & (Queued0 | Closed)) continue;
            q0[push0++] = make_tuple(ny, nx, d);
            flag[ny][nx] |= Queued0;
        }

        for (auto dy = -2; dy <= 2; ++dy) {
            for (auto dx = -2; dx <= 2; ++dx) {
                auto ny = y + dy;
                auto nx = x + dx;
                if (grid[ny][nx] != '.') continue;
                if (flag[ny][nx] & (Queued0 | Queued1 | Closed)) continue;
                q1[push1++] = make_tuple(ny, nx, d + 1);
                flag[ny][nx] |= Queued1;
            }
        }
    }
    return -1;
}

int main() {
    int h, w; // 1000x1000
    cin >> h >> w;

    int x_start, y_start;
    int x_goal, y_goal;
    cin >> y_start >> x_start >> y_goal >> x_goal;

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> grid[i + Offset][j + Offset];
        }
    }

    y_start += Offset;
    x_start += Offset;
    y_goal += Offset;
    x_goal += Offset;

    cout << solve(y_start, x_start, y_goal, x_goal) << endl;
}

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

int main() {
    map<string, int> ss;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ss[s]++;
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        string t;
        cin >> t;
        ss[t]--;
    }
    auto c = *max_element(begin(ss), end(ss), [](auto a, auto b) { return a.second < b.second; });
    cout << max(c.second, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

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

  if (P == 2 || P == 5) {
    vector<vector<ll>> dp(N + 1, vector<ll>(P, 0));
    for (int i = 0; i < (int)(N); ++i) for (int p = 0; p < (int)(P); ++p) {
      dp[i + 1][(p * 10 + (S[i] - '0')) % P] += dp[i][p] + (p == 0);
    }
    ll s = 0;
    for (int i = 0; i < (int)(N + 1); ++i) s += dp[i][0];
    cout << s << endl;
  } else {
    vector<ll> T(N + 1, 0);
    reverse((S).begin(), (S).end());
    ll r = 1;
    for (int i = 0; i < (int)(N); ++i) {
      T[i + 1] = T[i] + r * (S[i] - '0');
      T[i + 1] %= P;
      r *= 10;
      r %= P;
    }

    ll ans = 0;
    map<ll, ll> C;
    for (int i = 0; i < (int)(N + 1); ++i) {
      ans += C[T[i]];
      ++C[T[i]];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
int n;string s;
int main(){
	cin>>n>>s;
	if(n&1){
		cout<<"No\n";
		return 0;
	}
	n/=2;
	bool yes=true;
	for(int i=0; i<n; i++){
		if(s[i]!=s[n+i]){
			yes=false; break;
		}
	}
	if(yes) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0] * n
bypass = y - x
for i in range(n):
    for j in range(i + 1, n):
        far = min(j - i, abs(i - x) + 1 + abs(j - y))
        ans[far] += 1

for i in range(1, len(ans)):
    print(ans[i])

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

int num_of_days (int y, int m, int d) {
	int number_of_days = 0;

	int i, k, j, l;

	// OK
	if (y % 3 == 0) {

		i = 333 - y / 3;
		k = 1000 - y - i - 1;
		l = 20 - d;

		number_of_days = i * 200 + k * 195 + 20 * (10 - m) + l + 1;

	//
	} else if (y % 3 == 1) {
		i = 333 - y / 3;
		k = 1000 - y - i - 1;

		if (m % 2 == 0) {
		j = 39 * (10 - m) / 2;
		l = 19 - d;
		} else {
		j = 20 * ((10 - m) / 2) + 19 * ((10 - m) / 2 + 1);
		l = 20 - d;
		}

		number_of_days = i * 200 + k * 195 + j + l + 1;

	//
	} else if (y % 3 == 2) {

		i = 333 - y / 3;
		k = 1000 - y - i - 1;

		if (m % 2 == 0) {
			j = 39 * ((10 - m)/ 2);
			l = 19 - d;
		} else {
			j = 20 * ((10 - m)/ 2) + 19 * ((10 - m)/ 2 + 1);
			l = 20 - d;
		}

		number_of_days = i * 200 + k * 195 + j + l + 1;
	}

	return number_of_days;
}



int main(void) {
	int n, Y, M, D;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> Y >> M >> D;

		cout << num_of_days(Y, M, D) << "\n";

	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);
    int N;
    List<List<Integer>> G;
    List<Boolean> visited;
    int INF = Integer.MAX_VALUE / 2;

    int dfs(int v, int p) {
        if (v == 1) {
            return 0;
        }

        if (visited.get(v)) {
            return INF;
        }

        visited.set(v, true);

        int ret = INF;
        for (int nv : G.get(v)) {
            if (nv != p) {
                int tmp = dfs(nv, v) + 1;
                if (ret > tmp) {
                    ret = tmp;
                }
            }
        }

        return ret;
    }


    void solve() {
        N = sc.nextInt();
        G = new ArrayList<>(N);
        visited = new ArrayList<>(N);
        for (int i = 0; i < N; ++i) {
            G.add(new ArrayList<>());
            visited.add(false);
//            G.set(i , new ArrayList<>());
        }

        for (int i = 0; i < N; ++i) {
            int a = sc.nextInt();
            a--;
//            G.get(a).add(i);
            G.get(i).add(a);
        }

        int ans = dfs(0, -1);
        if (ans == INF) {
            System.out.println("-1");
            return;
        }
        System.out.println(ans);


    }

    public static void main(String[] args) {
        new Main().solve();
    }
}


Measured memory_bytes: 78960
#include <stdio.h>

int main(void)
{
	int a, b, mennseki, nagasa;

	scanf("%d", &a);
	scanf("%d", &b);

	mennseki = a * b;
	printf("%d ", mennseki);
	nagasa = (2 * a) + (2 * b);
	printf("%d\n", nagasa);
	return 0;
}


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

int main() {
    int n, m_right;;
    cin >> n;
    m_right = n % 10;
    if (m_right == 3) cout << "bon" << endl;
    else if (m_right == 0 || m_right == 1 || m_right == 6 || m_right == 8)
        cout << "pon" << endl;
    else cout << "hon" << endl;
}

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

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp
#define pb push_back

#define fi
#define se

#define each

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int f(int n, int m, vi a){
	vi t(n+1,INF);
	t[0] = 0;
	rep(i,m){
		REP(j,a[i],n+1){
			t[j] = min(t[j],t[j-a[i]]+1);
		}
	}
	return t[n];
}

int main(){
	vi a;
	vi ao;
	REP(i,1,200){
		a.pb(i*(i+1)*(i+2)/6);
	}
	rep(i,a.size()){
		if(a[i]%2==1) ao.pb(a[i]);
	}

	// rep(i,a.size()) cout<<a[i]<<endl;
	// cout<<"=--"<<endl;
	// rep(i,ao.size()) cout<<ao[i]<<endl;

	while(1){
		int n; cin>>n;
		if(n==0) break;
		cout<<f(n,a.size(),a)<<" "<<f(n,ao.size(),ao)<<endl;
	}
	return 0;
}

Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int sum=0,a;
  for(int i=1; i<=N; ++i){
    cin >> a;
    if((i%2==1) && (a%2==1))
      ++sum;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3592
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n;
    cin>>n;
    vi v(100005);
    rep(i,n){
        int x;
        cin>>x;
        if(x!=0)v[x-1]++;
        v[x]++;
        v[x+1]++;
    }
    sort(rall(v));
    cout<<v[0]<<enl;

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N + 1);
    rep(i, N) cin >> A[i];
    ll ans = 0, temp = 0;
    iter(i, A) {
        if(i == 0) ans += temp / 2, temp = 0;
        else temp += i;
    }
    cout << ans << endl;
    return 0;
}


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

/// TLE
// int fib(int n) {
//     if (n == 0 || n == 1) {
//         return 1;
//     }
//     return fib(n-1) + fib(n-2);
// }

int main() {
    int n;
    cin >> n;
    vector<int> f(n+1);
    f[0] = 1;
    f[1] = 1;;
    for (int i=2; i<=n; i++) {
        f[i] = f[i-1] + f[i-2];
    }

    cout << f[n] << endl;

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;




int main() {
    ll K, S;
    cin >> K >> S;
    ll counter = 0;
     rep(X,K+1) {
        rep(Y,K+1) {
            ll Z = S - X - Y;
            if (0<=Z&&Z<=K) {
                counter++;
            }
        }
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3640
//
// Created by moono on 2018/10/27.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


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


    vector<int> vec{a, b, c};
    sort(vec.begin(), vec.end());

    //
    for (int i = 0; i < k; ++i) {
        vec[2] *= 2;
    }


    //
    int sum = 0;
    for (int j = 0; j < 3; ++j) {
        sum += vec[j];
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll K,S;
    cin >>K>>S;
    ll ans=0;
    rep(i,K+1){
        rep(j,K+1){
            if(i+j<=S && S-i-j<=K){
                ans++;
            }
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3608
function Main(input) {
	var font = input;
	var one;
  	var length_arr = [0];
	var minNum = 0;
  	var flag = false;
  	String(font).split('');
	for (var i = 0; i < font.length; i++) {
    	one = font[i];
		if(one == 'A' || one == 'C' || one == 'G' || one == 'T'){
          if(!flag){
            minNum = i;
          }
          flag = true;
        }
      	else{
          if(flag){
	          length_arr.push(i - minNum);
        	}
	      flag = false;
        }
	}
	var num = Math.max.apply(null, length_arr);
  	console.log(num);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] s = new long[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextLong();
            if(i == 0){
                s[0] = a[0];
            } else {
                s[i] = s[i-1]+a[i];
            }
        }
        sc.close();

        long cnt1 = 0;
        long cnt2 = 0;
        long diff1 = 0;
        long diff2 = 0;
        for(int i = 0; i < n; i++){
            if(i%2 == 0){
                if(s[i]+diff1 <= 0){
                    cnt1 += 1-s[i]-diff1;
                    diff1 += 1-s[i]-diff1;
                }
            } else {
                if(s[i]+diff1 >= 0){
                    cnt1 += s[i] + diff1 + 1;
                    diff1 += -1-s[i]-diff1;
                }
            }
        }

        for(int i = 0; i < n; i++){
            if(i%2 == 0){
                if(s[i]+diff2 >= 0){
                    cnt2 += s[i] + diff2 + 1;
                    diff2 += -1-s[i]-diff2;
                }  
            } else {
                if(s[i]+diff2 <= 0){
                    cnt2 += 1-s[i]-diff2;
                    diff2 += 1-s[i]-diff2;
                }
            }
        }

        System.out.println(Math.min(cnt1, cnt2));
    }
}

Measured memory_bytes: 51156
#include<stdio.h>
int main(void)
{
	int a[28],flg[30],i;
	for(i=1;i<=30;i++){
		flg[i]=0;
	}
	for(i=0;i<28;i++){
		scanf("%d",&a[i]);
		flg[a[i]]=1;
	}
	for(i=1;i<=30;i++){
		if(flg[i]==0){
			printf("%d\n",i);
		}
	}
	return 0;
}

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

template <const int MAXN> struct Sieve {
    bool isPrime[MAXN]; int SPF[MAXN]; vector<int> primes;
    void run(int N) {
        primes.clear(); fill(isPrime, isPrime + N + 1, true); isPrime[0] = isPrime[1] = false;
        for (int i = 2; i <= N; i++) {
            if (isPrime[i]) primes.push_back(SPF[i] = i);
            for (int j = 0; j < (int) primes.size() && i * primes[j] <= N && primes[j] <= SPF[i]; j++) {
                isPrime[i * primes[j]] = false; SPF[i * primes[j]] = primes[j];
            }
        }
    }
    vector<int> primeFactor(int x) {
        vector<int> ret;
        while (x != 1) { ret.push_back(SPF[x]); x /= SPF[x]; }
        return ret;
    }
    vector<pair<int, int>> primeFactorWithCount(int x) {
        vector<pair<int, int>> ret;
        while (x != 1) {
            ret.emplace_back(SPF[x], 0);
            for (int spf = SPF[x]; x % spf == 0; x /= spf) ret.back().second++;
        }
        return ret;
    }
};

const int MAXA = 1e6 + 5;

Sieve<MAXA> sieve;

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int N;
  cin >> N;
  sieve.run(1e6);
  vector<int> A(N);
  vector<vector<int>> inds(MAXA);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (auto &&[p, c] : sieve.primeFactorWithCount(A[i])) inds[p].push_back(i);
  }
  bool isPw = true;
  for (int i = 0; i < N; i++) for (auto &&[p, c] : sieve.primeFactorWithCount(A[i])) if (sz(inds[p]) != 1) isPw = false;
  if (isPw) {
    cout << "pairwise coprime" << nl;
    return 0;
  }
  int g = 0;
  for (int i = 0; i < N; i++) g = __gcd(g, A[i]);
  if (g == 1) cout << "setwise coprime" << nl;
  else cout << "not coprime" << nl;
  return 0;
}


Measured memory_bytes: 57004
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# N = int(input())
# A = map(int, readline()).split())

X, N = map(int, readline().split())

P = map(int, readline().split())

has = set()
for p in P:
    has.add(p)


ans = 0
for i in range(0, 102):
    if not i in has:
        if abs(X - i) < abs(X - ans):
            ans = i
print(ans)





Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vcc;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim)
{
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
{
  ll i, j, n, m;
  string s = "";
  string t = "";
  cin >> s;
  cin >> t;
  if (s.find(t) <= s.size())
  {
    cout << 0 << endl;
  }
  else
  {
    vi ans;
    for (i = 0; i < (s.size() - t.size() + 1); i++)
    {
      string temp = s.substr(i, t.size());
      {
        ll count1 = 0;
        fo(j, t.size())
        {
          if (temp[j] == t[j])
          {
            continue;
          }
          else
          {
            count1++;
          }
        }
        ans.pb(count1);
      }
    }
    int ans1 = *min_element(all(ans));
    cout << ans1 << endl;
  }
}

int main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());

  int t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }

  return 0;
}

int mpow(int base, int exp)
{
  base %= mod;
  int result = 1;
  while (exp > 0)
  {
    if (exp & 1)
      result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m)
{
  int i, u, v;
  while (m--)
  {
    cin >> u >> v;
    u--, v--;
    g[u].pb(v);
    g[v].pb(u);
  }
}

void dfs(int u, int par)
{
  for (int v : g[u])
  {
    if (v == par)
      continue;
    dfs(v, u);
  }
}


Measured memory_bytes: 10668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int A , B , C , K;
    cin >> A >> B >> C >> K;
    if(K <= A){
        cout << K << endl;
    }
    else if(K <= A + B){
        cout << A << endl;
    }
    else{
        cout << A - min((K - (A + B)) , C) << endl;
    }
}

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input(), K = input();

  if ((1 << N) <= K || (N == 1 && K == 1)) {
    cout << -1 << endl;
    return;
  }


  vector< int > ans;

  if (K == 0) {
    range(i, 0, 1 << N) {
      ans.push_back(i);
      ans.push_back(i);
    }
  } else {

    vector<int> v, used(1 << N);
    range(i, 0, (1 << N)) {
      if (used[i]) continue;
      v.push_back(i);
      v.push_back(i ^ K);
      used[i] = used[i ^ K] = true;
    }

    for (int i = 0; i < v.size(); i += 4) {
      for (auto diff : {0, 1, 2, 3, 1, 0, 3, 2}) {
        ans.push_back(v[i + diff]);
      }
    } 
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}

Measured memory_bytes: 3052
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const int INF = int(1e9);
const int MAX = 100;
int N,M;
int Map[MAX][MAX]={0};
int a[MAX*MAX],b[MAX*MAX];
int visit[MAX];

int dfs(int l,int r)
{
   // cout<<l<<" "<<r<<endl;
    visit[l] = 1;
    if(l==r) return 0;
    for(int i = 1;i<=N;i++){
        if(visit[i]==1||Map[l][i]==0)continue;
        if(dfs(i,r)==0)
            return 0;
    }
    return 1;
}

int main()
{
    cin>>N>>M;
    for(int i = 1;i<=M;i++){
        int len;
        cin>>a[i]>>b[i];
        Map[a[i]][b[i]] = Map[b[i]][a[i]]  = 1;
    }
    int sum = 0;
    for(int i = 1;i<=M;i++){
        memset(visit,0,sizeof(visit));
        //cout<<"----------------"<<endl;
         Map[a[i]][b[i]] = Map[b[i]][a[i]]  = 0;
        if(dfs(a[i],b[i]))
            sum++;
         Map[a[i]][b[i]] = Map[b[i]][a[i]]  = 1;
    }

    cout<<sum<<endl;

    return 0;
}



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

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    a, b, c = map(int, input().split())
    count = 1

    while count < (b + 1):
        if ((a * count) % b) == c:
            print('YES')
            exit()

        count += 1

    print('NO')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N-1);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, N-1) cin >> C[i];

	ll ans = 0;
	rep(i, N) ans += B[i];

	//cout << ans << endl;

	rep(i, N-1) {
		if(A[i+1]-A[i]==1) {
			ans += C[A[i]-1];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define BE(x) (x).begin(), (x).end()

int main() {
    int n, x, a;
    cin >> n >> x;

    if (n > 1000) {
        cin >> a;
        a = abs(a-x);
        vector<int> b = {1, a};
        for (int i = 2; i*i <= a; i++) {
            if (a%i == 0) {
                b.push_back(i);
                b.push_back(a/i);
            }
        }
        for (int i = 1; i < n; i++) {
            cin >> a;
            a = abs(a-x);
            int s = b.size();
            for (int j = 0; j < s; j++) {
                if (a%b[j] != 0) {
                    b.erase(b.begin()+j);
                    s--;
                }
            }
            if (s == 1) break;
        }
        cout << *max_element(BE(b)) << endl;
    }

    else {
        vector<vector<int>> b(n);
        for (int i = 0; i < n; i++) {
            cin >> a;
            a = abs(a-x);
            int r = round(sqrt(a));
            for (int j = 1; j <= r; j++) {
                if (a%j == 0) {
                    b[i].push_back(j);
                    b[i].push_back(a/j);
                }
            }
        }
        sort (BE(b[0]));
        int s = b[0].size()-1;
        for (int i = s; i >= 0; i--) {
            int x = b[0][i];
            bool f = true;
            for (int j = 1; j < n; j++) {
                auto res = find(BE(b[j]), x);
                if (res == b[j].end()) {
                    f = false;
                    break;
                }
            }
            if (f) {
                cout << x << endl;
                return 0;
            }
        }
    }
    
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int l[3000];
int main(){
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>l[i];
	sort(l,l+n);
	ll ans=0;
	for (int i=0;i<n;i++)
		for(int j=i+1;j<n;j++){
		int lef=j+1;
		int lo=0,hi=n,mid;
		while (lo+1<hi){
			mid=(lo+hi)/2;
			if (l[mid]>=l[i]+l[j])  hi=mid;
			else  lo=mid;
		}
		ans+=hi-lef;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int dice[6], tmp;
    char NEWS[100];
    for(int i=0; i<6; i++){
        scanf("%d", &dice[i]);
    }
    scanf("%s", NEWS);
    for(int i=0; NEWS[i] != '\0'; i++){
        tmp = dice[0];
        if(NEWS[i] == 'N'){
            dice[0] = dice[1];
            dice[1] = dice[5];
            dice[5] = dice[4];
            dice[4] = tmp;
        }else if(NEWS[i] == 'E'){
            dice[0] = dice[3];
            dice[3] = dice[5];
            dice[5] = dice[2];
            dice[2] = tmp;
        }else if(NEWS[i] == 'W'){
            dice[0] = dice[2];
            dice[2] = dice[5];
            dice[5] = dice[3];
            dice[3] = tmp;
        }else if(NEWS[i] == 'S'){
            dice[0] = dice[4];
            dice[4] = dice[5];
            dice[5] = dice[1];
            dice[1] = tmp;
        }
    }
    printf("%d\n", dice[0]);
    return 0;
}



Measured memory_bytes: 2096
#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

fn main() {
  let n = get::val::<u32>();
  let mut xs = get::vals::<isize>(2usize.pow(n));

  let bump = |g: &[isize]| if g[0]==g[1] {g[0]} else {(g[0]-g[1]).abs()};

  while xs.len() > 1 {
    xs = xs.chunks(2).map(&bump).collect::<Vec<_>>()
  }

  println!("{}", xs[0])
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


Measured memory_bytes: 8444
#include <iostream>
#include <cstdio>

using namespace std;

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

int n, m, ta[100], score[100]; 

int main() {
	cin >> n >> m;
	REP(i,m) cin >> ta[i];

	REP(i,m) {
		REP(j,n) {
			int tmp;
			scanf("%d", &tmp);
			if (tmp == ta[i]) score[j]++;
			else score[ta[i]-1]++;
		}
	}

	REP(i,n) printf("%d\n", score[i]);

	return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int width = sc.nextInt();
		int limit = sc.nextInt();
		int tmp = 0;
		int answer = 0;
		if (height > width) {
			while (tmp < limit) {
				tmp += height;
				answer++;
			}
		} else {
			while (tmp < limit) {
				tmp += width;
				answer++;
			}
		}
		System.out.println(answer);

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
bool cantstep[100005];
int ans=0;
int dp[100005];
int main(int argc,char const* argv[])
{
  memset(cantstep,false,sizeof(cantstep));
  memset(dp,0,sizeof(dp));
  int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++)
    {
      int a;
      cin >> a;
      cantstep[a]=true;
    }
  dp[0]=1;
  for(int i=0;i<=n;i++)
    {
      if(!cantstep[i+1]) dp[i+1]=(dp[i+1]+dp[i])%MOD;
      if(!cantstep[i+2]) dp[i+2]=(dp[i+2]+dp[i])%MOD;
    }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
using namespace std;

const char *solve(){
	int c[20] = {};
	int a;
	for(int i = 0; i < 5; ++i){
		if(scanf("%d,", &a) == EOF){ return 0; }
		++c[a];
	}
	c[14] = c[1];

	int mc = 0, ms = 0, p = 0;
	for(int i = 1; i < 14; ++i){
		mc = max(mc, c[i]);
		if(c[i] > 1){ ++p; }
		int s = 0;
		for(int j = 0; j < 5 && c[i + j]; ++j){
			++s;
		}
		ms = max(ms, s);
	}
	
	if(mc == 4){ return "four card"; }
	if(p > 1 && mc > 2){ return "full house"; }
	if(ms > 4){ return "straight"; }
	if(mc > 2){ return "three card"; }
	if(p > 1){ return "two pair"; }
	if(p){ return "one pair"; }
	return "null";
}

int main(){
	const char *ans;
	while(ans = solve()){
		puts(ans);
	}
}

Measured memory_bytes: 1008
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        ArrayList<Integer> nzlist = new ArrayList<Integer>();
        int ans = 0;
        for(int i=0;i<n;i++){
            int s = Integer.parseInt(sc.next());
            if(s%10!=0) nzlist.add(s);
            ans += s;
        }
        if(ans%10==0){
            if(nzlist.isEmpty()) ans = 0;
            else {
                nzlist.sort((a,b)->a-b);
                ans -= nzlist.get(0);
            }
        }
        System.out.println(ans);
    }
}


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

int main() {
	int n;
	cin >> n;
	double x[n];
	string u[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> u[i];
	}

	double ans = 0;
	for (int i = 0; i < n; i++) {
		if (u[i] == "JPY") {
			ans += x[i];
		} else {
			ans += 38e4 * x[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll N, M;
vector<vector<edge>> g;

vector<bool> see;

vector<ll> pos;

void dfs(ll v) {
	see[v] = 1;

	for (edge e : g[v]) {
		if (see[e.to] == 1) { continue; }
		pos[e.to] = pos[v] + e.d;
		dfs(e.to);
	}

	return;
}




int main() {

	ll N;
	cin >> N;

	vector<ll> A(N + 1);
	vector<ll> B(N + 1);

	repn(i, N) cin >> A[i];
	repn(i, N) cin >> B[i];

	ll ans = 0;

	repn(i, N) {
		ll v = 0;
		repn(j, i) v += A[j];
		for (int j = i; j <= N; j++) v += B[j];
		ans = max(v, ans);
	}

	cout << ans;

	system("PAUSE");

	

}


Measured memory_bytes: 504
#include <iostream>
using namespace std;
int main(void){

int X, Y;

cin >> X >> Y;

if(Y % 2 != 0)
cout << "No" << endl;

else if(X * 4 >= Y && X * 2 <= Y)
cout << "Yes" << endl;

else
cout << "No" << endl;
    
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a[] = new int[n];
        int b = 0, c = 0;

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
            if (a[i] % 4 == 0) {
                b++;
            } else if (a[i] % 2 == 0) {
                c++;
            }
        }

        boolean flag = false;
        if (n <= b * 2 + 1) {
            flag = true;
        } else if (n - b * 2 <= c) {
            flag = true;
        }

        if (flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 50156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);
		
		int[] a=new int[3];
		int[] b=new int[3];
		int[][] c=new int[3][3];
		
		for(int i=0;i<3;i++) {
			
			for(int j=0;j<3;j++) {
				c[i][j]=scanner.nextInt();
			}
		}
		
		
		for(int i=0;i<3;i++) {
			b[i]=c[0][i];
		}
		
		a[0]=0;
		a[1]=c[1][0]-b[0];
		a[2]=c[2][0]-b[0];
		
		boolean wronganswer=false;
		
		for(int i=0;i<3;i++) {
			
			for(int j=0;j<3;j++) {
				if(c[i][j]!=a[i]+b[j]) {wronganswer=true;};
			}
		}

		if(wronganswer) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}

		scanner.close();

	}
}

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

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

  double ans = 0;
  for(int i=0; i<N; i++){
    string u; double x;
    cin >> x >> u;
    if(u == "JPY") ans += x;
    if(u == "BTC") ans += x*380000;
  }
  cout << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
using namespace std;
int dp[51][51][51][51][2][3], A[51], B[51], C[51], D[51];
int N, M, INF = (1e9);
bool done[51][51][51][51][2][3];

int dfs(int a, int b, int c, int d, int p, int t){
  if(done[a][b][c][d][p][t]) return dp[a][b][c][d][p][t];
  done[a][b][c][d][p][t] = true;

  if(a == N && b == M && c == N && d == M) return dp[a][b][c][d][p][t];
  
  if(t > 1) dp[a][b][c][d][p][t] = 0;
  else if(p) dp[a][b][c][d][p][t] = INF;
  else dp[a][b][c][d][p][t] = -INF;
  
  if(p){
    if(b < M){
      if(B[b] >= 0) dp[a][b][c][d][p][t] = min(dp[a][b][c][d][p][t],dfs(a,b+1,c,d,1-p,0));
      else dp[a][b][c][d][p][t] = min(dp[a][b][c][d][p][t],dfs(a,b+1,a,d,1-p,0));
    }
    if(t < 2) dp[a][b][c][d][p][t] = min(dp[a][b][c][d][p][t], C[a] - C[c] - D[b] + D[d] + dfs(a,b,a,b,1-p,t+1));//pass
  }else{
    if(a < N){
      if(A[a] >= 0) dp[a][b][c][d][p][t] = max(dp[a][b][c][d][p][t],dfs(a+1,b,c,d,1-p,0));
      else dp[a][b][c][d][p][t] = max(dp[a][b][c][d][p][t],dfs(a+1,b,c,b,1-p,0));
    }
    if(t < 2) dp[a][b][c][d][p][t] = max(dp[a][b][c][d][p][t], C[a] - C[c] - D[b] + D[d] + dfs(a,b,a,b,1-p,t+1));//pass
  }
  //cerr << a << " " << b << " " << c << " " << d << " " << p << " " << dp[a][b][c][d][p] << endl;
  return dp[a][b][c][d][p][t];
}

int main(){
  cin >> N >> M;
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < M; ++i) cin >> B[i];
  for(int i = 0; i < N; ++i) C[i+1] = C[i] + max(0,A[i]);
  for(int i = 0; i < M; ++i) D[i+1] = D[i] + max(0,B[i]);
  cout << dfs(0,0,0,0,0,0) << endl;
  return 0;
}



Measured memory_bytes: 90964