akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
typedef long long ll;
ll n, a[N], pre[N], t[5], ans = 1e9;

ll iabs(ll a) {return a > 0 ? a : -a;}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], pre[i] = pre[i - 1] + a[i];
    int l = 1, r = 3;
    for (int i = 2; i < n - 1; i++) {
        while (l < i && iabs(pre[l] - pre[0] - (pre[i] - pre[l])) >= iabs(pre[l + 1] - pre[0] - (pre[i] - pre[l + 1])))
            l++;
        while (r < n && iabs(pre[r] - pre[i] - (pre[n] - pre[r])) >= iabs(pre[r + 1] - pre[i] - (pre[n] - pre[r + 1])))
            r++;
        t[1] = pre[l] - pre[0];
        t[2] = pre[i] - pre[l];
        t[3] = pre[r] - pre[i];
        t[4] = pre[n] - pre[r];
        ans = min(ans, max(t[1], max(t[2], max(t[3], t[4]))) - min(t[1], min(t[2], min(t[3], t[4]))));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll n, k, digit=1;
    cin >> n >> k;
    ll lim = k;
    while(lim<=n){
        digit++;
        lim *= k;
    }
    cout << digit << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(void){
    long long N,A,B;
    cin >> N >> A >> B;
    long long cost = 0;
    int x1,x2;
    cin >> x2;
    for(int i=0;i<N-1;i++){
        x1 = x2;
        cin >> x2;
        cost += ((x2-x1)*A < B ? (x2-x1)*A : B);
    }
cout << cost;
return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    string S;
    cin >> S;
    i64 N = S.size(), K;
    cin >> K;
    string T = S + S + "$";
    i64 A = 0, B = 0, ans = 0;
    for(int i = 1; i < 2 * N; i++) {
        if(T[i - 1] == T[i]) {
            T[i] = '$';
            if(i < N) {
                A++;
            } else {
                B++;
            }
        }
    }
    if(T[N] == '$') {
        if(T[2 * N - 1] == '$') {
            ans = (A + B) * (K / 2) + A * (K % 2);
        } else {
            ans = A + B * (K - 1);
        }
    } else {
        ans = A * K;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
input = input().split()

intInput = [int(i) for i in input]

result = 0

#満足してしまうとき
if(intInput[0]*intInput[2] <= intInput[1]):
	print(intInput[2])
#一回も聞けないとき
elif(intInput[0]>intInput[1]):
	print(0)
#満足できないとき
else:
	for i in range(intInput[2]):
		result = result + intInput[0]
		if(intInput[1] - result < intInput[0]):
			print(i+1)
			break

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

using namespace std;

int main()
{
    int N, L;

    cin >> N >> L;

    vector<string> S;

    int i;

    for(i=0; i<N+1; i++){
        string s;
        getline(cin, s);
        S.push_back(s);
    }

    sort(S.begin(), S.end());

    for(i=0; i<N+1; i++){
        cout << S[i];
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    int K; cin>>K;
    int current = 7;
    for(int i=1; i<=1000001; ++i){
        if(current%K==0){
            cout<<i<<endl;
            return 0;
        }
        current = ((current*10)+7)%K;
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 3652
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
vvv = na()
even = vvv[::2]
odd = vvv[1::2]
d_even = {}
d_odd = {}
for i in range(n//2):
    if even[i] not in d_even.keys():
        d_even[even[i]] = 1
    else:
        d_even[even[i]] += 1

    if odd[i] not in d_odd.keys():
        d_odd[odd[i]] = 1
    else:
        d_odd[odd[i]] += 1

e_max = max(d_even, key=d_even.get)
o_max = max(d_odd, key=d_odd.get)
e1 = d_even[e_max]
o1 = d_odd[o_max]

if e_max == o_max:
    d_even[e_max] = 0
    d_odd[o_max] = 0

    e2 = max(d_even.values())
    o2 = max(d_odd.values())

    ans = n - max(e1 + o2, e2 + o1)

else:
    ans = n - e1 - o1

print(ans)


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

int main() {
  string S;
  cin >> S;
  vector<int> az(26);
  for (int i = 0; i < S.size(); ++i) {
    ++az.at(S.at(i) - 'a');
  }
  string ans = "None";
  for (int i = 0; i < 26; ++i) {
    if (az.at(i) == 0) {
      ans = i + 'a';
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
import * as fs from 'fs';

namespace AtCoder.abc109 {
    class ProgramA {
        // in
        //  3 1
        // out
        //  Yes
        main(inp: string) {

            const [a, b]: number[] = inp.split(' ').map(Number);
            const ab: number = a * b;

            for (let c = 1; c < 4; c++) {
                if ((ab * c) % 2 === 1) {
                    console.log('Yes');
                    return;
                }
            }
            console.log('No');
        }
    }

    const func = new ProgramA();
    func.main(fs.readFileSync('/dev/stdin', 'utf8').trim());


}

Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int a, b, c, n;
	cin >> n;
	for (int i = 0; i<=3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			a = n*i*j;
			b = 4*i*j - n*i - n*j;
			if (b > 0&&a%b==0) {
				cout << i << " " << j << " " << a / b << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
s = input()
n = len(s)
xy = list(map(int, input().split()))

right = 0
updown = []
rightleft = []

direction = 0
for i in range(n):
    if s[i]=='F':
        if direction == 0:
            right+=1
        elif direction == 1:
            updown[-1]+=1
        else:
            rightleft[-1]+=1
    else:
        if direction == 0 or direction == 2:
            direction = 1
            updown.append(0)
        else:
            direction = 2
            rightleft.append(0)

updown = [x for x in updown if x!=0]
rightleft = [x for x in rightleft if x!=0]

# 最初はx方向にしか進めないので補正
xy[0]-=right

# updownでyに行けるか？rightleftでxに行けるかを考えれば良い
dpy = [set() for i in range(len(updown)+1)]
dpy[0].add(0)
for i in range(len(updown)):
    for y in dpy[i]:
        dpy[i+1].add(y+updown[i])
        dpy[i+1].add(y-updown[i])

dpx = [set() for i in range(len(rightleft)+1)]
dpx[0].add(0)
for i in range(len(rightleft)):
    for x in dpx[i]:
        dpx[i+1].add(x+rightleft[i])
        dpx[i+1].add(x-rightleft[i])

if xy[1] in dpy[-1] and xy[0] in dpx[-1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 260872
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	long long  a,b,sum=0,x,y;
	cin>>a>>b;
	for(int i=0;i<a;i++)
	{
		cin>>x>>y;
		if(x*x+y*y<=b*b)
		  sum++;
	}
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 3576
use proconio::input;

fn main() {
    input! {
        x: i64,
    }

    let mut value: i64 = 100;
    let mut tmp_year = 0;
    loop {
        if value >= x {
           break;
        }

        value = ((value as f64) * 1.01) as i64;
        tmp_year += 1;
    };

    println!("{}", tmp_year);
}


Measured memory_bytes: 2172
//  main.cpp
//  CppTest

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

int main(int argc, const char * argv[]) {
    
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int A,B,N=0;
    cin>>A>>B;
    for(int i=A;i<B+1;i++){
        if(i/10000==i%10 && i%10000/1000==i%100/10){
            N++;
        }
    }
    cout<<N<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

# レベルnバーガー
def dfs(k):
    global count, ans
    # バン
    count += 1
    if k == 0:
        ans += 1
    elif count < x:
        # レベルn-1バーガー
        if count + b[k-1] > x:
            dfs(k-1)
        else:
            count += b[k-1]
            ans += p[k-1]
        if count < x:
            # パティ
            count += 1
            ans += 1
            if count < x:
                # レベルn-1バーガー
                if count + b[k-1] > x:
                    dfs(k-1)
                else:
                    count += b[k-1]
                    ans += p[k-1]

n, x = MAP()
b = [0]*n
p = [0]*n
b[0] = 1
p[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*2 + 3
    p[i] = p[i-1]*2 + 1

count = 0
ans = 0
dfs(n)
print(ans)

Measured memory_bytes: 10308
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
struct K{
	ll a,b,c;
	bool jud;
};
ll a,b,c,n;
K res[1000];
bool isok[301];
bool isbad[301];

int main()
{while(1241){
	cin>>a>>b>>c;
	if(!a) return 0;
	cin>>n;
	memset(isok,0,sizeof(isok));
	memset(isbad,0,sizeof(isbad));
	for(ll i=0;i<n;i++){
		cin>>res[i].a>>res[i].b>>res[i].c>>res[i].jud;
		if(res[i].jud) isok[res[i].a]=isok[res[i].b]=isok[res[i].c]=1;
	}
	for(ll i=0;i<n;i++){
		if(!res[i].jud){
			if(isok[res[i].a]&&isok[res[i].b]&&!isok[res[i].c]) isbad[res[i].c]=1;
			if(!isok[res[i].a]&&isok[res[i].b]&&isok[res[i].c]) isbad[res[i].a]=1;
			if(isok[res[i].a]&&!isok[res[i].b]&&isok[res[i].c]) isbad[res[i].b]=1;
		}
	}
	for(ll i=1;i<=a+b+c;i++){
		if(isbad[i]) puts("0");
		else if(isok[i]) puts("1");
		else puts("2");
	}
}}

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

int main()
{

int k;
cin>>k;

int a,b;
cin>>a>>b;

for(int index = a ;index<=b;index++)
if(index%k==0)
{
    cout<<"OK"<<endl;
    return 0;
}
 cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

int main() {
	int n;
	cin >> n;
	bool ans = true;
	rep(i, n) {
	  int a;
		cin >> a;
		if (a % 2 == 0) {
			if (!(a % 3 == 0 || a%5 == 0)) ans = false;
		}
	}

	if(ans) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;

	return 0;
}




Measured memory_bytes: 256
N=int(input())
P=[1]+list(map(int,input().split()))

ans=0
for i in range(1,N+1):
    if P[i]==i:
        if (i<N and i+1==P[i+1]) or i==1:
            P[i+1],P[i]=P[i],P[i+1]
            ans+=1
        else:
            P[i-1],P[i]=P[i],P[i-1]
            ans+=1
print(ans)

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

#define int long long

signed main() {
	int n;
	while ( cin >> n, n ) {
		bool used[21][21] = {{0}};
		for ( int i = 0; i < n; i++ ) {
			int x, y;
			cin >> x >> y;
			used[y][x] = 1;
		}

		int m;
		cin >> m;
		int nx = 10, ny = 10;
		used[ny][nx] = 0;
		for ( int i = 0; i < m; i++ ) {
			char c;
			int d;
			cin >> c >> d;
			if ( c == 'N' ) {
				for ( int i = 0; i < d; i++ ) {
					used[++ny][nx] = 0;
				}
			}
			if ( c == 'E' ) {
				for ( int i = 0; i < d; i++ ) {
					used[ny][++nx] = 0;
				}
			}
			if ( c == 'S' ) {
				for ( int i = 0; i < d; i++ ) {
					used[--ny][nx] = 0;
				}
			}
			if ( c == 'W' ) {
				for ( int i = 0; i < d; i++ ) {
					used[ny][--nx] = 0;
				}
			}			
		}
		int cnt = 0;
		for ( int i = 0; i < 21; i++ ) {
			for ( int j = 0; j < 21; j++ ) cnt += used[i][j];
		}

		if ( cnt ) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    string s, t; cin >> s >> t;

    ll ans = t.size();
    
    zep(i, 0, s.size() - t.size() + 1){
        ll cnt = 0;
        zep(j, 0, t.size()){
            if(s[i + j] != t[j])cnt++;
        }
        ans = min(ans, cnt);
    }
    print(ans)
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int M, N;
  cin >> M >> N;
  // M - cat N - room
  static double pos[16][17];
  REP(i, M) REP(j, N) cin >> pos[i][j];

  static double dp[1 << 16][17];
  REP(S, 1 << M) REP(u, N + 1) dp[S][N] = (u == N) ? 1.0 : 0.0;

  for(int u = N - 1; u >= 0; u--){
    for(int S = 0; S < 1 << M; S++){
      for(int i = 0; i < M; i++) if(S >> i & 1){
        double p = 1.0;
        double npos = 0.0;
        for(int v = u; v <= N; v++){
          npos += dp[S & ~(1 << i)][v] * p * (1.0 - pos[i][v]);
          p *= pos[i][v];
        }
        dp[S][u] = max(dp[S][u], npos);
      }
    }
  }

  printf("%.12f\n", dp[(1 << M) - 1][0]);
  return 0;
}

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

#define COUNTOF(ARR) (sizeof(ARR) / sizeof((ARR)[0]))

int main()
{
  int s[3] = {0};
  string input;
  cin >> input;
  
  for(int i = 0; i < strlen(input.c_str()); i++)
  {
    s[i] = stoi(input.substr(i,1));
      
    if(s[i] != 0 && s[i] != 1) 
    {
      cout << "s(each input number) must be 0 or 1.";
	  exit(1);
  	}
  }
  
  int sum = 0;
  for(int i = 0; i < COUNTOF(s); i++)
  {
    sum += s[i];
  }

  cout << sum << endl;
}

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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var counter = 0;
            for (int i = 0; i < input.Length; i++)
            {
                counter = counter + int.Parse(input[i].ToString());
            }

            if (int.Parse(input) % counter == 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


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

int main(void){
	
	int n,m,c,sum,count;
	int b[1000],a[101][101];
	count=0;
	
	
	scanf("%d%d%d",&n,&m,&c);
	
	for(int i=0;i<m;i++){
		scanf("%d",&(b[i]));
		}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			scanf("%d",&(a[i][j]));
		}
	}
	
	for(int i=0;i<n;i++){
		
		sum=0;
		
		for(int j=0;j<m;j++){
			sum=sum+a[i][j]*b[j];
		}
		
		if(sum+c>0){
			count++;
		}
	}
	
	printf("%d\n",count);
	
	return 0;
}
	

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1000000007;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	cout << (a[0]*a[1])/2 << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
vector<bool> v(100001,false);
vector<int> c(100001,0);
int main()
{
  int n,m;
  cin>>n>>m;
  int a1=0,a2=0;
  while(m--)
  {
    int p;
    string s;
    cin>>p>>s;
    if(v[p-1]==false)
    {
      if(s=="AC")
        v[p-1]=true,a2+=c[p-1],a1++;
      else
        c[p-1]++;
    }
    
      
  }
  cout<<a1<<" "<<a2<<"\n";
  
  return 0;
}


Measured memory_bytes: 640
<?php
 $a = Array();
 $input = fscanf(STDIN,"%d %d %d",$a[0],$a[1],$a[2]);
 sort($a);
 $cost = 0;
 $cost += abs(($a[0] - $a[1]));
 $cost += abs(($a[1] - $a[2]));
 echo $cost;
?>

Measured memory_bytes: 3576
import math
x = int(input())
i = 0
while True:
  if (i**5 <= x):
    s = (x-i**5)**0.2
    s = math.floor(s*(10**7))/(10**7)
  t = (x+i**5)**0.2
  t = math.floor(t*(10**7))/(10**7)
  if s.is_integer() and i**5 <= x:
    print(int(s),-i)
    break
  elif t.is_integer():
    print(int(t), i)
    break
  i += 1

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

int H,W;
string s[500];
int mini[500][500];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void compute() {
  rep(i,H) rep(j,W) mini[i][j] = INT_MAX;
  mini[0][0] = 0;
  deque<int> deq;
  deq.push_back(0);
  while( !deq.empty() ) {
    int cur = deq.front(); deq.pop_front();
    int x = cur % W, y = cur / W;
    rep(i,4) {
      int nx = x + dx[i], ny = y + dy[i];
      if( !( 0 <= nx && nx < W && 0 <= ny && ny < H ) ) continue;
      if( s[ny][nx] == '#' ) continue;
      if( mini[ny][nx] > mini[y][x] + 1 ) {
	mini[ny][nx] = mini[y][x] + 1;
	deq.push_back(nx+ny*W);
      }
    }
  }
  int ans = 0;
  rep(i,H) rep(j,W) ans += ( s[i][j] == '.' );
  if( mini[H-1][W-1] == INT_MAX ) puts("-1");
  else cout << ans - mini[H-1][W-1] - 1 << endl;
}

int main() {
  cin >> H >> W;
  rep(i,H) cin >> s[i];
  compute();
  return 0;
}


Measured memory_bytes: 384
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<int> H(N); cin >> H;
    vector<int> check(N,1);
    for (int i=0;i<M;++i){
        int A,B; cin >> A >> B; --A,--B;
        if (H[A]<=H[B]) check[A]=0;
        if (H[B]<=H[A]) check[B]=0;
    }
    int ans=accumulate(check.begin(),check.end(),0);
    cout << ans << '\n';
}


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using ll = long long;


int main() {
	int n; std::cin >> n;
	std::string s; std::cin >> s;
	std::vector<std::vector<ll>> cnt(3, std::vector<ll>(n + 2));
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < 3; j++) {
			cnt[j][i] += cnt[j][i + 1];
		}
		if (s[i] == 'R') cnt[0][i]++;
		if (s[i] == 'G') cnt[1][i]++;
		if (s[i] == 'B') cnt[2][i]++;
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j]) continue;
			int a = s[i] == 'R' ? 0 : s[i] == 'G' ? 1 : 2;
			int b = s[j] == 'R' ? 0 : s[j] == 'G' ? 1 : 2;
			int c = 0 ^ 1 ^ 2 ^ a ^ b;
			ans += cnt[c][j + 1];
			if (2 * j - i < n && s[2 * j - i] != s[i] && s[2 * j - i] != s[j]) ans--;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,n) for(int i=l; i<n; ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using mii = map<int,int>;
using pii = pair<int,int>;
using vpii = vector<pair<int,int>>;
using ti3 = tuple<int,int,int>;

int main(){
  string s; cin>>s;
  int max_cnt=0;
  REP(i,s.size()){
    FOR(j,i,s.size()){
      if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T'){
        max_cnt=max(max_cnt,j-i+1);
      } else break;
    }
  }  
  cout<<max_cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using cpx = complex<double>;
using namespace std::literals;
using Int = long long;
using Double = long double;
#ifdef __GNUG__
#define _GLIBCXX_DEBUG
#endif
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define perm(c)   \
    sort(ALL(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}
template <typename T>
void Puts(T x) {
    cout << x << endl;
}
void setPrecision(int num = 20) {
    std::cout << std::fixed << std::setprecision(num);
}
template <typename T>
T Max(T a) {
    return a;
}
template <typename T, typename... Args>
T Max(T a, Args... args) {
    return std::max(Max(args...), a);
}
template <typename T>
T Min(T a) {
    return a;
}
template <typename T, typename... Args>
T Min(T a, Args... args) {
    return std::min(Min(args...), a);
}
template <typename T>
bool vector_contains(std::vector<T> vec, T value) {
    return (std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value)) != vec.size());
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
int main() {
    int n;
    cin >> n;
    auto v = vector<pair<Int, Int>>(0);
    rep(i, n) {
        Int a, b;
        cin >> a >> b;
        v.PB(MP(a, b));
    }
    sort(ALL(v), [](const auto &t1, const auto &t2) {
        return (t1.F + t1.S) > (t2.F + t2.S);
    });
    Int ans = 0;
    rep(i, n) {
        if (i % 2 == 0) {
            ans += v[i].F;
        } else {
            ans -= v[i].S;
        }
    }
    Puts(ans);
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, q, k;
string s, t, s0,s1,s2;



// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c;
	cin>>a>>b>>c;

	ll mod = c % b;
	map<ll,ll> val;

	for(ll i=1;i<=100;i++) {
		if(a*i % b == mod) {
			cout<<"YES\n";
			return;
		}
	}
	cout<<"NO\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define dint __int128
#define ll long long
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define upf(i,a,b) for(int i=a;i<b;++i)
#define fdn(i,a,b) for(int i=a;i>=b;++i)
#define dnf(i,a,b) for(int i=a;i>b;++i)
#define hh putchar(10)
#define kg putchar(32)
inline ll read(){ll x,f=1;char a;while((a=getchar())<48||a>57)if(a=='-')f=-1;
for(x=a^48;(a=getchar())>47&&a<58;x=(x<<3)+(x<<1)+(a^48));return f*x;}

void Main()
{
    int a,b;
    double t;
    cin>>a>>b>>t;
    cout<<((int)(t+0.5))/a*b;
}
int main()
{
    Main();
    return 0;
}


Measured memory_bytes: 256
def modinv(a, mod):
    b = mod
    u = 1
    v = 0
    while(b):
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u

    u %= mod
    return u


def modcmb(n, r, mod):
    X = 1
    for i in range(n-r+1, n+1):
        X = X * i % mod

    Y = 1
    for i in range(1, r+1):
        Y = Y * i % mod
        
    res = X * modinv(Y, mod) % mod
    return res


n, a, b = map(int, input().split())
mod = 10**9 + 7

print((pow(2, n, mod) - 1 - modcmb(n, a, mod) - modcmb(n, b, mod)) % mod)

Measured memory_bytes: 3064
import collections
N = int(input())
a = collections.Counter(list(map(int,input().split())))
p = sorted([i for i in a.items() if i[1]>=2])
if len(p)<2:
    print(0)
elif p[-1][1]>=4:
    print(p[-1][0]**2)
else:
    print(p[-1][0]*p[-2][0])

Measured memory_bytes: 22132
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n,m; cin>>n>>m;
    vector<vector<int>> to(n);

    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    vector<int> pre(n, -1);
    queue<int> q;

    pre[0] = 0;
    q.push(0);

    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (int nv : to[v]) {
            if (pre[nv] != -1) continue;
            pre[nv] = v + 1;
            q.push(nv);
        }
    }

    cout << "Yes" << endl;
    for (int j = 1; j < n; ++j) {
        cout << pre[j] << endl;
    }
    return 0;
}


Measured memory_bytes: 10128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
namespace AtCoder_Beginner_Contest_13
{
    class Program
    {
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var cnt = 0;
            for (var i = 1; i <= N; ++i)
            {
                if (i / 10 == 0)
                {
                    ++cnt;
                    continue;
                }
                if (i / 1000 == 0 && i / 100 != 0)
                {
                    ++cnt;
                    continue;
                }
                if (i / 100000 == 0 && i / 10000 != 0)
                {
                    ++cnt;
                    continue;
                }
            }
            WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13396
using System;

class Program
{
    static void Main()
    {
            int i;
            string inp = Console.ReadLine();
            int n = int.Parse(inp);
            for (i = 3; i <= n; i++)
            {
                if (i % 3 == 0)
                {
                    Console.Write(" {0}", i);
                }
                else if (i % 10 == 3)
                {
                    Console.Write(" {0}", i);
                }
                else if (i %100/ 10 == 3)
                {
                    Console.Write(" {0}", i);
                }
                else if (i % 1000 / 100 == 3)
                {
                    Console.Write(" {0}", i);
                }
                else if (i % 10000 / 1000 == 3)
                {
                    Console.Write(" {0}", i);
                }
            }
            Console.Write("\n");
    }
}


Measured memory_bytes: 9324
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List <Long> a = new ArrayList<>();
        for(int i = 0;i < n;i++){
            a.add(sc.nextLong());
        }
        List <Long> sum = new ArrayList<>();
        sum.add(a.get(0));
        for(int i = 1;i < n;i++){
            sum.add(sum.get(i-1) + a.get(i));
        }
        long min = Long.MAX_VALUE;
        for(int i = 0;i < n-1;i++){
            long x = sum.get(i);
            long y = sum.get(n-1) - x;
            long abs = Math.abs(x-y);
            min = Math.min(min,abs);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 90008
#include<stdio.h>
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int a[n],j;
a[0]=1;
a[1]=1; 
for(j=2;j<=n;j++)
a[j]=a[j-1]+a[j-2];
printf("%d\n",a[n]);
}
return 0;
}


Measured memory_bytes: 2104
#include <iostream>

using namespace std;

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

const int N = (int)1e6;

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a, a+n);
  
  int p = 0, b[N+1];
  rep(i,N+1) b[i] = 0;
  rep(i,n) b[a[i]] += 1;
  rep(i,n) {
    if(p == a[i]) continue;
    p = a[i];
    rep(j,N-1) {
      int k = (j+2) * a[i];
      if(k > N) break;
      b[k] += 1;
    }
  }
  
  int s = 0;
  rep(i,n) if(b[a[i]] == 1) s += 1;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 7800
// https://atcoder.jp/contests/abc073/tasks/abc073_d

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;


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

	vector<int> travel_locations(r);
	for (int i = 0; i < r; i++) {
		cin >> travel_locations[i];
		travel_locations[i]--;
	}

	vector<vector<long long>> costs(n, vector<long long>(n, numeric_limits<long long>::max()));
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		costs[a][b] = c;
		costs[b][a] = c;
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (costs[i][k] == numeric_limits<long long>::max() || costs[k][j] == numeric_limits<long long>::max()) {
					continue;
				}
				costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
			}
		}
	}

	long long min_cost = numeric_limits<long long>::max();
	sort(travel_locations.begin(), travel_locations.end());
	do {
		long long cost = 0;
		for (int i = 0; i < travel_locations.size() - 1; i++) {
			cost += costs[travel_locations[i]][travel_locations[i + 1]];
		}
		min_cost = min(min_cost, cost);
	} while (next_permutation(travel_locations.begin(), travel_locations.end()));

	cout << min_cost << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));

typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    int ans=pow(3,n);
    int m=0;
    rep(i,n){
        if(a[i]%2==0)m++;
    }
    std::cout << ans-pow(2,m) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

int n;
string s;
const int bm = 3005;
int dp[bm][bm];
int ss[bm][bm];

void upd(int &x)
{
    x %= mod;
    x += mod;
    x %= mod;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> s;
    fin(x, bm) { dp[n-1][x] = 1; ss[n-1][x] = x+1; }
    ford(i, n-1) {
        int autour = n-i-1;
        fin(bas, autour+1) {
            dp[i][bas] = 0;
            if (s[i] == '<') { dp[i][bas] += (ss[i+1][autour-1] - (bas == 0? 0:ss[i+1][bas-1])); upd(dp[i][bas]); }
            if (s[i] == '>' && bas > 0) { dp[i][bas] += ss[i+1][bas-1]; upd(dp[i][bas]); }
            ss[i][bas] = dp[i][bas];
            if (bas > 0) ss[i][bas] += ss[i][bas-1];
            upd(ss[i][bas]);
        }
    }
    
    cout << ss[0][n-1] << '\n';
}

Measured memory_bytes: 139904
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    vector<int> v(3);
    for(int i=0; i<3; ++i)
        cin >> v[i];

    sort(v.begin(), v.end());
    int ans = v[0] * v[1] / 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9;
int gcd(int a, int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
/*----------------------------------------------*/
int dp[100005];
int h[100005];
signed main(){
  int n,k;
  cin>>n>>k;
  rep(i,n) cin>>h[i];
  rep(i,n)rep(j,k+1) dp[i]=INF;
  FOR(i,1,k)dp[0]=0;
  rep(i,n)FOR(j,1,k){
    if(i-j<0||i-j>=n) continue;
    chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
  }

  cout<<dp[n-1]<<endl;
  return 0;
}


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

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

ll gcd3(ll a, ll b, ll c){
  return gcd2(gcd2(a,b),c);
}

int main(){
  ll k;
  ll ans=0;
  cin >> k;
  for(ll i=1; i<=k; i++){
    for(ll j=1; j<=k; j++){
      for(ll h=1; h<=k; h++){
        ans = ans + gcd3(i,j,h);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
using 		namespace __gnu_pbds; 
using 		namespace std;
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopitr(vec) for(auto it=vec.begin();it!=vec.end();it++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	v(pi) vector<ll>pi
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	vp(pi) vector<pair<ll,ll>>pi
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	mi(lol) map<ll,ll>lol
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(30)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())


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

//code start from here 

int main() {
	fast;
	read(a)
	read(b)
	readarr(arr,b)
	ll sum=0;
	loop(j,0,b){
		sum+=arr[j];
		if(sum>a){
			sum-=arr[j];
			cout<<-1<<Endl;
			// break;
			return 0;
		}
	}
	cout<<abs(a-sum)<<endl;
	return 0;
}

//ends here 

Measured memory_bytes: 3720
N = int(input())
xylist = [[0, 0]]*N
for i in range(N):
  xy = list(map(int, input().split()))
  xylist[i] = xy

dl = {}
for i in range(N):
  for j in range(N):
    dx = str(xylist[j][0] - xylist[i][0])
    dy = str(xylist[j][1] - xylist[i][1])
    l = dx + "|" + dy
    if dx == "0" and dy == "0":
      continue
    if l in dl:
      dl[l] = dl[l] + 1
    else:
      dl[l] = 1

cnt = 0
if len(dl) != 0:
  cnt = N - max(dl.values())

print(cnt if cnt > 1 else "1")

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

double p[3004];
double dp[3004][3004];

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> p[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = dp[i - 1][j] * (1 - p[i]);
			if (j > 0) dp[i][j] += dp[i - 1][j - 1] * p[i];
		}
	}
	double ans = 0;
	for (int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i];
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 70656
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int x; cin >> x;
    int ans;
    if (x < 600) {
        ans = 8;
    } else if (x < 800) {
        ans = 7;
    } else if (x < 1000) {
        ans = 6; 
    } else if (x < 1200) {
        ans = 5;
    } else if (x < 1400) {
        ans = 4;
    } else if (x < 1600) {
        ans = 3;
    } else if (x < 1800) {
        ans = 2;
    } else {
        ans = 1;
    }

    cout << ans << endl;

    
    


    return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	llint a,b,am,bm,ax,bx;
	cin >> a >> b;
	if(a%2==0) {am=a*12.5;} else{ am=a*12.5+1;}
    bm=b*10;
    ax=a*12.5+12;
    bx=b*10+9;
    if(bx<am){
     	cout << "-1"; 
    } else if(ax<bm){
        cout << "-1";
    } else{
       if(am<bm){
         cout << bm;
       } else {
         cout << am;
       }
    }  
	return 0;
}

Measured memory_bytes: 256