akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
const int X = 31;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	int n,m;
	scanf("%d %d",&n,&m);
	ll wa = 0;
	std::vector<int> a(n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		wa+=a[i];
	}
	sort(all(a));
	reverse(all(a));
	int cnt = 0;
	wa = wa/(4*m) + (wa%(4*m) >= 1);
	for(int i=0;i<n;i++){
		if(a[i]<wa)break;
		cnt++;
	}
	if(cnt>=m)printf("Yes\n");
	else	printf("No\n");
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int n;
		String tarocard;
		String hanacard;
		int taropoint = 0;
		int hanapoint = 0;
		final int WIN = 3;

		Scanner stdIn = new Scanner(System.in);

		n = stdIn.nextInt();

		for(int i = 0; i < n; i++) {
			tarocard = stdIn.next();
			hanacard = stdIn.next();

			if(tarocard.equals(hanacard)) {
				taropoint++;
				hanapoint++;
			} else if(tarocard.compareTo(hanacard) > 0) {
				taropoint += WIN;
			} else {
				hanapoint += WIN;
			}
		}

		System.out.println(taropoint + " " + hanapoint);

		stdIn.close();
	}
}

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


int main() {
int a,b,c;
cin >> a>>b >>c;

cout << a+b+c-max(max(a,b),c) << endl;
}

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

A = []
for i in range(n):
    main = list(map(int, input().split()))
    A.append(main)

B = []
for j in range(m):
    sub = int(input())
    B.append(sub)

   
for i in A:
    answer_sum = 0 
    for j,k in enumerate(B):
        a = i[j]*k
        answer_sum  += a
    print(answer_sum)
        
    
    
    


Measured memory_bytes: 6012
import sys
import bisect
input = sys.stdin.readline
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
s = sorted(s)
t = sorted(t)

for _ in range(Q):
    x = int(input())
    idx1 = bisect.bisect_right(s, x)
    idx2 = bisect.bisect_right(t, x)
    ans = float('inf')
    if idx1 > 0:
        left_s = s[idx1-1]
    else:
        left_s = float('inf')
    if idx2 > 0:
        left_t = t[idx2-1]
    else:
        left_t = float('inf')
    if idx1 < A:
        right_s = s[idx1]
    else:
        right_s = float('inf')
    if idx2 < B:
        right_t = t[idx2]
    else:
        right_t = float('inf')

    ls = x-left_s
    lt = x-left_t
    rs = right_s-x
    rt = right_t-x 
    if left_s <= x <= right_t:
        tmp = right_t-left_s + min(ls, rt)
        ans = min(ans, tmp)
    if left_t <= x <= right_s:
        tmp = right_s-left_t + min(lt, rs)
        ans = min(ans, tmp)
    ans = min(ans, max(abs(ls), abs(lt)))
    ans = min(ans, max(abs(rs), abs(rt)))
    print(ans)


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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  int ans=0;
  for(int i=0;i<n;i++){
    while(a[i]%2==0){
      ans++;
      a[i]/=2;
    }
  }
  cout<<ans<<endl;
}


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 = sc.nextInt();
		
		if(A<=B){
			for(int i=A; i<=B; i++){
				if(i==C){
					System.out.println("Yes");
					return;
            	}
			}
        }else{
			for(int i=B; i<=A; i++){
				if(i==C){
					System.out.println("Yes");
					return;
            	}
			}
        }
		System.out.println("No");
	}
}


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

#define ll long long
using namespace std;

