akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int a[N]; rep(i,N) cin >> a[i];

  int result = pow(2,29);
  for(int n=-100; n<=100; n++){
    int tmp = 0;
    rep(i, N) tmp += pow(a[i]-n, 2);
    result = min(result, tmp);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  //cout << fixed << setprecision(12);
  cout << fixed << setprecision(4);

  while(1){
    Int r, N;
    cin>>r>>N;
    if(r == 0 && N == 0) break;

    vector<Int> mp(50);
    for(Int i=0;i<N;i++){
      Int l, r, h;
      cin>>l>>r>>h;
      l += 25;
      r += 25;
      for(Int x=l;x<r;x++) Max(mp[x], h);
    }

    auto dis = [&](Double x, Double y, Double a, Double b){
      return sqrt( (x - a) * (x - a) + (y - b) * (y - b));
    };

    auto check = [&](Double cy){
      Double cx = 25;
      Double H = cy + r;
      Double W = r;
      if(cy < 0) W = sqrt(r * r - cy * cy);

      for(Int x=1;x<49;x++){
        if(dis(cx, cy, x, mp[x]) < r) return (Int)0;
        if(dis(cx, cy, x, mp[x-1]) < r) return (Int)0;

        Int h = cy >= 0? cy:0;
        //if(x <= cx - W && cx - W <= x + 1 && mp[x-1] < h) return (Int)0;
        //if(x <= cx + W && cx + W <= x + 1 && mp[x] < h) return (Int)0;

        if(cx - W < x && x < cx + W){
          if(mp[x] < h) return (Int)0;
          if(cx - W != x && mp[x-1] < h) return (Int)0;

        }
      }
      return (Int)1;
    };

    Double L = 0, R = 100;
    for(Int t=0;t<100;t++){
      Double M = (L + R) / 2;
      if(check(M - r)) L = M;
      else R = M;
    }

    cout<<L<<endl;
  }
  return 0;
}



Measured memory_bytes: 3232
n=io.read("*number")
a=io.read("*number")
b=io.read("*number")
function solve()
	if a > b then
		return 0
	end
	if n == 1 then
		if a == b then
			return 1
		else
			return 0
		end
	end
	return a + (n - 1) * b - ( b + (n - 1) * a ) + 1
end

print(solve())

Measured memory_bytes: 888
#include <iostream>
#include <queue>
#include <map>

using namespace std;

typedef pair<int,int> P;
typedef queue<P> Q;

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

#define mp make_pair

int w,h;
char fie[21][21];

void bfs(int x, int y){
    Q q;
    q.push(mp(x,y));
    while(!q.empty()){
        for(int i=0; i<4; i++){
            int xx = q.front().first + dx[i];
            int yy = q.front().second + dy[i];
            if(0 <= xx && xx < w && 0 <= yy && yy < h && fie[yy][xx] == '.'){
                fie[yy][xx] = '@';
                q.push(mp(xx,yy));
            }
        }
        q.pop();
    }
}

