akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using  namespace std;
void moveNum(char* S, int* N, int ph, int pw, int h, int w){
  if(S[w*(ph+1)+pw]=='.' && ph<(h-1) && N[w*(ph+1)+pw]>N[w*ph+pw]+1){
    N[w*(ph+1)+pw] = N[w*ph+pw]+1;
    moveNum(S, N, ph+1, pw, h, w);
  }
  if(S[w*(ph-1)+pw]=='.' && ph>0 && N[w*(ph-1)+pw]>N[w*ph+pw]+1){
    N[w*(ph-1)+pw] = N[w*ph+pw]+1;
    moveNum(S, N, ph-1, pw, h, w);
  }
  if(S[w*ph+(pw+1)]=='.' && pw<(w-1) && N[w*ph+(pw+1)]>N[w*ph+pw]+1){
    N[w*ph+(pw+1)] = N[w*ph+pw]+1;
    moveNum(S, N, ph, pw+1, h, w);
  }
  if(S[w*ph+(pw-1)]=='.' && pw>0 && N[w*ph+(pw-1)]>N[w*ph+pw]+1){
    N[w*ph+(pw-1)] = N[w*ph+pw]+1;
    moveNum(S, N, ph, pw-1, h, w);
  }
}
int main(){
 int h, w, ph, pw, ans=0, moveMax;
 cin >> h >> w;
 char S[h*w];
 for(int i=0;i<h*w;i++){
  cin >> S[i];
 }
 int N[h*w];
 for(int i=0;i<h*w;i++){
  moveMax = -1;
  for(int i=0;i<h*w;i++){
  N[i]= 1000;
  }
  ph = i/w;
  pw = i%w;
  N[ph*w+pw] = 0;
  if(S[ph*w+pw]=='.'){
    moveNum(S, N, ph, pw, h, w);
    for(int i=0;i<h*w;i++){
      if(N[i]!=1000){
      moveMax = max(moveMax, N[i]);
      }
    }
    ans = max(ans, moveMax);
  }
 }
 /*
 for(int i=0;i<h*w;i++){
  if(i%w==0){
    cout << endl;
  }
  cout << N[i] << " ";
 }
 */
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	char c; cin >> c;
	cout << (char)(c + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, i, j, k, s, ans;
	cin >> n;
	vector<long long> a(n), b(n), c;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) cin >> b[i];

	s = 0;
	ans = 0;
	for (i = 0; i < n; i++) {
		if (a[i] >= b[i]) c.push_back(a[i] - b[i]);
		else s += b[i] - a[i], ans++;
	}
	sort(c.rbegin(), c.rend());
	for (auto p : c) {
		if (s <= 0) break;
		s -= p;
		ans++;
	}

	if (s > 0) cout << "-1\n";
	else cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 2936
def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n=int(input())
    a = list(map(int,input().split()))
    cnt=0
    for i in range(n):
        if a[i]<0:
            a[i]*=-1
            cnt+=1
    a.sort()
    S=sum(a)

    print(S) if cnt%2==0 else print(S-2*a[0])
main()

Measured memory_bytes: 64880
ac = wa = tle = re = 0

for i in range(int(input())):
    S = input()
    if S == 'AC':
        ac += 1
    elif S == 'WA':
        wa += 1
    elif S == 'TLE':
        tle += 1
    else:
        re += 1
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))


Measured memory_bytes: 74888
AB=[list(map(int,input().split())) for i in range(int(input()))]

for a,b in AB:
    if a<b:a,b=b,a
    if a==b:
        print(2*a-2)
        continue
    c=int((a*b)**0.5)
    if a*b>c**2:
        if c*(c+1)<a*b:
            print(c*2-1)
        else:
            print(c*2-2)
    elif a*b==c**2:
        print((c-1)*2-1)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PA;
#define INF (1<<30);
int dp[1005][1005];
int main(){
  string t,b;
  cin >> t >> b;
  fill_n(*dp,1005*1005,0);

  for(int i=0;i<b.size();i++){
    for(int j=0;j<t.size();j++){
      if(b[i]==t[j]){
	if(i == 0) dp[i][j] = 1;
	else if(j != 0) dp[i][j] = (dp[i][j]+dp[i-1][j-1])%1000000007;
      }
      if(j != 0) dp[i][j] = (dp[i][j]+dp[i][j-1])%1000000007;
      
    }
  }
  printf("%d\n",dp[b.size()-1][t.size()-1]);
  return(0);
}



Measured memory_bytes: 7168
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;cin >> N;
	vector<int>data(N);
	for (int i = 0;i < N;i++) {
		cin >> data[i];
	}
	int cnt = 0, a = 0;
	bool judge = true;
	for (int i = 0;i < N;i++) {
	  a = max(a, data[i]);
	  if (a - data[i] > 1)judge = false;
	}
	if (judge)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;