int main()
{
       int n;
       cin>>n;
       bool used[n+1]{};

       int arr[n]{};
       int taken = 0 ;
       for(int i =0 ; i< n ; i++)cin>>arr[i];

       for(int i =0 ; i<n ; i++)
       {
           if(used[arr[i]])
            {taken++; continue;}
           if(arr[i]>i+1-taken)
           {
               taken++;
            }
           else
           {
               used[arr[i]] = 1;
          }
       }
       if(taken>n-1)
       {
           cout<<-1<<endl;
           return 0;
       }
       cout<<taken<<endl;
        return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin>>n;
  int a;
  bool jud = false;

  rep(i,0,n){
    cin>>a;
  if(a % 2 != 0) jud = true;
  }

  if(jud == true) cout<<"first\n";
  else cout<<"second\n";

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j, m, n, tmp=0;
	int a[100][100]={0};
	int b[100] ={0};

	scanf("%d %d", &n, &m);
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%d", &a[i][j]);
		}
	}
	for(i=0; i<m; i++){
		scanf("%d", &b[i]);
	}

	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			tmp += a[i][j]*b[j];
		}
		printf("%d\n", tmp);
		tmp = 0;
	}
	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) (x).begin(), (x).end()

using namespace __gnu_pbds;
using namespace std;

using ull = unsigned long long;
using ll = long long;
using ld = long double;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 2e5 + 5;

int n, k, a[N];

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

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

    sort(a, a + n);
    if (a[n - 1] == 0 and (k & 1)) {
        cout << "0\n";
        return 0;
    }

    if (a[n - 1] < 0 and (k & 1)) {
        ll prod = 1;
        for (int i = n - k; i < n; i++)
            prod = prod * a[i] % mod;
        prod = (prod + mod) % mod;
        cout << prod << "\n";
        return 0;
    }

    ll prod = 1;
    if (a[n - 1] > 0 and (k & 1)) {
        prod = a[n - 1];
        n--;
    }

    int i = n - 1, j = 1;
    k--;

    while (n - 1 - i + j - 1 < k) {
        if (a[i] * (ll)a[i - 1] > a[j] * (ll)a[j - 1])
            prod = prod * a[i] % mod * a[i - 1] % mod, i -= 2;
        else prod = prod * a[j] % mod * a[j - 1] % mod, j += 2;
    }

    prod = (prod + mod) % mod;
    cout << prod << "\n";
    return 0;
}

Measured memory_bytes: 4396
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())


int main() {

	std::cin.tie(0);

	int tmp;
	int n,m;
	int even,odd;

	cin >> n >> m;

	even = (n*(n-1)) / 2 ;
	odd = (m*(m-1)) / 2 ;

	tmp = even + odd;



    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n; ll k;

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

    cin >> n >> k;
    if(n == 1){
        if(k == 1){
            cout << "1 2 3\n";
        } else{
            cout << "-1\n";
        }
        return 0;
    } else if(n == 2){
        if(k == 1){
            cout << "1 4 5\n2 3 6\n";
        } else{
            cout << "-1\n";
        }
        return 0;
    }
    if(n % 2 == 1){
        int p = (n+1)/2;
        if(k+k+n-1+p <= k+2*n){
            int a = k;
            int b = k+n-1+p;
            int c = k+2*n;
            F0R(i, n){
                cout << a << " " << b << " " << c << "\n";
                if(i % 2 == 0){
                    a += p;
                    b -= (p-1);
                    c++;
                } else{
                    a -= (p-1);
                    b += p;
                    c++;
                }
            }
        } else{
            cout << "-1\n";
        }
    } else{
        int p = n/2;
        if(k+k+n+p <= k+2*n){
            int a = k;
            int b = k+n+p;
            int c = k+2*n;
            F0R(i, n-1){
                cout << a << " " << b << " " << c << "\n";
                if(i % 2 == 0){
                    a += p;
                    b -= (p-1);
                    c++;
                } else{
                    a -= (p-1);
                    b += p;
                    c++;
                }
                if(c == k+2*n+(n/2)) c++;
            }
            cout << a << " " << k+n << " " << k+2*n+(n/2) << "\n";
        } else{
            cout << "-1\n";
        }
    }

    return 0;
}


Measured memory_bytes: 2304
N = int(input())
A = [int(_) for _ in input().split()]

r = 0
l_r_max = []
A_plus = 0
A_xor = 0
flag = 0

for l in range(N):
    while r < N:
        A_plus += (A[r] if flag == 0 else -A[l - 1])
        A_xor ^= (A[r] if flag == 0 else A[l - 1])

        if A_plus == A_xor:
            r += 1
            flag = 0
            continue
        else:
            flag = 1
            break

    l_r_max.append(r - l)

