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

const int MAXN = 51;
const int MAXX = 1001;

int N;
int T[MAXN];
bool dp[MAXN][MAXX][MAXX];

bool ok(int x) {
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= x; ++j) {
      for (int k = 0; k <= x; ++k) {
        dp[i][j][k] = false;
      }
    }
  }
  dp[0][0][0] = true;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= x; ++j) {
      for (int k = 0; k <= x; ++k) {
        if (!dp[i][j][k]) continue;
        dp[i+1][j][k] = true;
        if (j + T[i] <= x) {
          dp[i+1][j+T[i]][k] = true;
        }
        if (k + T[i] <= x) {
          dp[i+1][j][k+T[i]] = true;
        }
      }
    }
  }
  int sum = accumulate(T, T + N, 0);
  for (int j = 0; j <= x; ++j) {
    for (int k = 0; k <= x; ++k) {
      if (!dp[N][j][k]) continue;
      int rem = sum - j - k;
      if (rem <= x) return true;
    }
  }
  return false;
}

int main() {
  while (cin >> N) {
    for (int i = 0; i < N; ++i) {
      cin >> T[i];
    }
    int l = 0, r = MAXX;
    while (r - l > 1) {
      int x = (l + r) / 2;
      if (ok(x)) {
        r = x;
      } else {
        l = x;
      }
    }
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 50708
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll fact[200010];
ll invfact[200010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}


ll f(ll x,ll y,ll k){
	ll temp=0;
	rep(i,1,x)temp+=i*(x-i);
	return temp*y%MOD*y%MOD*choose(x*y-2,k-2,MOD)%MOD;
}

int main(){
	ll x,y,k;
	scanf("%lld%lld%lld",&x,&y,&k);
	makefact(200005,MOD);
	//x座標
	printf("%lld",(f(x,y,k)+f(y,x,k))%MOD);
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N, A, B;
int P[101];

int main(){

    cin >> N;
    cin >> A >> B;
    for(int i = 0; i < N; i++) cin >> P[i];
    int freq[3] = {};
    for(int i = 0; i < N; i++){
        if(P[i] <= A){
            freq[0]++;
        }
        else if(P[i] <= B){
            freq[1]++;
        }
        else{
            freq[2]++;
        }
    }
    cout << min(freq[0], min(freq[1], freq[2])) << endl;

}


Measured memory_bytes: 256
#pragma region header
#pragma warning(disable: 4996)
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion


int main(void) {
	lint n, a, b; 
	scanf("%lld%lld%lld", &n, &a, &b);
	vector<lint> d(n);
	for (int i = 0; i < n; i++) scanf("%lld", &d[i]);
	lint ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if ((d[i + 1] - d[i]) * a > b) ans += b;
		else ans += a * (d[i + 1] - d[i]);
	}
	printf("%lld\n", ans);

	return 0;
}

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

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

ll power(ll base, ll exp, ll mod) // O(logn) time
{
    ll ans=1LL; 
    while(exp){
        if(exp&1LL) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exp>>=1LL;
    }
    return ans%mod;
}

int main() { 
    ll tt = 1, n, q, m, l, r, c, i, j, k, w;
    boost;
    
    // cin >> tt;
    ll ans = 1;

    for(int _ = 1; _ <= tt; _++){
        cin >> n;

        ans = (power(10, n, fat) - (2*power(9, n, fat))%fat + power(8, n, fat) + fat)%fat;
        cout << ans << nl;
    }
}


Measured memory_bytes: 3688
using System;
using System.Linq;
using System.Collections.Generic;

class MainClass
{
  public static void Main(string[] args)
  {
    var n = int.Parse(Console.ReadLine());
    var 二行目 = Console.ReadLine().Split(' ');
    var d = int.Parse(二行目.First());
    var x = int.Parse(二行目.Last());

    var inputs = Enumerable.Range(0, n)
      .Select(i => int.Parse(Console.ReadLine()))
      .ToArray();
    Console.WriteLine(inputs.Aggregate(x, (sum, i) => sum + (d-1)/i + 1));
  }
}


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

#define fast ios::sync_with_stdio(0); cin.tie(0)

string a[101],ans="";int n,i,l;

int main(){
  fast;
  cin >>n>>l;
  for(i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  for(i=0;i<n;i++)
    ans+=a[i];
  cout<<ans;
  return 0;
}


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

const int dx[] = {0, 1}, dy[] = {1, 0};
int W, H;
char mp[51][51];
bool reachable[51][51][51][51];
int dp[51][51][51][51];
vector<vector<pair<int, int>>> hole;

void calc_reachable() {
    for (int fy = 0; fy < H; fy++) for (int fx = 0; fx < W; fx++) {
        reachable[fy][fx][fy][fx] = 1;
        for (int gy = fy; gy < H; gy++) for (int gx = fx; gx < W; gx++) {
            if (mp[gy][gx] == '#') continue;
            if (gy > 0)
                reachable[fy][fx][gy][gx] |= reachable[fy][fx][gy - 1][gx];
            if (gx > 0)
                reachable[fy][fx][gy][gx] |= reachable[fy][fx][gy][gx - 1];
        }
    }
}

int dfs(int fy, int fx, int gy, int gx) {
    int &ans = dp[fy][fx][gy][gx];
    if (ans != -1) return ans;

    ans = -1e9;
    if (mp[fy][fx] == '#' || !reachable[fy][fx][gy][gx]) return ans;
    for (int i = 0; i < 2; i++)
        if (fy + dy[i] < H && fx + dx[i] < W)
            ans = max(ans, dfs(fy + dy[i], fx + dx[i], gy, gx));

    if (islower(mp[fy][fx])) {
        char hole_c = mp[fy][fx] - 'a';
        for (auto hole_p : hole[hole_c]) {
            int hx, hy; tie(hy, hx) = hole_p;
            if (hx < fx || hx > gx || hy < fy || hy > gy || !reachable[fy][fx][hy][hx]) continue;

            int ret = 0;
            for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) {
                if (fy + dy[i] < H && fx + dx[i] < W && hy - dy[j] >= 0 && hx - dx[j] >= 0)
                    ret = max(ret, dfs(fy + dy[i], fx + dx[i], hy - dy[j], hx - dx[j]));
            }
            ans = max(ans, ret + dfs(hy, hx, gy, gx) + 1);
        }
    }
    return (dp[fy][fx][gy][gx] = ans);
}

int main() {
    while (cin >> H >> W, W+H) {
        hole = vector<vector<pair<int, int>>>(30);
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> mp[i][j];
                if (isupper(mp[i][j])) hole[mp[i][j] - 'A'].push_back({i, j});
            }
        }

        memset(reachable, false, sizeof(reachable));
        calc_reachable();

        if (!reachable[0][0][H - 1][W - 1]) {
            cout << -1 << endl;
            continue;
        }

        memset(dp, -1, sizeof(dp));
        for (int i = 0; i < H; i++) for (int j = 0; j < W; j++)
            dp[i][j][i][j] = 0;
        cout << dfs(0, 0, H - 1, W - 1) << endl;
    }
}



