akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

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


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  
  int a,b;
  cin>>a>>b;
  if(a>=1&&a<=9&&b>=1&&b<=9) cout<<a*b<<endl;
  else cout<<-1<<endl;
  return 0;
}



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

#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int ll 
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; } 
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; } 
        return x * f ;
    } 
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

using namespace std ;

#define N 3000100

ll d[N], b[4][N], c[N];

int main() {
	int x = read(), y = read(), z = read(), k = read();
	int cnt = 0;
	for(int i = 1; i <= x; ++i) {
		scanf("%lld", &b[1][i]);
	}
	for(int i = 1; i <= y; ++i) {
		scanf("%lld", &b[2][i]);
	}
	for(int i = 1; i <= z; ++i) {
		scanf("%lld", &b[3][i]);
	}
	for(int i = 1; i <= x; ++i) {
		for(int j = 1; j <= y; ++j) {
			c[++cnt] = (ll)b[1][i] + (ll)b[2][j];
		}
	}
	int tot = 0;
	sort(c+1,c+cnt+1); sort(b[3]+1,b[3]+z+1);
	reverse(c+1,c+cnt+1); reverse(b[3]+1,b[3]+z+1);
	for(int i = 1; i <= k; ++i) {
		for(int j = 1; j <= z; ++j) {
			d[++tot] = (ll)b[3][j] + (ll)c[i];
		}
	}
	sort(d+1,d+tot+1); reverse(d+1,d+tot+1);
	for(int i = 1; i <= k; ++i) outn(d[i]);
}

Measured memory_bytes: 38528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 2e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr, arr+3);
    int ans=0;
    ans=(arr[2]-arr[1])+(arr[1]-arr[0]+1)/2;
    if(arr[1]%2!=arr[0]%2)ans++;
    cout<<ans;
}

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

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

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

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

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

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

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

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

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

int N, M, K, T, Q, H, W;
signed main() {
	int A, B, C;
	cin >> A >> B >> C;
	string ans = "No";
	if (A == B && B != C || B == C && C != A || C == A && A != B)
		ans = "Yes";
	cout << ans << endl;
	return 0;
}

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


using ll = long long;
using namespace std;
using pii = pair<int, int>;


int main(){
	int x;
	scanf("%d", &x);
	int hap = 0, t = x / 500, mod = x % 500;
	hap += 1000 * t;
	mod /= 5;
	hap += 5 * mod;
	printf("%d", hap);

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static final int[] dx = {-1,-1,-1,0,0,1,1,1};
	public static final int[] dy = {-1,0,1,-1,1,-1,0,1};
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int width = sc.nextInt();
			int height = sc.nextInt();
			if (width==0) {
				break;
			}
			int c[][] = new int[width][height];
			for(int i=0;i<width*height;i++) {
				c[i%width][i/width] = sc.nextInt();
			}

			int ans = 0;
			for(int x=0;x<width;x++) {
				for(int y=0;y<height;y++){
					if (c[x][y]==1) {
						c[x][y] = 0;
						dfs(c,x,y,width,height);
						ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
	public static void dfs(int[][] c,int x,int y,int w,int h) {
		for(int i=0;i<8;i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx>=0 && nx<w && ny>=0 && ny<h) {
				if (c[nx][ny]==1) {
					c[nx][ny]=0;
					dfs(c,nx,ny,w,h);
				}
			}
		}
	}
}

Measured memory_bytes: 43036
from collections import deque, Counter


class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b)


N, M = map(int, input().split(' '))
edges = [tuple(map(int, input().split(' '))) for _ in range(M)]

dp = [0] * (M + 1)
dp[-1] = N * (N - 1) // 2
union_find = UnionFind(N)

for i in range(M - 1, 0, -1):
    if dp[i + 1] == 0:
        break
    a, b = edges[i]
    minus = union_find.union(a, b)
    dp[i] = dp[i + 1] - minus

for i in range(M):
    print(dp[i + 1])


Measured memory_bytes: 32168
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
    ll x=(a/gcd(a,b))*b; 
    return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;        
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;
    
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }
 
// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }
 
int solve() {fastio
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    int m=0;
    for(auto i:s){
        if(i=='I')ans++;
        else ans--;
        m=max(m,ans);
    }
    cout<<m;
    return 0;
}
    
//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    ans = [0 for i in range(N)]
    
    for _ in range(M):
        a,b = inputMap()
        ans[a-1] += 1
        ans[b-1] += 1
        
    for i in ans:
        print(i)
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38640
#include <iostream>
#include <string>

using namespace std;

string s;
int pos;

int length(){
	long long res = 0;
	while(isdigit(s[pos])) res = 10*res+s[pos++]-'0';
	if(!res){
		while(s[pos]!=')'&&!isdigit(s[pos])&&pos<s.size()) { res++; pos++;}
		return res;
	}
	long long tmp = 0;
	if(s[pos++] != '(') return res;
	while(s[pos] != ')') tmp += length();
	pos++;
	return min((int)(res*tmp), 1000001);
}

void print(int p, int n){
	if(p==s.size()) {
		puts("0");
		return;
	}
	pos = p;
	int L = length();
	if(n < L){
		if(isdigit(s[p])){
			while(isdigit(s[p])){ p++; }
			int L2 = 0;
			if(s[p]=='('){
				p++;
				pos = p;
				while(pos<s.length()&&s[pos]!=')') L2 += length();
			} else {
				pos = p;
				L2 = length();
			}
			print(p, n%L2);
		} else {
			cout << s[p+n] << endl;
		}
	} else {
		print(pos, n-L);
	}
}

int main(){
	int n;
	while(cin >> s >> n){
		if(s=="0"&&n==0) break;
		print(0,n);
	}
}

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 200010;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

int n;
int a[MAXN];

int main()
{
	
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	for (int i = 1; i <= n; ++ i)
	{
		int tx;
		cin >> tx;
		x = max(x, tx);
	}
	for (int i = 1; i <= m; ++ i)
	{
		int ty;
		cin >> ty;
		y = min(y, ty);
	}
	puts(x < y ? "No War" : "War");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n,h;
  cin >> h >> n;
  vector<pp> a(n);
  rep(i,n) cin >> a[i].first >> a[i].second;
  vector<int> d(h+1,inf);
d[0]=0;
int ans=inf;
rep(i,n){
  rep(j,h){
    if (d[j]!=inf){
      if (j+a[i].first<h) d[j+a[i].first]=min(d[j+a[i].first],d[j]+a[i].second);
      else ans=min(ans,d[j]+a[i].second);
    }
  }
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,r;
	cin >> n >> r;
	cout << (r+100*(max(10-n,0))) << endl;
	return 0;
}


Measured memory_bytes: 256
cards = [[False for j in range(13)] for i in range(4)]
pattern = ["S", "H", "C", "D"]
numbers = int(input())
for a in range(numbers):
    ch,rank = input().split()
    rank = int(rank)
    if ch == "S":
        cards[0][rank-1] = True
    elif ch == "H":
        cards[1][rank-1] = True
    elif ch == "C":
        cards[2][rank-1] = True
    elif ch == "D":
        cards[3][rank-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i],j+1)


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

using namespace std;

const int N_CONTEST = 26;
//int SUM_SCORE = 0;

struct Contest {
    int day;
    vector<int> complain;
    vector<vector<int>> satisfy;

    Contest() {
        cin >> day;

        complain.resize(N_CONTEST+1);
        for ( int c = 1; c <= N_CONTEST; c++ )
            cin >> complain.at(c);

        satisfy.resize(day+1);
        for ( int d = 1; d <= day; d++ ) {
            satisfy.at(d).resize(N_CONTEST+1);
            for ( int c = 1; c <= N_CONTEST; c++ )
                cin >> satisfy.at(d).at(c);
        }
    }