int main()
{
    FAST_IO;

    string s, t; cin >> s >> t;
    cout << t << s << endl;

    return 0;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

long long A,B,C;
int X,Y;
long long Ans;

int main(){
	register int i;
	scanf("%lld%lld%lld%d%d",&A,&B,&C,&X,&Y);
	Ans=A*X+B*Y;
	for(i=1;i<=max(X,Y);i++) Ans=min(Ans,C*(i<<1)+A*max(X-i,0)+B*max(Y-i,0));
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int s[11];
int top=0;

void push(int x){
  top++;
  s[top]=x;
}
int pop(){
  top--;
  return s[top+1];
}
int main(){
  int a;
  while(scanf("%d",&a)!=EOF){
    if(a==0)printf("%d\n",pop());
    else push(a);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector <int> a(3 * n);
    for (int i = 0; i < n * 3; ++ i) {
        cin >> a[i];
    }
    multiset <int> st;
    vector <ll> mx(3 * n), mn(3 * n);
    ll now;
    st.clear(); now = 0;
    for (int i = 0; i < n * 3; ++ i) {
        now += a[i];
        st.insert(a[i]);
        if (st.size() > n) {
            now -= *st.begin();
            st.erase(st.begin());
        }
        mx[i] = now;
    }
    st.clear(); now = 0;
    for (int i = n * 3 - 1; ~i; -- i) {
        now -= a[i];
        st.insert(-a[i]);
        if (st.size() > n) {
            now -= *st.begin();
            st.erase(st.begin());
        }
        mn[i] = now;
    }
    ll ans = -1e18;
    for (int i = n - 1; i < n * 2; ++ i) {
        ans = max(ans, mx[i] + mn[i + 1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<P> ans;
    int a = n-n%2;
    for(int i = 1; i <= a; i++){
        for(int j = i+1; j <= a; j++){
            if(i + j != a+1)ans.push_back({i, j});
        }
    }
    for(int i = 1; i <= (n%2)*(n-1); i++)ans.push_back({i, n});
    cout << ans.size() << endl;
    rep(i, ans.size())cout << ans[i].first << " " << ans[i].second << endl;
}  

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define MAX_X 3
#define MAX_Y 3
int C[MAX_X][MAX_Y];
int DX[MAX_X][MAX_Y];
int DY[MAX_X][MAX_Y];
int main() {
  for (int i{0}; i < MAX_X; ++i) {
    for (int j{0}; j < MAX_Y; ++j) {
      cin >> C[i][j];
    }
  }
  for (int i{0}; i < MAX_X; ++i) {
    for (int j{0}; j < MAX_Y; ++j) {
      DX[i][j] = C[i][j] - C[(i + 1) % MAX_X][j];
      DY[i][j] = C[i][j] - C[i][(j + 1) % MAX_Y];
    }
  }
  bool result{true};
  for (int i{0}; i < MAX_X; ++i) {
    for (int j{0}; j < MAX_Y; ++j) {
      if (DY[i][j] != DY[(i + 1) % MAX_X][j] ||
          DX[i][j] != DX[i][(j + 1) % MAX_Y]) {
        result = false;
        goto END;
      }
    }
  }

END:
  cout << (result ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
N,M,C = map(int,input().split())
B=[int(i) for i in input().split()]

A=[]
for i in range(N):
    A.append(list(map(int,input().split())))

ans = 0
for i in range(N):
  c = 0
  for j in range(M):
    c += A[i][j]*B[j] 
  if c + C >0:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

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

    u int len = S.length();
    REP(i, 0, len)
    {
        if (S[i] == '?')
        {
            if (i != 0 and S[i - 1] == 'P')
                S[i] = 'D';
            else if ((i != len - 1) and (S[i + 1] == 'D' or S[i + 1] == '?'))
                S[i] = 'P';
            else
                S[i] = 'D';
        }
    }

    cout << S << "\n";

    return 0;
}

Measured memory_bytes: 3724
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    for(int i=1;i < 101;i++){
        c -= b;
        a -= d;
        if (c <= 0){
            cout << "Yes" << endl;
            break;
        }else if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  double n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  double x=(d+c)/2,y=(d-c)/2;
  double l=-y*(n-1),r=y*(n-1);
  for(ll i=-(n-1); i<=n-1; i+=2) {
    if(a+l+x*i<=b&&b<=a+r+x*i) {
      pr("YES");
      return;
    }
  }
  pr("NO");
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 256
s = input()
u = int(s[0:2])
l = int(s[2:])
if u>12 and  0<l<=12:
  print("YYMM")
elif 0<u<=12 and l>12:
  print("MMYY")
elif 0<u<=12 and 0<l<=12:
  print("AMBIGUOUS")
elif u ==0 and 0<l<=12:
  print("YYMM")
elif 0<u<=12 and l ==0:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

string s;
int ta, mu;

signed main() {
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'B')mu++;
		else ta += mu;
	}
	cout << ta << endl;
	ggr
}

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

int main(){
    int N;
    cin >> N;
    int x[100001], y[100001], t[100001];
    int dt, dx, dy, dst;
    x[0] = y[0] = t[0] = 0;
    for(int i=1; i<N+1; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i=1; i<N+1; i++){
        dt = t[i] - t[i-1];
        dx = x[i] - x[i-1];
        dy = y[i] - y[i-1];
        dst = abs(dx)+abs(dy);
        if(dt < dst || (dt-dst)%2 != 0){
            cout << "No";
            return EXIT_SUCCESS;
        }
    }
    cout << "Yes";
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1408
MOD = 10**9+7

N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

ans=0
for k in range(K,N+2):
	i = k*(k-1)//2
	j = (N + (N-k+1))*k//2
	ans += (j-i+1) % MOD

print(ans % MOD)



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

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a;
    int tmp;
    cin >> tmp;
    int tmp2 = tmp;
    a.push_back(tmp);
    for (int i = 0; i < n - 1; i++)
    {
        tmp2 = tmp;
        cin >> tmp;
        a.push_back(tmp - tmp2);
    }
    a.push_back(k - tmp + a[0]);
    /*for (int i = 0; i < a.size(); i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
    */
    cout << k - *max_element(a.begin(), a.end()) << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define tii tuple<int,int,int>
int two(int X){
  int i=0;
  while(X%2==0){
    X/=2;
    i++;
    }
  return i;
  }
signed main(){
  int N,ans=10000000;
  cin>>N;
  rep(i,0,N){
    int X;
    cin>>X;
    ans=min(ans,two(X));
    }
  cout<<ans<<endl;
}


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

vector<int> st;
vector<int> top;

vector<int> calc(int a, int b, int n) {
    if (n == 1) return {a, b};
    int s = __builtin_ffs(a^b);
    int t = 0;
    if ((a & (1 << (s-1))) != 0) t = (1 << (s-1));
    int aa = a % (1 << (s-1)) + ((a >> s) << (s-1));
    int bb = b % (1 << (s-1)) + ((b >> s) << (s-1));
    int d = aa ^ 1;
    //cout << a << b << " " << aa << " " << bb << " " << d <<  endl;
    vector<int> e = calc(aa, d, n-1), f = calc(d, bb, n-1);
    for (int i = 0; i < (int)e.size(); i++) e[i] = ((e[i] >> (s-1)) << s) + t + e[i] % (1 << (s-1));
    for (int q : f) e.push_back(((q >> (s-1)) << s) + (1 << (s-1))-t + q % (1 << (s-1)));
    return e;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    if (__builtin_parity(A^B) == 0) {
        cout << "NO" << endl;
        return 0;
    }
    
    vector<int> ans = calc(A, B, N);
    
    cout << "YES\n";
    for (int i = 0; i < (1<<N); i++) {
        if (i < (1<<N)-1) printf("%d ", ans[i]);
        else printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 1648
#include <stdio.h>

int main()
{
	int H, W, i, j;
	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0){
			break;
		}
		for (i = 0; i<H; i++)
		{
			for (j = 0; j<W; j++)
			{
				if (i == 0 || j == 0 || j == W - 1 || i == H - 1)
					printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2112
#!/usr/bin/env python3

ABC = "abcdefghijklmnopqrstuvwxyz"
assert len(ABC) == 26

def main():
    s = input()
    t = input()
    ss = sets_of_indices(s)
    tt = sets_of_indices(t)
    print("Yes" if ss == tt else "No")

def sets_of_indices(s):
    di = {c: [] for c in ABC}
    for i, c in enumerate(s):
        di[c].append(i)
    res = {tuple(di[c]) for c in ABC}
    return res

main()


Measured memory_bytes: 21552
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define ll long long int
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};

int main() {
	string a,b,c;
	int num;
	cin>>num>>a>>b>>c;
	int ans=0;
	rep(i,0,num){
		int n=0;
		if(a[i]==b[i]&&a[i]==c[i])n=3;
		else if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i])n=2;
		else n=1;
		ans+=3-n;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int a[7] = {1,3,5,7,8,10,12};
const int b[4] = {4,6,9,11};

bool check(const int *a,int N,int key){
    for(int i=0;i<N;i++){
        if(key==a[i])return true;
    }
    return false;
}

int main(){
    int x,y;
    cin >> x >> y;
    if(x==2&y==2){
        cout << "Yes" << endl;
    }else if(check(&a[0],7,x)&&check(&a[0],7,y)){
        cout << "Yes" << endl;
    }else if(check(&b[0],4,x)&&check(&b[0],4,y)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std ; 
int main()
{
	int num1,num2;
	string col1,col2,name;
	cin>>col1>>col2>>num1>>num2>>name;
	if(name==col1)
	{
		cout<<num1-1<<" "<<num2;
	}
	else
	cout<<num1<<" "<<num2-1;
}

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

using namespace std;
typedef long long int ll;

void solve()
{
	int n;
	cin >> n;
	map <string,int> mp1;
	mp1["AC"] = 0, mp1["RE"] = 0, mp1["TLE"] = 0, mp1["WA"] = 0;
	for(int i = 0; i < n; i++) 
	{
		string s;
		cin >> s;
		mp1[s]++;
	}
	cout << "AC x " << mp1["AC"] << "\n";
	cout << "WA x " << mp1["WA"] << "\n";
	cout << "TLE x " << mp1["TLE"] << "\n";
	cout << "RE x " << mp1["RE"] << "\n";
}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n, done[3000][3000];
double dp[3000][3000], p[3000];

double solve(int i, int j){
  if(i+j == n) return i > j;
  double &r = dp[i][j];
  if(done[i][j]) return r;
  done[i][j] = true;
  r = p[i+j]*solve(i+1,j) + (1-p[i+j])*solve(i,j+1);
  return r;
}

int main(){FIN;
  cin >> n;
  fore(i,0,n) cin >> p[i];
  cout << fixed << setprecision(10) << solve(0,0) << "\n";
}

Measured memory_bytes: 105216
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

struct point{
    double x,y;
    point operator+(point p){
        return point{x+p.x,y+p.y};
    }
    point operator-(point p){
        return point{x-p.x,y-p.y};
    }
    point operator*(double p){
    return point{x*p,y*p};
    }
    point operator/(double p){
        if(!p) return point{0,0}; 
        return point{x/p,y/p};
    }
    bool operator==(point p){
        return fabs(x-p.x)<eps&&fabs(y-p.y)<eps;
    }
};
 
typedef pair<point,point> pp;
typedef vector<point> VP;
const point O{0,0};
 
class Geom{
    public:
    double Length(point x,point y){
        point z=y-x;
        return sqrt(z.x*z.x+z.y*z.y);
    }
    double IP(point p,point q){
        return p.x*q.x+p.y*q.y;
    }
    double CP(point p,point q){
        return p.x*q.y-q.x*p.y;
    }
    string Counter_Clockwise(pp a,point x){
        point A=a.second-a.first;
        point X=x-a.first;
        double ip=IP(A,X),cp=CP(A,X),Al=Length(O,A),Xl=Length(O,X);
        if(cp>eps) return "Counter_Clockwise";
        if(cp<-eps) return "Clockwise";
        if(ip<-eps) return "Online_Back";
        if(Xl<Al||fabs(Xl-Al)<eps) return "On_Segment";
        return "Online_Front";
    }
	double Heron(point A,point B,point C){
		double a=Length(B,C),b=Length(C,A),c=Length(A,B),s=(a+b+c)/2;
		return sqrt(s*(s-a)*(s-b)*(s-c));
	}
	double Area(VP p){
		double sum;
		string s;
		p.push_back(p[0]);
		for(VP::iterator i=p.begin()+1;i!=p.end();i++){
			s=Counter_Clockwise(pp(O,*(i-1)),*i);
			if(s[1]=='o') sum+=Heron(O,*(i-1),*i);
			else if(s[1]=='l') sum-=Heron(O,*(i-1),*i);
		}
		return sum;
	}
    void Point_in(point& p){
        cin>>p.x>>p.y;
    }
};

int N;
VP p;

int main(){
	cout<<syosu(1);
	Geom geo;
	cin>>N;
	p=VP(N);
	for(VP::iterator i=p.begin();i!=p.end();i++) geo.Point_in(*i);
	cout<<geo.Area(p)<<endl;
}

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

int main(){

    int n,h;
    int max;
    int sum = 0;
    vector<int> H_i;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> h;
        H_i.push_back(h);
    }

    // calculate inns
    max = H_i[0];
    sum ++;
    for(int i=1; i<n; i++){
        if(H_i[i] > max){
            sum++;
            max = H_i[i];
        }
        else if(H_i[i] == max){
            sum++;
        }
        
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
def BubbleSort(A, N):
    cnt = 0  # 隣接要素の交換回数
    t = 0
    for i in range(N):   # iは未ソートの部分列の先頭のインデックス
        t = cnt
        for j in range(N-1, i, -1):     # 隣接要素を比較するのは未ソート部分列の末尾から先頭まで
            if A[j-1] > A[j]:           # 隣接要素を比較
                A[j-1], A[j] = A[j], A[j-1]     # 大小関係が逆の場合、交換
                cnt += 1        # 交換回数をカウント
        if t == cnt:
            return A, cnt

N = int(input())
A = list(map(int, input().split()))

ans, cnt = BubbleSort(A,N)
print(*ans)    # リストの中身を値で取り出す
print(cnt)


Measured memory_bytes: 5612
#include<stdio.h>

int main(void){
    char s[3];
    int ans = 0;
    scanf("%s",s);
    char day[7][3] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    int i;
    for(i = 0; i < 7; i++){
        if(s[0] == day[i][0] && s[1] == day[i][1] && s[2] == day[i][2]){
            ans = 7 - i;
        }
    }

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

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main() {
        vector<int> x(3), y(3);
        scanf("%d%d", &x[0], &y[0]);
        scanf("%d%d", &x[1], &y[1]);
        scanf("%d%d", &x[2], &y[2]);
        vector<double> edge;
        edge.push_back(sqrt((double)(pow(x[0] - x[1], 2) + pow(y[0] - y[1], 2))));
        edge.push_back(sqrt((double)(pow(x[1] - x[2], 2) + pow(y[1] - y[2], 2))));
        edge.push_back(sqrt((double)(pow(x[2] - x[0], 2) + pow(y[2] - y[0], 2))));
        sort(edge.rbegin(), edge.rend());
        double a = edge[0], b = edge[1], c = edge[2];
        double s = (a + b + c) / 2;
        double area = sqrt(s * (s - a) * (s - b) * (s - c));
        double R = 2.0 * area / (a + b + c);
        double l = a;
        double ans = l / (l / R + 2.0);
        printf("%.20lf\n", ans);
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S / 3600;
		int m = (S % 3600) / 60;
		int s = ((S % 3600) % 60) / 1;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26072
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    unordered_set <string> se;
    ll n; cin >> n;
    REP(i, n){
        string s; cin >> s;
        se.insert(s);
    }
    ll ans = 0;
    for(auto s: se){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17792
(n, m) = map(int, raw_input().split())

A = []
for i in xrange(0,n):
	line = map(int, raw_input().split())
	A.append(line)

b = []
for j in xrange(0,m):
	temp = int(raw_input())
	b.append(temp)

result = []
for x in xrange(0,n):
	temp = 0
	for y in xrange(0,m):
		temp = temp + A[x][y] * b[y]
	result.append(temp)

for k in xrange(0,n):
	print result[k]

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

using namespace std;

typedef long long int lli;

class cake {
    public:
    lli x, y, z;
};

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

    int n, m;
    lli cake[1001];

    cin >> n >> m;

    class cake c[1001];
    for (int i=1; i<=n; i++) {
        cin >> c[i].x >> c[i].y >> c[i].z;
    }

    lli ans = -1e+15;
    for (int pat = 0; pat<8; pat++) {
        vector<vector<lli>> dp(1001, vector<lli>(1001, 0));
        for (int i=1; i<=n; i++) {
            lli cake = ((pat&0b100)?c[i].x : -c[i].x) + ((pat&0b010)?c[i].y : -c[i].y) + ((pat&0b001)?c[i].z : -c[i].z);
            for (int j=1; j<=m; j++) {
                // if (j > i) continue;
                dp[i][j] = (i-1 < j) ? dp[i-1][j-1]+cake : max(dp[i-1][j-1]+cake, dp[i-1][j]);
            }
        }
        ans = max(ans, dp[n][m]);
    }

    cout << ans << endl;

    return 0;
}


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

/** defines and macros */
#define ll long long
#define ull unsigned long long
#define loop(n) for(int i = 0; i < n; i++)
#define loop1(n) for(int i = 1; i <= n; i++)
#define all(v) (v.begin(), v.end())
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vvi vector<vi>
#define vvpii vector<vii>
#define PB push_back

#define fw(fileName) freopen(fileName, "w", stdout)
#define fr(fileName) freopen(fileName, "r", stdin)
#define fc(stream) fclose(stream);

#define faster_IO_stream ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

/*To compile and run

	g++ -o main main.cpp && ./main

*/

/*
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣤⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣤⣀⡀⠄⠄⠄⠄⠄⣰⣷⡀⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⣀⣀⣀⠄⠄⠄⠄⠄⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠄⠄⢠⣿⣿⣷⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠤⠒⠛⠛⠛⠛⠻⠷⣦⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣿⣿⣿⠟⠁⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢀⣤⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⡤⠐⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⢀⣶⣿⣿⠿⢛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⢠⣿⠟⠉⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠘⠁⠄⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠻⣿⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⣾⣿⡿⣽⡿⢹⣿⣿⣟⣿⢻⠇⢀⢹⣿⢿⣿⣿⣿⣿⣿⣦⣙⢿⣿⢷⣈⠻⢿⣟⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢿⡿⠁⡿⠁⢸⣿⣿⢹⡇⢸⠄⠈⠄⠻⣏⠻⣿⡿⣿⣿⣿⣌⠛⢿⡌⠙⢧⣀⠙⢳⡹⢻⣿⣿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠘⡇⠄⡇⢠⣼⣿⣿⠈⡇⠘⠤⠤⠤⠤⢜⣢⣘⡻⢮⡛⢿⣿⣷⣬⡤⠤⠤⠤⠥⠤⠥⢬⣿⣧⡄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠁⠄⠄⠘⢿⡏⠛⠄⠄⠄⠄⠄⠄⠄⠄⠄⠙⣿⣿⣿⡿⠋⠉⠛⠉⠄⠄⠄⠄⠄⠄⠄⢹⡿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡟⠁⠈⢳⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠱⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⡜⠁⠄⠄⠈⢇⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠑⠦⢄⣀⣀⣀⣀⣀⠴⠊⠄⠄⠄⠄⠄⠄⠑⠤⢀⣀⣀⣀⡀⠠⠔⠋⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣶⣦⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣤⣶⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣶⣄⣀⣀⣀⣀⣤⣾⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⣿⣿⣿⣿⠟⠁⠄⠄⠄⠄⠙⢿⣿⣿⣿⡟⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⠟⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠉⠛⠿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
 */

int main() {
	faster_IO_stream

	int n, x, t;
	cin >> n >> x >> t;

	cout << (ull) (ceil(n / (x * 1.0)) * t) << endl;

	return 0;
}


Measured memory_bytes: 3648
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
            String S = sc.nextLine();
            for (int i = 0; i < S.length(); i++) {
                if (Character.isUpperCase(S.charAt(i))) {
                    System.out.print(Character.toLowerCase(S.charAt(i)));
                } else {
                    System.out.print(Character.toUpperCase(S.charAt(i)));
                }
            }
            System.out.println("");
    }
}


Measured memory_bytes: 26572
#include<iostream>
using namespace std;
int main(){
    char s;
    int i=0,a[127];
    for (int j = 7; j < 123; j++)
        a[j] = 0;
    while (cin >> s){
        if (s < 'a')
            a[s + 32]++;
        else a[s]++;
    }
     
    for (i = 97; i < 123; i++)
        cout  << (char)i << " : " << a[i] << endl;
 
    return 0;
}

Measured memory_bytes: 3076
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

L = [[0 for _ in range(w)] for _ in range(h)]
R = [[0 for _ in range(w)] for _ in range(h)]
D = [[0 for _ in range(w)] for _ in range(h)]
U = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
  for j in range(w):
    if s[i][j] == '.':
      if j == 0:
        L[i][j] = 1
      else:
        L[i][j] = L[i][j-1]+1     
      if i == 0:
        D[i][j] = 1
      else:
        D[i][j] = D[i-1][j]+1
      if i == h-1:
        U[i][j] = 1
      else:
        U[i][j] = U[i+1][j]+1
  for j in range(w-1, -1, -1):
    if s[i][j] == '.':
      if j == w-1:
        R[i][j] = 1
      else:
        R[i][j] = R[i][j+1]+1

for i in range(h-1, -1, -1):
  for j in range(w):
    if s[i][j] == '.':
      if i == h-1:
        U[i][j] = 1
      else:
        U[i][j] = U[i+1][j]+1
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)

print(ans)



Measured memory_bytes: 313096
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};

int a[100005],dp[100005];

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

	int n;
	cin>>n;

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

	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);

	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}

	cout<<dp[n-1];


	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){

    int i,n;

    double x,sum=0;

    scanf("%d",&n);

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

    scanf("%lf",&x);

    sum=sum+(1/x);

    }

    printf("%.5lf",1/sum);

    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Comp {
public:
        const vector<int> &_v;
        Comp(const vector<int> &v): _v(v) {}
        bool operator()(int a, int b) { return _v[a] < _v[b]; }
};

void sort2vectors(vector<int> &a, vector<int> &b)
{
        int n = a.size();
        vector<int> p(n), a2(n), b2(n);
        for (int i = 0; i < n; i++)
                p[i] = i;
        sort(p.begin(), p.end(), Comp(a));
        for (int i = 0; i < n; i++) {
                a2[i] = a[p[i]];
                b2[i] = b[p[i]];
        }
        a = a2;
        b = b2;
}

int main() {
  int N, M;
  vector<int> A(100010, 1000000010), B(100010, 0);
  cin >> N >> M;
  for(int i=0; i < N; i++){
      std::cin >> A[i] >> B[i];
  }
  long answer=0;
  sort2vectors(A, B);
  for(int i=0; M > 0; i++){
      if(M>B[i]){
        answer += (long)A[i] * B[i];
        M = M - B[i];
    }
   else{
        answer += (long)A[i] * M;
        M = 0;
    }
  }
  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def prime(n: Int, primes: Seq[Int]) = primes.forall(p => n % p != 0)

  def solve(sc: Scanner): String = {
    val X = sc.nextInt
    var primes = Seq(2, 3, 5, 7, 11, 13)
    for (i <- 17 to 100003 by 2) {
      if (prime(i, primes)) {
        primes = primes :+ i
      }
    }
    primes.find(_ >= X).head.toString
  }
}


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

const string YES = "Yes";
const string NO = "No";
using ll = long long;

void solve(std::string N){
    string s;cin >> s;
    int digsum = 0;
    for(auto a : N){
        digsum += a - '0';
    }
    if(digsum % 9 == 0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

int main(){
    std::string N;
    std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
#include <cmath>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)


int main(int argc, char *argv[])
{
    int N, M;
    cin >> N >> M;

    // map P -> set(pair<year, index>)
    vector<set<pair<int, int>>> m(N+1);

    // calc order in each P
    Rep(i, M) {
        int p, y;
        cin >> p >> y;
        m[p].insert(make_pair(y, i));
    }

    // map<set<year, index>> to vector<pair<P, index in the P>>
    vector<pair<int, int>> v(M);
    Rep(i, N+1) {
        int p = i;
        auto s = m[p];
        int idx = 1;
        for (auto it=s.cbegin(); it!=s.cend(); ++it) {
            v[it->second] = make_pair(p, idx++);
        }
    }

    // output
    for (auto x : v) {
        printf("%06d%06d\n", x.first, x.second);
    }


    return 0;
}

Measured memory_bytes: 16384
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 2e5+5;
vector<vector<ll>> G(MAX);
template <typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid,Monoid) >;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M;

  SegmentTree(int n,const F f,const Monoid &M) : f(f),M(M){
    sz = 1;
    while(sz<n) sz<<=1;
    seg.assign(sz*2,M);
  }
  void set(int k,const Monoid &v){
    seg[k+sz] = v;
  }
  void build(){
    for(int k=sz-1;k>0;k--){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  void update(int k,const Monoid &v){
    k += sz;
    seg[k] = v;
    while(k >>= 1){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  Monoid que(int a,int b){
    Monoid L=M,R=M;
    for(a+=sz, b+=sz;a<b;a>>=1,b>>=1){
      if(a&1) L = f(L,seg[a++]);
      if(b&1) R = f(seg[--b],R);
    }
    return f(L,R);
  }
  Monoid operator[](const int &k) const{
    return seg[k+sz];
  }
};
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  for(int i=0;i<n-1;i++){
    ll u,v;
    cin >> u >> v;
    if(u>v) swap(u,v);
    ans += (i+1)*(n-i);
    ans -= u*(n-v+1);
  }
  ans += n;
  cout << ans << endl;
}


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

int main(){
	string s, t;
	cin>>s>>t;
	int m=s.size();
	int n=t.size();
	int dp[m+1][n+1];
	for(int i=0;i<=m;i++)
		dp[i][0]=0;
	for(int i=0;i<=n;i++)
		dp[0][i]=0;

	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(s[i-1] == t[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int i=m;
	int j=n;
	string ans="";
	while(i>0 && j>0){
		if(s[i-1] == t[j-1]){
			ans+=s[i-1];
			i--;
			j--;
		}
		else if(dp[i][j-1] > dp[i-1][j])
			j--;
		else
			i--;
	}
	reverse(ans.begin(), ans.end());
	cout<<ans;
	return 0;
}

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


int main(){
  int N, M, X;
  cin >> N >> M >> X;
  set<int> A;
  for(int i = 0; i < M; i++){
    int a;
    cin >> a;
    A.insert(a);
  }
  int upcost = 0;
  int downcost = 0;

  int me = X;
  while(me > 0){
    if(A.count(me)) downcost++;
    me--;
  }

  me = X;
  while(me < N){
    if(A.count(me)) upcost++;
    me++;
  }

  cout << min(upcost, downcost) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <string.h>

int main(void){
  
  int a,b,c;
  
  scanf("%d %d %d", &a, &b, &c);
  //scanf("%d %d", &h, &w);
  
  if(b/a>c) printf("%d", c);
  else printf("%d", b/a);

  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
	int sy, sx, gy, gx;
	cin >> sy >> sx >> gy >> gx;
	--sy, --sx, --gy, --gx;
	vector<string> S(h);
    rep(i,h) cin >> S[i];
    vector<vector<int>> dist(h, vector<int>(w, INF));
    vector<int> vy{ 0, 0, -1, +1 };
    vector<int> vx{ -1, +1, 0, 0 };
    deque<P> q;
    dist[sy][sx] = 0;
    q.emplace_back(sy, sx);
    while (!q.empty()) {
        int y = q.front().first;
        int x = q.front().second;
        int d = dist[y][x];
        q.pop_front();
        rep(v,4) {
            int ny = y + vy[v], nx = x + vx[v];
            if (ny<0 || ny>=h || nx<0 || nx>=w) continue;
            if (S[ny][nx]=='#') continue;
            if (dist[ny][nx]<=d) continue;
            dist[ny][nx] = d;
            q.emplace_front(ny,nx);
        }
        rep(i,5) rep(j,5) {
            int ny = y + i - 2, nx = x + j - 2;
            if (ny<0 || ny>=h || nx<0 || nx>=w) continue;
            if (S[ny][nx]=='#') continue;
            if (dist[ny][nx]<=d+1) continue;
            dist[ny][nx] = d+1;
            q.emplace_back(ny,nx);
        }
    }
    int ans = dist[gy][gx];
    if (ans==INF) ans = -1;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 8756
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll l,r;
    cin>>l>>r;
    r=min(r,l+4037);
    ll m=2018;
    for(ll i=l;i<r;i++){
        for(ll j=i+1;j<=r;j++) m=min(m,(i%2019)*(j%2019)%2019);
    }
    cout<<m<<endl;
    return 0;
}

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

void solve(long long N)
{
    cout << (N % 2 == 0 ? N : 2 * N) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, p[5001], cnt, res, q[5001];

int main() {
	cin >> N;
	res = intmax;
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
		q[i] = p[i];
	}
	for (int i = 0; i <= p[0]; ++i) {
		cnt = 0;
		cnt += i;
		p[0] -= i;
		for (int j = 0; j < 5000; ++j) {
			p[j] = max(p[j], 0);
			if (j != N - 1) {
				cnt += p[j];
			}
			cnt += p[j];
			p[j + 1] -= p[j];
		}
		res = min(res, cnt);
		for (int j = 0; j < 5000; ++j) {
			p[j] = q[j];
		}
	}
	cout << res << endl;
}


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

typedef long long ll;

int main() {
	// string s;
	// cin >> s;
	// if (s[(int)s.size()-1] != 's') {
		// cout << s << 's';
	// } else {
		// cout << s <<  "es";
	// }
	// int N;
	// cin >> N;
	// vector< bool > v(N);
	// for(int i=0; i<N; i++) {
		// int x,y;
		// cin >> x >> y;
		// v[i] = (x == y);
		
	// }
	// bool y = 0;
	// for (int i=2; i<N; i++) {
		// bool yy = 1;
		// for (int j=i-2; j<=i; j++) {
			// yy &= v[j];
		// }
		// y |= yy;
	// }
	// cout << (y ? "Yes" : "No");
	int N;
	cin >> N;
	ll ans = 0;
	for (int i=1; i<N; i++) {
		for (int j=1; i*j<N && j<N; j++) {
			ans ++;
		}
	}
	cout << ans;
	return 0;
	
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1e9;
const int mod = 1000000007;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  cout<<s[0]<<n-2<<s[n-1]<<endl;
  return 0;                       
}

Measured memory_bytes: 3604
array_count = gets(chomp:true).to_i
nums = gets.split.map(&:to_i)

flag = 1
count = 0

while flag == 1
  flag = 0
  
  ( array_count - 1 ).downto( 1 ) do | j |
    
    if nums[ j ] < nums[ j - 1 ]
      
      tmp = nums[ j ]
      
      nums[ j ] = nums[ j - 1 ]
      
      nums[ j - 1 ] = tmp
      
			flag = 1
			count += 1
    end
    
  end
  
end

puts nums.join(" ")
puts count


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int c = 0, d = 0;
   for (int i = 0; i < N; i++) {
     if (c > 0 && S.at(i) != 'A' && S.at(i) != 'C' &&
         S.at(i) != 'G' && S.at(i) != 'T')
       d = 0;
     else if (S.at(i) == 'A' || S.at(i) == 'C' ||
         S.at(i) == 'G' || S.at(i) == 'T') {
       d ++;
       if (d >= c)
         c = d;
     }     
   }
  cout << c << endl;
}

Measured memory_bytes: 3592
class Card
	attr_accessor :suit, :value
	
	def initialize(str)
		@suit = str[0]
		@value = str[1].to_i
	end

	def to_s
		"#@suit#@value"
	end

	def self.bubble_sort(c)
		c = c.dup
		n = c.size
		0.upto(n-1){|i|
			(n-1).downto(i+1){|j|
				if c[j].value < c[j-1].value
					c[j], c[j-1] = c[j-1], c[j]
				end
			}
		}
		c
	end

	def self.selection_sort(c)
		c = c.dup
		n = c.size
		0.upto(n-1){|i|
			minj = i
			i.upto(n-1){|j|
				if c[j].value < c[minj].value
					minj = j
				end
			}
			c[i], c[minj] = c[minj], c[i]
		}
		c
	end
end

gets
cards = gets.split.map{|s| Card.new s }

cards1 = Card.bubble_sort(cards)
cards2 = Card.selection_sort(cards)

puts cards1*' '
puts 'Stable'
puts cards2*' '
puts cards1 == cards2 ? 'Stable' : 'Not stable'

Measured memory_bytes: 8696
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};


Node *NIL, *root;

void insert(int k) { //insert k
    Node *y = NIL;
    Node *x = root;

    Node *z = (Node *) malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while ( x!= NIL ) {
        y = x;
        if ( z->key < x->key ) {
            x = x->left;
        } else {
            x = x-> right;
        }
    }

    z->parent = y;

    if(y == NIL) {
        root = z;
    }else if(z->key < y->key) {
        y->left = z;
    }else {
        y->right = z;
    }
}

void inOrder(Node *u) {
    if( u == NIL ) return;
    inOrder(u->left);
    printf(" %d",u->key);
    inOrder(u->right);
}

void preOrder(Node *u) {
    if( u == NIL ) return;
    printf(" %d", u->key);
    preOrder(u->left);
    preOrder(u->right);
}

Node *find(Node *u, int k) {
    while (u!= NIL && k != u->key) {
        if ( k < u->key ) {
            u = u->left;
        }else {
            u = u->right;
        }
    }
    return u;
}

int main(void) {
    int k,n,i;
    Node *a;
    string com;
    scanf("%d", &n);
    for (i = 0 ; i < n ; i++ ) {
        cin >> com;
        if ( com == "insert") {
            scanf("%d", &k);

            insert(k);
        }else if (com == "print") {
            inOrder(root);
            printf("\n");
            preOrder(root);
            printf("\n");
        }else if (com == "find") {
            scanf("%d", &k);
            a = find(root, k);
            if (a != NIL) printf("%s","yes\n");
            else printf("%s","no\n");
        }
    }
    return 0;
}

Measured memory_bytes: 22032
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  string s;
  cin>>s;
  int n = s.size();
  map<char, int> mp;
  REP(i,n){
    mp[s[i]]++;
  }
  bool flag = true;
  if(mp['N'] > 0 && mp['S'] == 0){
    flag = false;
  }else if(mp['N'] == 0 && mp['S'] > 0){
    flag = false;
  }else if(mp['W'] > 0 && mp['E'] == 0){
    flag = false;
  }else if(mp['W'] == 0 && mp['E'] > 0){
    flag = false;
  }else{
    ;
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int a,b;
	cin>>a>>b;
	
	REP(i,1400){
		int tmp=i*0.08;
		int tmpp=i*0.1;
		if(tmp==a and tmpp==b){
			cout<<i<<endl;
			return 0;
		}
	}
	
	cout<<-1<<endl;
}

Measured memory_bytes: 256