Measured memory_bytes: 36152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

#define INF 10000001

int main()
{
	int a, n;
	int maxi, mini;
	int i;
	long long sum = 0ll;

	mini = INF;
	maxi = -10000001;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		maxi = max(a, maxi);
		mini = min(a, mini);
		sum += a;
	}

	printf("%d %d ", mini, maxi);
	cout << sum << endl;
	
	return (0);
}

Measured memory_bytes: 1240
#include <iostream>

using namespace std;

//height
int f(int x)
{
    return x * x;
}

int main()
{
    int d;
    
    while (cin>>d)
    {
        int ans = 0;
        
        for (int i = 1; d * i < 600; i++)
        {
            ans += f(d * i) * d; // equation is informed from question
        }
        
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <set>
#include <cstdio>
using namespace std;
using ll = long long;


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


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll no09 = 1;
    ll both09 = 0;
    ll only0 = 0;
    ll only9 = 0;
    for (int i = 1; i <= N; i++) {
        auto no09n = no09 * 8;
        auto both09n = both09 * 10 + only0 + only9;
        auto only0n = only0 * 9 + no09;
        auto only9n = only9 * 9 + no09;
        no09 = no09n%1000000007;
        both09 = both09n % 1000000007;
        only0 = only0n % 1000000007;
        only9 = only9n % 1000000007;
    }
    
    cout << both09 << endl;;

}

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

int main() {
  ios::sync_with_stdio(false);
  
  int N, Q;
  cin >> N >> Q;

  vector<char> A(N);
  for (int i = 0; i < N; i++) {
    char C;
    cin >> C;
    A.at(i) = C;
  }

  vector<int> B(N);
  for (int i = 1; i < N; i++) {
    if (A.at(i - 1) == 'A' && A.at(i) == 'C') B.at(i)++;
    B.at(i) += B.at(i - 1);
  }

  for (int i = 0; i < Q; i++) {
    int L, R;
    cin >> L >> R;
    cout << B.at(R - 1) - B.at(L - 1) << "\n";
  }
}

Measured memory_bytes: 1280
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int count=0;
		String d = sc.nextLine();
		while (true) {
			String a = sc.nextLine();
			if (a.equals("END_OF_TEXT"))break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			}
		}
		System.out.println(count);

	}
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long A, long long B){
  if(A>B){
    swap(A,B);
  }
  if(abs(A-B)%2==0){
    cout<<(B-A)/2<<endl;
  }else{
    cout<<min(A-1+1+(B-A)/2,N-B+1+(B-A)/2)<<endl;
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include<iomanip>


#define ll long long
using namespace std;
//const ll MOD = (int) 10e9 + 7;

/*ll dp[100001];
vector<vector<ll>>adj;
ll dfs(ll node)
{
    if (dp[node] != -1)
        return dp[node];

    ll ans = 0;
    for (int i = 0; i < adj[node].size(); i++)
    {
        ans = max(dfs(adj[node][i]) + 1, ans);

    }
    return dp[node] = ans;
}
*/
ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;

    return n * factorial(n - 1);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    ll arr[n];
    ll dp[k + 1];
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    dp[0] = 0;
    for (ll i = 1; i <= k; i++)
    {
        dp[i] = 0;
        for (ll j = 0; j < n; j++)
        {
            if (i - arr[j] >= 0 && dp[i - arr[j]] == 0)
            {
                dp[i] = 1;
                break;
            }
        }
    }
    cout << (dp[k] == 1 ? "First" : "Second");

    /*std::cout<<std::fixed;
    std::cout<<std::setprecision(10)<<ans;*/
    return 0;
}


Measured memory_bytes: 1024
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
A1 = A[0]*T[0]
A2 = A[1]*T[1]
B1 = B[0]*T[0]
B2 = B[1]*T[1]
D1 = A1-B1
D2 = A2-B2
if D1*D2>0:
    output = 0
elif (D1==0)and(D2==0):
    output = "infinity"
elif D1==0:
    output = "infinity"
elif D1+D2==0:
    output = "infinity"
elif abs(D1)>abs(D2):
    output = 0
else:
    Z = abs(D1+D2)
    M1 = abs(D1)
    M2 = abs(D2)
    kanzen = M1//Z
    if Z*kanzen==M1:
        output = kanzen*2
    else:
        output = kanzen*2+1
print(output)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> u(n), v(n);
  int up = -2e9, down = 2e9, left = 2e9, right = -2e9;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    u[i] = x + y;
    v[i] = x - y;
    up = max(up, v[i]);
    down = min(down, v[i]);
    left = min(left, u[i]);
    right = max(right, u[i]);
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max({ans, abs(u[i] - left), abs(u[i] - right), abs(v[i] - up), abs(v[i] - down)});
  }
  
  cout << ans << '\n';
}

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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  if(b-a+1 <= k*2){
    for(int i = a; i<=b; i++){
      cout << i << endl;
    }
  }else{
    for(int i = a; i<=a+k-1; i++){
      cout << i << endl;
    }
    for(int j = b-k+1; j<=b; j++){
      cout << j <<endl;
    }
  }
}