    void dump() {
        printf("----- Dump contents of struct Contest -----\n"
               "%d\n", day);
        for ( int c = 1; c <= N_CONTEST; c++ )
            printf("%d ", complain.at(c));
        printf("\n");
        for ( int d = 1; d <= day; d++ ) {
            for ( int c = 1; c <= N_CONTEST; c++ )
                printf("%d ", satisfy.at(d).at(c));
            printf("\n");
        }
        printf("----- Dump done -----\n");
    }
};

static int calc_greedy_ans (Contest contests, int day, vector<int> &last) {
    int max_score = INT_MIN;
    int ans_c = 1;

    for ( int con = 1; con <= N_CONTEST; con++ ) {
        int score = contests.satisfy.at(day).at(con);
        for ( int con_ = 1; con_ <= N_CONTEST; con_++ ) {
            if ( con_ == con ) {
                continue;
            }
            score -= contests.complain.at(con_) * (day - last.at(con_));
        }
        if ( score > max_score ) {
            max_score = score;
            ans_c = con;
        }
    }
//SUM_SCORE += max_score;
//printf("day %d score %d satisfy %d\n", day, max_score, SUM_SCORE);
    last.at(ans_c) = day;

    return ans_c;
}

static void dump_ans (Contest contests) {
    vector<int> last(N_CONTEST+1, 0);

    for ( int d = 1; d <= contests.day; d++ ) {
        int c = calc_greedy_ans(contests, d, last);
        cout << c << endl;
    }
}

int main (void) {
    Contest contests;

    dump_ans(contests);

    return 0;
}



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

using namespace std;

int main()
{
    int n, i,flag = 0, f2 = 0;
    cin >> n;
    unsigned long long int arr[n], ans = 1, m = pow(10,18);
   
   for(i = 0; i < n; i++)
   {
       cin >> arr[i];
       
       if(!arr[i])
        f2 = 1;
       
       if(log10(ans))
       
       if(log10(ans) + log10(arr[i]) > 18)
            flag = 1;
       ans *= arr[i];
       
       if(ans > m)
        flag = 1;
   }
   
   if(f2)
   {
       cout << 0;
        return 0;
   }
   
  if(flag == 1)
        cout << -1;
  else if(ans > m || ans < 0)
    cout << "-1";
    
    else
    cout << ans;
   
   return 0;
}


