akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		long a[] = new long[n];
		long b[] = new long[n];
		long c[] = new long[n];

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

		long ppp=calc(1,1,1,a,b,c,m,n);
		long ppm=calc(1,1,-1,a,b,c,m,n);
		long pmp=calc(1,-1,1,a,b,c,m,n);
		long mpp=calc(-1,1,1,a,b,c,m,n);
		long pmm=calc(1,-1,-1,a,b,c,m,n);
		long mpm=calc(-1,1,-1,a,b,c,m,n);
		long mmp=calc(-1,-1,1,a,b,c,m,n);
		long mmm=calc(-1,-1,-1,a,b,c,m,n);

		long max = Math.max(Math.max(Math.max(ppp,ppm),Math.max(pmp,mpp)),Math.max(Math.max(pmm,mpm),Math.max(mmp,mmm)));

		System.out.println(max);


	}

	public static long calc(int p,int q,int r,long[] a,long[] b,long[] c,int m,int n){
		long sum[] = new long[n];
		for(int i=0;i<n;i++){
			sum[i] = p*a[i] + q*b[i] + r*c[i];
		}
		Arrays.sort(sum);

		long all = 0;
		for(int i=n-1;i > n-m-1;i--){
			all += sum[i];
		}

		return all;
	}
 
}

Measured memory_bytes: 26000
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
a,b = inp
if(a*b == 15)
  puts "*"
else
  puts (a+b == 15)? "+" : "x"
end
#n = inp[0]
=begin
t = []
n.times do
  t.push(inp)
end  
=end