print(sum(l_r_max))

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

int main() {
    string s; cin >> s;
    bool fumi = true;
    for(int i = 1; i <= s.size(); i++){
        if(i % 2 == 0 && s[i - 1] == 'R') fumi = false;
        else if(i % 2 == 1 && s[i - 1] == 'L') fumi = false;
    }
    if(fumi) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
Ps = list(map(int, input().split()))

LOW = []
MID = []
HIG = []

for p in Ps:
    if p <= A:
        LOW.append(p)
    elif p <= B:
        MID.append(p)
    else:
        HIG.append(p)

ll = len(LOW)
lm = len(MID)
lh = len(HIG)

print(min(ll, lm, lh))


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,i,j,k,count=0,p;
  cin>>n;
  p=sqrt(n);
  for(i=1;i<n;i++)
  {
  	for(j=1;j*j<=(n-i);j++)
  	{
  		k=(n-i)%j;
  		if(k==0)
  		{
  			count++;
		  }
	  }
  }
  if(p*p==n)
  {
  	cout<<2*count-p+1;
  }
  else
  {
  	cout<<2*count-p;
  }
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	map<ll, int> a;
	ll m0 = -1, m1 = -1;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;

		a[x]++;
		if (a[x] % 2 == 0)
		{
			if (m0 == -1)
			{
				m0 = x;
			}
			else
			{
				if (x >= m0)
				{
					m1 = m0;
					m0 = x;
				}
				if (m0 != x && x > m1)
				{
					m1 = x;
				}
			}
		}
	}
	if (m1 == -1)
	{
		if (m0 == -1)
		{
			m0 = 0;
			m1 = 0;
		}
		else
		{
			m1 = m0;
		}
	}

	ull ans = m0 * m1;

	cout << ans << endl;
}

Measured memory_bytes: 6528
import java.util.Scanner;

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

        while (sc.hasNext()) {
            String s = sc.next();

            for (int len = s.length() / 2 - 1; len >= 1; len--) {
                String left = s.substring(0, len);
                String right = s.substring(len, len + len);
                if (left.equals(right)) {
                    System.out.println(len * 2);
                    break;
                }
            }
        }
    }
}


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