Measured memory_bytes: 4792
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		
		int ho = 60*h2-60*h1;
		int mi = m2-m1;
		
		int total = ho+mi;
		
		System.out.println(total-k);
		
 
	}
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ld ret=0;
  ll n;cin>>n;
  vector<ld>a(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n){
    ret+=1/a[i];
  }
  ret=1/ret;
  cout lfs ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,k[100005],l[100005],ans=0;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>k[i]>>l[i];
  }
  for(int i=n-1;i>=0;--i){
    k[i]+=ans;
    if(k[i]%l[i]!=0){
      ans+=l[i]-k[i]%l[i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int CountDigits(ll n){
   if (n==0)return 0;
   int sum = 0;
   while(n>0){
       sum ++;
       n /= 10;
   }
   return sum;
}

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll n;
   int ans = INF;
   cin >> n;
   for (ll i=1;i*i<=n;i++){
       if (n%i==0){
           //dump(n/i);
           ans = min(ans, CountDigits(n/i));
       }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n,ans, date[1111][4],a,b,c,m,x,kura[1111][4],ku;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		a = 0;
		b = 0;
		c = 0;
		ans = 0;
		for (int z = 1; z <= 3; z++) {
			cin >> m;
			if (a <= m) {
				c = b;
				b = a;
				a = m;
			}
			else {
				if (b <= m) {
					c = b;
					b = m;
				}
				else {
					c = m;
				}
			}
		}
		date[i][1] = a;
		date[i][2] = b;
		date[i][3] = c;
	}
	ku = 0;
	for (int i = 1; i <= n; i++) {
		for (int z = 1; z <= ku; z++) {
			if (kura[z][1] == date[i][1] && kura[z][2] == date[i][2] && kura[z][3] == date[i][3]) {
				ans = ans + 1;
				goto x;
			}
		}
		ku = ku + 1;
		kura[ku][1] = date[i][1];
		kura[ku][2] = date[i][2];
		kura[ku][3] = date[i][3];
	x:;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3168
import java.io.IOException;
import java.util.Scanner;

/**
 * NumberOfIsland</br>
 * ??¶?????°???????????????
 *
 * @author ?????????????????§???
 *
 */
public class Main{

	/*
	 * ????????°???????????¨?????????????????????
	 */
	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		// ????????????????´????????????????????????§
		while (sc.hasNext()) {
			// ??°??¢???????´???´???
			boolean map[][] = new boolean[12][12];

			for (int rowIndex = 0; rowIndex < map.length; rowIndex++) {
				// ????????????
				int colIndex = 0;
				// ????????°??????(???)???true(1)??? ?????? ????????????(???)???false(0)???
				for (char info : sc.next().toCharArray()) {
					// ??°??????????£?
					map[rowIndex][colIndex++] = (info == '1')/*(info =='1'? true:false)*/;
				}
			}
			// ??¶?????°???????´???´???
			int ans = 0;
			for (int rowIndex = 0; rowIndex < map.length; rowIndex++) {
				for (int colIndex = 0; colIndex < map[0].length; colIndex++) {
					// ?????°
					if (map[rowIndex][colIndex]/* == true */) {
						// ?????°?????´?£?????????£???????????????
						destruction_of_island(rowIndex, colIndex, map);
						ans++;
					}
				}
			}
			// ??¶?????°?????????
			System.out.println(ans);
		} // ?????????????????????

		// ????????????????????????
		sc.close();
	}// ?????????????????????????????????

	/**
	 * ??? ?????°????????????????????´?£?</br>
	 * ??? ???????????????????????°???????????°???????¶??????´?£???????
	 *
	 * @param rowIndex
	 *            ??????????????????
	 * @param colIndex
	 *             ???????????????
	 * @param map
	 */
	private static void destruction_of_island(int rowIndex, int colIndex, boolean[][] map) {
		// ????????????
		map[rowIndex][colIndex] = false;

		// ?§????????????????????????????????????????
		final int MOVELIST_R[] = { 1, 0, -1, 0 };
		final int MOVELIST_C[] = { 0, 1, 0, -1 };
		for (int cnt = 0; cnt < MOVELIST_R.length; cnt++) {

			// ?????¨??°?????£????§????
			int move_r = rowIndex + MOVELIST_R[cnt];
			int move_c = colIndex + MOVELIST_C[cnt];

			// ??°??????????????? && ?????°
			if (0 <= move_r && 0 <= move_c && move_r < map.length && move_c < map[0].length
					&& map[move_r][move_c]/* ==true */)
				// ???????¶??????´?£?
				destruction_of_island(move_r, move_c, map);
		}
	}// recursive_landSurvey????????????????????????

}// ??????????????????????????????

Measured memory_bytes: 26024
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>
using namespace std;
struct Range {
	int from, to;
};
class Bit {
	vector<int> vec;
public:
	Bit(int size) :vec(size, 0) { };
	void add(int position, int value) {
		while (position < vec.size()) {
			vec[position] += value;
			position += ~position & (position + 1);
		}
	}
	int get(int position) const {
		int result = 0;
		while (position >= 0) {
			result += vec[position];
			position -= ~position & (position + 1);
		}
		return result;
	}
};
int main() {
	int n, q; cin >> n >> q;
	vector<int> balls(n);
	for (auto& ball : balls) {
		cin >> ball; --ball;
	}
	vector<Range> ranges(q);
	for (auto& range : ranges) {
		cin >> range.from >> range.to;
		--range.from; --range.to;
	}
	const auto comparator = [](const pair<int, int>& a, const pair<int, int>& b) {return a.first > b.first; };
	priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(comparator)> right(comparator);
	for (auto i = 0; i < q; ++i) {
		right.emplace(ranges[i].to, i);
	}
	vector<int> result(q);
	int all_count = 0;
	Bit bit(n);
	vector<int> color_last(n, -1);
	for (auto i = 0; i < n; ++i) {
		if (color_last[balls[i]] == -1) {
			++all_count;
		}
		else {
			bit.add(color_last[balls[i]], -1);
		}
		color_last[balls[i]] = i;
		bit.add(i, 1);
		while (!right.empty() && right.top().first == i) {
			const auto top = right.top(); right.pop();
			const auto range = ranges[top.second];
			result[top.second] = all_count - bit.get(range.from - 1);
		}
	}
	for (const auto r : result) {
		cout << r << '\n';
	}
}

Measured memory_bytes: 19400
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 100005
using namespace std;
typedef long long ll;
int n,a[MN],b[MN];ll sum;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum+=a[i];
	if(sum%(1ll*n*(n+1)/2))return 0*puts("NO");ll round=sum/(1ll*(n+1)*n/2);
	for(int i=1;i<n;i++)b[i]=a[i+1]-a[i];b[n]=a[1]-a[n];
	for(int i=1;i<=n;i++){
		b[i]-=round;
		if(b[i]>0||b[i]%n)return 0*puts("NO");
	}puts("YES");
}


Measured memory_bytes: 896
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = Integer.parseInt(sc.next());
       	int Z = Integer.parseInt(sc.next());
	int W = Integer.parseInt(sc.next());
	int[] a = new int[N];

	for(int i = 0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

	if(N==1) {
	    System.out.println((int)Math.abs(a[N-1]-W));
	    return;
	}

	System.out.println(Math.max((int)Math.abs(a[N-1]-W),(int)Math.abs(a[N-1]-a[N-2])));


    }
}

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

N,D,A=map(int,input().split())
L=[]
for i in range(N):
    x,h=map(int,input().split())
    L.append([x,h])
L.sort()

import math

ans=0
S=0
P=0
RL=[0]
RC=[0]
cnt=0
for i in range(N):
    for j in range(P,len(RL)):
        if RL[P]<L[i][0]:
            cnt+=RC[P]
            P+=1
        else:
            break
    if L[i][1]-S+cnt>0:
        ans+=math.ceil((L[i][1]-S+cnt)/A)
        
        RL+=[L[i][0]+2*D]
        RC+=[math.ceil((L[i][1]-S+cnt)/A)*A]
        S+=math.ceil((L[i][1]-S+cnt)/A)*A
    #print(i,ans,P,RL,RC,S,cnt)
print(ans)

Measured memory_bytes: 110556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            int a = vs[0];
            int b = vs[1];
            Console.WriteLine(Math.Max(a + b, Math.Max(a - b, a * b)));
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var (N, M, X, Y) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var x = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var y = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var xMax = x.Max();
        var yMin = y.Min();

        var ans = (xMax < yMin && xMax < Y && yMin > X) ? "No War" : "War";

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28264
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        a: i32,
    }

    println!("{}", n*n - a);
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

