akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<double, int> d_i;
typedef pair<int, int> i_i;

struct path {
    int to;
    int bound;
    double dist;
    path(int a, int b, double c) {
        to = a;
        bound = b;
        dist = c;
    }
};
double TIME[31][31][31];

struct query {
    int pos;
    int from;
    int speed;
    query(int a, int b, int c) {
        pos = a;
        from = b;
        speed = c;
    }
    /*
    bool operator< (const query &a) const {
        return TIME[pos][from][speed] < TIME[a.pos][a.from][a.speed];
    }
    */
};

bool operator>(const query &a, const query &b) {
    return TIME[a.pos][a.from][a.speed] > TIME[b.pos][b.from][b.speed];
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
//dist[i][j][k] 現在地i jから来た 現在の速さk
int n, m;
vector<path> pathes[31];
int main() {
    cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> n >> m;
        if(n == 0) break;
        for(int i = 0; i <= 30; i++) {
            pathes[i].clear();
            for(int j = 0; j <= 30; j++) {
                for(int k = 0; k <= 30; k++) {
                    TIME[i][j][k] = 1e18;
                }
            }
        }
        int s, g;
        cin >> s >> g;
        while(m--) {
            int x, y, c;
            double d;
            cin >> x >> y >> d >> c;
            pathes[x].emplace_back(y, c, d);
            pathes[y].emplace_back(x, c, d);
        }
        priority_queue<query, vector<query>, greater<query>> que;
        que.emplace(s, 0, 0);
        TIME[s][0][0] = 0.0;
        bool reach = false;
        double ans;
        while(!que.empty()) {
            query now = que.top();
            que.pop();
            //cerr << now.pos << " " << now.from << " " << now.speed << " " << TIME[now.pos][now.from][now.speed] << endl;
            if(now.pos == g && now.speed == 1) {
                reach = true;
                cout << TIME[now.pos][now.from][now.speed] << endl;
                break;
            }
            for(int speed = now.speed-1; speed <= now.speed+1; speed++) {
                if(speed <= 0) continue;
                for(int i = 0; i < pathes[now.pos].size(); i++) {
                    path nowpath = pathes[now.pos][i];
                    if(nowpath.to == now.from) continue;
                    if(nowpath.bound < speed) continue;
                    double nowtime = TIME[now.pos][now.from][now.speed] + nowpath.dist / (double)speed;
                    if(nowtime < TIME[nowpath.to][now.pos][speed]) {
                        TIME[nowpath.to][now.pos][speed] = nowtime;
                        que.emplace(nowpath.to, now.pos, speed);
                    }
                }
            }
        }
        if(!reach) cout << "unreachable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define cc pair<char,char>
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000000
#define inf 1000000000
#define N 300005
#define LOG 20
#define magic 100
#define KOK 250
#define EPS 0.0025
#define pw(x) (1<<(x))
#define PI 3.1415926535
using namespace std;

int ans=inf,n;
int pre[N],suf[N];
char s[N];

int main() {

	#if 0
	freopen("input.txt","r",stdin);
	#endif
		
	scanf("%d",&n);

	scanf("%s",s+1);

	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+(s[i]=='W');

	for(int i=n;i>=1;i--) suf[i]=suf[i+1]+(s[i]=='E');

	for(int i=1;i<=n;i++) {

		if(pre[i-1]+suf[i+1]<ans) {

			ans=pre[i-1]+suf[i+1];

		}

	}

	printf("%d",ans );

}

Measured memory_bytes: 2944
import sys
from collections import Counter

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    A = imi(N)
    c = Counter(A)
    ans = 0
    for v in c.values():
        if v % 2 == 1:
            ans += 1
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 16616
def main():
    h, w, n, *a = map(int, open(0).read().split())
    l = [[i + 1] * a[i] for i in range(n)]
    s = sum(l, [])

    f = False
    ans = ''
    for i in range(h):
        x = s[i * w: (i + 1) * w]
        if f:
            x = x[::-1]
        f = not f
        ans += ' '.join(map(str, x)) + '\n'

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4716
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


#if 1

int main()
{
	int n,m;
	cin >> n >> m;

	vector <ll> sum(n);
	for (int i=0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		if (a > b)
		{
			swap(a,b);
		}
		a--;
		b--;

		sum[a]++;
		sum[b]--;
	}

	bool ok = true;
	int value = 0;
	for (int i=0;i<n;i++)
	{
		value += sum[i];
		if(value%2)
		{
			ok = false;
			break;
		}
	}

	if(ok)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}


#else

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

	for (int i=0;i<1000000;i++)
	{
		if (a % 2 || b % 2 || c % 2)
		{
			printf("%d\n", i);
			return 0;
		}
		ll na = (b+c)/2;
		ll nb = (c+a)/2;
		ll nc = (a+b)/2;

		a = na;
		b = nb;
		c = nc;
	}

	printf("%d\n", -1);
	return 0;
}

#endif

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {
        int N = scanner.nextInt();
        int W = scanner.nextInt();
        int value[] = new int[N+1];
        int weights[] = new int[N+1];
        for(int i = 1 ; i<= N ; i++){
            weights[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
        }
        System.out.println(knapsack(N , W , weights,value));


    }
    public static long knapsack(int N , int W , int[] weights , int[] value){
        long dp[][] = new long[N+1][W+1];

         dp[1][weights[1]] = value[1];

         for(int i = 2 ; i<= N ; i++){
             for(int w = 0 ; w<= W ; w++){

                 dp[i][w] = dp[i-1][w];
                 if(weights[i] > w)
                     continue;
                 dp[i][w] = Math.max(dp[i][w] , value[i] + dp[i - 1][w - weights[i]]);
             }
         }
         long max = Integer.MIN_VALUE;
         for(int i  = 1 ; i<= N ; i++){
             for(int w = 1 ; w<= W ; w++) {
                 max = Math.max(dp[i][w], max);
             }
         }
        return max;
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  vector<int> dp(n);
  for(int i = 0; i < n; i++){
    dp[i] = 100010;
  }
  dp[0] = 0;
  for(int i = 1; i < n; i++){
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    if(i == 1) continue;
    dp[i] = min(dp[i], dp[i-2] + abs(h[i-2] - h[i]));
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


template<class T>
vec<T> makeVec(const int n1, const T initValue) {
  return vec<T>(n1, initValue);
}


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


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


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


#define dbg(...) ;


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  vec<int> ws(n), ss(n);
  vec<int64_t> vs(n);
  vec<int> ids(n);
  FOR(i, n) {
    ids[i] = i;
  }
  int maxS = 0;
  FOR(i, n) {
    ws[i] = next<int>(in);
    ss[i] = next<int>(in);
    vs[i] = next<int64_t>(in);
    maxS = max(maxS, ss[i]);
  }

  sort(all(ids), [&] (int i1, int i2) -> bool {
    return ss[i1] + ws[i1] < ss[i2] + ws[i2];
  });

  vec<int64_t> f(maxS + 1, -1);
  vec<int64_t> nxt(maxS + 1, -1);
  f[0] = 0;

  dbg(ids);

  int64_t res = 0;
  FOR(i, n) {
    FOR(j, maxS + 1) {
      if (f[j] != -1) {
        nxt[j] = max(nxt[j], f[j]);
        if (j <= ss[ids[i]] && j + ws[ids[i]] <= maxS) {
          nxt[j + ws[ids[i]]] = max(nxt[j + ws[ids[i]]], f[j] + vs[ids[i]]);
        }
        if (j <= ss[ids[i]]) {
          res = max(res, f[j] + vs[ids[i]]);
        }
      }
    }
    f = nxt;
    nxt = makeVec<int64_t>(maxS + 1, -1);
  }
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  for(int i = 0; i < n; i++) cin >> b.at(i);
  for(int i = 0; i < n - 1; i++) cin >> c.at(i);
  
  int next = a.at(0);
  int sum = b.at(a.at(0) - 1);
  for(int i = 1; i < n; i++){
    sum += b.at(a.at(i) - 1);
    if(a.at(i) - 1 == next) sum += c.at(next - 1);
    next = a.at(i);
  }
  
  cout << sum << endl;
}

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

int main(void){
  int n, m;
  cin >> n >> m;
	
  priority_queue<int> a;
  for (int i = 0; i < n; i++) {
	int tmp;
    cin >> tmp;
    a.push(tmp);
  }
  
  int max;
  for (int i = 0; i < m; i++) {
	max	= a.top();
    a.pop();
    max /= 2;
    a.push(max);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
	ans += (long long) a.top();
    a.pop();
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 892
# ABC153C

def f(n, k, h):
    if n <= k:
        print(0)
    else:
        h = sorted(h)[::-1]
        for i in range(k):
            h[i] = 0
        print(sum(h))

n, k = map(int, input().split())
h = list(map(int, input().split()))
f(n, k, h)


Measured memory_bytes: 31444
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}

struct edge
{
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};

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

  vector<int> d(N, INF);
  d.at(0) = 0;
  for (int i = 0; i < 2 * N; i++)
  {
    for (int v = 0; v < N; v++)
    {
      for (int k = 0; k < G.at(v).size(); k++)
      {
        edge e = G.at(v).at(k);
        if (d.at(v) != INF && chmin(d.at(e.to), d.at(v) + e.cost))
        {
          if (i >= N - 1)
          {
            d.at(e.to) = -INF;
          }
        }
      }
    }
  }

  if (-d.at(N - 1) >= INF)
    cout << -1 << endl;
  else
    cout << max((int)0, -d.at(N - 1)) << endl;
}


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

int main()
{
    int N, K;
    cin>>N>>K;
    vector<int> A(N);
    for (int &a: A)
        cin>>a;

    vector<int> D(N+1);
    for (int k=0; k<K; k++)
    {
        for (int i=0; i<=N; i++)
            D[i] = 0;
        for (int i=0; i<N; i++)
        {
            D[max(0, i-A[i])]++;
            D[min(N, i+A[i]+1)]--;
        }
        int a = 0;
        bool up = false;
        for (int i=0; i<N; i++)
        {
            a += D[i];
            if (a!=A[i])
            {
                up = true;
                A[i] = a;
            }
        }
        if (!up)
            break;
    }
    for (int i=0; i<N; i++)
        cout<<(i==0 ? "" : " ")<<A[i];
    cout<<endl;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, ans = 0; cin >> n;
	int max_ = INT_MIN;
	for(int i = 0 ; i < n; i++){
		int t; cin >> t;
		max_ = max(max_, t);
		ans += max_ - t;
	}
    
	cout << ans;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, m;
  cin >> n;
  vector<string> s(n);
  map<string, int> m1, m2;
  rep(i, n){
    cin >> s[i];
    m1[s[i]]++;
  }
  cin >> m;
  vector<string> t(m);
  rep(i, m){
    cin >> t[i];
    m2[t[i]]++;
  }
  int mx = 0;
  for(auto itr = m1.begin(); itr != m1.end(); itr++){
    int k = 0;
    k = itr->second - m2[itr->first];
    mx = max(mx, k);
  }
  cout << mx << endl;
  system("pause");
}


Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1){
            res*=a;
        }
        a*=a;
        x>>=1;
    }
    return res;
}