int main() {
  int r,D,x,ans;
  cin >> r >>D >>x;
  
  ans = r*x-D;
  cout << ans << endl;
  for(int i=1;i <10;i++){
    ans= ans*r-D;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vint sum_w(n+1,0), sum_r(n+1,0);
    REP(i,n+1) {
        sum_w[i] = sum_w[i-1];
        sum_r[i] = sum_r[i-1];
        if (s[i-1] == 'W') sum_w[i]++;
        if (s[i-1] == 'R') sum_r[i]++;
    }
    int ans = inf;
    rep(i,n+1) {
        int n_l = sum_w[i];
        int n_r = sum_r[n] - sum_r[i];
        ans = min(ans,max(n_l,n_r));
    }
    cout << ans << endl;
}

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

int main()
{
	int N;
	cin >>N;
	
	long long sum = 0;
	
	for(int i=0; i<N; i++){
		if((i+1)%3!=0&&(i+1)%5!=0){
			sum += i+1;
		}
	}
	cout <<sum <<endl;
}	


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

int main(){
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    int kijical;
    cin>>kijical;
    vector<int> topcal(n);
    for (int i = 0; i < n; ++i) {
        cin>>topcal[i];
    }
    sort(topcal.begin(),topcal.end(),greater<int>());
    double tcal=kijical,tval=a;
    double ans=tcal/tval;
    for (int i = 0; i < topcal.size(); ++i) {
        tcal+=topcal[i];
        tval+=b;
        if(tcal/tval>ans)ans=tcal/tval;
        else break;
    }
    cout<< static_cast<int>(ans)<<endl;
    return 0;
}


Measured memory_bytes: 3092
def main():
    S=input()
    Q=int(input())
    Left=[]
    Right=[]

    reverse_flag=0
    for i in range(Q):
        query=input().split()
        if query[0]=="1":
            if reverse_flag==1:
                reverse_flag=0
            else:
                reverse_flag=1
        else:
            if query[1]=="1":
                if reverse_flag==0:
                    Left.append(query[2])
                else:
                    Right.append(query[2])
            else:
                if reverse_flag==0:
                    Right.append(query[2])
                else:
                    Left.append(query[2])

    res=""
    if reverse_flag==0:
        Left.reverse()
        res+="".join(Left)
        res+=S
        res+="".join(Right)

    else:
        Right.reverse()
        res+="".join(Right)
        S=list(S)
        S.reverse()
        res+="".join(S)
        res+="".join(Left)
    print(res)

if __name__=="__main__":
    main()

Measured memory_bytes: 91344
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = nextInt();
        int B = nextInt();

        if(A == 1){
            if(B == 3){
                println(2);
                return;
            }else{
                println(3);
                return;
            }
        }else if(A == 2){
            if(B == 1){
                println(3);
                return;
            }else{
                println(1);
                return;
            }
        }else{
            if(B == 1){
                println(2);
                return;
            }else{
                println(1);
                return;
            }
        }
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 22612
// https://atcoder.jp/contests/arc077/submissions/1390993
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
 
// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
 
//https://atcoder.jp/contests/arc077/submissions/1390993

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;
 
int main(){
  int n;
  scanf("%d",&n);
  deque<int> Q;
  REP(i,n){
    int a;
    scanf("%d",&a);
    if(i%2==0){
      Q.push_back(a);
    }else{
      Q.push_front(a);
    }
  }
  if(n%2==0){
    REP(i,n)printf("%d%c",Q[i],i==n-1?'\n':' ');
  }else{
    REP(i,n)printf("%d%c",Q[n-1-i],i==n-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n;
	cin>>n;
	ll ans = 1;
	ll arr[n];
	ll v  = pow(10,18);
	bool flag = 0;
	REP(i,0,n){
		cin>>arr[i];
		if(arr[i] == 0){
			flag = 1;
		}
	}
	if(flag == 1){
		cout<<0<<endl;
		return 0;
	}
	bool f = 0;
	REP(i,0,n){
		// ans = ans*arr[i];
		ll v1 = v / arr[i];
		if(ans > v1){
			f = 1;
			break;
		}
		else {
			ans = ans * arr[i];
		}
	}
	if(f == 0)
		cout<<ans<<endl;
	else 
		cout<<-1<<endl;
	// if(f = 0) cout<<ans<<endl;
	// else cout<<-1<<endl;
	return 0;
}




Measured memory_bytes: 4408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      while (true) {
        int H = in.nextInt();
        int W = in.nextInt();
        if (H == 0 && W == 0) break;
        
        for (int i = 0; i < H; i++) {
          if (i % 2 == 0) {
            for (int j = 0; j < W; j++) {
              if (j % 2 == 0) {
                out.print("#");
              } else {
                out.print(".");
              }
            }
            out.print("\n");
          } else {
              for (int j = 0; j < W; j++) {
                if (j % 2 == 1) {
                  out.print("#");
                } else {
                  out.print(".");
                }
              } 
            out.print("\n");
          }
        } 
        out.print("\n");
      }
    }
}

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 26520
#include<stdio.h>

int main(void)
{
  int n, k, x, y;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  scanf("%d", &y);

  if(n <= k)
    printf("%d\n", n*x);
  else
    printf("%d\n", k*x+(n-k)*y);
}


Measured memory_bytes: 128
n, t = map(int, raw_input().split())
cm = 1000
f = 0
for i in range(n):
    ci, ti = map(int, raw_input().split())
    if ti <= t:
        f = 1
        if ci <= cm:
            cm = ci
if f == 0:
    print "TLE"
else:
    print cm

Measured memory_bytes: 2568
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 ans = 0;
        if(a*b == 6) ans = 1;
        if(a*b == 3) ans = 2;
        if(a*b == 2) ans = 3;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 22612
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;cin>>a>>b>>c;
  cout<<(a+b>=c?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll  long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// using ll = long long;
int main()
{
    ll int n;
    ll int sum=0;
    cin >> n;
    std::vector<ll int>a(n);
    for(ll int i=0;i<n;i++)
    {
    cin >> a[i];sum += a[i];
    }
    ll int x = floor(sum/(n));
    ll int y = x+1;
    ll int total1=0,total2=0;
    // cout << x << endl;
    for(ll int i=0;i<n;i++)
    {
        total1 += (x-a[i])*(x-a[i]);
        total2 += (y-a[i])*(y-a[i]);
    }
    cout << min(total1,total2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <ii> vii;
typedef vector <vii> vvii;
#define endl '\n'
#define PB push_back
#define MP make_pair
#define fr first
#define sc second
#define OO (1000000000)         // ToDo
#define EPS (1e-9)              // ToDo
#define MOD (1000000007)        // ToDo
#define all(v) ((v).begin()),((v).end())
#define WT(x) cout<< #x <<" = "<<"\""<< (x) <<"\""<<endl
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
void read_file(bool outToFile = true){
#ifdef LOCAL_TEST
    freopen("in", "rt", stdin);
    if(outToFile)
    freopen("out", "wt", stdout);
#endif
}
//
int n, m;
const int MAXN = 1000000+99;
int can1[MAXN], can2[MAXN];
//
int main()
{
    read_file();
    while(scanf("%d%d", &n, &m) != -1)
    {
        memset(can1, 0, sizeof can1);
        memset(can2, 0, sizeof can2);
        for(int i=0; i<m; i++)
        {
            int u, v;
            scanf("%d%d", &u, &v);
//            if(u > v) swap(u, v);
            
            if(u == 1) can1[v] = 1;
            if(v == n) can2[u] = 1;
        }
        
        bool ok = 0;
        for(int i=2; i<n; i++)
        {
            if(can1[i] && can2[i])
                ok = 1;
        }
        
        string ans = ok? "POSSIBLE" : "IMPOSSIBLE";
        printf("%s\n", ans.c_str());
    }
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, a, b[10], c[10][10], ans;
string s;
int main(){
	cin >> n >> s;
	for(char t: s){
		int d = t - '0';
		rep(i,10) c[d][i] = b[i];
		b[d] = a;
		a |= 1<<d;
	}
	rep(i,10) rep(j,10) rep(k,10) if(c[i][j]>>k&1) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int r, c;
    cin >> r >> c;
    vector<vector<int> > sheet;
    sheet = vector<vector<int> >(r+1, vector<int>(c+1, 0));
    for (int i=0; i<r; ++i) {
        for (int j=0; j<c; ++j) {
            cin >> sheet[i][j];
            sheet[r][j] += sheet[i][j];
            sheet[i][c] += sheet[i][j];
            sheet[r][c] += sheet[i][j];
        }
    }
    for (int i=0; i<r+1; ++i) {
        for (int j=0; j<c+1; ++j) {
            if (j != 0) {
                cout << " ";
            }
            cout << sheet[i][j];
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 1316
import java.util.Scanner;

class Main {
	public static void trace(int N, int A[]) {
		for (int i = 0; i < N; ++i) {
			if (i > 0) System.out.print(" ");
			System.out.print(A[i]);
		}
		System.out.println();
	}

	public static int bubbleSort(int N, int A[]) {
		int ans = 0, tmp;
		for (int i = 0; i < N - 1; ++i) {
			for (int j = N - 1; j > i; --j) {
				if (A[j - 1] > A[j]) {
					tmp = A[j - 1];
					A[j - 1] = A[j];
					A[j] = tmp;
					++ans;
				}
			}
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), A[] = new int[N], ans;
		for (int i = 0; i < N; ++i) A[i] = sc.nextInt();
		sc.close();
		ans = bubbleSort(N, A);
		trace(N, A);
		System.out.println(ans);
	}
}


Measured memory_bytes: 26388
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a - b), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
rs = [input().split() for _ in range(n)]
rs = [(r, int(p)) for r, p in rs]
srs = sorted(sorted(rs, key=lambda p: p[1], reverse=True), key=lambda p: p[0])
 
for p in srs:
  print(rs.index(p)+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) cout << a+b << endl;
    else cout << b-a << endl;
    return 0;
}

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

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]

if x in a and y in a:
  	print("Yes")
elif x in b and y in b:
  	print("Yes")
else:
  	print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
#define int              long long
#define ps(x,y)         fixed<<setprecision(y)<<x //how much precision is required
#define max(x,y)        ((x>y)?x:y)
#define min(x,y)        ((x<y)?x:y)
#define pb              push_back
#define mp              make_pair
#define vi              vector<int>
#define pii             pair<int,int>
#define setbits(x)      __builtin_popcountll(x)// how many 1 are present
#define zrobits(x)      __builtin_ctzll(x)//how many zero are present from left to first 1.
#define w(x)            int x; cin>>x; while(x--)
#define PI 3.1415926535897932384626
const int mod = 1000000007;//1e9+7
void ash()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("/home/ashish/Desktop/C++/in.txt", "r", stdin);
    freopen("/home/ashish/Desktop/C++/out.txt", "w", stdout);
#endif
}
int32_t main()
{
    ash();
int N;
cin>>N;
vi a;
int t;
while(N!=0)
 {
t=N%10;
a.emplace_back(t);
N=N/10;
 }   
 for(int x:a)
 {
     if(x==7)
     {
         cout<<"Yes";
         exit(0);
     }
     continue;
 }
cout<<"No";
}
 

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

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

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

}


int main()
{
    textIO();
    fastIO();

    long long h, w, k, ans = 0;
    cin >> h >> w >> k;

    vector<vector<char> > arr(h, vector<char> (w));

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> arr[i][j];
        }
    }

    for(int row=0;row<(1<<h);row++){
        for(int col=0;col<(1<<w);col++){
            long long black = 0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((row &(1<<i)) == 0 && (col & (1<<j)) == 0){
                        if(arr[i][j] == '#'){
                            black++;
                        }
                    }
                }
            }
            if(black == k){
                ans++;
            }
        }
    }

    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