int main(){
    while(cin >> w >> h , w||h){
        int sx,sy;
        for(int i=0; i<h; i++){
            cin >> fie[i];
            for(int j=0; j<w; j++){
                if(fie[i][j] == '@'){
                    sx = j; sy = i;
                }
            }
        }
        bfs(sx,sy);
        int ans = 0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(fie[i][j] == '@') ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<int> a(N);
	int sum = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		sum += a[i];
	}
	int minIndex = 0;
	int minVal = 1e9;
	for (int i = 0; i < N; ++i)
	{
		if (minVal > abs(sum - N * a[i]))
		{
			minVal = abs(sum - N * a[i]);
			minIndex = i;
		}
	}
	cout << minIndex << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 
int w[110];
int n,ans=INF;
signed main(){
    cin>>n;
    rep(i,n)cin>>w[i];

    rep(t,n){
        int s1=0;int s2=0;
        rep(i,t)s1+=w[i];
        for(int i=t;i<n;i++)s2+=w[i];
        ans=min(ans,abs(s2-s1));
    }
    cout<<ans<<endl;
 
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int h = sc.nextInt();
			int n = sc.nextInt();
			List<Magic> list = new ArrayList<Magic>();
			for (int i = 0; i < n; i++) {
				list.add(new Magic(sc.nextInt(), sc.nextInt()));
			}

			System.out.println(calcDP(list, h));

		}
	}

	static long calcDP(List<Magic> list, int hp) {
		Comparator<Magic> comparator = new Comparator<Magic>() {
			@Override
			public int compare(Magic a, Magic b) {
				return a.a - b.a;
			}
		};
		int minA = Collections.min(list, comparator).a;
		int maxA = Collections.max(list, comparator).a;

		Long[] dp = new Long[hp + maxA];

		dp[0] = 0L;

		for (int d = minA; d < hp + maxA; d++) {
			for (Magic magic : list) {
				if (d - magic.a >= 0 && dp[d - magic.a] != null && (dp[d] == null || dp[d - magic.a] + magic.b < dp[d])) {
					dp[d] = dp[d - magic.a] + magic.b;
				}
			}
		}

		Long minMp = null;
		for (int d = hp; d < hp + maxA; d++) {
			if (dp[d] != null && (minMp == null || dp[d] < minMp)) {
				minMp = dp[d];
			}
		}

		return minMp;

	}
}

class Magic {
	int a;
	int b;
	Magic(int a, int b) {
		this.a = a;
		this.b = b;
	}
}


Measured memory_bytes: 28600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9+7
#define ll long long
#define f(x) for(ull i=0;i<x;i++)
#define F first
#define S second
#define N 100005
#define M 1000000009
#define mp make_pair
#define ull unsigned long long
#define sc(n) scanf("%d",&n)
#define gcd __gcd
using namespace std;
int a[N];
int main() {
	ios::sync_with_stdio(false);
    int n,k;
    ll b=0,sum=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(i<=k)
            sum+=a[i];
        else if(a[i]>0)
            b+=a[i];
    }
    ll m=max(sum+b,b);
    for(int i=2;i<=n-k+1;i++){
        sum=sum-a[i-1]+a[i+k-1];
        if(a[i-1]>0)
            b+=a[i-1];
        if(a[i+k-1]>0)
            b-=a[i+k-1];
        m=max(m,max(sum+b,b));
    }
    cout<<m<<endl;
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