int main(){
    int n,p;cin>>n>>p;
    int a[n];
    bool flag=true;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==1) flag=false;
    }
    if(flag){
        if(p==1) cout<<0<<endl;
        else cout<<power(2,n)<<endl;
        return 0;
    }
    cout<<power(2,n-1)<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  int number = 1, count = 0;
  
  for (int i = 0; i < n; i++) {
    if (a[i] == number) {
      number++;
    }
    else {
      count++;
    }
  }
  
  int ans = number == 1 ? -1 : count;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, z, w;
    scan(n, z, w);
    auto a = readln.split.to!(int[]);

    if (n == 1) {
        auto ans = abs(a[0] - w);
        writeln(ans);
        return;
    }
    
    auto ans = max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1]));

    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 380
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

class Plant{
public:
	string name;
	int d,m;
	bool operator<(const Plant plant)const{
		if(m*plant.d==plant.m*d){
			return name<plant.name;
		}else{
			return m*plant.d>plant.m*d;
		}
	}
};

vector<Plant> plants;

int main() {
	int n;
	while(n=in()){
		plants.clear();
		string l;
		int p,a,b,c,d,e,f,s,m;
		int i;
		for(i=0;i<n;i++){
			cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
			Plant plant;
			plant.name=l;
			plant.d=a+b+c+(d+e)*m;
			plant.m=f*s*m-p;
			plants.push_back(plant);
		}
		sort(plants.begin(),plants.end());
		for(i=0;i<n;i++){
			cout<<plants[i].name<<endl;
//cout<<plants[i].d<<" "<<plants[i].m<<endl;
		}
		cout<<"#\n";
	}
	return 0;
}