void pre(){


}


void solve(){

    ll a,v,b,w,t;
    cin >> a >> v >> b >> w;
    cin >> t;
    if(b > a){
        ll x = a + v*t;
        ll y = b + w*t;
        if(x >= y){
            cout << "YES";
        }else{
            cout << "NO";
        }
    }else{
        ll x = a - v*t;
        ll y = b - w*t;
        if(x <= y){
            cout << "YES";
        }else{
            cout << "NO";
        }
    }
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main() {
  long int N; cin >> N;
  int a = 1;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      a = i;
    }
  }
  cout << a + N / a - 2 << endl;
}


Measured memory_bytes: 256
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] > @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      # 右側の child が無い場合
      if @data[b].nil?
        c = a
      else
        c = @data[a] < @data[b] ? a : b
      end

      if @data[target_idx] > @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < (@data.size - 1)
  end
end


N, M = gets.chomp.split(' ').map(&:to_i)

AB = []
N.times do |i|
  AB[i] = gets.chomp.split(' ').map(&:to_i)
end

group_by_day = Hash[AB.group_by{|v|v[0]}.sort]

day_fee = Array.new(M){[]}
group_by_day.each do |k,v|
  day_fee[k-1] = v.map{|j| j[1]}
end

# require 'pry'
# binding.pry