string s;
void solve(){
	cin >> s;
	if(s[1] == 'B') s[1] = 'R';
	else s[1] = 'B';
	cout << s << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 998244353;

int v[50],c[50];

int main(void){
  int n;
  cin >> n;
  for(int i = 0;i < n;++i){
    cin >> v[i];
  }
  for(int i = 0;i < n;++i){
    cin >> c[i];
  }
  int res = 0;
  for(int i = 0;i < n;++i){
    res += max(0, v[i]-c[i]);
  }
  cout << res << endl;
  return 0;
}


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

typedef long long ll;

const int MAXN = 1e4 + 10;
const int MAXD = 1e2 + 10;
const int MOD = 1e9 + 7;

vector<int> digitos;
string s;
int N,D;
ll dp[MAXN][2][MAXD];

ll solve(int pos,int flag,int resto){

	if(pos == N) return (resto == 0);
	if(dp[pos][flag][resto] != -1) return dp[pos][flag][resto];

	ll tot = 0;
	int limit = (flag) ? (digitos[pos]) : (9);
	for(int i = 0;i<=limit;i++){
		tot += solve(pos+1,flag && (i == limit), (resto + i) % D );
	}

	return dp[pos][flag][resto] = tot % MOD;

}

int main(){

	cin >> s;
	cin >> D;
	N = (int)s.size();
	for(int i = 0;i<N;i++){
		digitos.push_back(s[i] - '0');
	}
	memset(dp,-1,sizeof(dp));

	ll ans = solve(0,1,0) - 1;
	if(ans < 0) ans += MOD;
	cout << ans << endl;


	return 0;

}

Measured memory_bytes: 18432
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let s = it
        .next()
        .unwrap()
        .chars()
        .map(|x| x.to_digit(10).unwrap())
        .collect::<Vec<_>>();
    let n = s.len();
    let mut r = vec![0; 2020];
    r[0] = 1;
    let mut prev = 0;
    let mut x = 1;
    for i in (0..s.len()).rev() {
        prev = (prev + x * s[i]) % 2019;
        r[prev as usize] += 1;
        x = (x * 10) % 2019;
    }
    let mut ret = 0;
    for ri in r {
        if ri > 0 {
            ret += ri * (ri - 1) / 2;
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2964
def examA():
    S, T = LSI()
    A, B = LI()
    U = SI()
    if S==U:
        print(A-1,B)
    else:
        print(A,B-1)
    return

def examB():
    S = SI()
    N = len(S)
    ans = ""
    for i in range(N):
        ans += "x"
    print(ans)
    return

def examC():
    N = I()
    A = LI()
    d = defaultdict(int)
    for a in A:
        d[a] += 1
        if d[a]>=2:
            print("NO")
            return
    print("YES")
    return

def examD():
    N, K = LI()
    P = LI()
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    ans = 0
    for i in range(N-K+1):
        cur = S[i+K]-S[i]
        ans = max(ans,cur)
    print(ans)
    return

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

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

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.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)]

if __name__ == '__main__':
    examD()

"""

"""

Measured memory_bytes: 73592
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long int ll;
const int MAXN = 2e3 + 10;
int cnt[MAXN];
int main(void){
    ll n , x , y ;
    cin >> n >> x >> y ;

    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ll w = j - i;
            w = min(w , abs(i - x) + 1 + abs(y - j));
            cnt[w]++;
        }
    }
    for (int i = 1; i <= n - 1; i++) {
       cout << cnt[i]<< endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, l[2000];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> l[i];
	sort(l, l + n);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int x = l[i] + l[j];
			ans += lower_bound(l + j + 1, l + n, x) - lower_bound(l + j + 1, l + n, l[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

long long in(){
	long long n;
	scanf("%lld",&n);
	return n;
}


//owari
int main(){
	//ios_base::sync_with_stdio(false);
	int L;
	cin >> L;
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	int X = max( (A+C-1) / C , (B+D-1) / D );
	cout << max(0,L - X) << endl;
}

Measured memory_bytes: 1168
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    res = 700
    for i in r:
        if i == "o":
            res += 100
    print(res)

if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  vector<int> a(4);
  rep(i,4){
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
    cout << "YES" << "\n";
  }
  else{
    cout << "NO" << "\n";
  }

  
  return 0;
}


Measured memory_bytes: 256
import java.text.ParseException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws ParseException {

		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		for (char d : c) {
			int count=0;
			for (char e : c) {
				if(d==e) count++;
			}
			if(count != 2) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


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

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REP2(i, a) REP3(i, 0, a)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += (s))
#define REPR(...) GET_MACRO(__VA_ARGS__, REPR4, REPR3, REPR2)(__VA_ARGS__)
#define REPR2(i, a) REPR3(i, 0, a)
#define REPR3(i, a, b) REPR4(i, a, b, 1)
#define REPR4(i, a, b, s) for (int i = (b)-1; i >= (int)(a); i -= (s))
#define ALL(c) (c).begin(), (c).end()
#define DUMP(x) (std::cerr << #x << ':' << ' ' << x << '\n')
#define TMPL_T template <typename T>
#define TMPL_TU template <typename T, typename U>
#define mut auto
#define let const auto

using Int = long long;
// clang-format off
namespace extio {
std::string delimiter=" ",pdelimiter=" ";
std::string bracket_b="",bracket_e="";
void chdelim(const std::string&s){delimiter=s;}
void chpdelim(const std::string&s){pdelimiter=s;}
void chbracket(const std::string&b,const std::string&e){bracket_b=b,bracket_e=e;}
TMPL_T  void pcont(std::ostream&os,const T&x){int c=0;for(const auto&a:x){if(c++)os<<delimiter;os<<a;}}
TMPL_TU void ppair(std::ostream&os,const std::pair<T,U>&p){os<<bracket_b<<p.first<<pdelimiter<<p.second<<bracket_e;}
}
namespace std {
TMPL_T ostream& operator<<(ostream&os,const vector<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const set<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const multiset<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const deque<T>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const map<T,U>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const pair<T,U>&x){extio::ppair(os,x);return os;}
}
TMPL_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
TMPL_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}

inline int in(){int x;std::cin>>x;return x;}

struct Initializer_ {
  Initializer_(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(0);
    std::cout << std::setprecision(10);
    std::cerr << std::setprecision(10);
  }
} precalc;
// clang-format on
// }}}

using namespace std;

signed main() {
  int a, b;
  while (cin >> a >> b) {
    cout << to_string(a + b).size() << endl;
  }
  return 0;
}

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

int main(){
	int N;
	scanf("%d", &N);
	int a[N], b[N];
	for (int i = 0; i < N; ++i) scanf("%d", a + i);
	for (int i = 0; i < N; ++i) scanf("%d", b + i);
	int answer = 0, T = 1 << 28;
	bool digit = false;
	sort(b, b + N);
	for (int i = 0; i < N; ++i)	digit ^= distance(lower_bound(b, b + N, T - a[i]), b + N) & 1;
	if(digit) answer += T;
	T >>= 1;
	digit = false;
	for (int i = 0; i < N; ++i)	digit ^= (distance(lower_bound(b, b + N, T - a[i]), lower_bound(b, b + N, T*2 - a[i])) ^ distance(lower_bound(b, b + N, T*3 - a[i]), b + N)) & 1;
	if(digit) answer += T;
	for (int i = 27; i > 0; --i){
		T >>= 1;
		digit = false;
		for (int j = 0; j < N; ++j){
			a[j] %= (1 << i);
			b[j] %= (1 << i);
		}
		sort(b, b + N);
		for (int j = 0; j < N; ++j)	digit ^= (distance(lower_bound(b, b + N, T - a[j]), lower_bound(b, b + N, T*2 - a[j])) ^ distance(lower_bound(b, b + N, T*3 - a[j]), b + N)) & 1;
		if(digit) answer += T;
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
	double r;
	cin >> r;
	cout << fixed << setprecision(6) << r * r*M_PI << ' ' << 2 * r*M_PI << endl;
	return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <unordered_map> //C++11
using namespace std;

typedef long long ll;

ll fact(ll);

int main() {
	ll n, m;
	cin >> n >> m;
	if (abs(n - m) > 1) cout << 0 << endl;
	else {
		ll factn = 1, factm = 1;
		for (ll i = 1; i <= n; i++) factn = (factn*i)%1000000007;
		for (ll i = 1; i <= m; i++) factm = (factm*i) % 1000000007;
		factn %= 1000000007;
		factm %= 1000000007;
		if (n == m) cout << (((factn*factm) % 1000000007) * 2) % 1000000007 << endl;
		else cout << (factn*factm) % 1000000007 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector<int> L(N);
    for(int i=0; i<N; i++) {
        scanf("%d", &L[i]);
    }
    sort(L.begin(), L.end());

    int ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            for(int k=j+1; k<N; k++) {
                if(L[i] == L[j]) continue;
                if(L[j] == L[k]) continue;
                if(L[k] == L[i]) continue;
                if(L[k] < L[i] + L[j]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3672
using System;

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int width = int.Parse(input.Split(' ')[0]);
            int a = int.Parse(input.Split(' ')[1]);
            int b = int.Parse(input.Split(' ')[2]);
            int answer = 0;
            //b- (w+a)
            if(b >= a)
            {
                answer = b - (width + a);
                if(answer > 0)
                {
                    Console.WriteLine(answer);
                }
                else
                {
                    Console.WriteLine(0);
                }
            }
            else if(b < a)
            {
                answer = a - (width + b);
                if (answer > 0)
                {
                    Console.WriteLine(answer);
                }
                else
                {
                    Console.WriteLine(0);
                }
            }
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int b[n];
    for (int i = 0; i < n-1; ++i){
        cin >> b[i];
    }

    int count = b[0] + b[n-2]; //i==0 or i==n
    for (int i = 1; i < n-1; ++i){
        if (b[i-1] < b[i]){
            count+=b[i-1];
        }else{
            count+=b[i];
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
//1181100049 大町泰史
using System;
class a
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int k = int.Parse(str[1]);
        int q = int.Parse(str[2]);
        int[] count = new int[n];
        for(int i = 0; i < n; i++)
        {
            count[i] = 0;
        }
        for (int i = 0; i < q; i++)
        {
            int a = int.Parse(Console.ReadLine());
            count[a-1]++;
        }
        for (int i = 0; i < n;i++)
        {
            if (q - count[i] < k)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 15708
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int t[] = {60, 60, 24};
    int x[] = new int[3];
    int S = in.nextInt();
    for (int i = 0; i < 3; i++) {
      x[i] = S % t[i];
      S = S / t[i];
    }
    System.out.printf("%d:%d:%d\n", x[2], x[1], x[0]);
  }
}

Measured memory_bytes: 26336
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
p = []
idx = [0]*(n+1)

for _ in range(n):
    p.append(ni())

for i,pi in enumerate(p):
    idx[pi] = i+1

con = [0]*(n+1)
con[1] = 1
for i in range(1,n):
    if idx[i] < idx[i+1]:
        con[i+1] = con[i] + 1
    else:
        con[i+1] = 1
        
print(n - max(con))

Measured memory_bytes: 26828
#include<bits/stdc++.h>
#define int long long int
const int mod=1e9+7;
#define fastinout     ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int imod(int a, int m)
{
    return power(a, m - 2, m);
}

void myfun()
{
	int n,i;
	cin>>n;
	if(n==0)
	cout<<1;
	else
	cout<<0;
}

signed main()
{
	 fastinout;
	int t=1;
	//cin>>t;
	while(t--)
	myfun();
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll ans=1e18;
  for(ll i=1;i*i<=n;i++) {
    if(n%i!=0) continue;
    ll j=n/i;
    ans=min(ans,i+j-2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    // vector<string> S(N);
    vector<vector<int>> map(N, vector<int>(26));
    string str;
    int index;
    for (int i = 0; i < N; i++)
    {
        cin >> str;
        for (int j = 0; j < str.size(); j++)
        {
            index = str[j] - 'a';
            map[i][index]++;
        }
    }

    // debug
    // for (int i = 0; i < N; i++)
    // {
    //     for (int j = 0; j < 26; j++)
    //     {
    //         printf("%d ", map[i][j]);
    //     }
    //     printf("\n");
    // }

    string ans = "";
    int mn;
    for (int i = 0; i < 26; i++)
    {
        mn = INF;
        for (int j = 0; j < N; j++)
        {
            if (map[j][i] == 0)
            {
                break;
            }
            else
            {
                mn = min(mn, map[j][i]);
            }
            if (j == N - 1)
            {
                for (int k = 0; k < mn; k++)
                {
                    ans += 'a' + i;
                }
            }
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main(){
  int N,ans=0,L=0;
  cin>>N;
  
  string S[N],X;
  int T[N];
  
  REP(i,N) cin>>S[i]>>T[i];
  cin>>X;
  
  REP(i,N) if(S[i]==X) L=i+1;
  
  for(int i=L; i<N; ++i) ans+=T[i];
  co(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

	public class Main {

		static long mod = 1000000007;

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			String[] t = sc.nextLine().split(" ");
			long n = Long.parseLong(t[0]);
			long k = Long.parseLong(t[1].replaceAll("\\.", ""));

			System.out.println(n * k / 100);
		}
	}


Measured memory_bytes: 35640
N=int(input())
H=list(map(int,input().split()))
H.reverse()
cnt=0
ans=0

for i in range(N-1):
    if H[i]<=H[i+1]:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
        
ans=max(ans,cnt)

print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
const int MAX=1e6+9;
const int mod=1e9+7;
using namespace std;
int cnt[MAX];

int main(){
	ll n,m,c;
	cin>>n>>m;
	pair<ll,ll>p[n+3];
	for(int i=0;i<n;i++)
	{
		cin>>p[i].first>>p[i].second;
	}
	sort(p,p+n);
	ll tot=0;
	for(int i=0;i<n;i++){
		if(m>p[i].second){
			tot=tot+p[i].first*p[i].second;
			m=m-p[i].second;
		}
		else if(m>0)
		{
			tot=tot+m*p[i].first;
			m=0;
		}
	}
	cout<<tot;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..

 int dp[100005];

int main(void) {

  int n;
  cin >> n;
  int h[n + 1];
  rep (i, n) cin >> h[i + 1];

  dp[n] = 0;
  dp[n - 1] = abs(h[n] - h[n - 1]);

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

  cout << dp[1] << endl;

  return 0;
}

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

using namespace std;

using ll = long long;

constexpr ll mod = 1e9 + 7;

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

  int n;
  cin >> n;

  string s;
  cin >> s;

  vector<vector<ll>> dp(n, vector<ll>(n));
  dp[0][0] = 1;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '>') {
      ll acc = dp[i][i];
      for (int j = i; j >= 0; --j) {
        dp[i + 1][j] = acc;
        if (j - 1 >= 0) {
          acc = (acc + dp[i][j - 1]) % mod;
        }
      }
    } else {
      ll acc = dp[i][0];
      for (int j = 1; j <= i + 1; ++j) {
        dp[i + 1][j] = acc;
        acc = (acc + dp[i][j]) % mod;
      }
    }
  }

  cout << accumulate(dp[n - 1].begin(), dp[n - 1].end(), 0LL) % mod << '\n';

  return 0;
}


Measured memory_bytes: 70656
/**/
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],b[100001],ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		ans+=b[i]-a[i]+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>

using namespace std;

#define MAX_N 100000
#define MAX_Q 50000
int S[MAX_N];
int T[MAX_Q];

int main(int argc, char** argv) {
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> S[i];
  }

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

  set<int> s;
  for(int i = 0; i < n; ++i) {
    s.insert(S[i]);
  }

  int r = 0;
  for(int i = 0; i < q; ++i) {
    if (s.find(T[i]) != s.end()) {
      r += 1;
    }
  }
  cout << r << endl;

  // NOTE: for debug
  // cout << "n: " << n << endl;
  // cout << "S: ";
  // for(int i = 0; i < n; ++i) {
  //   cout << S[i] << " ";
  // }
  // cout << endl;

  // BinSearch b0;
  // int ans = b0.bin_search;
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 8252
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;



int main(){
    
    for(string s; cin >> s;){
        if(s == "#")break;
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll mp[10][10] = {};
        ll w = 0, h = 1;
        for(ll i = 0, y = 0, x = 0; i < s.size(); i++){
            if(s[i] == '/'){
                w = x;
                x = 0;
                y++;
                h++;
                continue;
            }
            if(s[i] == 'b'){
                mp[y][x] = 1;
                x++;
                continue;
            }
            int step = s[i] - '0';
            x += step;
        }
        a--;
        b--;
        c--;
        d--;
        swap(mp[a][b], mp[c][d]);
        stringstream ss;
        for(ll y = 0; y < h; y++){
            if(y)ss<<"/";
            for(ll x = 0; x < w; x++){
                if(mp[y][x])ss << "b";
                else{
                    ll cnt = 0;
                    for(;;){
                        cnt++;
                        if(x+1==w)break;
                        if(mp[y][x+1])break;
                        x++;
                    }
                    ss << cnt;
                }
            }
        }
        cout << ss.str() << endl;
    }
    
    return 0;    
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 200005;

vector<int> A[maxn];

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

   int f = 1;

   _for(i,0,N){
        int num;
        cin >> num;
        if(num == f) f++;
   }

   if(f == 1) cout << -1 << endl;
   else cout << N - f + 1 << endl;




    return 0;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int H, W;

int c[10][10];

int A[201][201];

int main(void) {

	cin >> H >> W;

	int tmp;

	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			cin >> tmp;
			c[i][j] = tmp;
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> tmp;
			A[i][j] = tmp;
		}
	}

	//=========================
	for (int u = 1; u <= 10; u++) {
		for (int i = 0; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				for (int k = 0; k <= 9; k++) {
					if (c[i][j] > c[i][k] + c[k][j]) { c[i][j] = c[i][k] + c[k][j]; }
				}
			}
		}
	}

/*	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			cout << " " << c[i][j];
		}cout << endl;

	}*/

	long long int count = 0;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (A[i][j] == -1) { continue; }
			else { count += c[A[i][j]][1]; }
		}
	}

	cout << count << endl;

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

Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s = read().rstrip().decode()
cnt = 0
for i in range(1000):
    num = ''
    if i < 100:
        num += '0'
        if i < 10:
            num += '0'
    num += str(i)
    index = 0
    for ss in s:
        if ss == num[index]:
            index += 1
            if index == 3:
                cnt += 1
                break
print(cnt)


Measured memory_bytes: 41180
N = int(input())

TA = [[int(_) for _ in input().split()] for _ in range(N)]

x, y = 1, 1


def ceil(a, b):
    return a // b + (a % b > 0)


for t, a in TA:
    tv = ceil(x, t)
    av = ceil(y, a)
    n = max(tv, av)
    x = n * t
    y = n * a
print(x + y)


Measured memory_bytes: 3188
def solve(N, W, vals, weights):
    dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
    for i in range(N):
        for w in range(W + 1):
            if weights[i] <= w:
                dp[i + 1][w] = max(dp[i][w - weights[i]] + vals[i], dp[i][w])
            else:
                dp[i + 1][w] = dp[i][w]
    print(dp[N][W])

if __name__ == "__main__":
    N, W = map(int, input().split())
    vals = []
    weights = []
    for _ in range(N):
        v, w = map(int, input().split())
        vals.append(v)
        weights.append(w)
    solve(N, W, vals, weights)


Measured memory_bytes: 42272
from collections import defaultdict as dd

n, m = map(int, input().split())
H = [0] + list(map(int, input().split()))
# print(H)

road = set()
for i in range(m):
    a, b = map(int, input().split())
    road.add((a, b))

counter = 0
not_highest = set()
for a, b in road:
    if H[a] == H[b]:
        not_highest.add(a)
        not_highest.add(b)
    elif H[a] > H[b]:
        not_highest.add(b)
    elif H[b] > H[a]:
        not_highest.add(a)

print(n - len(not_highest))

Measured memory_bytes: 100328
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if a <= c && c <= b && b <= d {
		fmt.Println(b - c)
	} else if a <= c && c < d && d <= b {
		fmt.Println(d - c)
	} else if c <= a && a < b && b <= d {
		fmt.Println(b - a)
	} else if c <= a && a <= d && d <= b {
		fmt.Println(d - a)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
#include<iostream>

int main() {
	char s[11];
	std::cin >> s;

	int length = 0;
	for (int i = 0; s[i] != '\0'; i++)length++;

	long long int ans = 0;
	for (int i = 0; i < 1 << length-1; i++) {
		long long int temp = s[0] - '0', sum = 0;
		for (int j = 1; j < length; j++) {
			if (i >> j-1 & 1) {
				sum += temp;
				temp = s[j] - '0';
			}
			else {
				temp = temp * 10 + s[j] - '0';
			}
		}
		sum += temp;
		//printf("%lld\n", sum);
		ans += sum;
	}

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

Measured memory_bytes: 256
/*
                        Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x)%M;
            x=(x*x)%M;
            n=n/2;
        }
    return result%M;
}      
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi
    int n;
    cin>>n;
    bool x=false;
    while(n)
    {   int y=n%10;
        if(y==7)
        x=true;
        n=n/10;
    }
    if(x)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> a(N);
  rep(i,N) cin >> a[i];

  int ans = *max_element(all(a)) - *min_element(all(a));
  cout << ans << endl;
}


Measured memory_bytes: 3632
import collections
#入力
N = int(input())
n = 100001
Alist = list(map(int,input().split()))
Q = int(input())
Blist = []
Clist = []
for i in range(Q):
  B, C = map(int,input().split())
  Blist.append(B)
  Clist.append(C)

Adic = dict(collections.Counter(Alist))
numlist = [0]*n

for j in range(n):
  if j in Adic:
    numlist[j] = Adic[j]
sum = sum(Alist)
for k in range(Q):
  sum += (Clist[k]-Blist[k])*numlist[Blist[k]]
  numlist[Clist[k]] += numlist[Blist[k]] 
  numlist[Blist[k]] = 0

  print(sum)

Measured memory_bytes: 27340
k, houses = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

res = 1000000000

houses.times do |i|
  tmp = k
  
  if i == 0
    tmp -= (a[i] + k) - a[houses - 1]
  else
    tmp -= a[i] - a[i - 1]
  end
  
  res = tmp if tmp < res
end

puts res

Measured memory_bytes: 15364
#include<iostream>
#include<cstdio>
#include<vector>
#define gmx(x,y) x=(x>(y)?x:(y))
#define gmi(x,y) x=(x<(y)?x:(y))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=200200,INF=1000010000;
int n,m,Q,X,Y,cx,cy,mi,t[2],a[N],b[N],c[2][N];
char s[N];
struct ele{
	int k,x,y;
	ele(int _k=0,int _x=0,int _y=0){k=_k,x=_x,y=_y;}
};
vector<ele>q[N];
void cha(int k,int x,int y,int I){
	for(;x<=m;x+=x&-x)
		q[I].push_back(ele(k,x,c[k][x])),gmx(c[k][x],y);
}
int ask(int k,int x){int y=-INF;for(;x;x-=x&-x) gmx(y,c[k][x]);return y;}
bool chk(int X,int C){return C>=0 && ask(C&1,X)>=C;}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);m=n+1;
	FOR(i,1,n) scanf("%d",&a[i]),a[i]=m-a[i];
	a[0]=INF;
	FOR(i,1,n)if(a[i]<a[mi]) mi=i,b[i]=1,Q++;
	//FOR(i,1,n) cout<<a[i]<<' ';cout<<'\n';
	//FOR(i,1,n) cout<<b[i]<<' ';cout<<'\n';
	FOR(i,1,n) c[1][i]=-INF;
	ROF(i,n,1){
		FOR(k,0,1) t[k]=ask(k,a[i]);
		//cout<<t[0]<<' '<<t[1]<<'\n';
		FOR(k,0,1) cha(k^b[i]^1,a[i],t[k]+b[i]+1,i);
	}
	if(ask(Q&1,n)<Q) return puts("-1"),0;
	X=Y=n+1;
	FOR(i,1,n){
		for(ele e:q[i]) c[e.k][e.x]=e.y;Q-=b[i];
		int tX=X,tC=cx;
		cx+=a[i]<X;gmi(X,a[i]);s[i]='0';
		//cout<<X<<' '<<cx<<' '<<Y<<' '<<cy<<' '<<Q<<'\n';
		if(!chk(X,cy+Q-cx) && !chk(Y,cx+Q-cy))
			s[i]='1',X=tX,cx=tC,cy+=a[i]<Y,gmi(Y,a[i]);
	}
	puts(s+1);
}

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

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


int main() {
  int n,k,d,a,ans=0;
  vector<bool> f(10001,false);
  cin >> n >> k;
  rep(i,k) {
    cin >> d;
    rep(j,d){
      cin >> a;
      f[a-1] = true;
    }
  }
  rep(i,n){
    if(!f[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624