Measured memory_bytes: 0
from itertools import accumulate
N, Q = map(int,input().split())
S = input()
AC = [0]*N
flag = 0
for idx, s in enumerate(S):
    if flag and s == "C":
        AC[idx] = 1
    if s == "A":
        flag = 1
    else:
        flag = 0

acc = list(accumulate(AC))

for i in range(Q):
    l, r = map(int,input().split())
    print(acc[r-1]-acc[l-1])

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

using namespace std;
typedef long long ll;

int main(){
	int n,k;
	cin>> n >> k;
	ll ans = 1;
	for (int i = 1; i <= n; i++){
		if(ans * 2 <= ans + k){
			ans *= 2;

		} else {
			ans += k;
		}
	}
	cout << ans << endl;
}



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

int main() {
  long long int n,m;
  cin>>n>>m;
  if(n>m){
    swap(n,m);
  }
  if(n==1){
    if(m==1){
      cout<<n<<endl;
      return 0;
    }
    cout<<m-2<<endl;
    return 0;
  }
  long long int answer=(n-2)*(m-2);
  cout<<answer<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    double x;
    double h;

    void run(){
	while(sc.hasNext()){
	    x = sc.nextDouble();
	    h = sc.nextDouble();
	    if(x!=0) solve();
	}
    }

    void solve(){
	double r = Math.sqrt(h*h+(x/2)*(x/2));
	double s = x*x + 2*(x*r);
	System.out.println(s);
    }
}