long long a[n+1];
for(long long i=1;i<=n;i++){
  cin>>a[i];
}
long long ans=0;
for(long long i=1;i<=n;i++){
if((i%2==1)&&(a[i]%2==1)){
  ans++;
}
}
cout<<ans<<endl;
return 0;

}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-

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

A = [list(map(int, input().split())) for i in range(N)]
A = sorted(A)

ans = 0
m = M
for a, b in A:
    if m <= b:
        ans += m*a
        break
    else:
        ans += b*a
        m -= b

print(ans)


Measured memory_bytes: 28656
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToArray();
        var A = line[0];
        var B = line[1];
        var C = line[2];
        var D = line[3];
        var E = line[4];
        var F = line[5];

        var waterAmax = F / (A * 100);

        decimal max = 0;
        decimal maxSugarWater = A*100;
        decimal maxSugar = 0;
        for (int i = 0; i <= waterAmax; ++i)
        {
            var bCount = (F - (A * i * 100)) / (B * 100);
            for (int j = 0; j <= bCount; ++j)
            {
                if (i == 0 && j == 0) continue;
                if (F < (A * i + B * j) * 100) break;
                var cCount = (F - (A * i * 100 + B * j * 100)) / C;
                for (int k = 0; k < cCount; ++k)
                {
                    if (F < (A * i + B * j) * 100 + C * k) break;
                    var dCount = (F - ((A * i * 100 + B * j * 100) + C)) / D;
                    for (int l = 0; l < dCount; ++l)
                    {
                        if (F < (A * i + B * j) * 100 + C * k + D * l) break;
                        if ((C * k + D * l) <= (i*A + j*B) * E)
                        {
                            var sugarWater = (A * i)*100 + (B * j)*100 + C * k + D * l;
                            var sugar = C * k + D * l;
                            var concentration = sugar == 0 ? 0 : sugar / sugarWater * 100;
                            if (max < concentration)
                            {
                                max = concentration;
                                maxSugarWater = sugarWater;
                                maxSugar = sugar;
                            }
                        }
                    }

                }
            }
        }
        Console.WriteLine($"{maxSugarWater} {maxSugar}");
    }
}