=begin
=end

Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  string s;
  int ans=0;
  while(cin>>s){
    for(int i=0;i<s.size();i++){
      if('0'<=s[i]&&s[i]<='9'){
        //cout<<i<<" "<<s[i]<<endl;
        string tmp="";
        while('0'<=s[i]&&s[i]<='9'){
          tmp+=s[i];
          i++;
        }
        //cout<<tmp<<endl;
        int k=1;
        for(int j=tmp.size()-1;j>=0;j--){
          ans+=k*(tmp[j]-'0');
          k*=10;
        }
        //cout<<ans<<endl;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define ll long long
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;


int main()
{
    FAST
    ll n;cin>>n;
    ll a[n];f(i,0,n) cin>>a[i];
    ll ans=0;
    f(i,0,n) if((i+1)&1 && a[i]&1) ans++;
    cout<<ans;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int K = Integer.parseInt(in.readLine());
    StringTokenizer st = new StringTokenizer(in.readLine());
    int A = Integer.parseInt(st.nextToken());
    int B = Integer.parseInt(st.nextToken());
    for(int score=A; score<=B; score++){
      if(score%K==0){
        System.out.println("OK");
        break;
      } else if(score==B && score%K!=0){
        System.out.println("NG");
      }
    }
  }
}

Measured memory_bytes: 32576
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1005;
int n,k;
LL a[N];
vector <LL> v;
bool check(LL x){
	int tot=0;
	for (auto y : v)
		if ((y&x)==x)
			tot++;
	return tot>=k;
}
int main(){
	cin >> n >> k;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	for (int i=1;i<=n;i++)
		a[i]+=a[i-1];
	v.clear();
	for (int i=1;i<=n;i++)
		for (int j=i;j<=n;j++)
			v.push_back(a[j]-a[i-1]);
	sort(v.begin(),v.end());
	LL ans=0;
	for (int i=40;i>=0;i--)
		if (check(ans|(1LL<<i)))	
			ans|=1LL<<i;
	cout << ans;
	return 0;
}


Measured memory_bytes: 6512
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int h = sc.nextInt();
        int n = sc.nextInt();

        // 処理
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
        }
        String out = sum >= h ? "Yes" : "No";

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 47292
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int check(vector<int> a){
	int s=0;
	for(int i=0 ; i < a.size() ; i++ ){
		s += a[i];
	}
	return s;
}

void solve(vector<int> a, int n, int ans[10] ){
	if( check(a) == 0 ){
		ans[n] = 1;
		return;
	}

	for(int i=1; i <= 9 ; i++ ){
		if( a[i] >= 3 ){
			a[i] -= 3;
			solve( a , n , ans );
			a[i] += 3;
		}
	}
	for(int i=3 ; i <= 9 ; i++ ){
		if( a[i-2] && a[i-1] && a[i] ){
			a[i-2]--;
			a[i-1]--;
			a[i]--;
			solve( a , n , ans );
			a[i-2]++;
			a[i-1]++;
			a[i]++;
		}
	}
}

int main(){
	string s;
	while( cin >> s ){
		vector<int> a;
		int ans[10] = {0};
		for(int i=0 ; i <= 9 ; i++ ){
			a.push_back( 0 );
		}
		for(int i=0 ; i < s.size() ; i++ ){
			a[s[i]-'0']++;
		}

		for(int i=1 ; i <= 9 ; i++ ){
			if( a[i] == 4 ){
				continue;
			}else{
				a[i]++;
				for(int j=1 ; j <= 9 ; j++ ){
					if( a[j] >= 2 ){
						a[j] -= 2;
						solve( a , i , ans );
						a[j] += 2;
					}
				}
				a[i]--;
			}
		}

		bool NA = true;
		for(int i=1 ; i <= 9 ; i++ ){
			if( ans[i] ){
				NA = false;
			}
		}
		if( NA ){
			cout << 0 << endl;
		}else{
			bool flag = true;
			for(int i=1 ; i <= 9 ; i++ ){
				if( ans[i] == 1 ){
					if( flag ){
						flag = false;
					}else{
						cout << " ";
					}
					cout << i;
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1204
#include <iostream>
using namespace std;
int main(void){
   int k,n,c;
   cin >> n;
   c=0;
   int A[n];
    for(int i=0;i<n;i=i+1){
        cin >> A[i];
    }
//
    for(int l=1;l<=n;l=l+1){
    
    for(int j=n-1;j>0;j=j-1){
        if(A[j]<A[j-1]){
            k=A[j-1];
            A[j-1]=A[j];
            A[j]=k;
            c=c+1;
        }
    
    }
    }

   for(int i=0;i<n;i=i+1){
            if(i==n-1){
                cout << A[i] <<endl;
            }else{
                cout << A[i] <<" ";
            }
                
            }
            cout << c <<endl;

}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n; cin >> n;
    ll h, w; cin >> h >> w;
    ll ans = 0;
    rep(i, 0, n){
        ll a, b; cin >> a >> b;
        if(a >= h && b >= w) ans++;
    }
    cout << ans << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
      	int c = a * b;
     	if(c % 2 == 0){
			// 出力
			System.out.println("Even");
        }else{
			// 出力
			System.out.println("Odd");
        }
	}
}


Measured memory_bytes: 35716
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	ll a, b, k;
	cin >> a >> b >> k;
	if (a >= k)
		cout << (a - k) << " " << b << ln;
	else
	{
		cout << 0 << " " << max(0ll, b - k + a) << ln;
	}
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;


void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}


const double EPS = 1e-8;
const long long mod = 1e9+7;

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

const int N = 1e5 + 5;

int n ,m,u,v;
vector<pair<int,int> > edgs;
int par[N],rnk[N];
void init(){
    for(int i = 1; i < N; ++i)
            par[i] = i, rnk[i] = 1;
}
int findpar(int u){

    return par[u] = (u == par[u] ? u : findpar(par[u]));
}
long long join(int u, int v){
        u = findpar(u);
        v = findpar(v);
        if(u == v)
            return 0;
        ll ret = rnk[u] * rnk[v];
        if(rnk[u] < rnk[v])
            swap(u,v);
        par[v] = u;
        rnk[u] += rnk[v];
        return ret;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
            cin >> u >> v;
            edgs.push_back({u,v});
    }
    reverse(edgs.begin(),edgs.end());
    init();
    long long ans[N];
    memset(ans,0,sizeof ans);
    ans[0] = (1ll * n * ( n - 1)/2);

    for(int i = 0; i < m - 1; ++i){
            ll ret = join(edgs[i].first,edgs[i].second);
            ans[i + 1] = ans[i] - ret;
    }
    for(int i = 0; i <m; ++i)
            cout <<ans[m - i - 1] << '\n';

    return 0;
}


Measured memory_bytes: 3828
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
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;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  cout << (1000-(n%1000))%1000 << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

int bit[100010+1];

int sum(int i){
	int s=0;
	while(i>0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i,int x){
	while(i <= 100010){
		bit[i] += x;
		i += i& -i;
	}
}


int a[100010];


int main(){
	int n;
	cin >> n;
	vector<pair<int,int> > v(n);
	for(int i=0;i<n;i++){
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		a[v[i].first]+=1;
		a[v[i].second]-=1;
	}
	vector<int>x(n),y(n);
	for(int i=0;i<n;i++){
		x[i] = v[i].first;
		y[i] = v[i].second;
	}
	for(int i=1;i<=100000;i++){
		a[i]+=a[i-1];
	}
	int p1,p2;
	p2 = *max_element(a,a+100000);
	int mx = 1;
	for(int i=0;i<n;i++){
		if(i==0){
			int tmp;
			tmp = lower_bound(x.begin()+1,x.end(),y[i])-x.begin();
			mx = max(tmp,mx);
		}else{
			int tmp;
			tmp = lower_bound(x.begin()+i+1,x.end(),y[i])-x.begin();
			tmp -= i;
			tmp += sum(100002)-sum(x[i]);
			mx = max(tmp,mx);
		}
		add(y[i],1);
	}
	cout << mx << " " << p2 << endl;
	return 0;
}

Measured memory_bytes: 6680
#include<iostream>
using namespace std;
int main()
{
	int coin[6] = { 1, 5, 10, 50, 100, 500 };
	int v=0,n;
	for (int i = 0; i < 6; i++){
		cin >> n;
		v += coin[i] * n;
	}
	if (v >= 1000)
		cout << "1" << endl;
	else
		cout << "0" << endl;
}

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

int main() {
  int n;
  bool b = false;
  cin >> n;
  while (n != 0) {
    if (n % 10 == 7) {
      b = true;
    }
    n /= 10;
  }

  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

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

    vector<int> P(N), Q(N);
    REP(i, N) {
        cin >> P[i];
        Q[P[i] - 1] = i + 1;
    }

    int ans = 0;
    int len = 1;
    REP(i, N - 1){
        if (Q[i] < Q[i + 1]) {
            len++;
        } else {
            chmax(ans, len);
            len = 1;
        }
    }
    chmax(ans, len);

    cout << N - ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 
int main () {
  int n;
  cin >> n;
  int a [n];
  int i, j, k, count, flag, temp;
  REP (i, n) {
    cin >> a [i];
  }
  flag = 1;
  count = 0;
  while (flag) {
    flag = 0;
    for (j = n - 1; j > 0; j--) {
      if (a [j] < a [j - 1]) {
        temp = a [j - 1];
        a [j - 1] = a [j];
        a [j] = temp;
        flag = 1;
        count++;
      }
    }
  }
  cout << a [0];
  REP1 (k, n) {
    cout << " " << a [k];
  }
  cout << endl << count << endl;

  return 0;
}
  

Measured memory_bytes: 3080
s = input()
n = len(s)
count1 = 0
count2 = 0
for i in range(n):
    if i%2 == 0:
        if s[i] == "1":
            count2 += 1
        elif s[i] == "0":
            count1 += 1
    if i%2 != 0:
        if s[i] == "0":
            count2 += 1
        elif s[i] == "1":
            count1 += 1
print(min(count1, count2))


Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;
	int num = 0;
	int kaigai = 1;
	rep(i, N) {
		if (S[i] == 'a') {
			if (num < A + B) {
				num++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
		else if (S[i] == 'b') {
			if (num < A + B) {
				if (kaigai <= B) {
					num++;
					kaigai++;
					cout << "Yes" << endl;
				}
				else cout << "No" << endl;
			}
			else cout << "No" << endl;
		}
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 896
s = input().split()
a = int(s[0])

u = 0
x= 0
d = 0
for i,v in enumerate(reversed(s[1])):
    if v == '.':
        d = i
        continue
    x += (a * int(v) * pow(10,u))
    u += 1
x //= pow(10,d)
print(x)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n;
  cin >> n;

  int ans = 0;
  rep(i, 1, n / 2 + 1) {
    if(i != n - i) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>

#define LOP(N) for(int i=0; i<N; i++)
#define LOOP(i, N) for(int i=0; i<N; i++)
#define LOOP_s(i, start, end) for(int i=start; i<end; i++)

using namespace std;


int main() {
    int H, W;
    cin >> H >> W;
    char grid[50][50];
    LOOP(r, H) {
        LOOP(c, W) {
            cin >> grid[r][c];
        }
    }
    
    LOOP(r, H) {
        LOOP(c, W) {
            if (grid[r][c] == '.') continue;

            if (r > 0 && grid[r-1][c] == '#') continue;
            if (r < H-1 && grid[r+1][c] == '#') continue;
            if (c > 0 && grid[r][c-1] == '#') continue;
            if (c < W-1 && grid[r][c+1] == '#') continue;

            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

vi prime(int n){ // n以下の素数を要素に持つviを返す
  vector<bool> isprime(n+1,true);
  vi ans;
  isprime[0] = isprime[1] = false;
  FOR(i,2,n+1)
    if(isprime[i]){
      ans.pb(i);
      for(int j = 2 * i; j <= n; j += i) isprime[j] = false;
    }
  return ans;
}

main()
{
  vi p = prime(55555);
  ROF(i,sz(p),0) if(p[i] % 5 != 1) p.erase(p.begin() + i);

  //cout << sz(p) << endl;

  int n; cin >> n;
  rep(i,n-1) cout << p[i] << " ";
  cout << p[n-1] << endl;
}

Measured memory_bytes: 384
N = int(input())
hl = list(map(int, input().split()))
l = [0]*N
count = 0

for i in range(N-1):
    if hl[i]>=hl[i+1]:
        count += 1
        l[i+1] = count
    else:
        count = 0
        l[i+1] = count
print(max(l))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

char field[10][10];
bool grand[10][10] = {false};
bool reached[10][10] = {false};

int main() {
    string S,T;
    cin >> S >> T;

    int ans = 0;
    REP(i, 3){
        if (S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main() {
	int a = 0;
	int b = 0;
	cin >> a >> b;
	if (b%a==0)
	{
		cout << a + b << endl;
	}
	else
	{
		cout << b - a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	int n, m;
	double p;
	cin >> n >> m >> p;
	p /= 100;

	vector<vector<int>> G(n);
	for(int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	vector<double> dp(1 << n, 0.0);

	for(int bit = 0; bit < 1 << (n - 1); ++bit) {
		const int V = (bit << 1) | 1;

		double sum = 0.0;
		for(int S = V; S > 0; S = (S - 1) & V) {
			if(!(S & 1)) continue;

			const int T = V ^ S;
			double q = 1.0;
			for(int v = 0; v < n; ++v) {
				if(!(S >> v & 1)) continue;

				for(const auto &u : G[v]) {
					if(!(T >> u & 1)) continue;
					q *= p;
				}
			}
			sum += dp[S] * q;
		}
		dp[V] = 1.0 - sum;
	}

	cout << dp[(1 << n) - 1] << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1384
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,y;
  cin>>n>>y;
  int a=10000,b=5000,c=1000;
  int ans1,ans2,ans3;
  bool ans=false;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      int k=n-i-j;
        if((a*i+b*j+c*k)==y){
          ans1=i;ans2=j;ans3=k;
          ans=true;
          break;
        }
      }
    }
  if(ans==true){
    cout<<ans1<<" "<<ans2<<" "<<ans3<<endl;
  }else{
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
}

Measured memory_bytes: 256
import math

N, D = map(int, input().split())

x_list = []
c = 0
for i in range(N):
    x_list.append(list(map(int, input().split())))
    if i != 0:
        for j in range(i):
            S = 0
            for k in range(D):
                s = (x_list[j][k]-x_list[i][k])**2
                S += s
            a = math.sqrt(S)
            if float.is_integer(a) == True:
                c += 1

print(c)

Measured memory_bytes: 3060
import java.util.Scanner;
class Main{

    public static void main(String args[]){
        Main main = new Main();
        main.start();
    }

    public void start(){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if(str.equals("A"))System.out.println("T");
        if(str.equals("T"))System.out.println("A");
        if(str.equals("C"))System.out.println("G");
        if(str.equals("G"))System.out.println("C");
    }


}

Measured memory_bytes: 23252
A,B,C,D=map(int, input().split())

#上と右

p=998244353
dp=[[0]*(D+1) for _ in range(C+1)]



for h in range(A,C+1):
    for w in range(B,D+1):
        if h==A and w==B:
            dp[A][B]=1
            continue

        if h>A and w>B:
            x=dp[h][w-1]*h
            y=dp[h-1][w]*w
            z=dp[h-1][w-1]*(h-1)*(w-1)
            sub=x+y-z
            dp[h][w]=(sub)%p
        elif h==A:
            dp[h][w]=(dp[h][w-1]*h)%p
        else:
            dp[h][w]=(dp[h-1][w]*w)%p


print(dp[C][D])

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

void solve(long long N, std::vector<long long> L)
{
    sort(L.begin(), L.end());
    long long cnt = 0LL;

    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = i + 1; j < N; j++)
        {
            for (size_t k = j + 1; k < N; k++)
            {
                if (k == N - 1 && L[k] < L[i] + L[j])
                {
                    cnt += (N - j - 1);
                }
                else if (L[k] >= L[i] + L[j])
                {
                    cnt += (k - j - 1);
                    break;
                }
            }
        }
    }

    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(), b = s.nextInt();
        int[][] g = new int[a][a];
        for (int i = 0; i < a; i++) {
            Arrays.fill(g[i], 99999999);
        }
        for (int i = 0; i < b; i++) {
            String[] l = s.next().split(",");
            int c = Integer.parseInt(l[0]) - 1, d = Integer.parseInt(l[1]) - 1, e = Integer.parseInt(l[2]), f = Integer.parseInt(l[3]);
            g[c][d] = e;
            g[d][c] = f;
        }
        String[] l = s.next().split(",");
        int c = Integer.parseInt(l[0]) - 1, d = Integer.parseInt(l[1]) - 1, e = Integer.parseInt(l[2]), f = Integer.parseInt(l[3]);
        for (int i = 0; i < a; i++)
            for (int j = 0; j < a; j++)
                for (int k = 0; k < a; k++)
                    if (g[j][k] > g[j][i] + g[i][k])
                        g[j][k] = g[j][i] + g[i][k];
        System.out.println(e - f - g[c][d] - g[d][c]);
    }
}



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

int main() {
    int H, W, ans = -1;
    cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W + 1));
    vector<vector<bool>> seen(H, vector<bool>(W));
    queue<pair<int, int>> que, que2;
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            cin >> A[i][j];
            if(A[i][j] == '#') {
                que.push(make_pair(i, j));
                seen[i][j] = true;
            }
        }
    }

    que.push(make_pair(-1, -1));
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    while(!que.empty()) {
        auto p = que.front();
        que.pop();
        if(p.first == -1) {
            ++ans;
            if(que.empty())
                break;
            que.push(make_pair(-1, -1));
            continue;
        }
        A[p.first][p.second] = '#';
        for(int i = 0; i < 4; ++i) {
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(nx < 0 || ny < 0 || nx >= W || ny >= H)
                continue;
            if(seen[ny][nx])
                continue;
            seen[ny][nx] = true;
            que.push(make_pair(ny, nx));
        }
    }
    cout << ans << endl;
    return 0;
}


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

string A, B, C;

int main(void) {
    cin >> A >> B >> C;
    if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main()
{
  int i, N, p[10], indexOfMax = 0, sum = 0;

  cin >> N;
  for (i = 0; i < N; i++)
  {
    cin >> p[i];
  }

  for (i = 0; i < N; i++)
  {
    if (p[i] >= p[indexOfMax])
    {
      indexOfMax = i;
    }
  }

  for (i = 0; i < N; i++)
  {
    sum += i != indexOfMax ? p[i] : p[indexOfMax] / 2;
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
if n == 0:
    print(0)
    exit()
bit = []
while n != 0:
    bit.append(-(-n % -2))
    n = -(-n // -2)

for i in range(len(bit) - 1, -1, -1):
    print(bit[i], end = "")
print()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>

#define rep(i,n) (int i = 0; i < (n); i++)
#define FOR(i,a,b) (int i=(a); i < (b); i++)
#define INF 100000000000
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }

    cout <<endl;
    return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    sort(a.begin(), a.end());
    cout<<a[N-1] - a[0]<<endl;
}


Measured memory_bytes: 256
import numpy as np

def check(mass,x,y):
  cnt=0
  for in_i in [-1,0,1]:
    for in_j in [-1,0,1]:
      if mass[x+in_i][y+in_j]=="#":
        cnt+=1
  return cnt

a,b = map(int,input().split())
temp=["." for _ in range(b+2)]
mass=[temp]

for i in range(a):
  mass.append(["."]+list(input())+["."])
mass.append(temp)

for i in range(1,a+1):
  for j in range(1,b+1):
    if mass[i][j]==".":
      mass[i][j] = check(mass,i,j)
    
for i in range(1,a+1):
  temp = [str(temp_i) for temp_i in list(mass[i][1:b+1])]
  sentence = "".join(temp)
  print(sentence)

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

int main()
{
    int n;
    bool w;
    int max = 0;
    int num = 0;
    int sum = 0;
    int a[11] = {};
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++)
    {
        if (max < a[i])
        {
            num = i;
            max = a[i];
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (i == num)
        {
            a[i] = 0;
        }
        sum += a[i];
    }

    if (max < sum)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		long ans =0;
		for(int i=1;i<=N;i++){
			if(String.valueOf(i).length()%2==1)
				ans++;
		}

		System.out.println(ans);


	}

}


Measured memory_bytes: 25812
#include <stdio.h>
int main(void){
     int r, c, i, j, num;
     int a[101][101]={};
     scanf("%d%d", &r, &c);
     for(i=0; i<r; i++){
         for(j=0; j<c; j++) {
            scanf("%d", &num);
            a[i][j]+=num;
        }
    }
    for(i=0; i<r; i++) {
        for(j=0; j<c; j++) a[i][c]+=a[i][j];
    }
    for(j=0; j<c+1; j++) {
        for(i=0; i<r; i++) a[r][j]+=a[i][j];
        }
        for(i=0; i<r+1; i++) {
            for(j=0; j<c+1; j++) {
                printf("%d", a[i][j]);
                if(j<c) putchar(' ');
                if(j==c) putchar('\n');
        }
    }
    return 0;
    
}


Measured memory_bytes: 2072
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    sort(All(A));
    vector<ll> sum(N+1);
    rep(i,N)sum[i+1]=sum[i]+A[i];
    int imp = 0;
    FOR(i,1,N){
        if(sum[i]*2<A[i])imp=i;
    }
    cout << N-imp << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int mod = 1'000'000'007;
int mul(long long a, long long b){
	return a * b % mod;
}
int xp(long long a, long long b){
	a %= mod;
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a)) if(b&1) r = mul(r, a);
	return r;
}
using pii = pair<int,int>;
pii solve(vector<int> f){
	int h = *min_element(f.begin(), f.end());
	vector<pii> sub;
	vector<int> smp;
	int miss = 0;
	for(int v : f){
		if(v > h){
			smp.push_back(v - h);
		} else {
			miss++;
			if(!smp.empty()){
				sub.push_back(solve(smp));
			}
			smp.clear();
		}
	}
	if(!smp.empty()) sub.push_back(solve(smp));
	pii now = {1, 1};
	for(pii p : sub) now.first = mul(now.first, p.first);
	for(pii p : sub) now.second = mul(now.second, p.first + p.second);
	now.second = mul(now.second, xp(2, miss));
	now.second += mod - mul(2, now.first); if(now.second >= mod) now.second -= mod;
	now.first = mul(now.first, xp(2, h));
	now.second += now.first; if(now.second >= mod) now.second -= mod;
	return now;
}
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	cout << solve(a).second << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
v = list(map(int, input().split()))
v.sort()

tmp = 0
for idx,val in enumerate(v):
        if tmp == 0:
                tmp = (val + v[idx + 1]) / 2
        else:
                tmp = (tmp + v[idx + 1]) / 2
        
        if idx == len(v) - 2:
                print(tmp)
                exit()


Measured memory_bytes: 3064
abalable_H = []
N = int(input())
x = []
y = []
h = []
first =-1
for i in range(0,N,1):
    tmpx,tmpy,tmph = map(int,input().split())
    x.append(tmpx)
    y.append(tmpy)
    h.append(tmph)
    if tmph !=0 and first == -1:
        first = i

for cx in range(0,101,1):
    for cy in range(0,101,1):
        H = h[first]+abs(x[first]-cx)+abs(y[first]-cy)
        ok = True
        for i in range(0,N,1):
            if h[i] != max(H-abs(cx-x[i])-abs(cy-y[i]),0):
                ok =False
        if ok == True:
            print(cx,cy,H)
            break

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int n,ans=0,x=0;
    cin>>n;
    while(1)
    {
        x+=n;
        ans++;
        if(x%360==0)
            break;
    }
    cout<<ans<<nl;

    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    if((n-1)*(n-2)/2<k){
        cout<<-1<<endl;
        return 0;
    }
    vector<vector<int>> g(n,vector<int>(n,-1));
    FOR(i,1,n){
        g[0][i]=g[i][0]=1;
    }
    int cnt=(n-1)*(n-2)/2-k;
    FOR(i,1,n)FOR(j,i+1,n){
        if(cnt){
            g[i][j]=g[j][i]=1;
            cnt--;
        }
    }
    int m=0;
    rep(i,n)rep(j,n) if(g[i][j]==1) m++;
    cout<<m/2<<endl;
    rep(i,n)FOR(j,i+1,n){
        if(g[i][j]==1){
            cout<<i+1<<' '<<j+1<<endl;
        }
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
#include <unordered_set>

#define FOR(i, a, b) for(int i = (int)a; i < (int)b; ++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
template <class T, class U> void CHMAX(T & a, const U & b) { if (a < b) a = b; }
template <class T, class U> void CHMIN(T& a, const U& b) { if (a > b) a = b; }

signed main() {
	int n, k, s;
	while (std::cin >> n >> k >> s, n || k || s) {
		std::vector<int> x(n), y(n), z(n);
		REP(i, n) std::cin >> x[i] >> y[i] >> z[i];

		if (k == 1) {
			std::cout << 6ll * s * s << std::endl;
			continue;
		}

		using P = std::pair<int, ll>;
		std::vector<std::vector<P>> g(n);

		REP(i, n) FOR(j, i + 1, n) {
			int tx = 0;
			if (x[i] <= x[j]) CHMAX(tx, (x[i] + s) - (x[j]));
			else CHMAX(tx, (x[j] + s) - (x[i]));
			int ty = 0;
			if (y[i] <= y[j]) CHMAX(ty, (y[i] + s) - (y[j]));
			else CHMAX(ty, (y[j] + s) - (y[i]));
			int tz = 0;
			if (z[i] <= z[j]) CHMAX(tz, (z[i] + s) - (z[j]));
			else CHMAX(tz, (z[j] + s) - (z[i]));

			if (tx == 0 || ty == 0 || tz == 0) continue;
			ll cost = 2ll * tx * ty + 2ll * ty * tz + 2ll * tz * tx;
			g[i].emplace_back(j, cost);
			g[j].emplace_back(i, cost);
		}

		ll ma = -1;
		REP(i, n) {
			for (P e0 : g[i]) {
				std::unordered_set<int> st; st.reserve(k);
				ll sum = e0.second;
				st.insert(i);
				st.insert(e0.first);

				int pre = i, cur = e0.first, cnt = 2;
				while (cnt < k) {
					bool f = false;
					for (auto& e : g[cur]) {
						int nex = e.first;
						ll cost = e.second;
						if (st.count(nex)) continue;
						st.insert(nex);
						f = true;
						sum += cost;
						pre = cur;
						cur = nex;
						++cnt;
					}
					if (!f) break;
				}
				if (st.size() != k) continue;
				if (k != 2) {
					for (auto& e : g[cur]) {
						if (e.first == i) {
							sum += e.second;
							break;
						}
					}
				}

				CHMAX(ma, sum);
			}
		}

		ll ans = 6ll * s * s * k;
		if (ma == -1) ans = -1;
		else ans -= ma;

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


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int n,m,v,p,a[233333];
long long chk(int x)
{
	long long ret=1ll*(p-1)*m;
	for(int i=p;i<=n;i++)
	{
		ret+=min(m,a[x]+m-a[i]);
	}
//	cerr<<"chk "<<x<<'='<<ret<<endl;
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1,greater<int>());
	int l=p,r=n;
	while(l<r)
	{
		int mid=(l+r+1)/2;
		if(a[p]-a[mid]<=m&&chk(mid)>=1ll*m*v)l=mid;
		else r=mid-1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 640
def solve(h, w, n):
    s = max(h, w)
    return (n + (s - 1)) // s


def main():
    h = int(input())
    w = int(input())
    n = int(input())
    res = solve(h, w, n)
    print(res)


def test():
    assert solve(3, 7, 10) == 2
    assert solve(14, 12, 112) == 8
    assert solve(2, 100, 200) == 2


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s,t;
    cin >> s >> t;
    intl a = s.length();
    intl b = t.length();
    string ans = "EQUAL";
    if(a != b)a > b ? ans = "GREATER" : ans = "LESS";
    else rep(i,a){
        if((s[i] - '0') > (t[i] - '0')){
            ans = "GREATER";
            break;
        }
        else if((s[i] - '0') < (t[i] - '0')){
            ans = "LESS";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, A = map(int, input().split())
    x = list(map(int, input().split()))
    dp = [[0] * (50*N + 1) for _ in range(N+1)]
    dp[0][0] = 1
    for k in range(N):
        for i in reversed(range(k+1)):
            for j in range(50 * N + 1 -x[k]):
                dp[i+1][j+x[k]] += dp[i][j]
    r = 0
    for i in range(1, N+1):
        r += dp[i][i*A]
    return r
print(main())


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

vector<vector<pll>> edges(220000);

struct Seg{
  vector<ll>mx, sum;
  Seg(){
    mx.resize(1<<19);
    sum.resize(1<<19);
  }

  void add(ll l, ll r, ll score, ll pos=1, ll bottom=0, ll top=1<<18){
    if(top <= l || r <= bottom)return;
    if(l <= bottom && top <= r){ sum[pos] += score;return; }

    ll mid = (bottom + top)/2;
    add(l, r, score, pos*2, bottom, mid);
    add(l, r, score, pos*2+1, mid, top);
    mx[pos] = max<ll>(mx[pos*2]+sum[pos*2], mx[pos*2+1]+sum[pos*2+1]);
  }

  ll mxv(ll l, ll r, ll pos=1, ll bottom = 0, ll top = 1<<18){
    if(top <= l || r <= bottom)return -INF;
    if(l<=bottom && top <= r)return mx[pos]+sum[pos];

    ll mid = (bottom + top)/2;
    return max<ll>(
      mxv(l,r, pos*2, bottom, mid),
      mxv(l,r, pos*2+1, mid, top)
    )+sum[pos];
  }
};

int main(){
  ll n,m;cin>>n>>m;
  rep(i, m){
    int l,r,a;cin>>l>>r>>a;
    edges[r].push_back({l, a});
  }

  Seg seg;

  rep1(r, n){
    ll mx = seg.mxv(0, r);
    for(auto p: edges[r]){
      ll l = p.first;
      ll a = p.second;
      seg.add(l, r+1, a);
    }
    seg.add(r, r+1, mx);
  }

  cout<<max<ll>(0LL, seg.mxv(0, n+1))<<endl;

//  rep(i, n)cout<<seg.mxv(i, i+1)<<' ';cout<<endl;

  return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}

double f(double l,double r,double v,double x){
	if(x<=l) return v+(l-x);
	if(l<x&&x<=r)return v;
	return v+r+x;
}

int main()
{
	int n;
	cin>>n;
	vector<double> t(n+1,0),v(n);
	repi(i,1,n+1)cin>>t[i];
	rep(i,n)cin>>v[i];

	rep(i,n)t[i+1]+=t[i];
	int T=t[n];

	vector<double> speed(2*T+1,0);
	
	double time=0.5;
	repi(i,1,2*T){
		speed[i]=speed[i-1]+0.5;
		rep(j,n){
			speed[i]=min(speed[i],f(t[j],t[j+1],v[j],time));
		}
		time+=0.5;
	}
	time=T-0.5;
	for(int i = 2*T-1; i >0; i--){
		rep(j,n){
			speed[i]=min(speed[i],speed[i+1]+0.5);
		}
		time-=0.5;
	}
	
	// for(auto s:speed)cout<<s<<" ";
	// cout<<endl;

	double ans=0;
	rep(i,2*T){
		ans += 0.25*(speed[i]+speed[i+1]);
	}
	cout<<setprecision(10)<<ans<<endl;

	return 0;
}

Measured memory_bytes: 512