akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

double intersect(double x1, double y1, double x2, double y2, double x3, double \
y3,                                                                             
              double x4, double y4) {                                           
    return ((x1-x2)*(y3-y1)+(y1-y2)*(x1-x3))*((x1-x2)*(y4-y1)+(y1-y2)*(x1-x4));
}

int main(void) {                                                                
    double x1, x2, x3, y1, y2, y3;                                              
    double xp, yp, xc, yc;                                                      
                                                                                
    while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y\
3, &xp, &yp) != EOF) {                                                          
        xc = (x1 + x2 + x3) / 3;                                                
        yc = (y1 + y2 + y3) / 3;                                                        if (intersect(x1, y1, x2, y2, xp, yp, xc, yc) < 0) {                    
            printf("NO\n");                                                     
        } else if (intersect(x1, y1, x3, y3, xp, yp, xc, yc) < 0) {             
            printf("NO\n");                                                     
        } else if (intersect(x2, y2, x3, y3, xp, yp, xc, yc) < 0) {             
            printf("NO\n");                                                     
        } else {                                                                            printf("YES\n");                                                    
        }                                                                       
    }                                                                           
                                                                                
    return 0;                                                                   
}

Measured memory_bytes: 612
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
struct range {
	int l, r, c;
	range(int l = 0, int r = 0, int c = 0) : l(l), r(r), c(c) {}
	bool operator<(const range &rhs) const {
		return c < rhs.c;
	}
};
signed main() {
	cin >> N;
	vector< range > R(N);
	rep(i, N) cin >> R[i].l >> R[i].r;
	bool z = true;
	rep(i, N) {
		R[i].c = R[i].l - R[i].r;
		if (R[i].c != 0)
			z = false;
	}
	if (z) {
		cout << 0 << endl;
		return 0;
	}
	sort(R.begin(), R.end());
	int ans = 0, tmp = LINF;
	rep(i, N) {
		ans += R[i].l;
		if (R[i].l > R[i].r) {
			chmin(tmp, R[i].r);
		}
	}
	cout << ans - tmp << endl;
	return 0;
}

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