Measured memory_bytes: 256
h,w = (int(i) for i in input().split())
a = []
ct = 0
for i in range(h):
  s = input()
  a.append(s)
  ct += s.count('#')
queue = [(0,0)]
check = []
if a[0][0] == '.':
 print('Impossible')
 exit()
while queue != []:
 i,j = queue[0]
 queue.pop(0)
 if not (i,j) in check:
  if i+1 < h:
   if a[i+1][j] =='#':
    queue.append((i+1,j))
  if j+1 < w: 
   if a[i][j+1] =='#':
    queue.append((i,j+1))
  check.append((i,j))
  if i+1 < h and j+1 < w: 
    if a[i+1][j] =='#' and  a[i][j+1] =='#':
      break
  if queue != []:
   if queue[0] == (h-1,w-1) and a[h-1][w-1] == '#':
     if h+w-1 == ct:
      print('Possible')
      exit()
print('Impossible')

Measured memory_bytes: 3064
def solve():
    n, m = map(int, raw_input().split())
    edge = {v:[] for v in range(1,n+1)}
    dist = {}
    for i in range(m):
        l, r, d = map(int, raw_input().split())
        edge[l].append(r)
        edge[r].append(l)
        dist[l,r] = d
        dist[r,l] = -d
    return "Yes" if ok(edge, dist, n) else "No"

