akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

#include <complex>
typedef complex<double> P;

#define EQ(x,y) (abs((x)-(y))<EPS)
#define EQV(a,b) (EQ((a).real(),(b).real())&&EQ((a).imag(),(b).imag()))

namespace std {
	bool operator<(const P &a, const P &b) {
		return a.real()!=b.real() ? a.real()<b.real() : a.imag()<b.imag();
	}
}

double cross(P a, P b) {
	return a.real()*b.imag()-a.imag()*b.real();
}

int is_point_on_ls(P a, P b, P c) {
	return (abs(a-c)+abs(c-b)<abs(a-b)+EPS);
}

int is_intersection_ls(P a1, P a2, P b1, P b2) {
	if((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < -EPS) &&
		(cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < -EPS))
		return true;
	return is_point_on_ls(a1, a2, b1) || is_point_on_ls(a1, a2, b2) ||
		is_point_on_ls(b1, b2, a1) || is_point_on_ls(b1, b2, a2);
}

P intersection_ls(P a1, P a2, P b1, P b2) {
	P b = b2-b1;
	double d1 = abs(cross(b, a1-b1));
	double d2 = abs(cross(b, a2-b1));
	double t = d1/(d1+d2);

	return a1+(a2-a1)*t;
}

typedef vector<P> vp;

struct crossPoint {
	P p;
	pii info;
	crossPoint(P p, pii info) : p(p), info(info) {};
};

namespace std {
	bool operator<(const crossPoint &a, const crossPoint &b) {
		return a.p.real()!=b.p.real() ? a.p.real()<b.p.real() : a.p.imag()<b.p.imag();
	}
}

int getUpDown(int f, vector<crossPoint> cp) {
	int res = 0;
	int size = cp.size();
	REP(i, size) {
		if(cp[i].info.first == 0) {
			if(f != cp[i].info.second) {
				f = 1-f;
				res++;
			}
		} else {
			if(f == cp[i].info.second) {
				f = 1-f;
				res++;
			}
		}
	}

	return res;
}