Measured memory_bytes: 18688
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	cout << (a + 1 + b) / 2 << endl;
	return 0;
}

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

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

	int N = w.size();
	map<char, int> mp;
	for( int i = 0; i < N; i++ ) {
		mp[ w[i] ]++;
	}
	string ans = "Yes";
	for( auto it = mp.begin(); it != mp.end(); it++ ) {
		if( it->second % 2 ) {
			ans = "No";
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3604
n, m = map(int, input().split())

flag = []
for _ in range(n):
    string = list(input())
    flag.append(string)

ans = 10**9
for white in range(1, n-1):
    for blue in range(1, n-1):
        red = n - white - blue
        if red <= 0:
            continue

        cnt = 0
        for i in range(white):
            for j in range(m):
                if flag[i][j] != "W":
                    cnt += 1

        for i in range(blue):
            for j in range(m):
                if flag[white+i][j] != "B":
                    cnt += 1

        for i in range(red):
            for j in range(m):
                if flag[white+blue+i][j] != "R":
                    cnt += 1

        if ans > cnt:
            ans = cnt

print(ans)





Measured memory_bytes: 5600
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

unsigned long long dp[301][301];
const int cm = 1 << 12;
char cn[cm], * ci = cn, ct;

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


	fread(cn, 1, cm, stdin);
	int N = 0, M = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';
	while ((ct = *ci++) >= '0') M = M * 10 + ct - '0';

	int xm[301][4], xM[301][4];
	rep1(i, N) {
		xm[i][1] = N;
		xm[i][2] = N;
		xM[i][2] = -1;
		xM[i][3] = -1;
	}
	rep(i, M) {
		int l = 0, r = 0;
		while ((ct = *ci++) >= '0') l = l * 10 + ct - '0';
		while ((ct = *ci++) >= '0') r = r * 10 + ct - '0';
		int x = *ci++ - '0';
		+ci++;
		chmin(xm[r][x], l);
		chmax(xM[r][x], l);
	}

	const int mod = 1e9 + 7;
	dp[0][0] = 1;
	int mj = 0;
	int mk = 0;
	unsigned long long yabai = 1;
	rep1(i, N) {
		for (int j = i - 1; j >= mj; j--) {
			auto dpj = dp[j];
			for (int k = i - 1; k >= max(j, mk); k--) {
				dpj[i] += dpj[k];
				dp[k][i] += dpj[k];
			}
		}
		yabai *= i + 1;
		bool yaba = (yabai > 18446744073709551615 / (i + 1));
		for (int j = i; j > max(xm[i][2], mj - 1); j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		for (int j = xm[i][2]; j > max(xM[i][3], mj - 1); j--) {
			for (int k = i; k > max(max(xm[i][1], mk - 1), j - 1); k--) dp[j][k] = 0;
			if (yaba) {
				for (int k = min(i, xm[i][1]); k > max(max(xM[i][2], mk - 1), j - 1); k--) {
					dp[j][k] %= mod;
				}
			}
			for (int k = xM[i][2]; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		for (int j = xM[i][3]; j >= mj; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		if (yaba) yabai = mod;
		if (mj <= xM[i][3]) mj = xM[i][3] + 1;
		if (mk <= xM[i][2]) mk = xM[i][2] + 1;
	}

	ll kotae = 0;
	for (int j = mj; j <= N; j++) for (int k = max(mk, j); k <= N; k++) {
		kotae += dp[j][k] % mod;
	}
	printf("%lld", kotae% mod);

	Would you please return 0;
}

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




int main(){
    int x;
    cin>>x;
    if(x==7 || x==5 || x==3) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll n;
vector<ll> x,y;
int main(){ //srand((unsigned)time(NULL));
  cin >> n;
  x.resize(n); y.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> y[i];
  }
  vector<ll>ab(n);
  double ans=0;
  for (int i = 0; i < n; i++) {
    ab[i] = abs(x[i]-y[i]);
    ans += ab[i];
  }cout << syo(5) << ans << endl;
  ans = 0;
  for (int i = 0; i < n; i++) {
    ans += pow(ab[i],2.0);
  }cout << syo(5) << pow(ans,(1.0/2.0)) << endl;
  ans = 0;
  for (int i = 0; i < n; i++) {
    ans += pow(ab[i],3.0);
  }cout << syo(5) << pow(ans,(1.0/3.0)) << endl;
  ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans,(double)ab[i]);
  }cout << syo(5) << ans << endl;
}



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

int main () {
	int t,n,s,f;
	int sum;
	
	while ( cin >> t, t ) {
		//初期化
		sum = 0;
		
		cin >> n;
		for ( int i = 0; i < n; i++ ) {
			cin >> s >> f;
			sum += f - s;
		}
		if ( t > sum ) {
			cout << t - sum << endl;
		} else {
			cout << "OK" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
 
typedef struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
} Node;
 
typedef Node *NodePointer;
NodePointer root = NULL;
 
NodePointer createNode(){
  NodePointer a = malloc(sizeof(Node));
  a->l = NULL;
  a->r = NULL;
  a->p = NULL;
  a->key = 0;
  return a;
}
 
void insert(int key){
   
  NodePointer a = createNode();
  NodePointer b = NULL;
  NodePointer c = root;
  a->key = key;
   
  while(c != NULL){
    b = c;
    if(a->key<c->key) c=c->l;
    else c =c->r;
  }
  a->p = b;
  if(b== NULL) root = a;
  else if(a->key<b->key)b->l = a;
  else b->r = a;
}
   
void inorder(NodePointer p){
     
  if(p != NULL){
    inorder(p->l);
    printf(" %d",p->key);
    inorder(p->r);
  }
}
 
void preorder(NodePointer p){
  if(p != NULL){
    printf(" %d",p->key);
    preorder(p->l);
    preorder(p->r);
  }
}

NodePointer minimum(NodePointer p){
  while(p->l != NULL){
    p = p->l;
  }
  
  return p;
}

NodePointer successor(NodePointer p){

  NodePointer c;

  if(p->r!= NULL) return minimum(p->r);
  c=p->p;
  while(c!= NULL && p==c->r){
    p=c;
    c=c->p;
  }
  return c;
}

void Delete(NodePointer p){

  NodePointer c;
  NodePointer b;

  if(p->l == NULL || p->r == NULL)
    c=p;
  else
    c=successor(p);
  if(c->l!= NULL)
    b=c->l;
  else
    b=c->r;
  if(b!= NULL)
    b->p = c->p;
  if(c->p == NULL)
    root =b;
  else if(c == c->p->l)
    c->p->l=b;
  else
    c->p->r=b;
  if(b!= p)
    p->key =c->key;
}


NodePointer find(NodePointer p, int key){

  if(p == NULL) return p;
  else if(p->key == key) return p;
  if(key < p->key)  return find(p->l,key);
  else  return find(p->r,key);
}
 
int main(void){
 
  int i,key,n;
  char str[20];
  NodePointer c;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",str);
 
    if(str[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(str[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(str[0] == 'f'){
      scanf("%d",&key);
	c=find(root,key);
	if(c!= NULL) printf("yes\n");
	else printf("no\n");
    }
    else{
      scanf("%d",&key);
      Delete(find(root,key));

    }
  }
  return 0;
}



Measured memory_bytes: 20448
// abc079-b
object Main extends App {
  val n = io.StdIn.readInt

  /* stackoverflow case
  def lucas(i: Int): Long = i match {
    case 0 => 2.toLong
    case 1 => 1.toLong
    case j => lucas(j-1) + lucas(j-2)
  }

  val result = lucas(n)
  println(result)
  */

  // lazy eval and memorize!
  def lucasFrom(a: Long, b: Long): Stream[Long] = a #:: lucasFrom(b, a+b)
  val lucas = lucasFrom(2, 1)
  println(lucas.take(n+1).last)
}

Measured memory_bytes: 54920
//abc150_e.cpp
//Sat Feb 29 10:37:18 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n;
	ll MOD = 1000000007;
	cin >> n;

	ll c[n];
	for (int i=0;i<n;i++){
		cin >> c[i];
	}

	sort(c,c+n,greater<ll>());

	ll ans = 0;
	for (ll i=0;i<n;i++){
		ll tmp = (i+2)*c[i]%MOD;
		ans = (ans+tmp)%MOD;
	}

	for (ll i=0;i<n-1;i++){
		ans = ans*4%MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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

ll a1, a2, ans;

int main() {
	ll N, x;
	cin >> N >> x >> a1;
	repi(i, 0, N - 1) {
		cin >> a2;
		ll s = a1 + a2;
		if (s > x) {
			ll d = s - x;
			a1 = max(0LL, a2 - d);
			ans += d;
		}
		else a1 = a2;
	}
	wrln(ans);
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

dist = []
for i in range(1, len(A)):
    dist.append(abs(A[i] - A[i-1]))

total = sum(dist)

for i in range(N):
    a = total - dist[i] - dist[i+1]
    a += abs(A[i] - A[i+2])
    print(a)

Measured memory_bytes: 14040
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

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

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
vi A;
pi bes[1<<18];

pi comb(pi a, pi b) {
	// cout << "OH " << a.f << " " << a.s << " " << b.f << " " << b.s << "\n";
	if (a.f == b.f) {
		if (a.s == -1) return b;
		if (b.s == -1) return a;
		if (A[a.s] >= A[b.s]) return a;
		return b;
	} else if (A[a.f] >= A[b.f]) {
		if (a.s == -1) return {a.f,b.f};
		if (A[a.s] >= A[b.f]) return a;
		return {a.f,b.f};
	} else {
		if (b.s == -1) return {b.f,a.f};
		if (A[a.f] >= A[b.s]) return {b.f,a.f};
		return b;
	}
}
void process(int x) {
	bes[x] = {x,-1};
	F0R(i,N) if (x&(1<<i)) bes[x] = comb(bes[x],bes[x^(1<<i)]);
}

int ans[1<<18];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N; A.resize(1<<N);
	F0R(i,1<<N) cin >> A[i];
	F0R(i,1<<N) {
		process(i);
		// cout << bes[i].f << " " << bes[i].s << "\n";
		if (i) {
			ans[i] = A[bes[i].f]+A[bes[i].s];
			ans[i] = max(ans[i],ans[i-1]);
			cout << ans[i] << "\n";
		}
	}
}

Measured memory_bytes: 7168
n=input()
if len(n)==1:
    if n=="3":
        print("bon")
    elif n=="0" or n=="1" or n=="6" or n=="8":
        print("pon")
    else:
        print("hon")
elif len(n)==2:
    if n[1]=="3":
        print("bon")
    elif n[1]=="0" or n[1]=="1" or n[1]=="6" or n[1]=="8":
        print("pon")
    else:
        print("hon")
else:
    if n[2]=="3":
        print("bon")
    elif n[2]=="0" or n[2]=="1" or n[2]=="6" or n[2]=="8":
        print("pon")
    else:
        print("hon")

Measured memory_bytes: 9092
n,m=input().split()
n,m=[int(n),int(m)]
A=[0]*n
b=[0]*m
for i in range(n):
    A[i]=list(map(int, input().split()))
for i in range(m):
    b[i]=int(input())
for i in range(n):
    c=0
    for j in range(m):
        c=c+A[i][j]*b[j]
    print(c)



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

using namespace std;

const int MOD = 1e9 + 7;

int d, l;
char s[100005];
long long dp[100005][105][2];

long long solve(int idx, int sum, bool ok) {
	if (dp[idx][sum][ok] != -1) return dp[idx][sum][ok];
	
	if (idx == l) {
		if (sum == 0) return 1;
		return 0;
	}
	
	int to = s[idx] - '0';
	
	if (ok) to = 9;
	dp[idx][sum][ok] = 0;
	
	for (int i = 0; i <= to; i++) {
		bool new_ok = ok;
		
		if (i != s[idx] - '0') new_ok |= 1;
		
		dp[idx][sum][ok] = (dp[idx][sum][ok] + solve(idx + 1, (sum + i) % d, new_ok)) % MOD;
	}
	
	return dp[idx][sum][ok];
}

int main() {
	scanf("%s", s);
	scanf("%d", &d);
	
	l = strlen(s);
	memset(dp, -1, sizeof(dp));
	
	printf("%lld\n", (solve(0, 0, 0) - 1 + MOD) % MOD);
}


Measured memory_bytes: 165120
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

points = 0
for i in range(N):
  if T[i]=="r":
    if i-K < 0 or T[i]!=T[i-K]:
      points+=P
    else:
      T[i]="x"
  elif T[i]=="s":
    if i-K < 0 or T[i]!=T[i-K]:
      points+=R
    else:
      T[i]="x"
  else:
    if i-K < 0 or T[i]!=T[i-K]:
      points+=S
    else:
      T[i]="x"
print(points)

Measured memory_bytes: 4084
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,i,x,maxx:Integer;
  s:string;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);
    Readln(s);

    x:=0;
    for i := 1 to n do begin
      if s[i]='I' then begin
        Inc(x);
        maxx:=(maxx+x+abs(maxx-x))div 2;
      end else
        x:=x-1;
    end;

    Writeln(maxx);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int solve() {
    
    char a, b, c, d;
    cin >> a >> b >> c >> d;
    
    string aa, cc;
    aa += a;
    aa += b;
    cc += c;
    cc += d;
    
    bool aaa = aa >= "01" && aa <= "12";
    bool ccc = cc >= "01" && cc <= "12";
    if (aaa && ccc) return 0;
    if (aaa) return 1;
    if (ccc) return 2;
    return 3;
    
    
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    switch (solve()) {
        case 0:
            out("AMBIGUOUS");
            break;
        case 1:
            out("MMYY");
            break;
        case 2:
            out("YYMM");
            break;
        case 3:
            out("NA");
            break;
    }
}



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

//この２つはmazeの大きさによって可変
const int MAX_X = 1001;
const int MAX_Y = 1001;



const int INF = -1;
int h,w; //h:mazeの高さ、w:mazeの幅
char maze[MAX_X][MAX_Y];
int sx,sy,gx,gy;
int warp_n = 0;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int dx_w[24]={-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,1,2,-2,-1,0,1,2,-2,-1,0,1,2};
int dy_w[24]={-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,1,1,1,1,1,2,2,2,2,2};
int d[MAX_X][MAX_Y];

int bfs(){


    queue<P> que;
    queue<P> que_w;
    rep(i,w){
        rep(j,h){
            d[i][j] = INF;
        }
    }
    que.push(P(sx,sy));
    que_w.push(P(sx,sy));
    d[sx][sy]=0;

    while(1){
        while (que.size()){
            P p = que.front(); que.pop();
            que_w.push(P(p.first,p.second));
            if(p.first==gx && p.second==gy)break;

            rep(i,4){
                int nx = p.first + dx[i];
                int ny = p.second + dy[i];

                if(0<=nx && nx<w && 0<=ny && ny<h && maze[nx][ny]!='#' && d[nx][ny]==INF){
                    que.push(P(nx,ny));
                    que_w.push(P(nx,ny));
                    d[nx][ny] = d[p.first][p.second];
                }
            }
        }


        if(d[gx][gy]==INF){
            /*
            rep(y,h){
                rep(x,w){
                    if(d[x][y]==(warp_n)){
                        que_w.push(P(x,y));
                    }
                }
            }
            */
            warp_n++;
            
            while (que_w.size()){
                P p_w = que_w.front(); que_w.pop();
                rep(i,24){
                    int nx_w = p_w.first + dx_w[i];
                    int ny_w = p_w.second + dy_w[i];

                    if(0<=nx_w && nx_w<w && 0<=ny_w && ny_w<h && maze[nx_w][ny_w]!='#' && d[nx_w][ny_w]==INF){
                        que.push(P(nx_w,ny_w));
                        d[nx_w][ny_w] = warp_n;
                        if(nx_w==gx && ny_w==gy)break;
                    }
                }
            }

            if(que.size()==0)break;
        }else{
            break;
        }
    }

    return d[gx][gy];
}

int main(){
    cin>>h>>w;
    cin>>sy>>sx>>gy>>gx;
    sy--;
    sx--;
    gy--;
    gx--;


    //mazeのinput
    string tmp;
    rep(y,h){
        cin>>tmp;
        rep(x,w){
            maze[x][y] = tmp[x];
        }
    }


    int res = bfs();
    cout<<res<<endl;


}



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

int main() {
  string S;
  cin >> S;
  int a = 0;
  
  for (int i = 0; i < 3; i++){
    if (S.at(i) == '1')
      a++;
  }
  
  cout << a << endl;


}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b;
    while (cin >> n >> a >> b, n || a || b) {
        vector<ll> s(n); cin >> s;
        P ans(-linf, -linf);
        rep(i, n-1) {
            if (a <= i+1 && i+1 <= b) {
                chmax(ans, P(s[i] - s[i+1], i+1));
            }
        }
        cout << ans.second << endl;
    }
}

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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<ll,ll> P;

struct edge {
	int from ,to, cost;
};
int ans;
vector<edge> G[1 << 17];
int main(){
  int N;cin>>N;
  int l[N];
  rep(i,N-1){
    int u,v,w;cin>>u>>v>>w;
    u-=1;v-=1;w%=2;
    G[u].push_back({u,v,w});
    G[v].push_back({v,u,w});
  }
  rep(i,N) l[i]=-1;
  l[0]=0;
  queue<edge> q;
  for(auto v:G[0]) q.push(v);
   
  while(!q.empty()){
    edge p=q.front();q.pop();
    l[p.to]=(l[p.from]+p.cost)%2;
    for(auto v:G[p.to]){
      if (l[v.to]==-1) q.push(v);
    }
  }
  rep(i,N) cout<<l[i]<<endl;
}


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

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-8)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i,m,n) for(int i=m; i<=(int)(n); ++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int n;
vector<pair<double,double> > app;

void solve(){
  set<int> appheight;
  app.clear();
  PI in[n];
  rep(i,n){
    cin >> in[i].F >> in[i].S;
    appheight.insert(in[i].S);
  }

  
  FOR(it,appheight)
    rep(i,n-1){
    double kata=
      (in[i+1].S-in[i].S)*1./
      (in[i+1].F-in[i].F);
    double x=(*it-in[i].S)/kata+in[i].F;

    if(in[i].F < x-EPS && x+EPS < in[i+1].F)
      app.pb(mp(x,*it));
    }
  rep(i,n) app.pb(in[i]);
  
  sort(ALL(app));

  priority_queue<pair<double,PI> > q;
  q.push(mp(0,mp(0,SZ(app)-1)));
  set<PI> vis;
  
  while(!q.empty()){
    double cc=-q.top().F;
    int p1=q.top().S.F;
    int p2=q.top().S.S;
    q.pop();
    if(vis.count(mp(p1,p2))) continue;
    vis.insert(mp(p1,p2));
    if(p1==p2){
      printf("%.8f\n",cc);
      return;
    }

    for(int i=-1;i<2;++i){
      int np1=p1+i;
      if(np1<0 || np1>=SZ(app)) continue;
      for(int j=-1;j<2;++j){
        if(i==0 && j==0) continue;
        int np2=p2+j;
        if(np2<0 || np2>=SZ(app)) continue;
        if(abs(app[np1].S - app[np2].S) < EPS){
          double dx1=app[p1].F - app[np1].F;
          double dy1=app[p1].S - app[np1].S;
          double dx2=app[p2].F - app[np2].F;
          double dy2=app[p2].S - app[np2].S;
          dx1 *= dx1;
          dx2 *= dx2;
          dy1 *= dy1;
          dy2 *= dy2;
          q.push(mp(-cc-sqrt(dx1+dy1)-sqrt(dx2+dy2),mp(np1,np2)));
        }
      }
    }
  }
}
  
main(){
  while(cin >> n, n)
    solve();
}

Measured memory_bytes: 2796
n = int(input())
a = list(map(int, input().split()))
p = 10**18
a.sort()
#print(a)
if 0 in a:
    print(0)
    exit()

a.reverse()
#print(a)
ans = 1
for i in a:
    ans *= i
    #print(ans)
    if ans > p:
        print(-1)
        exit()

print(ans)



Measured memory_bytes: 21636
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
#define debug(q,x) cout<<q<<x<<endl
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1e3+5;
const int MOD = 1e9 + 7;
const double ext = 1e-6;
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	while (cin >> s ) {
		int n = s.size();
		_for(i, 0, n)cout << 'x';
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	while(a>0&&c>0){
		c-=b;
		if(c<=0)break;
		a-=d;
	}
	if(a<=0) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 3660