def ok(edge, dist, n):
    used = [False] * (n+1)
    used[0] = True
    path = {}
    for s in range(1, n+1):
        if used[s]:
            continue
        que = [s]
        path[s, s] = 0
        used[s] = True
        while que:
            u = que.pop()
            for v in edge[u]:
                d = path[s,u] + dist[u,v]
                if not used[v]:
                    path[s,v] = d
                    que.append(v)
                    used[v] = True
                elif d != path[s,v]:
                    return False
    return True

print solve()

Measured memory_bytes: 117152
N,W = map(int,input().split())

w=[0]*N
v=[0]*N

for i in range(N):
    w[i],v[i] = map(int,input().split())

dp= [[0]*(W+1) for i in range(N)]

for i in range(0,N):
    for j in range(1,W+1):
        if w[i] <= j:
            dp[i][j] = max(v[i]+dp[i-1][j-w[i]],dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N-1][W])


Measured memory_bytes: 120044
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int f(int n) {
    if (n == 1) {
        return 0;
    }
    int ans = 1;
    for (int i = 0; i < n - 1; i++) {
        ans *= 10;
    }
    return ans;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vi> data(M, vi(2));
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> data.at(i).at(j);
        }
    }
    for (int i = 0; i <= 1000; i++) {
        if (f(N + 1) <= i) {
            break;
        }
        if (i < f(N)) {
            continue;
        }
        bool check = false;
        for (int j = 0; j < M; j++) {
            int a;
            if (data.at(j).at(0) == N) {
                a = i % 10;
            }
            else {
                a = (i / f(N + 1 - data.at(j).at(0))) % 10;
            }
            if (a != data.at(j).at(1)) {
                check = true;
                break;
            }
        }
        if (!check) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3596
H,W = map(int, input().split())
S = [list(input()) for _ in range(H)]

dp = [[[0, False] for _ in range(W)] for _ in range(H)]

# 初期条件
if S[0][0] == "#":
    dp[0][0][0] = 1
    dp[0][0][1] = True
for j in range(1,W):
    dp[0][j] = dp[0][j-1].copy()
    if not dp[0][j-1][1]:
        if S[0][j] == "#":
            dp[0][j][0] += 1
            dp[0][j][1] = True
    else:
        if S[0][j] == ".":
            dp[0][j][1] = False
for i in range(1,H):
    dp[i][0] = dp[i-1][0].copy()
    if not dp[i-1][0][1]:
        if S[i][0] == "#":
            dp[i][0][0] += 1
            dp[i][0][1] = True
    else:
        if S[i][0] == ".":
            dp[i][0][1] = False

def which(i,j):
    """
    True -> 上
    False -> 左
    """
    if dp[i-1][j][0] > dp[i][j-1][0]:
        return False
    elif dp[i-1][j][0] < dp[i][j-1][0]:
        return True
    else:
        if S[i][j] == "#":
            if dp[i-1][j][1]:
                return True
            else:
                return False
        else:
            if not dp[i-1][j][1]:
                return True
            else:
                return False

# DPループ
for i in range(1,H):
    for j in range(1,W):
        if which(i,j): # 上
            dp[i][j] = dp[i-1][j].copy()
            if not dp[i-1][j][1]:
                if S[i][j] == "#":
                    dp[i][j][0] += 1
                    dp[i][j][1] = True
            else:
                if S[i][j] == ".":
                    dp[i][j][1] = False
        else: # 左
            dp[i][j] = dp[i][j-1].copy()
            if not dp[i][j-1][1]:
                if S[i][j] == "#":
                    dp[i][j][0] += 1
                    dp[i][j][1] = True
            else:
                if S[i][j] == ".":
                    dp[i][j][1] = False

print(dp[H-1][W-1][0])

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

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

  string ans = "Three";
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    if (S == "Y")
      ans = "Four";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  int n;
  double a[111];
  cin>>n;
  double sum=0;
  for(int i=0;i<n;i++){
	cin>>a[i];
	sum+=a[i];
  }
  sum/=(double)n;
  double min=1111;
  int ans=0;
  for(int i=0;i<n;i++){
	if(abs(sum-a[i])<min){
	  min=abs(sum-a[i]);
	  ans=i;
	}
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
int n;
ll x;
ll b[200000],l[200000],u[200000];
P s[200000];
int id[200000];
ll sum=0;

bool C(ll t){
	ll m=t/x;
	if(m>=n)return true;
	ll S=0;
	rep(i,m)S+=s[i].first;
	ll r=t%x;
	ll Max=0;
	rep(i,n){
		ll d=(id[i]<m?S-s[id[i]].first+s[m].first:S);
		if(r<=b[i])d+=r*l[i];
		else d+=b[i]*l[i]+(r-b[i])*u[i];
		Max=max(Max,d);
	}
	return sum+Max>=0;
}

int main(){
	cin>>n>>x;
	rep(i,n){
		scanf("%lld%lld%lld",&b[i],&l[i],&u[i]);
		sum-=b[i]*l[i];
		s[i]=P(b[i]*l[i]+(x-b[i])*u[i],i);
		//cout<<s[i].first<<" "<<s[i].second<<endl;
	}
	sort(s,s+n);reverse(s,s+n);
		//rep(i,n){ cout<<s[i].first<<" "<<s[i].second<<endl;}
	rep(i,n)id[s[i].second]=i;
	ll ok=n*x,ng=0;
	while(ok>ng){
		ll md=(ok+ng)/2;
		if(C(md))ok=md;
		else ng=md+1;
	}
	cout<<ok<<endl;
}

Measured memory_bytes: 8064
S=str(input())
T=str(input())

lists=[]
listt=[]
k=0
for i in range (100):
    try:
        if S[i]==T[i]:
            continue
        else:
            k+=1
    except IndexError:
        break
if k==0:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 9116
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const int maxn = 440;
int n;
ll a[maxn];
ll f[maxn][maxn];

void work() {
  n = read();
  rep(i, 1, n) a[i] = read(), a[i] += a[i - 1];
  rep(i, 1, n) f[i][i] = a[i] - a[i - 1];
  rep(i, 2, n) {
    rep(l, 1, n) {
      int r = l + i - 1;
      if (r > n) break;
      f[l][r] = 1e18;
      rep(k, l, r) f[l][r] = min(f[l][r], f[l][k] + f[k + 1][r]);
      f[l][r] += a[r] - a[l - 1];
    }
  }
  cout<<f[1][n] - a[n]<<endl;
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {
	
	int N;
	cin >> N;
	int ans = 0;
	for(int i=0; i<N; i++) {
		int a;
		cin >> a;
		ans += a-1;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
import sys
range = xrange
input = sys.stdin.readline

n = int(input())

coupl = [[] for _ in range(n)]
weight = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,w = [int(x) for x in input().split()]
    coupl[a-1].append(b-1)
    weight[a-1].append(w)

    coupl[b-1].append(a-1)
    weight[b-1].append(w)


depth = [0]*n
found = [False]*n

stack = [0]
found[0] = True
while stack:
    node = stack.pop()
    for nei,w in zip(coupl[node],weight[node]):
        if not found[nei]:
            found[nei] = True
            depth[nei] = depth[node] + w
            stack.append(nei)

print '\n'.join(str(x%2) for x in depth)


Measured memory_bytes: 63388
#include <bits/stdc++.h>
using namespace std;
 
 int main(){
     int S;
     cin >> S;
     int h;
     int m;
     int s;
     
     h = S/3600;
     m = (S - h*3600)/60;
     s = S%60;
     
     cout << h<< ":"<<m << ":"<<s << endl;
     
 }
 


Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    string s;
    cin >> s;
    string ans;
    for (char c : s){
        if (c == 'B'){
            if (!ans.empty()) ans.pop_back();
        } else ans += c;
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, P: int):
    def primeFactorize(n: int):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    # print(primeFactorize(P))
    from collections import Counter
    c = Counter(primeFactorize(P))

    ans = 1
    for k, v in c.most_common():
        if v >= N:
            ans *= k**(v//N)


    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(N, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    ll sub = 1;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        if(tmp % 2 == 0){
            sub *= 2;
        }
    }
    for(int i = 0; i < n; i++){
        ans *= 3;
    }
    ans -= sub;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    long double ans = 0.0;
    vector<long double> a(n);
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    while (a.size() != 1) {
        auto x = a.back();
        a.pop_back();
        auto y = a.back();
        a.pop_back();
        a.push_back((x + y) / 2.0);
    }
    cout << a.front();
}

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

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long i64;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const i64 INF_LONG = 1LL << 62;
const i64 INF_LONG_NEG = INF_LONG * -1;

int notMonth(char a, char b){
    if (a == '0'){
        if (b == '0') return 1;
        else return 0;
    }
    if (a == '1'){
        if (b == '0' || b == '1' || b == '2') return 0;
        else return 1;
    }
    return 1;
}

int main()
{
    char S[9]; cin >> S;
    int hi  = notMonth(S[0], S[1]);
    int low = notMonth(S[2], S[3]);

    switch(hi * 2+ low){
        case 3: puts("NA"); break;
        case 2: puts("YYMM"); break;
        case 1: puts("MMYY"); break;
        case 0: puts("AMBIGUOUS"); break;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

void disp_s (vector <bool> s )
{
	int size = s.size();
	int i;

	for (i = 0; i < size; ++i){
		cout << setw(2) << i;
	} // end for
	cout << endl;

	for (i = 0; i < size; ++i){
		cout << setw(2) << s[i];
	} // end for

	cout << endl;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.jp", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int n, m;

		stringstream ss(str);
		ss >> n >> m;
		if (n == 0 && m == 0){
			break;
		} // end if
		vector <bool> s (n, true );
		int i = n - 1;
		while ((int)count (s.begin(), s.end(), true ) != 1 ){
			int c = 0;
			while (c < m ){
				if (s[ (i + 1) % n ]){
					++c;
				} // end if
				i = (i + 1) % n;
			} // end while

			s[i] = false;
//			disp_s (s );
		} // end while
		
		for (i = 0; i < n; ++i){
			if (s[i]){
				cout << i + 1 << endl;
			} // end if
		} // end for
	} // end loop
		
	return 0;
}

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

typedef long long ll;

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

    int a,b;
    cin >> a >> b;
    if(a<b) cout << "a < b" << endl;
    else if(a>b) cout << "a > b" << endl;
    else cout << "a == b" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int n;
int a[500010];
int b[500010];

ll cnt;

void mg(int l,int r)
{
    int mid=(l+r)/2;

    int tmp=0;
    int i,j;

    for(i=l,j=mid;i<mid&&j<r;)
    {
        if(a[i]>a[j])
        {
            b[tmp++]=a[j++];
            cnt+=mid-i;
        }else
        {
            b[tmp++]=a[i++];
        }
    }

    while(i<mid)
    {
        b[tmp++]=a[i++];
    }

    while(j<r)
    {
        b[tmp++]=a[j++];
    }

    for(int i=l;i<r;i++)
    {
        a[i]=b[i-l];
    }
}

void merge_sort(int l,int r)
{
    int mid=(l+r)/2;

    if(l+1==r)
    {
        return;
    }

    merge_sort(l,mid);
    merge_sort(mid,r);
    mg(l,r);
}

int main()
{

    while(scanf("%d",&n)!=EOF)
    {

        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }

        cnt=0;
        merge_sort(0,n);

        printf("%lld\n",cnt);
    }

    return 0;
}



Measured memory_bytes: 4804
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define Sec     second
#define ALL(V)  V.begin(),V.end()
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod     1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,i,K;
    cin>>N>>K;
    
    lli Product=K;
    
    rep(i,0,N-1)
    {
        Product*=(K-1);
    }
    
    cout<<Product;
    
    
    









 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
///-------------------------

int main()
{
    Phuong_; /// <3333
    ll a;
    string s;
    cin >> a;
    cin >> s;
    ll b=0;
    for(char c:s)
    {
        if (c=='.') continue;
        int id = c-'0';
        b= b*10 +id;
    }
    cout << (a*b)/100;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/

int main(){
    int mod=1000000007;
    int x,h;
    for (;;) {
        scanf("%d",&x);
        scanf("%d",&h);
        if (x==h && x==0) break;
        printf("%lf\n",1.0*x*x+sqrt((1.0*x/2)*(1.0*x/2)+h*h)*x*2);
    }
    return 0;
}

Measured memory_bytes: 3160
package main

import (
	"fmt"
)

func main() {
	var a int
	fmt.Scan(&a)
	// nums := createArray(a)
	// fmt.Println(nums)
	// point := N
	// for i:= len(nums) -1; i <0; i-- {
	// if nums[i]
	// }
	// newNums := []int{}
	// if a%2 == 0 {
	// 	newNums = nums[a/2:]
	// } else {
	// 	newNums = nums[(a+1)/2:]
	// }

	res := a * (a - 1) / 2
	fmt.Println(res)

}

func createArray(a int) (res []int) {
	for i := 0; i < a; i++ {
		res = append(res, i+1)
	}
	return
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

class UnionFind{
public:
	vector<int> par;
	vector<int> rank;
	vector<int> size;
 
	UnionFind(int n){
		rep(i,n){
			par.push_back(i);
			rank.push_back(0);
			size.push_back(1);
		}
	}
 
	int find(int x) {
		if(par[x]==x){
			return x;
		}else{
			return par[x]=find(par[x]);
		}
	}
 
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			par[x]=y;
			size[y]+=size[x];
		}else{
			par[y]=x;
			size[x]+=size[y];
			if(rank[x]==rank[y]) rank[x]++;
		}
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k,l;
  cin>>n>>k>>l;
  UnionFind uf1(n),uf2(n);
  rep(i,k){
    int p,q;
    cin>>p>>q;
    p--,q--;
    uf1.unite(p,q);
  }
  rep(i,l){
    int r,s;
    cin>>r>>s;
    r--,s--;
    uf2.unite(r,s);
  }
  map<P,int> cnt;
  rep(i,n){
    cnt[P(uf1.find(i),uf2.find(i))]++;
  }
  rep(i,n){
    cout<<cnt[P(uf1.find(i),uf2.find(i))]<<endl;
  }
}

Measured memory_bytes: 16608
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    stack<char> st;
    int ans = 0;
    for (auto& c : S) {
        if (st.empty()) {
            st.push(c);
        } else {
            if (st.top() != c) {
                st.pop();
                ans += 2;
            } else {
                st.push(c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import math

N = int(input())
if N % 2 == 1:
  print(0)
else:
  zero_count = 0
  if N == 0:
    print(0)
  else:  
    for i in range(1,1+int(math.log(N//2,5)//1)):#ここのN//2がN/2にしてただけで計算が狂った。floatの扱いの問題か
      zero_count += (N//2)//(5**i)
    print(int(zero_count))

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

signed main(){
    int m;
    long long a,b;
    int N = 10000;
    vector<bool>p(N,true);
    vector<int>prm;
    p[0] = p[1] = false;
    for(int i = 2;i<N;i++){
        if(p[i]){
            for(int j = 2; j*i < N;j++)
                p[i*j] = false;
            prm.emplace_back(i);
        }
    }
    vector<int>vv = prm;
    while(scanf("%lld%lld%lld",&m,&a,&b)){
        if(m==0)break;
        int maxi = -10000000;
        int ans1,ans2;
        for(auto && p :prm){
            for(auto && q:vv){
                if(p*q>m) break;
                if(p*q <= m  and  p*b >= q*a and p*q > maxi and p <= q){
                    ans1 = max(p,q);
                    ans2 = min(p,q);
                    maxi = p*q;
                }
            }
        }
        printf("%d %d\n",ans2,ans1);
    }
}



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

using namespace std;
using ll = long long;

int N;
pair<int, int> p[2020];
ll dp[2020][2020];

void solve(){
    int i, j, k, l, r, x, y;
    string s;
    cin >> N;
    rep(i, N){
        cin >> x;
        p[i] = {x, i};
    }

    sort(p, p+N);
    reverse(p, p+N);

    rep(x, N+1) rep(y, N+1) dp[x][y] = -1LL << 60;
    dp[0][0] = 0;
    rep(i, N){
        ll k = p[i].first;
        r = p[i].second;
        for(x = 0; x <= i; x++){
            y = i - x;
            dp[x+1][y] = max(dp[x+1][y],dp[x][y]+abs(r-(x))*k);
            dp[x][y+1] = max(dp[x][y+1], dp[x][y] + abs(r-(N-1-y))*k);
        }
    }
    ll ret = -1LL << 60;
    rep(x, N+1) ret = max(ret, dp[x][N-x]);
    cout << ret << endl;

}

int main(){
    solve();

    return 0;
}



Measured memory_bytes: 35224
N = int(input())
K = int(input())
Ans = 1
def dowhich(x):
    if Ans*2 >= Ans+x:
        return Ans+x
    elif Ans*2 < Ans+x:
        return Ans*2
for _ in range(N):
    Ans = dowhich(K)

print(Ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define int long long
#define MAXN 100000;
bool sortc1( const vector<int>& v1,const vector<int>& v2 ) {
 return v1[0] < v2[0];
}
bool sortc2( const vector<int>& v1,const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
int32_t main()
{
    int n;cin>>n;
    vector<vector<int>> v(n);
    for(int i=0;i<n;i++)
    {
        v[i]=vector<int>(2);
        for(int j=0;j<2;j++)
        {   cin>>v[i][j];
        }
    }
    stable_sort(v.begin(),v.end(),sortc1);
    stable_sort(v.begin(),v.end(),sortc2);
    int flag=0;
    for(int i=0;i<=n-1;i++)
    {
        if(v[i][0]>v[i][1])
        {
            flag=1;
            break;
        }
        else
        {
            if(i!=n-1)
            {
                v[i+1][0]+=v[i][0];
            }
        }
    }
    if(flag)cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 15920
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <algorithm>
#define ii pair<int, int>
#define iii pair<ii, int>
#define pq priority_queue

using namespace std;

int long_bfs(vector<vector<char>> graph, ii start, int h, int w) {
    queue<iii> possible;
    set<ii> visited;
    int longest = 0;
    possible.push(make_pair(start, 0));
    while (!possible.empty()) {
        ii xy = possible.front().first;
        int dist_from_start = possible.front().second;
        possible.pop();
        if (visited.find(xy) == visited.end()) {
            if (xy.first + 1 < h && graph[xy.first + 1][xy.second] == '.') {
                possible.push(make_pair(make_pair(xy.first + 1, xy.second), dist_from_start + 1));
            }
            if (xy.first - 1 >= 0 && graph[xy.first - 1][xy.second] == '.') {
                possible.push(make_pair(make_pair(xy.first - 1, xy.second), dist_from_start + 1));
            }
            if (xy.second - 1 >= 0 && graph[xy.first][xy.second - 1] == '.') {
                possible.push(make_pair(make_pair(xy.first, xy.second - 1), dist_from_start + 1));
            }
            if (xy.second + 1 < w && graph[xy.first][xy.second + 1] == '.') {
                possible.push(make_pair(make_pair(xy.first, xy.second + 1), dist_from_start + 1));
            }
            if (dist_from_start > longest) {
                longest = dist_from_start;
            }
            visited.insert(xy);
        }
    }
    return longest;
}

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

    int h, w;
    cin >> h >> w;
    vector<vector<char>> graph(h, vector<char>(w));
    cin.get();
    ii start;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin.get(graph[i][j]);
        }
        cin.get(); //get \n character
    }
    int longest = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (graph[i][j] == '.') {
                longest = max(longest, long_bfs(graph, make_pair(i, j), h, w));
            }
        }
    }
    cout << longest;
}

Measured memory_bytes: 3592
#include <iostream>
#include <math.h>
using namespace std;
 
int main() {
    // your code goes here
    int a,b,c;
    cin>>a>>b>>c;
    if((a<b)&&(b<c))  cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)



int main() {
    int n, m;
    
    cin >> n >> m;
    
    vector<int> b(n, 1);
    vector<bool> f(n, false);
    f[0] = true;
    
    REP(i, m){
        int x, y;
        
        cin >> x >> y;
        x--;y--;
        
        b[x]--;
        b[y]++;
        if(f[x]){
            f[y] = true;
        }
        if(!b[x]){
            f[x] = false;
        }
    }
    
    int ans = 0;
    REP(i, n){
        if(f[i])ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
N=int(input())
A=[int(input()) for _ in range(N)]

ans=0
for i in range(N-1):
    a=A[i]//2
    ans+=a
    A[i]-=a*2
    if A[i]==1 and A[i+1]>1:
        ans+=1
        A[i+1]-=1
ans+=A[N-1]//2
print(ans)




Measured memory_bytes: 49880