int main() {
	int m;
	cin >> m;
	REP(szg, m) {
		double xa, ya, xb, yb;
		int n;
		cin >> xa >> ya >> xb >> yb >> n;
		P a = P(xa, ya), b = P(xb, yb); 
		
		double xs, ys, xt, yt;
		vi o(n), l(n);
		vector<vp> lines(n, vp(2));
		REP(i, n) {
			cin >> xs >> ys >> xt >> yt >> o[i] >> l[i];
			lines[i][0] = P(xs, ys);
			lines[i][1] = P(xt, yt);
		}

		vi isCross(n, 0);
		vector<crossPoint> cp;
		REP(i, n) {
			if(is_intersection_ls(a, b, lines[i][0], lines[i][1])) {
				P p = intersection_ls(a, b, lines[i][0], lines[i][1]);
				cp.push_back(crossPoint(p, pii(o[i], l[i])));
			}
		}

		sort(ALL(cp));
		int size = cp.size();
		int ans = min(size, min(getUpDown(0, cp), getUpDown(1, cp)));

		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 1268
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []

AC_codes = 0

for _ in range(N):
  A.append(list(map(int, input().split())))

for i in A:
  for j in range(len(B)):
    i[j] = i[j] * B[j]
  if sum(i) + C > 0:
    AC_codes += 1
print(AC_codes)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  int i;
  i = (a < b)? a : b;
  a -= i; b -= i;
  a = (a < b)? b : a;
  //printf("i: %d\n", i);
  if(2*a <= 16 - 2*i){ printf("Yay!\n"); } else { printf(":(\n"); }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll a,b,c;cin>>a>>b>>c;
  if(a%2==0&&b%2==0&&c%2==0&&a==b&&b==c){
    cout << -1 << endl;
  } else {
    ll cnt = 0;
    while(a%2==0&&b%2==0&&c%2==0){
      ll ta = b/2 + c/2;
      ll tb = c/2 + a/2;
      ll tc = a/2 + b/2;
      a = ta;
      b = tb;
      c = tc;
      ++cnt;
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import itertools
#0-indexed
N = int(input())
A = [[int(_) - 1 for _ in input().split()][::-1] for _ in range(N)]
ans = 0
cand = range(N)
left = 1
while True:
    cand_ = set()
    for i in cand:
        v = A[i]
        if not len(v):
            continue
        if A[v[-1]][-1] == i:
            f = 0
            cand_.add(i)
            cand_.add(v[-1])
    if not cand_:
        break
    cand = cand_
    left = 0
    for i in cand:
        A[i].pop()
        left |= len(A[i]) > 0
    ans += 1
if left:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 34804
#include<bits/stdc++.h>
using namespace std;
int n,k,i,j,x[200001],y,t,p;
int main(){
    cin>>n>>k;
    for(i=1;i<=n;i++){
		cin>>t;
   		x[t]++;
	}
   	sort(x+1,x+n+1);
   	for(i=n;i>n-k;i--) y+=x[i];
   	cout<<n-y<<endl;
   	return 0;
}

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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int mod = 1e9 + 7;

void solve(void) {

	int n, k;
	cin >> n >> k;

	vi A(n);
	for(int& x : A) cin >> x;

	vector<ll> dp(k+1);
	dp[0] = 1;

	vector<ll> pre(k+2);

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

		for(int i = 1; i <= k + 1; i++)
			pre[i] = (pre[i-1] + dp[i-1]) % mod;

		for(int j = 0; j <= k; j++) {
			dp[j] = (dp[j] + pre[j] - pre[max(0, j-A[i])]) % mod;
			if(dp[j] < 0) dp[j] += mod;
		}

	}

	cout << dp[k] << '\n';
}

int main(void) {

	solve();

	return 0;
}


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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        double d = Double.parseDouble(str[0]);
        double t = Double.parseDouble(str[1]);
        double s = Double.parseDouble(str[2]);

        if ( (d/s) > t )
            System.out.println("No");
        else
            System.out.println("Yes");

    }
}


Measured memory_bytes: 33184
N, M = gets.split.map(&:to_i)
array = Array.new(M).map{Array.new(4,0)}
count = 0
M.times do
  pr, y = gets.split.map(&:to_i)
  array[count][0] = pr
  array[count][1] = y
  array[count][2] = count
  count += 1
end
array.sort! { |a,b| a[1] <=> b[1] }
pref = Array.new(N,1)
M.times do |i|
  a = array[i][0]
  array[i][3] = ( a.to_s.rjust(6,"0") + (pref[a-1]).to_s.rjust(6, "0") )
  pref[a-1] += 1
end
array.sort! { |a,b| a[2] <=> b[2] }
M.times do |i|
  puts array[i][3]
end


Measured memory_bytes: 23024
use proconio::input;
use proconio::marker::Usize1;
use std::collections::BinaryHeap;
use std::cmp::Reverse;

fn main()
{
    input! {
    n:usize,
    m:usize,
    edge:[(Usize1,Usize1,i64);m],
    }

    let mut v = vec![vec![]; n];
    for i in 1..n {
        v[i].push((i - 1, 0));
    }
    for (a, b, c) in edge {
        v[a].push((b, c));
    }

    let inf = 1i64 << 60;
    let mut dist = vec![inf; n];

    let mut q = BinaryHeap::new();
    q.push(Reverse((0, 0)));

    while let Some(Reverse((dst, idx))) = q.pop() {
        if dist[idx] < dst {
            continue;
        }
        for &(nxt, cost) in v[idx].iter() {
            let dst = dst + cost;
            if dist[nxt] <= dst {
                continue;
            }
            dist[nxt] = dst;
            q.push(Reverse((dst, nxt)));
        }
    }

    let ans = if dist[n - 1] == inf {
        -1
    } else {
        dist[n - 1]
    };
    println!("{}", ans);
}

Measured memory_bytes: 14140
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	int a;
	cin >> a;
	cout << a * a * 3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
map<char,int> ans;
int main(){
	int n,k;
	int a1,a2,a3;
	cin>>n>>k;
	cin>>a1>>a2>>a3;
	string s;
	cin>>s;
	int cnt1=0,cnt2=0,cnt3=0;
	for(int i=0;i<k;i++){
		int left=i,cnt=0;
		for(int j=i;j<s.size();j=j+k){
			if(s[j]==s[left])	cnt++;
			else{
				ans[s[left]]+=(cnt+1)/2;
				cnt=1;
				left=j;	
			}
		}
		ans[s[left]]+=(cnt+1)/2;
	}
	int Ans=ans['r']*a3+ans['s']*a1+ans['p']*a2;
	cout<<Ans<<endl;
//	cout<<ans['r']<<' '<<ans['s']<<' '<<ans['p']<<endl;
	
	return 0;
	
}

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


int main()
{
    int arr[5];
    for(int i=0;i<5; i++)
        cin>>arr[i];

    for(int i=0; i<5; i++)
    {
        if(arr[i]==0) cout<<i+1<<endl;
    }

    return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll dp[60][60][3000];
//配るDP
int main(){
    cout << fixed << setprecision(10);
    ll n;
    ll a;
    cin >> n >> a;
    vector<ll> v(n);
    dp[0][0][0] = 1;
    rep(i,n) cin >> v[i];
    rep(i,n){
        rep(j,60){
            rep(k,n*a+1){
                if(dp[i][j][k] == 0) continue;
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k + v[i]] = dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    /*rep(j,10){
        rep(k,35) cout << dp[n-1][j][k] << " ";
        cout << endl;
    }*/
    for(int j=1;j < 51; j ++){
        ans += dp[n][j][j*a];
    }

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


Measured memory_bytes: 12836
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int H,W; cin >> H >> W;
  vv<char> field(H,v<char>(W));
  vv<int> table(H,v<int>(W,0));
  vv<int> table2(H,v<int>(W,0));
  rep(i,H){
    int res=0;
    rep(j,W){
      cin >> field[i][j];
      if(field[i][j]=='.') res++;
      else{
        if(j>0){
          table[i][j-1]=res;
        }
        table[i][j]=-1;
        res=0;
      }
    }
    if(field[i][W-1]=='.') table[i][W-1]=res;
  }

  for(int i=H-1;i>=0;i--){
    for(int j=W-2;j>=0;j--){
      if(table[i][j]==0) table[i][j]=table[i][j+1];
    }
  }
  rep(j,W){
    int res=0;
    rep(i,H){
      if(field[i][j]=='.') res++;
      else{
        if(i>0) table2[i-1][j]=res;
        table2[i][j]=-1;
        res=0;
      }
    }
    if(field[H-1][j]=='.') table2[H-1][j]=res;
  }
  for(int j=W-1;j>=0;j--){
    for(int i=H-2;i>=0;i--){
      if(table2[i][j]==0) table2[i][j]=table2[i+1][j];
    }
  }
  int ans=0;
  rep(i,H){
    rep(j,W){
      chmax(ans,table[i][j]+table2[i][j]-1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 67200
#include <iostream>
using namespace std;
int main (){
int i, x, y;
cin >> x >> y;
i = 0;
while(x != 0 || y != 0){
	i++;
	if (x < y){
		cout << x << " " << y << endl;
 	}else{
 		cout << y << " " << x << endl;
 	}
	cin >> x >> y;
}

}



Measured memory_bytes: 3004
n, m = [int(i) for i in input().split(' ')]
wa = [0] * n
ac = [0] * n
for _ in range(m):
    problem, status = input().split(' ')
    problem = int(problem) - 1
    if status == 'WA':
        if ac[problem] == 0:
            wa[problem] += 1
        continue
    ac[problem] = 1

no_ac = 0
no_wa = 0

for i in range(n):
    if ac[i] == 1:
        no_ac += 1
        no_wa += wa[i]

print(str(no_ac) + ' ' + str(no_wa))

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, k, t, u, v, l;
    cin >> n >> k >> t >> u >> v >> l;
    double remainDash = 0;
    double place = 0;
    double time = 0;
    int count = 0;
    vector<int> ds(n);
    for (int i = 0; i < n; i++)
        cin >> ds[i];
    ds.push_back(l);
    for (auto&& d : ds){
        while (true){
            if (place + remainDash * v >= d){
                var takeTime = (d - place) / v;
                time += takeTime;
                remainDash -= takeTime;
                place = d;
                break;
            }
            place += remainDash * v;
            time += remainDash;
            remainDash = 0;
            if (count != 0){
                remainDash = t;
                count--;
                continue;
            }
            break;
        }
        var takeTime = (d - place) / u;
        time += takeTime;
        place = d;
        count++;
        if (count > k){
            count = k;
            remainDash = t;
        }
    }

    cout << fixed << setprecision(15);
    cout << time << endl;

    return 0;
}


Measured memory_bytes: 3308
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    ll x;cin>>x;
    string s="";
    while(x){
        s+=('0'+x%2);
        x/=2;
    }
    while(s.size()!=32)s+="0";
    reverse(all(s));
    cout<<s<<endl;
    rep(i,0,s.size()){
        cout<<(s[i]=='0'?1:0);
    }
    cout<<endl;
    rep(i,1,s.size())cout<<s[i];
    cout<<0<<endl;
    
    cout<<0;
    rep(i,0,s.size()-1)cout<<s[i];
    cout<<endl;
    
}



/*
00000000000000000000000000001000
11111111111111111111111111110111
00000000000000000000000000010000
00000000000000000000000000000100

00000000000000000000000000001000
11111111111111111111111111110111
00000000000000000000000000010000
*/



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
int main() {
	fastio();
	ll n;
	cin>>n;
	ll ar[n+5],dp[n+5];
	
	for(int i=1;i<=n;i++)
	cin>>ar[i];
	dp[1]=0;
	dp[2]=abs(ar[1]-ar[2]);
	for(int i=3;i<=n;i++)
	{
	dp[i]=min(abs(ar[i]-ar[i-2])+dp[i-2],abs(ar[i]-ar[i-1])+dp[i-1]);	
	}
	cout<<dp[n];
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int A[n], B[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  for ( int i = 0; i < n; i++) {
    B[i] = A[i];
  }
  sort(B,B+n,greater<>());
  for (int i = 0; i < n; i++){
    if ( A[i] == B[0] ) {
      cout << B[1] << endl;
    }
    else {
      cout << B[0] << endl;
    }
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if((s[0]==s[s.size()-1]) && (s.size()%2==0)){
        cout<<"First"<<endl;
    }
    else if((s[0]!=s[s.size()-1]) && (s.size()%2==1)){
        cout<<"First"<<endl;
    }
    else {
        cout<<"Second"<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    b = LI()
    t = 0
    k = 0
    d = []
    for i in range(n):
        if a[i] < b[i]:
            t += 1
            k += b[i] - a[i]
        else:
            d.append(b[i]-a[i])
    d.sort()
    for e in d:
        if k <= 0:
            break
        k += e
        t += 1
    if k > 0:
        return -1

    return t



print(main())




Measured memory_bytes: 21164
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    vector<queue<int>> v(n);
    REP(i,n){
        REP(j,m){
            int a;
            cin >> a;
            a--;
            v[i].emplace(a);
        }
    }
    int ans = INF;
    bool del[m] = {};
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            while(del[v[j].front()]){
                v[j].pop();
            }
        }
        int cnt[m] = {};
        for(int j = 0; j < n; j++){
            cnt[v[j].front()]++;
        }
        int mx = 0, mx_itr;
        for(int j = 0; j < m; j++){
            if(cnt[j] > mx){
                mx = cnt[j];
                mx_itr = j;
            }
        }
        ans = min(ans, mx);
        del[mx_itr] = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include<algorithm>
 using namespace std;
 #define ll long long int
 
 int main(){
 ll n;
 cin>>n;
 ll a[n];
 for(int i=0;i<n;i++){
	 cin>>a[i];
 }
 ll temp=0,sum=0;
 for(int i=1;i<n;i++){
	 if(a[i]>=a[i-1])
		 continue;
 else if(a[i]<a[i-1])
 {
	 temp=a[i-1]-a[i];
	 sum+=temp;
	 a[i]=a[i]+temp;
 }
 }
 cout<<sum<<endl;
 
 }
 

Measured memory_bytes: 5140
a=int(input())
b=int(input())

if (a == 1 and b == 2) or (a == 2 and b == 1):
  print(3)
elif (a == 1 and b == 3) or (a == 3 and b == 1):
  print(2)
elif (a == 2 and b == 3) or (a == 3 and b == 2):
  print(1)


Measured memory_bytes: 2940
l = []

while(1):
    num = list( map(int, input().split()) )
    x = num[0]
    y = num[1]
    if(x==0 and y==0):
        break
    l.append(x)
    l.append(y)

pairs = int(len(l)/2)

for i in range(0,pairs):
    a = l[i*2]
    b = l[i*2+1]
    if(a<=b):
        print(a,end=" ")
        print(b)
    else:
        print(b,end=" ")
        print(a)


Measured memory_bytes: 6100
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int h, w;
    int i, j;

    for(;;){
      h = sc.nextInt();
      w = sc.nextInt();
      if(h == 0 && w == 0)break;

      for(i = 0;i < h;i++){
        for(j = 0;j < w;j++){
          if((i + j) % 2 == 0){
            System.out.print("#");
          }else{
            System.out.print(".");
          }
        }
        System.out.println();
      }
      System.out.println();
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 26808
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <valarray>

using namespace std;

int main()
{
    long long x;
    scanf("%lld\n", &x);

    printf("%lld\n", (x / 11) * 2 + ((x % 11 > 0) ? ((x % 11 > 6) ? 2 : 1) : 0));
}


Measured memory_bytes: 128
# include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;

int D,M,d,q;
int c[30];
int s[400][30];
int type[400];
int last[29];
ll satis_level[400];

int calc_score(){
  rep(i,0,400) satis_level[i] = 0;
  rep(j,1,27) last[j]=0;
  ll down_satis;
  rep(i,1,D+1){
    down_satis=0;
    last[type[i]] = i;
    satis_level[i] += s[i][type[i]];
    rep(j,1,27) down_satis += c[j]*(i-last[j]);
    satis_level[i] -= down_satis;
    satis_level[i+1] += satis_level[i];
  }
  return 0;
}

int main(){
  cin >> D;
  rep(i,1,27) cin >> c[i];
  rep(i,1,D+1){
    rep(j,1,27){
      cin >> s[i][j];
    }
  }
  
  rep(j,1,D+1) cin >> type[j];
  cin >> M;
  
  rep(query,1,M+1){
    cin >> d >> q;
    type[d] = q;
    calc_score();
    cout << satis_level[D] << '\n';
  }
  return 0;
}

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


using namespace std;
int a[2000002],t[2000002]={0};
long long k,n;
vector<int> v;

int main()
{
    cin>>n>>k;
    rep(i,n) cin>>a[i+1];
    int b=1;
    t[1]=1;
    v.push_back(1);



   for(long long i=k;i>0;--i){
        b=a[b];
        v.push_back(b);


    if(t[b]==1&&i>=n+1){
            long long tt;
            rep(j,v.size()){
                if(v[j]==b){
                tt=v.size()-1-j;
                break;
                }

            }
        i=(i-1)%tt+1;

        }
            t[b]=1;
        }

    cout<<b;

    return 0;
}

Measured memory_bytes: 5812
def is_prime(n):
    if n==1:
        return False
    for i in range(2, int(n**.5)+1):
        if n%i==0:
            return False
    return True

x = int(input())
if x!=2 and x%2==0:
    x+=1
for i in range(x, 10**6, 2):
    if is_prime(i):
        print(i)
        break


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

ans=[0] * n
for i in range(1, n+1):
    for j in range(i+1, n+1):
        dist1 = j-i
        dist2 = abs(x-i)+abs(y-j)+1
        d = min(dist1,dist2)
        ans[d] += 1
for i in range(1, n):
    print(ans[i])
    

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n+m; i++)
#define ALL(v) v.begin(), v.end()

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a==b+c) {
        cout << "Yes" << endl;
    } else if (b==a+c) {
        cout << "Yes" << endl;
    } else if (c==a+b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
x = [int(i) for i in input().split()]

_list = [-1 for i in range(100)]
if min(x)==max(x):
    print(0)
else:
    for i in range(min(x), max(x), 1):
        a = 0
        for j in range(n):
            a += (x[j]-i)**2
        _list[i] = a
    _list = np.array(_list)
    print(min(_list[_list>=0]))

Measured memory_bytes: 12448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i; i < n; i++){
    cin >> a.at(i).first;
    a.at(i).second = i+1;
  }
  
  sort(a.begin(), a.end());
  for(auto x : a) cout << x.second << " ";
  cout << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep2(i, n) for(int i = 1; i <= (int)n; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)

#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define EPS 1.0e-6
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    if(vt.size() == 0) return;
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;

int main(void){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    char hd = s[0];
    char tl = s[n - 1];
    char winner;
    if(hd == 'o' && tl == 'o'){
        int os = 0;
        int xs = 0;
        rep(i, n){
            if(s[i] == 'o') os++;
            else xs++;
        }
        winner = (os >= xs) ? 'o' : 'x';
    }
    else if(hd != tl)
        winner = 'o';
    else
        winner = 'x';
    cout << winner << endl;
    return 0;


}

Measured memory_bytes: 1180
import sys
from collections import deque
 
 
def bfs(H, W, maze, visited, sharp):
    queue = deque([[0, 0]])
    visited[0][0] = 0
    while queue:
        y, x = queue.popleft()
        if[y, x] == [H-1, W-1]:
            return ((H*W-sharp)-(visited[y][x]+1))
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if  new_y != -1 and new_y != H and  \
                new_x != -1 and new_x != W and  \
                maze[new_y][new_x] == "." and   \
                visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
 
    return -1
 
 
def main():
    sharp = 0
 
    H, W = map(int,input().split())
    maze = [input() for i in range(H)]
    visited = [[-1]*W for j in range(H)]
 
    for k in range(H):
        sharp += maze[k].count('#')
 
    print(bfs(H, W, maze, visited, sharp))
 
main()

Measured memory_bytes: 3316
#include<stdio.h>

int main()
{
	int d;
	int i;
	long int sum;
	while(scanf("%d",&d)!=EOF)
	{
		sum=0;
		for(i=d;i<600;i+=d)
		{
			sum+=d*i*i;
		}
		printf("%ld\n",sum);
	}
return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main()
{
  int n,i,j,k,u,a;
  int v[101][101];

  scanf("%d",&n);

  for(i=1;i<=n;i++)
    {
       for(j=1;j<=n;j++)
	 {
	   v[i][j]=0;
	 }
    }
  
  for(i=1;i<=n;i++)
  {
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++)
      {
        scanf("%d",&a);
	v[u][a]=1;
      }
  }

  for(i=1;i<=n;i++)
  {
    for(j=1;j<n;j++)
      {
        printf("%d ",v[i][j]);
      }
    printf("%d\n",v[i][n]);
  }

  return 0;
}



Measured memory_bytes: 2148
n,k,c = map(int,input().split())
s = list(input())

ans = []
cnt = 0
kcn = 0
for i,x in enumerate(s[::-1]):
    i = n - i - 1
    if cnt:
        cnt -= 1
    elif x == 'o' and kcn < k:
        cnt += c
        kcn += 1
        ans.append(i)

cnt = 0
j = len(ans) - 1
kcn = 0
for i,x in enumerate(s):
    if cnt:
        cnt -= 1
    elif x == 'o' and kcn < k:
        cnt += c
        kcn += 1
        if ans[j] == i:
            print(i+1)
        j -= 1


Measured memory_bytes: 63464
//繰り返し二乗法
//x^nを高速に求めるアルゴリズム
//pow()はどうなっているんだろう
#include<math.h>
#include<iostream>
#define MOD 1000000007
using namespace std;

long long mod_poW(long long x, long long n){
    long long res = 1;
    while(n > 0){
        if(n & 1) res = res * x % MOD;

        x = x * x % MOD;
        n = n >> 1;
    }

    return res;
}

int main(){
    long long x, n; cin >> x >> n;
    //cout << pow(x, n) << endl;
    cout << mod_poW(x, n) << endl;
    return 0;
}


Measured memory_bytes: 3080
n, data = int(input()), list(map(int, input().split()))
idx, t = 0, 0
for i in range(n-1):
    for j in range(i+1, n):
        if j == i+1:
            idx = j
        elif data[idx] > data[j]:
            idx = j
    if data[i] > data[idx]:
        data[i], data[idx] = data[idx], data[i]
        t += 1
print(" ".join(map(str, data)))
print(t)



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

from bisect import bisect_left

n, *a = map(int, read().split())
b = sorted(a)
cnt = 0
for i, aa in enumerate(a):
    if abs(i - bisect_left(b, aa)) % 2 == 1:
        cnt += 1
print(cnt // 2)


Measured memory_bytes: 12408
#include<stdio.h>

int main(){
  int a[100], n, i;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  
  for(i=(n-1); i>-1; i--){
    printf("%d", a[i]);
    if(i==0){
    } else {
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
n = int(input())
a = [int(i) for i in input().split()]
sum_abs, min_abs, cnt_minus = 0, 10**9, 0
for ai in a:
    if ai < 0:
        cnt_minus += 1
    abs_ai = abs(ai)
    sum_abs += abs_ai
    if abs_ai < min_abs:
        min_abs = abs_ai
if cnt_minus % 2 == 0 or 0 in a:
    print(sum_abs)
else:
    print(sum_abs - 2*min_abs)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned 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 % p;
}
void solve()
{
    int n,k;
    cin >> n>>k;
    int a[n];
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }
    sort(a, a + n);
    int sum = 0;
    for (int i = 0; i < k;i++){
        sum += a[i];

    }
    cout << sum << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

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

using namespace std;

using ll = long long;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (b <= c || d <= a) cout << "0\n";
    else if (a <= c && d <= b) cout << d - c << endl;
    else if (c <= a && b <= d) cout << b - a << endl;
    else if (a <= c && c <= b) cout << b - c << endl;
    else cout << d - a << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
#define TMP template<typename
// #define DEBUG
#ifdef DEBUG
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cout << name << ": " << arg1 << "\n";}
TMP Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{const char *comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);
}
#endif
// TMP Arg1>
// void oup(Arg1 arg1){
// (cout << arg1 <<"\n");
// }
// TMP... T>
// void oup(T&... args){
// ((cout << args <<"\n") , ...);
// }

typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define F first
#define S second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define frb(i,j, n) for (auto (i) = (j); (i) >= (n); (i)--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define ra(a) for(int &x : (a)) in(x)
#define pa(a) for(int &x : (a)) cout << (x) << " ";cout << "\n"
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vlli vector<lli>

/*----------fast input-------------*/
#define ff
#ifdef ff
TMP T>
inline void in(T &x)
    {
    register T c = getchar_unlocked();
    x = 0;
    T neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }

#else
TMP... T>
void in(T&... args){
((cin >> args) , ...);
}
#endif
/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  lli a,b;
  in(a);
  in(b);
  cout << max({a+b , a-b , a*b}); 
}

Measured memory_bytes: 256
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int a,b,c,x,y;
LL risan = INFF;

int main()
{
  scanf("%d %d %d %d %d",&a,&b,&c,&x,&y); 
  FORN(i,0,max(x,y))
  {
    LL beli = (LL)c * i * 2;
    beli += max(0LL, (LL)(x - i) * a);
    beli += max(0LL, (LL)(y - i) * b);
    MIN(risan,beli);
  }
  printf("%lld\n",risan);
  return 0;
}











Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

	while (true)
	{
		s.pop_back();

		if (s.size() % 2 == 0)
		{
			int l = s.size() / 2;
			if (s.substr(0, l) == s.substr(l, l)) {
				break;
			}
		}
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

dict_diffs = dict()
for i in range(1, n+1):
  dict_diffs[i+a[i-1]] = dict_diffs.get(i+a[i-1], 0) + 1
total = 0
for j in range(1, n+1):
  total += dict_diffs.get(j-a[j-1], 0)
print(total)

Measured memory_bytes: 111352
H, W = map(int, input().split())
ans = H * W

def f(a, b):
	mod = b % 3
	if mod == 0:
		return 0
	else:
		return 1 

# カットする線が全て平行
# 縦にカットした場合、 W // 3 が2つと、 W - 2 * (W // 3) が1つできるから、この2つの差を取る
dif = H * f(H, W)
ans = min(ans, dif)
# print(ans)

# 横にカットした場合も同様
# 横にカット
dif = W * f(W, H)
ans = min(ans, dif)
# print(ans)

# 平行ではない
# 大きく縦にカット
for i in range(W):
	s_1 = H * i
	aft_W = W - i
	# 横にカットするやり方は先と同様
	s_2 = aft_W * (H // 2)
	s_3 = aft_W * (H - H // 2)
	
	dif = max(s_1, s_2, s_3) - min(s_1, s_2, s_3)
	ans = min(ans, dif)
	
# print(ans)
	
	
# 大きく横にカット
for i in range(H):
	s_1 = W * i
	aft_H = H - i
	# 縦にカットするやり方は先と同様
	s_2 = aft_H * (W // 2)
	s_3 = aft_H * (W - W // 2)
	
	dif = max(s_1, s_2, s_3) - min(s_1, s_2, s_3)
	ans = min(ans, dif)
	
	
print(ans)

Measured memory_bytes: 40304
#include <iostream>

using namespace std;

int main()
{
  int N;
  cin >> N;
  bool check_ok = false;
  for (int i = 0; i <= N / 4; i++)
  {
    for (int j = 0; j <= N / 7; j++)
    {
      if (4 * i + 7 * j == N)
        check_ok = true;
    }
  }

  if (check_ok == false)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


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

using namespace std;

int main(){
  int X;
  cin >> X;
  int n = X / 100;
  X %= 100;
  int m = X / 5;
  X %= 5;
  if(X != 0) m++;
  if(n >= m) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split(" "))

first = []
second = []
flag = 0
end = True

for i in range(M):
  a,b = map(int,input().split(" "))
  if b == N:
    second.append(a)
  if a == 1:
    first.append(b)

first.sort()
second.sort()
    
if len(first) == 0 or len(second) == 0:
  print("IMPOSSIBLE")
else:
  firsti = 0
  secondi = 0
  while(end == True):
    if first[firsti] == second[secondi]:
      print("POSSIBLE")
      break
    elif first[firsti] < second[secondi]:
      firsti += 1
      if firsti > len(first) - 1:
        print("IMPOSSIBLE")
        break
    else:
      secondi += 1
      if secondi > len(second) - 1:
        print("IMPOSSIBLE")
        break
    

Measured memory_bytes: 11440
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int cnt = 0;

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    while (true) {
      boolean ok = true;

      for (int i = 0; i < n; i++) {
        if ((a[i] % 2) == 0) {
          a[i] /= 2;
        } else {
          ok = false;
          break;
        }
      }

      if (ok) {
        cnt++;
      } else {
        break;
      }
    }

    System.out.println(cnt);

  }
}

Measured memory_bytes: 36056
#include <iostream>
#define int long long
using namespace std;

signed main() {
	int t1, t2, a1, a2, b1, b2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	
	//bから見たaの相対速度
	int c = a1 - b1;
	int d = a2 - b2;
	
	//標準化. c < 0なら, aから見たbの相対速度にする (グラフを反転)
	if (c < 0) {
		c = -c;
		d = -d;
	}
	
	//相対位置のグラフの形は3パターン.
	//これは1周期ごとの相対位置の変化量sによって判別
	int s = c * t1 + d * t2;
	
	if (s > 0) {	//上向き. x軸と交差しない.
		cout << 0 << endl;
	}
	else if (s == 0) {
		cout << "infinity" << endl;
	}
	else {	//下向き. 基本的に1周期あたり2回交差.
			//ただし, 1回だけ1回交差するパターンがあり得る。
		int q = -d * t2;	//1回あたりの下降量(正にする)
		s = -s;				//sを正の値にしておく
		
		//q > nsなる最大のnを取ると、n回2回交差が起きる.
		//n < q / s
		//ここでn = [q / s]とすると、基本的に最大のnだが、
		//q % s == 0のときだけ1回余計に足すことになるので、足しすぎた分を引く.
		
		int cnt = 2 * (q / s) - (q % s == 0);
		
		//また、時刻0の分は数えないので、1引く
		cnt--;
		
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    ll n, m;
    cin >> n >> m;
    cout << min(n % m, m - n % m);
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>  
#include <cmath>
#include <algorithm> 
#include <vector> 

using namespace std; 

unsigned long long k, a, b;

int main(){
    unsigned long long bl = 100 * 1ll, x;
    cin >> x;
    while (bl < x) {
        ++k;
        bl += (long long)(bl * 0.01);
        // cout << bl << "\n";
    }
    cout << k;
}
/* 3.57 */

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

using namespace std;

#define EPS 1e-9
#define For(i,N) FOR(i,N)
#define Forr(i,a,b) FORR(i,a,b)
#define Fotr(i,a,b,c) FOTR(i,a,b,c)
#define FOR(i,N) FORR(i, 0, N)
#define FORR(i,a,b) FOTR(i, a, b, 1)
#define FOTR(i,a,b,c) for(int i=(a);i<(b);i+=(c))
#define FOREACH(i,x) for(__typeof__((x).begin())i=(x).begin();i!=(x).end();i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define BCHK(a,x) (((a)>>(x))&1)
#define BSET(a,x) ((a)|(1<<(x)))
#define BCLR(a,x) ((a)&(~(1<<(x))))
#define BTGL(a,x) ((a)^(1<<(x)))
#define FMT(...) (sprintf(CRTBUFF, __VA_ARGS__)?CRTBUFF:0)
#define read() freopen("input.txt","r",stdin)
#define write() freopen("output.txt","w",stdout)
#define cpp_io() {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define BUFFSIZE 30000
#define INF 1000000000
#define MAX 300010
#define MOD 1000000007
#define pb push_back
#define mkpr make_pair
#define pii pair<int, int>
#define PI acos(-1)
#define ll long long
#define fi first
#define si second
#define all(x) x.begin(), x.end()
#define double long double

char CRTBUFF[BUFFSIZE];
#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

int main(){
    cpp_io();
    #ifdef LOCAL
        //read();
        //write();
    #endif

    ll n, m;
    cin>>n>>m;
    if(n>m)swap(n, m);

    if(n==1){
        if(m>=2)cout<<m-2<<"\n";
        else cout<<1<<"\n";
    }
    else if(n == 2){
        cout<<0<<"\n";
    }
    else {
        cout<<(n-2)*(m-2)<<"\n";
    }

}











Measured memory_bytes: 256