Measured memory_bytes: 11348
import sys
import itertools


def resolve(in_):
    N, K = map(int, next(in_).split())
    R, S, P = map(int, next(in_).split())
    T = next(in_).rstrip()
    r = ord(b'r')
    s = ord(b's')
    p = ord(b'p')

    temp = [0] * (N + 1)

    ans = 0
    for i, v in enumerate(T):
        j = i - K
        if j < 0:
            if v == r:
                ans += P
                temp[i] = p
            elif v == s:
                ans += R
                temp[i] = r
            elif v == p:
                ans += S
                temp[i] = s
        else:
            if v == r and temp[j] != p:
                ans += P
                temp[i] = p
            elif v == s and temp[j] != r:
                ans += R
                temp[i] = r
            elif v == p and temp[j] != s:
                ans += S
                temp[i] = s
    
    return ans


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10236
N,M=map(int,input().split())
ans=0
L,R=0,(10**5)+1
for i in range(M):
    l,r=map(int,input().split())
    L=max(L,l); R=min(R,r)
    if r<l: break
R=min(R,N)
print(abs((L-1)-R) if 0<=R-L else 0)

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

 
int main() {
    int n;
    cin>>n;
    int p=0,q=0,r=0;
    rep(i,n){
        int a;
        cin>>a;
        if(a%4==0)p++;
        else if(a%2==0)q++;
        else r++;
    }
    if(q==0){
        if(r<=p+1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
    }
    if(r<=p)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, x := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()

	sort.Ints(A)
	for i := 0; i < N-1; i++ {
		if x >= A[i] {
			x -= A[i]
		} else {
			fmt.Println(i)
			return
		}
	}
	if x == A[N-1] {
		fmt.Println(N)
	} else {
		fmt.Println(N - 1)
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S;
    cin >> S;
    for (int i = 0; i < 3; ++i) {
        if (S[i] == '7') {
            cout << "Yes" << endl;
            break;
        }
        else if (i == 2) cout << "No" << endl;
    }
}


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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int N;
    int i;
    LL H;
    ULL sum;
    ULL temp;
    ULL count;
    ULL *a,*b;
    cin >> N >> H;
    
    a = new ULL[N];
    b = new ULL[N];
    sum = 0;
    for(i=0;i<N;i++){
        cin >> a[i] >> b[i];
        sum += b[i];
    }
    sort(a,a+N,std::greater<ULL>());
    sort(b,b+N,std::greater<ULL>());
    count = 0;
    //cout << "sum:" << sum << endl;

    if( sum < H ){
        temp = H - sum;
        count = temp / a[0];
        if( temp % a[0] != 0){
            count++;
        }
        //cout << count << "*" << a[0] << endl;
        H -= count * a[0];
    }
    //cout << "MOD H:" << H << endl;
    sum = 0;
    for(i=0;i<N;i++){
        if( sum >= H){
            break;
        }
        if( b[i] <= a[0]){
            temp = H - sum;
            count += temp / a[0];
            if( temp % a[0] != 0){
                count++;
            }
            break;
        }
        sum += b[i];
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N, M;
	cin >> N >> M;
	vector<int>X(N);
	map<int, int>mp;
	priority_queue<pair<ll, ll>>q[101010];
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		mp[X[i]]++;
	}
	int ans = 0;
	fore(x, mp)q[x.first % M].push({x.second % 2,x.first});

	for (int i = 1; i <= M - 1; i++) {
		if (M - i == i)continue;
		while (q[i].size() && q[M - i].size()) {
			pair<ll,ll>tp1 = q[i].top();
			pair<ll, ll>tp2 = q[M - i].top();
			q[i].pop();
			q[M - i].pop();
			ll x1 = tp1.second;
			ll m1 = tp1.first;
			ll x2 = tp2.second;
			ll m2 = tp2.first;
			ans++;
			mp[x1]--;
			mp[x2]--;
			if (mp[x1] != 0)q[i].push({1-m1,x1});
			if (mp[x2] != 0)q[M - i].push({1-m2,x2});
		}
	}

	ll cntdiv = 0;
	ll cnthalf = 0;
	fore(x, mp) {
		ll num = x.first;
		ll cnt = x.second;
		if (num % M == 0)cntdiv += cnt;
		else if(M%2 == 0 && M/2 == num%M)cnthalf += cnt;
		else ans += cnt / 2;
	}
	ans += (cntdiv / 2) + (cnthalf / 2);
	puts(ans);

	return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <iomanip>

using namespace std;
typedef long long ll;
const int maxn=1e6+1111;

int arr[maxn];
int dp[maxn];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    memset(dp,0x3f3f3f,sizeof(dp));
    dp[0]=dp[1]=0;
    for(int i=1;i<=n;++i){
        scanf("%d",arr+i);
        for(int j=1;j<=k&&i-j>0;++j){
            dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
        }
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 6400
N,X = map(int,input().split())
l = [1]*(N+1)
p = [1]*(N+1)
for i in range(N):
    l[i+1] = 2*l[i]+3
    p[i+1] = 2*p[i]+1
def f(n,x):
    if n==0:return 1
    if x==1:return 0
    if x<= l[n-1]+1:return f(n-1,x-1)
    if x== l[n-1]+2:return 1+p[n-1]
    return 1+p[n-1]+f(n-1,x-2-l[n-1])
print(f(N,X))

Measured memory_bytes: 3064
var
	S:String;
	N,K,C,i,now:Longint;
	L,R:Array[1..200000]of Longint;
begin
	readln(N,K,C);
	readln(S);
	now:=0;i:=1;
	while i<=N do begin
		if S[i]='o'then begin
			inc(now);
			L[i]:=now;
			inc(i,C);
		end;
		inc(i);
	end;
	now:=0;i:=N;
	while i>=1 do begin
		if S[i]='o'then begin
			dec(now);
			R[i]:=now;
			dec(i,C);
		end;
		dec(i);
	end;
	for i:=1 to N do if(L[i]>0)and(R[i]<0)and(L[i]=K+1+R[i])then writeln(i);
end.


Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		List<Double[]> list = new ArrayList<Double[]>();


		for(int i = 0, loopMax = Integer.parseInt(reader.readLine()); i < loopMax; i++){
			String[] 	strings = reader.readLine().split(" ");
			double[]	values  = new double[strings.length];

			for(int j = 0; j < values.length; j++) values[j] = Double.parseDouble(strings[j]);

			Double[] array = new Double[3];
			double a1 = 2 * (values[2] - values[0]);
			double a2 = 2 * (values[4] - values[0]);
			double b1 = 2 * (values[3] - values[1]);
			double b2 = 2 * (values[5] - values[1]);
			double c1 = ((values[0] * values[0]) - (values[2] * values[2])) + ((values[1] * values[1]) - (values[3] * values[3]));
			double c2 = ((values[0] * values[0]) - (values[4] * values[4])) + ((values[1] * values[1]) - (values[5] * values[5]));

			array[0] = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
			array[1] = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);

			double dx = Math.abs(array[0] - values[0]);
			double dy = Math.abs(array[1] - values[1]);

			array[2] = Math.sqrt(dx * dx + dy * dy);
			list.add(array);
		}

		for(Double[] array : list){
			double x, y, r;

			x = (-0.0005 < array[0] && array[0] < 0.0005) ? 0 : array[0];
			y = (-0.0005 < array[1] && array[1] < 0.0005) ? 0 : array[1];
			r = (-0.0005 < array[2] && array[2] < 0.0005) ? 0 : array[2];

			System.out.printf("%.3f %.3f %.3f\n", x, y, r);

		}
	}

}

Measured memory_bytes: 11000
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    int H, A;
    cin >> H >> A;

    int n = H/A, a = H%A;
    //cout << n << a << endl;

    if( a != 0){
        n ++;
    }
    cout << n << endl;
return 0;
}

Measured memory_bytes: 256