int main() {
	
	int n;
	cin>>n;
	vector<ll> A(n),pre(n);
	for(int i=0;i<n;i++)cin>>A[i];
	for(int i=0;i<n;i++)pre[i]=(i==0?A[i]:pre[i-1]+A[i]);

ll imax=pow(10,18);
		vector<vector<ll>> dp(n,vector<ll>(n,imax));
		for(int i=0;i<n;i++)dp[i][i]=0;
	for(int i=n-1;i>=0;i--)
	for(int j=i;j<n;j++)
	{
		for(int k=i;k<j;k++)
		{
			dp[i][j]=min(dp[i][j], dp[i][k]+dp[k+1][j]+ pre[j]-pre[i]+A[i]);
		}
		
		
	}
	cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 4852
# -*- coding: utf-8 -*-
import itertools


def change(val):
    # 黒なら1
    if val == '#':
        return 1

    # 白なら0
    return 0


# def calc_root(board):


def main():
    h, w = map(int, input().split())
    board = [[s for s in input()] for i in range(h)]

    cnt = 200
    dp = [[200] * w for i in range(h)]

    for i_row, row in enumerate(dp):
        for i_col, col in enumerate(row):
            if i_row == 0 and i_col == 0:
                dp[i_row][i_col] = change(board[i_row][i_col])
                continue

            if i_row >= 1:
                if board[i_row][i_col] == '#' and board[i_row - 1][i_col] == '.':
                    dp[i_row][i_col] = min(dp[i_row - 1][i_col] + 1, dp[i_row][i_col])
                else:
                    dp[i_row][i_col] = min(dp[i_row - 1][i_col], dp[i_row][i_col])

            if i_col >= 1:
                if board[i_row][i_col] == '#' and board[i_row][i_col - 1] == '.':
                    dp[i_row][i_col] = min(dp[i_row][i_col - 1] + 1, dp[i_row][i_col])
                else:
                    dp[i_row][i_col] = min(dp[i_row][i_col - 1], dp[i_row][i_col])

    print(dp[-1][-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
	ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		return ModInt(u);
	}

	bool operator==(ModInt that) const { return x == that.x; }
	bool operator!=(ModInt that) const { return x != that.x; }
	ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD>
ostream &operator << (ostream &os, const ModInt<MOD> &m) { return os << m.x; }
template<int MOD>
istream &operator >> (istream &is, ModInt<MOD> &m) { signed long long s; is >> s; m = ModInt<MOD>(s); return is; };

using mint = ModInt<1000000007>;

mint pow(mint a, unsigned long long k) {
	mint r = 1;
	while (k) {
		if (k & 1) r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	mint n(N), m(M);
	if (N == 1) {
		cout << m + 1 << endl;
		return 0;
	}
	mint maxd = M / (N - 1);
	mint A = m - maxd*(n - 1) + 1;
	mint B = m - (n - 1) + 1;
	mint ans = (A + B)*maxd + (m + 1);
	dump(n, m);
	dump(maxd);
	dump(A, B);
	cout << ans << endl;
	return 0;
}

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

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

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int sum = 0;
    if(n < k){
        sum = n * x;
    }
    else {
        sum = k * x + (n - k) * y;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define S static
#define rep(i,n) for(ll i=0LL; i<n; ++i)
typedef long long ll;

#define MOD  (1000000007LL)

int main()
{
    ll n; cin >> n;
    string s; cin >> s;

    S ll dp[5005] = {};
    dp[0] = 1LL;

    rep (i, n) {
        S ll dp_prev[5005];
        memcpy(dp_prev, dp, sizeof(dp_prev));
        memset(dp, 0, sizeof(dp));

        rep (len, 5005) {
            if (len) dp[len] += dp_prev[len-1];
            dp[len] %= MOD;
            if (len < 5004) dp[len] += dp_prev[len+1] * 2LL;
            dp[len] %= MOD;
            if (!len) dp[len] += dp_prev[len];
            dp[len] %= MOD;
        }
    }

    cout << dp[s.size()] << endl;

    return 0;
}


Measured memory_bytes: 384
//arc060_c.cpp
//Sat Jun 23 13:19:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int n,a,X;
int x[50];
ll dptable[51][51][2600];

int main(){
	cin >> n >> a;
	X = a;
	for (int i=0;i<n;i++){
		cin >> x[i+1];
		X = max(X,x[i+1]);
	}

	for (int j=0;j<=n;j++){
		for (int k=0;k<=n;k++){
			for (int s=0;s<=2500;s++){
				if (j==0 && k==0 && s==0){
					dptable[j][k][s] = 1;
				}else if (j>=1 && s<x[j]){
					dptable[j][k][s] = dptable[j-1][k][s];
				}else if (j>=1 && k>=1 && s>=x[j]){
					dptable[j][k][s] = dptable[j-1][k][s] + dptable[j-1][k-1][s-x[j]];
				}else {
					dptable[j][k][s] = 0;
				}
			}
		}
	}

	ll ans = 0;

	for (int k=1;k<=n;k++){
		ans += dptable[n][k][k*a];
	}

	cout << ans << endl;
}

Measured memory_bytes: 53120
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) //cerr<< #x <<": "<<x<<endl
#define debug2(x,y) //cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional deque
template<typename T> ostream& operator<<(ostream& s, const deque< deque<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int r, c, n;
bool on_edge(int x, int y) {
  return (x == 0 || x == r) || (y == 0 || y == c);
}

double xcenter, ycenter;
double get_atan(vi a) {
  return atan2(a[1] - ycenter, a[0] - xcenter);
}

int main() {
  scanf("%d %d %d", &r, &c, &n);
  xcenter = r / 2.0;
  ycenter = c / 2.0;
  vvi points;
  rep (i, n) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (on_edge(x1, y1) && on_edge(x2, y2)) {
      vi point1 = {x1, y1, i};
      vi point2 = {x2, y2, i};
      points.push_back(point1);
      points.push_back(point2);
    }
  }
  int m = points.size();
  sort(all(points), [](vi a, vi b) {
      return get_atan(a) < get_atan(b);
      });

  debug(points);

  deque<int> stk;
  set<int> si;
  rep (i, m) {
    int num = points[i][2];
    if (si.find(num) == end(si)) {
      si.insert(num);
      stk.push_back(num);
    } else if (stk.back() == num) {
      stk.pop_back();
    } else {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");

  return 0;
}


Measured memory_bytes: 16940
from collections import Counter

# sys.setrecursionlimit(100000)
from heapq import heappop, heappush, heapify


def main():
    h, w = [int(i) for i in input().strip().split()]
    s = ""
    for _ in range(h):
        s += input().strip()
    counts = Counter(s).most_common()
    cands = [-int(i) for v, i in counts]

    def pop(): return -heappop(cands)
    def push(x): return heappush(cands, -x)

    tasks = [4] * (h // 2) * (w // 2)
    tasks += [2] * ((h % 2) * (w // 2) + (w % 2) * (h // 2))
    tasks += [1] * ((h % 2) * (w % 2))

    flag = True
    for e in tasks:
        c = pop()
        if c < e:
            flag = False
            break
        push(c - e)

    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 74704
n, y = map(int, input().split())


for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if k < 0:
            continue
        if 1000 * i + 5000 * j + 10000 * k == y:
            print(k, j, i)
            exit(0)


print('-1 -1 -1')


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

int main(void)
{
    char a;
    cin >> a;

    if ('a' <= a && a <= 'z')
    {
        cout << "a";
    }
    if ('A' <= a && a <= 'Z')
    {
        cout << "A";
    }
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		try (Scanner sc = new Scanner(System.in)) {
			char[] s = sc.next().toCharArray();
			
			for (int i = 0; i < s.length - 1; i++) {
				if (s[i] == s[i+1]) {
					System.out.println("Bad"); 
					return;
				}
			}
			System.out.println("Good");
			
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

}


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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int r, a, b;

signed main() {
	cin >> r >> a >> b;
	r -= a;
	r -= r/b * b;
	cout << r << ln;
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
S=[input() for _ in range(h)]
y=0
for i in range(2**h):
  T=[S[j] for j in range(h) if (i>>j)&1]
  for l in range(2**w):
    x=0
    for m in range(w):
      if (l>>m)&1:
        for n in range(len(T)):
          if T[n][m]=='#':
            x+=1
    if x==k:
      y+=1
print(y)

Measured memory_bytes: 8984
from bisect import bisect_left
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

C = [0]*N

for i in range(N):
  C[i] = A[i] - B[i]
C.sort()
if sum(C) < 0:
  ans = -1
else:
  b = bisect_left(C,0)
  C_minus = C[:b]
  sum_C_minus = sum(C_minus)
  if sum_C_minus == 0:
    ans = 0
  else:
    count = len(C_minus)
    C_plus = C[b:]
    C_plus.sort(reverse = True)
    for j in range(len(C_plus)):
      count += 1
      if abs(sum_C_minus) <= C_plus[j]:
        ans = count
        break
      else: sum_C_minus += C_plus[j]

print(ans)

Measured memory_bytes: 19188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const mod=1000000007;
ll const md=998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ifstream in("txt.in");
ofstream out("txt.out");

#define mp make_pair
#define pb push_back
#define fi first
#define se second

int f[100005];
int dp[100005];

int main()
{
    cout<<fixed<<setprecision(12);
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cout.tie(0);

    ll n;cin>>n;
    for(int i=1;i<=n;++i){
        cin>>f[i];
    }
    ll cnt=0;
    dp[1]=0;
    dp[0]=2e9;
    for(int i=2;i<=n;++i){
        dp[i]=min(dp[i-1]+abs(f[i]-f[i-1]),dp[i-2]+abs(f[i]-f[i-2]));
    }
    cout<<dp[n]<<'\n';


    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

void yes(){printf("Yes\n");exit(0);}
void no(){printf("No\n");exit(0);}

int main(){
    int n, i, h[100000];
    scanf("%d", &n);
    for(i = 0;i < n; i++){ scanf("%d", &h[i]);}
    if(n != 1){
        for(i = 0; i < n - 1; i++){
            if(0 <= h[i + 1] - h[i]){
                if(1 <= h[i + 1] - h[i]){ h[i + 1]--;}
            }else{ no();}
        }
        yes();
    }else{ yes();}
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int N,k;
int weight[100000];
int ch(long long int p){
        int locate=0;
        for(int i=0 ; i<k ; i++ ){
                long long int s=0;
                while(s+weight[locate]<=p){
                        s+=weight[locate];
                        locate++;
                        if(locate>=N)return N;
                }
        }
        return locate;
}
int main(){
        cin >> N >> k;
        for(int i=0 ; i<N ; i++ )
                cin >> weight[i];
        long long int left=0,right=100000*10000;
        while(right-left>1){
                long long int mid=(left+right)/2;
                int v=ch(mid);
                if(v>=N)right=mid;
                else    left=mid;
        }
        cout<<right<<endl;
}


Measured memory_bytes: 3500
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {

	long long int A, B, C;

	cin >> A >> B >> C;

	long long int ans = 0;

	ans = min(A + B + 1, C);

	ans += B;

	cout << ans << endl;

	//system("pause");
	return 0;
}

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

mod = 2019

s = input().rstrip()
n = len(s)

t = [int(s[n - 1])]

mul = 10
for i in range(n - 2, -1, -1):
    t.append((t[-1] + int(s[i])*mul) % mod)
    mul *= 10
    mul %= mod
t.append(0)

from collections import Counter

c = Counter(t)
ans = 0

for i in c.keys():
    ans += c[i]*(c[i] - 1) // 2

print(ans)






Measured memory_bytes: 76588
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
   int n;
   cin>>n;
   cout<<a[n-1];


}


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

int main(){
    int N; cin >> N;
    vector <ll> A(N);
    rep(i,N) cin >> A[i];
    
    ll ans=1;
    bool judge=true;
    rep(i,N-1){
        if(A[i]<A[i+1]){
            i++;
            while(i<=N-2){
                if(A[i]>A[i+1]){
                    ans++;
                    //cout << A[i] << " " << A[i+1] << endl;
                    break;
                }
                i++;
            }
        }
        else if(A[i]>A[i+1]){
            i++;
            while(i<=N-2){
                if(A[i]<A[i+1]){
                    ans++;
                    //cout << A[i] << " " << A[i+1] << endl;
                    break;
                }
                i++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 1024
def d(x, y, p)
  x.zip(y).sum{|a,b|(a-b).abs**p}**(1.0/p)
end

def c(x, y)
  x.zip(y).map{|a,b|(a-b).abs}.max
end

def pf(*a)
  puts "%.6f" % a
end

n=gets.to_i
x=gets.split.map(&:to_i)
y=gets.split.map(&:to_i)

pf d(x,y,1)
pf d(x,y,2)
pf d(x,y,3)
pf c(x,y)



Measured memory_bytes: 6940
#define DEBUG 0

/**
 * File    : C2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-29 17:31:56
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

vector<int> ans;

void Yes()
{
  cout << "YES" << endl;
  int M = ans.size();
  for (auto i = 0; i < M; i++)
  {
    cout << ans[i];
    if (i < M - 1)
    {
      cout << " ";
    }
    else
    {
      cout << endl;
    }
  }
  exit(0);
}

void No()
{
  cout << "NO" << endl;
  exit(0);
}

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

// const ll MOD = 1000000007;

int N;

int cnt(int x)
{
  int ans = 0;
  for (auto i = 0; i < 30; i++)
  {
    if (x >> i & 1)
    {
      ans++;
    }
  }
  return ans;
}

void dfs(int A, int B, int mask)
{
  if (cnt(mask) == N - 1)
  {
    ans.push_back(A);
    ans.push_back(B);
    return;
  }
  int ind;
  for (ind = 0; ind < N; ind++)
  {
    if (mask >> ind & 1)
    {
      continue;
    }
    if ((A >> ind & 1) != (B >> ind & 1))
    {
      break;
    }
  }
  int new_mask = mask | 1 << ind;
  int next;
  for (next = 0; next < N; next++)
  {
    if (new_mask >> next & 1)
    {
      continue;
    }
    break;
  }
  int C = A ^ 1 << next;
  int D = C ^ 1 << ind;
  dfs(A, C, new_mask);
  dfs(D, B, new_mask);
}

int main()
{
  int A, B;
  cin >> N >> A >> B;
  if (cnt(A ^ B) % 2 == 0)
  {
    No();
  }
  else
  {
    dfs(A, B, 0);
    Yes();
  }
}

Measured memory_bytes: 1656
/*
        KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!" 
                -PICT,PUNE! :)
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test ll t;cin>>t;while(t--)
ll zero=0;

ll gcd(ll a,ll b){    if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) {    return (a/gcd(a,b)*b);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
bool prime(ll n){ll i;if(n==1) return false;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
 
/*ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (ll i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (ll j=i*i; j<MAXN; j+=i)
            if (spf[j]==j)
            spf[j] = i;
        }
    }
}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b)return(a.second<b.second);*/
 
//https://www.youtube.com/watch?v=k4V3Mo61fJM
 
using namespace std;

signed main()
{
    bolt;
    ll n;cin>>n;
    ll a[n],dp[n];
    forci(0,n)
    cin>>a[i],dp[i]=INT_MAX;
    dp[0]=0;
    forci(0,n)
    {
        if(i+1<n)
        dp[i+1]=min(dp[i+1],abs(a[i+1]-a[i])+dp[i]);
        if(i+2<n)
        dp[i+2]=min(dp[i+2],abs(a[i+2]-a[i])+dp[i]);
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353 
#define pb push_back
#define mb make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

 int main(){
	IOS;
	long long int n,w; cin >> n >> w;
	long long int W[n],val[n];
	for(long long int i=0;i<n;i++)
		cin >> W[i] >> val[i];
	if(n==1){
		cout << val[0] ;

		return 0;
	}


	long long int dp[n+1][w+1];
	// memset(dp,0,sizeof(dp));
	// cout << sizeof(dp[0]);

	for(long long int i=0;i<=n;i++){

		for(long long int j=0;j<=w;j++){
			if(i==0 or j==0){
				dp[i][j]=0;
				continue;
			}
			dp[i][j]=0;

			if(j<W[i-1]){
				dp[i][j]=dp[i-1][j];
				continue;
			}
			dp[i][j] = max(dp[i-1][j],dp[i-1][j-W[i-1]]+val[i-1]);
			// cout << dp[i][j] << " ";
		}
		// cout << endl;
	}
	cout << dp[n][w] << endl;


	return 0;
}




Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

const ld pi=(4.0*atan(1));
ll n;
vector<pair<ll,ll>> v;

ll po(ll x,ll y,ll md=mod){
    ll res=1;
    x%=md;
    
    while(y>0){
        if (y&1){
            res=(res*x)%md;
        }
        
        y>>=1;
        x=(x*x)%md;
    }
    return res;
}
void solve(){
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   ll cnt=0,nu=k;
   nu=min(a,k);
   cnt+=nu;
   k-=nu;
   
   nu=min(b,k);
   k-=nu;
   
   cnt-=min(k,c);
   
   cout<<cnt<<"\n";
   
}

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    cout<<fixed<<setprecision(12);
    for (ll tc=1;tc<=tt;tc++){
       solve();
    }
    
	return 0;
}

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

const int maxn = 2e5 + 5, maxm = 4e5 + 5;
int head[maxn], next[maxm], ver[maxm], tot = 1;
int bloc[maxn], cur = 0, ans[maxn], cnt_b[maxn];
void add(int a, int b){
	ver[++tot] = b;
	next[tot] = head[a], head[a] = tot;
}
void dfs(int u){
	bloc[u] = cur;
	cnt_b[cur] ++; 
	for(int i=head[u];i;i=next[i]){
		if(bloc[ver[i]]) continue;
		dfs(ver[i]);
	}
}
int main(){
	int n, m, k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=m;i++){
		int a, b;
		scanf("%d%d",&a,&b);
		add(a, b); add(b, a);
		ans[a] --; ans[b] --;
	}
	for(int i=1;i<=n;i++){
		if(!bloc[i]) cur ++, dfs(i);
	}
	for(int i=1;i<=n;i++) ans[i] += cnt_b[bloc[i]] - 1;
	for(int i=1;i<=k;i++){
		int a, b;
		scanf("%d%d",&a,&b);
		if(bloc[a] == bloc[b]) ans[a] --, ans[b] --;
	}
	for(int i=1;i<=n;i++) printf("%d ", ans[i]);
	return 0;
}

Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using Job = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  int a, b;
  auto comp = [](const auto& a, const auto& b) { return a.first > b.first; };
  priority_queue<Job, vector<Job>, decltype(comp)> jobs(comp);
  for(int i = 0; i < N; ++i) {
    cin >> a >> b;
    jobs.push({a, b});
  }

  priority_queue<int> ss;
  ll ans = 0;
  for(int d = M - 1; d >= 0; --d) {
    while(!jobs.empty()) {
      auto jb = jobs.top();
      if(jb.first <= M - d) {
        jobs.pop();
        ss.push(jb.second);
      } else {
        break;
      }
    }
    if(!ss.empty()) {
      auto tb = ss.top();
      ss.pop();
      ans += tb;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
char s[maxn], p[maxn];

int main(){
	scanf("%s", s);
	scanf("%s", p);
	int len = strlen(s);
	int ans = 0;
	for(int i=0; i<len; i++){
		if(s[i]!=p[i])
			ans++;
	}
	printf("%d", ans);
	return 0;
}

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

using namespace std;

int lower_bound(vector<int>& L, int l, int r, int key){
    if(l >= r - 1){
        if(L[l] >= key) return l-1;
        return l;
    }
    int mid = (l + r) / 2;
    if(L[mid] < key) return lower_bound(L, mid, r, key);
    else return lower_bound(L, l, mid, key);
}

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0;i<N;++i){
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());
    
    int a, b, c, ans=0;
    for(int i=0;i<N-2;++i){
        for(int j=i+1;j<N-1;++j){
            a = L[i];
            b = L[j];
            c = lower_bound(L, j+1, N, a+b);
            if(c != -1){
                ans += c - j;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 100010
using namespace std;
int n,sz[maxn];
vector<int> m[maxn];
int line[maxn],s;
bool vis[maxn];
bool dfs(int u) {
	vis[u]=1;
	sz[u]=1;
	bool t=false;
	if (u==n)
		t=true;
	for (int i=0;i<m[u].size();i++) {
		int v=m[u][i];
		if (!vis[v]) {
			t|=dfs(v);
			sz[u]+=sz[v];
		}
	}
	if (t) {
		s++;
		line[s]=u;
	}
	return t;
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d",&n);
	int x,y;
	for (int i=1;i<n;i++) {
		scanf("%d %d",&x,&y);
		m[x].push_back(y);
		m[y].push_back(x);
	}
	s=0;
	dfs(1);
	x=y=0;
	int i=2,j=s-1;	
	/*
	for (int i=1;i<=s;i++)
		printf("%d %d\n",i,line[i]);
	printf("\n");
	
	for (int i=1;i<=n;i++)
		printf("%d %d\n",i,sz[i]);
	*/
	while (j>=i) {
		y+=sz[line[j]]-sz[line[j-1]];
		j--;
		if (j<i)
			break;
		x+=sz[line[i]]-sz[line[i-1]];
		i++;
		if (j<i)
			break;
	}
	y+=sz[1]-sz[line[s-1]]-1;
	x+=sz[n]-1;
	//printf("%d %d\n",x,y);
	if (y<=x)
		printf("Snuke\n");
	else printf("Fennec\n");
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

int main(void){
    int A,B,M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    for(int i=0;i<A;i++) cin >> a[i];
    for(int i=0;i<B;i++) cin >> b[i];

    int minA = *min_element(a.begin(), a.end());
    int minB = *min_element(b.begin(), b.end());

    int ans = minA+minB;
    for(int i=0;i<M;i++){
        int x,y,c;
        cin >> x >> y >> c;
        ans = min(ans,a[x-1]+b[y-1]-c);
    }

    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4000
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(){
int H, W;
cin >> H >> W;
  
  //最上段の#
  rep(i, W+2)
    cout << '#' ;
  cout << endl;
  
  char tmp;
  rep(i, H){
    //左端の#
  cout << '#' ;
    rep(j, W){
      cin >> tmp;
      cout << tmp;
    }
    //右端の#
    cout << '#' <<endl;
  }
  
  //最下段の#
  rep(i, W+2)
    cout << '#' ;
  cout << endl;
  

return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

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

Measured memory_bytes: 3120
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count=0
for i in range(n):
  a=list(map(int,input().split()))
  p=c
  for j in range(m):
    p+=a[j]*b[j]
  if p>0:
    count+=1
print(count)


Measured memory_bytes: 38256
X = int(input())
sinamono = [100, 101, 102, 103, 104, 105]
dp = [[False for _ in range(X+100)] for _ in range(len(sinamono)+1)]

dp[0][0] = True

for i in range(len(sinamono)):
    for j in range(X+10):
        if (j < sinamono[i]):
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = dp[i][j] or dp[i + 1][j - sinamono[i]]

if dp[len(sinamono)][X]:
    print(1)
else:
    print(0)

Measured memory_bytes: 81904
N, Y = map(int, input().split())

o_a = -1
o_b = -1
o_c = -1

for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b

        total = 10000 * a + 5000 * b + 1000 * c
        if total == Y:
            o_a = a
            o_b = b
            o_c = c

print("{} {} {}".format(o_a, o_b, o_c))

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

int main(){
  
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  cout << A[0] * 10 + A[1] + A[2] << endl;
  return 0;
}

Measured memory_bytes: 3568
def examA():
    K = I()
    A, B = LI()
    for i in range(A,B+1):
        if i%K==0:
            print("OK")
            return
    print("NG")
    return

def examB():
    X = I()
    now = 100
    ans = 0
    while(now<X):
        ans += 1
        now += now//100
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 76752
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int N, M;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
bool is_prime[200010];

// テーブルを作る前処理
void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<int, int> prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

signed main()
{
	cin >> N >> M;

	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}

	// N >= 2
	com_init();

	int ans = 1;

	map<int, int> counter = prime_factor(M);

	for (pair<int, int> p : counter) {
		int index = p.second;

		ans *= com(index + N - 1, N - 1);
		ans %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll MOD;
vector<ll> fact, fact_inv, inv;
void init_nCk(ll n){
  fact.resize(n+5);
  fact_inv.resize(n+5);
  inv.resize(n+5);
  fact[0]=fact[1]=1;
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for (ll i=2;i<n+5;i++){
    fact[i]=fact[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
ll nCk(ll n,ll k){
  assert(!(n<k));
  assert(!(n<0||k<0));
  return fact[n]*(fact_inv[k]*fact_inv[n-k]%MOD)%MOD;
}
ll pow(ll x,ll y){//x^yを返す
  if(x==1){return 1;}
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
  ll p,a;
  cin>>p;
  MOD=p;
  vector<ll> a1(0);
  vector<ll> ans(p);
  for(ll i=0;i<p;i++){
    cin>>a;
    if(a==1){a1.push_back(i);}
  }
  init_nCk(p-1);
  for(ll i=0;i<(ll)a1.size();i++){
    ans.at(0)++;
    a=1;
    for(ll j=p-1;j>=0;j--){
      ans.at(j)-=nCk(p-1,j)*a-MOD*MOD;
      ans.at(j)%=MOD;
      a*=-1*a1.at(i);
      a%=MOD;
    }
  }
  for(ll i=0;i<p;i++){
    cout<<ans.at(i);
    if(i<p-1){cout<<" ";}
  }
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int N, W;
  cin >> N >> W;

  vector<int> w1, w2, w3, w4;
  int w, v;
  rep(i, N) {
    if (i == 0) {
      cin >> w >> v;
      w1.push_back(v);
    } else {
      int x;
      cin >> x >> v;
      if (x - w == 0)
        w1.push_back(v);
      else if (x - w == 1)
        w2.push_back(v);
      else if (x - w == 2)
        w3.push_back(v);
      else
        w4.push_back(v);
    }
  }

  sort(all(w1), greater<int>());
  sort(all(w2), greater<int>());
  sort(all(w3), greater<int>());
  sort(all(w4), greater<int>());
  int ans = 0;
  rep(i, w1.size() + 1) {
    rep(j, w2.size() + 1) {
      rep(k, w3.size() + 1) {
        rep(l, w4.size() + 1) {
          if (W < i * w + j * (w + 1) + k * (w + 2) + l * (w + 3)) continue;
          int tmp = 0;
          rep(x, i) tmp += w1[x];
          rep(x, j) tmp += w2[x];
          rep(x, k) tmp += w3[x];
          rep(x, l) tmp += w4[x];
          cmax(ans, tmp);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9+7;

int main() {
	long long n, m;
	cin >> n >> m;
	vector<pair<long long, long long> > data(n);
	rep(i, n){
		long long a, b;
		cin >> a >> b;
		data.at(i) = make_pair(a, b);
	}
	sort(data.begin(), data.end());
	long long ans = 0;
	rep(i, n){
		ans += min(m, data.at(i).second)*data.at(i).first;
		m -= min(m, data.at(i).second);
		if(m == 0) break;
	}

	cout << ans << endl;

}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
    int n, tmp, cnt=0, i, ans=0;
    cin >> n;
    for(i=1;i<=n;i++){
        tmp=i;
        cnt=0;
        while(tmp>0){
            tmp=tmp/10;
            cnt++;
        }
        if(cnt%2!=0) ans++;
    }

    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <algorithm>

using namespace std;
string s, t;
int d[3005][3005], ct;
char r[3005];

int main() {
    int i, j;
    //ifstream cin("LCS.in");
    cin >> s >> t;
    for (i = 0; i < s.length(); i++) {
        for (j = 0; j < t.length(); j++) {
            if (s[i] == t[j]) d[i + 1][j + 1] = d[i][j] + 1;
            else d[i + 1][j + 1] = max(d[i][j + 1], d[i + 1][j]);
        }
    }

    i = s.length();
    j = t.length();
    while (i > 0 && j > 0) {
        if (s[i-1] == t[j-1]) {
            ct++;
            r[ct] = s[i-1];
            i--;
            j--;
        } else if (d[i][j - 1] > d[i - 1][j])j--;
        else i--;
    }
    //cout<<d[s.length()][t.length()];
    for (i = ct; i >= 1; i--)
        cout<<r[i];
}

Measured memory_bytes: 35456
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int X = fs.nextInt();

        int ans = 1;
        for (int i = 2; i <= X; ++i) {
            for (int j = 1; j <= (int)Math.sqrt(i); ++j) {
                for (int k = 1; k <= 9; ++k) {
                    if (i == (int)Math.pow(j, k)) {
                        ans = Math.max(ans, i);
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 32664
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        double max = Double.MIN_VALUE;
        double min = Double.MAX_VALUE;

        String line;

        while((line = br.readLine()) != null){
            Double height = Double.parseDouble(line);
            max = Math.max(height,max);
            min = Math.min(height,min);
        }

        System.out.println((max-min));
    }
}


Measured memory_bytes: 24288
#include <bits/extc++.h>
using namespace std;
using i64=int64_t;

struct union_find
{
    union_find(const size_t n = 0) : link(n, -1) {}

    size_t find(size_t x)
    {
        assert(x < size());
        return link[x] < 0 ? x : (link[x] = find(link[x]));
    }

    size_t size() const { return link.size(); }

    size_t size(const size_t x)
    {
        assert(x < size());
        return -link[find(x)];
    }

    bool same(const size_t x, const size_t y)
    {
        assert(x < size() && y < size());
        return find(x) == find(y);
    }

    bool unite(size_t x, size_t y)
    {
        assert(x < size() && y < size());
        x = find(x), y = find(y);
        if(x == y) return false;
        if(link[x] > link[y]) std::swap(x, y);
        link[x] += link[y];
        link[y] = x;
        return true;
    }

protected:
    std::vector<int> link;
}; // class union_find


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

    int n,m; cin>>n>>m;
    union_find uf(n);
    for(int i=0; i<m; ++i)
    {
        int a,b; cin>>a>>b; --a,--b;
        uf.unite(a,b);
    }
    size_t ans{};
    for(int i=0; i<n; ++i)
    {
        ans=max(ans,uf.size(i));
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N, M; cin >> N >> M;
  vector <int> cnt(N);

  for (int i = 0; i < M; i++){
    int a, b; cin >> a >> b;
    a--; b--;
    cnt[a]++; cnt[b]++;
  }

  bool ans = true;
  for (int i = 0; i < N; i++){
    if (cnt[i] % 2 == 1){
      ans = false;
    }
  }

  if (ans == false){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
  
  
  
   
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
	int i,s=0,in[500][2],tate,yoko;
	for(i=0;i<500;i++){
		scanf("%d %d",&in[i][0],&in[i][1]);
		if(in[i][0]==0&&in[i][1]==0)
			break;
		s++;
	}
	for(i=0;i<s;i++){
		for(tate=0;tate<in[i][0];tate++){
			if(tate%2==0){
				for(yoko=0;yoko<in[i][1];yoko++){
					if(yoko%2==0)
						printf("#");
					else
						printf(".");
				}
				printf("\n");	
			}
			else{
				for(yoko=0;yoko<in[i][1];yoko++){
					if(yoko%2==1)
						printf("#");
					else
						printf(".");
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 1804
use std::io::*;
use std::str::FromStr;
use std::cmp;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut a = vec![0; n];
    for i in 0..n {
        a[i] = read::<i64>();
    }
    a.sort();
    println!("{}", a[a.len() - 1] - a[0]);
}

Measured memory_bytes: 4352