ans = 0
pq = PriorityQueue.new
day_fee.each_with_index do |fees, idx|
  break if idx > M - 1
  fees.each do |fee|
    pq.push(fee*(-1))
  end
  ans += pq.pop.to_i
  # p pq
  # p pq.pop*(-1)
end

puts ans*(-1)


Measured memory_bytes: 38284
import heapq
#これを加える！！！！
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

n, m = map(int, input().split(' '))
income = []
for i in range(10**5+1):
  income.append([])
ans = 0

for i in range(n):
  a, b = map(int, input().split(' '))
  income[a].append(b)

# print(n, m)
# print(income)

# tmp = sorted(income, key=lambda x: x[0], reverse=True)
# sorted_income = sorted(tmp, key=lambda x: x[1], reverse=True)

# print(sorted_income)

heap = []
for i in range(1, m+1):
  values = income[i]
  for j in range(len(values)):
    _heappush_max(heap, values[j])
  
  if len(heap) < 1:
    continue
  
  max_value = _heappop_max(heap)
  if max_value:
    ans += max_value
  # print(ans)
  

print(ans)

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

int n;
char buf[100];
map<char, bool> is_right;

int main() {
  const char *p = "uyiophjklnm";
  for (int i=0; i<strlen(p); i++) {
    is_right[p[i]] = true;
  }

  while (1) {
    scanf(" %s", buf);
    n = strlen(buf);

    if (n == 1 && buf[0] == '#') return 0;

    int cnt = 0;
    bool flg = is_right[buf[0]];
    for (int i=1; i<n; i++) {
      if (flg != is_right[buf[i]]) cnt++;
      flg = is_right[buf[i]];
    }

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

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{ 
  ll n;
  cin >> n;
  map<string, ll> ana;
  string s;
  for (ll i = 0; i < n; i++)
  {
    cin >> s;
    sort(s.begin(), s.end());
    ana[s]++;
  }
  ll ans = 0;
  for (auto x : ana)
  {
    ans+= x.second * (x.second - 1) / 2; // nC2 
  }
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n; s64 k;
    cin >> n >> k;
    vs64 a(n);
    rep (i, n)
    {
        cin >> a[i];
    }

    const int max_keta = 40;
    int zeros[max_keta + 1];
    int ones[max_keta + 1];
    rep (i, max_keta + 1) zeros[i] = ones[i] = 0;
    rep (i, max_keta + 1)
    {
        rep (j, n)
        {
            if ((a[j] >> i) & 1) ++ones[i];
            else ++zeros[i];
        }
    }

    s64 ans = 0;
    int keta = max_keta;
    while (keta > 0 && (k >> keta) == 0) --keta;
    for (s64 i = keta; i >= -1; --i)
    {
        s64 w = 0;
        s64 x = 0;
        for (s64 j = keta; j > i; --j)
        {
            if ((k >> j) & 1) x |= 1ll << j;
        }
        for (s64 j = i - 1; j >= 0; --j)
        {
            if (ones[j] < zeros[j]) x |= 1ll << j;
        }
        if (x > k) continue;
        rep (j, n) w += a[j] ^ x;
        ans = max(ans, w);
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1024
H,W = map(int,input().split())
A = [list(input()) for h in range(H)]
A1 = [a for a in A if '#' in a]
A2 = [a for a in zip(*A1) if '#' in a]
A3 = [a for a in zip(*A2)]
for a in A3:
    print(''.join(a))

Measured memory_bytes: 3316
h, w = map(int, input().split())
n = int(input())
A = list(map(int,input().split()))
C = [[0]*w for _ in range(h)]
idx = 0
for _h in range(h):
    if _h%2==0:
        loop = list(range(w))
    else:
        loop = list(range(w-1,-1,-1))
    for _w in loop:
            C[_h][_w] = idx+1
            A[idx] -= 1
            if A[idx] == 0:
                idx += 1
for c in C:
    print(" ".join([str(_c) for _c in c]))

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

using EDGE = vector<vector<pair<ll, ll>>>;

void dfs(ll node, ll pnode, ll dist, vector<ll>& dist_from_root, const EDGE& edges)
{
    dist_from_root[node] = dist;
    for (auto&& e : edges[node]) {
        if (e.first != pnode) {
            dfs(e.first, node, dist + e.second, dist_from_root, edges);
        }
    }
}

void main_()
{
    ll N;
    cin >> N;

    EDGE edges(N + 1);
    for (ll i = 0; i < N - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }

    ll Q, K;
    cin >> Q >> K;
    vector<ll> dist_from_K(N + 1);
    dfs(K, 0, 0, dist_from_K, edges);

    for (ll i = 0; i < Q; i++) {
        ll x, y;
        cin >> x >> y;
        cout << dist_from_K[x] + dist_from_K[y] << "\n";
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll w[100], v[100], dp[105][10005];
int main() {
    init();
    ll N, W;
    cin >> N >> W;
    rep(i, N) cin >> v[i] >> w[i];

    rep(i,N){
        rep(j,W+1){
            dp[i + 1][j] = dp[i][j];
            if (j >= w[i]) chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 11048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var k = Console.ReadLine().ToInt();
		var s = Console.ReadLine();
		
		if(s.Length <= k)
		{
			Console.WriteLine(s);
		}
		else
		{
			Console.WriteLine("{0}...", s.Substring(0,k));
		
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

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

    ll n, m, k, x;
    cin >> n >> m >> k;

    vector<ll> cum(n+4,0);

    ll ans= 0;
    for(int i=1;i<=n;i++)
    {
        cin >> x;
        cum[i] = cum[i-1]+x;

        if(cum[i]<=k) ans = i;
    }

    ll sum = 0;
    for(int i=1;i<=m;i++)
    {
        cin >> x;
        sum+=x;

        ll inx = -1, lo=1, hi = n;
        while(lo<=hi)
        {
            ll mid = (lo+hi)/2;

            if(sum+cum[mid]<=k)
            {
                inx = mid;
                lo = mid+1;
            }
            else hi = mid-1;
        }

        if(inx!=-1)
        {
            ans = max(inx+i,ans);
        }
        else if(sum<=k) ans = max(ans,(ll)i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n; ld ar[N],dp[N][N];
ld findans(ll i,ll cnt_h){
	if(i==n+1){
		ll a,b;
		a=cnt_h; b=(n-cnt_h);
		if(a>b) return 1.0;
		else return 0.0;
	}
	if(dp[i][cnt_h]!=-1.0){
		return dp[i][cnt_h];
	}

	ld a,b;
	a=findans(i+1,cnt_h+1)*ar[i];
	b=findans(i+1,cnt_h)*(1.0-ar[i]);
	return dp[i][cnt_h]=(a+b);
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}

	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			dp[i][j]=-1.0;
		}
	}
	ld an=findans(1,0);
	cout<<fixed<<setprecision(10)<<an<<endl;
	return 0;
}

Measured memory_bytes: 145308