akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long N;
    cin >> N;
    long long ans = 0;
    for(long long i=1; i<=N; i++){
        for(long long j=i; j<=N; j+=i){
            ans += j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
(defun split (input stack-string output-list)
  (let ((chara (car input)))
    (case chara
          ((nil) (append output-list (list stack-string)))
          (#\space (split (cdr input)
                                  '()
                                  (append output-list (list stack-string))))
          (otherwise (split (cdr input)
                                    (concatenate 'string stack-string (list chara))
                                    output-list)))))

(defun input-to-list (input)
  (mapcar #'parse-integer (split (concatenate 'list input)
                                 '()
                                 '())))

(defparameter nk (input-to-list (read-line)))
(format t "~d" (if (eq 1 (cadr nk))
    0
    (- (car nk) (cadr nk))))

Measured memory_bytes: 10468
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;


int main() {
  fastio;
  ld a,b;
  cin>>a>>b;
  ll ans = a*b;
  cout<<ans<<"\n";
}

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

int dp[100005];vector<int>v[100005];

int dfs(int s)
{
	if(dp[s]!=-1)
	return dp[s];
	
	for(int i=0;i<v[s].size();i++)
	{
		dp[s]= max(dfs(v[s][i])+1,dp[s]);
	}
	if(dp[s]==-1)
	dp[s]=0;
	return dp[s];
}
main()
{ int n,m,x,y,ans=0;

   for(int i=0;i<100002;i++)
   dp[i]=-1;
   
	cin>>n>>m;
	
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
	}
	
	for(int i=1;i<=n;i++)
	dfs(i);
	
	for(int i=1;i<=n;i++)
	ans = max(ans,dp[i]);
	
	cout<<ans;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

bool judge(int64_t th, const int64_t k, const vector<int64_t>& as, const vector<int64_t>& fs)
{
    int64_t practice = 0;
    for (int i = 0; i < as.size(); i++)
    {
        const int64_t t = th / fs[i];
        if (t < as[i])
        {
            practice += as[i] - t;
        }
    }
    return practice <= k;
}

int main()
{
    int64_t n, k;
    cin >> n >> k;

    vector<int64_t> as(n);
    for (auto& a : as)
    {
        cin >> a;
    }

    vector<int64_t> fs(n);
    for (auto& f : fs)
    {
        cin >> f;
    }

    sort(fs.begin(), fs.end());
    sort(as.begin(), as.end(), greater<int64_t>());

    int64_t left = 0;
    int64_t right = std::numeric_limits<int64_t>::max();

    if (judge(left, k, as, fs))
    {
        cout << 0 << endl;
    }
    else
    {
        for (int i = 0; i < 64; i++)
        {
            const int64_t middle = (left + right) / 2ll;
            (judge(middle, k, as, fs) ? right : left) = middle;
        }
        cout << right << endl;
    }
}


Measured memory_bytes: 3328
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
// Dijkstra's algorithm
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

using namespace std;

int main(int argc, char **argv)
{
        int V, E, r;
        cin >> V >> E >> r;
        vector<vector< pair<int, int>>> A(V);
        for (int i = 0; i < E; i++) {
                int s, t, d;
                cin >> s >> t >> d;
                A[s].push_back({d, t});
        }
        vector<int> d(V, INT_MAX);
        d[r] = 0;
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
        q.push({0, r});
        while (!q.empty()) {
                auto c = q.top();
                q.pop();
                if (d[c.second] < c.first)
                        continue;
                for (auto n: A[c.second]) {
                        int m = c.first + n.first;
                        if (m < d[n.second]) {
                                d[n.second] = m;
                                q.push({m, n.second});
                        }
                }
        }
        for (int i = 0; i < V; i++) {
                if (d[i] == INT_MAX)
                        cout << "INF";
                else
                        cout << d[i];
                cout << endl;
        }
        return 0;
}

Measured memory_bytes: 12964
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    A = read_list()

    for k in range(K):
        S = [0] * (N + 1)
        for i, a in enumerate(A):
            S[max(0, i - a)] += 1
            S[min(N, i + a + 1)] -= 1
        
        A[-1] = 0
        c = 0
        for i, s in enumerate(S[:N]):
            A[i] = A[i - 1] + s
            if A[i] == N:
                c += 1
            
        if c == N:
            break

    print(" ".join(map(str, A)))


if __name__ == "__main__":
    main()



Measured memory_bytes: 135764
#include <iostream>
#include <vector>

using namespace std;

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

int main(){
    int K;
    cin >> K;
    int s = 0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int l=1;l<=K;l++){
                s += gcd(i, gcd(j,l));
            }
        }
    }

    cout << s <<endl;
}

Measured memory_bytes: 3632
mod = (10 ** 9) + 7

n = int(input())
a = input()
b = input()
ans = 1
for i in range(n):
    if a[i] == b[i]:
        if i == 0:
            ans *= 3
        elif a[i-1] == b[i-1]:
            ans *= 2
    else:
        if i == 0:
            ans *= 6
        else:
            if a[i-1] == a[i]:
                continue
            elif a[i-1] == b[i-1]:
                ans *= 2
            else:
                ans *= 3
    ans = ans % mod
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }


int main()
{
	string s;
	cin >> s;
	string ans = "Good";
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
		ans = "Bad";
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define INF 2e8
#define all(a) a.begin(), a.end()
#define pb push_back
#define maxer max_element
#define miner min_element

int main() {
  int nHeight, nWidth;
  cin >> nHeight >> nWidth;

  /*マス目の情報を読み込み，横方向の白線を除去*/
  vector<string> vcTableFiltered;
  rep(i, nHeight) {
    const string strWhite(nWidth, '.');
    string strInput;
    cin >> strInput;
    if (strInput != strWhite) {
      vcTableFiltered.pb(strInput);
    }
  }
  int nHeightNew = vcTableFiltered.size();

  /*縦方向の白線の位置を列挙*/
  unordered_set<int> stPositionWhite;
  rep(j, nWidth) {
    bool fAllWhite = true;
    rep(i, nHeightNew) {
      if (vcTableFiltered[i][j] != '.') {
        fAllWhite = false;
      }
    }
    if (fAllWhite) {
      stPositionWhite.emplace(j);
    }
  }

  /*答えを出力*/
  rep(i, nHeightNew) {
    rep(j, nWidth) {
      if (not stPositionWhite.count(j))
        cout << vcTableFiltered[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

# D
# 解説AC
# すべて正もしくは負なら累積和をとって行けばいいという考え
# あとはn回で全部負もしくは正にできればよくてという考え迄持っていく必要
def D():
    n = II()
    a = LI()
    mina = min(a)
    maxa = max(a)
    if mina * maxa >= 0:
        print(n - 1)
        if mina >= 0:
            for i in range(n - 1):
                print(i + 1, i + 2)
        else:
            for i in range(n - 1):
                print(n - i, n - i - 1)
    else:
        print(2 * n - 1)
        if abs(mina) > abs(maxa):
            for i in range(n):
                if a[i] == mina:
                    break
            for k in range(n):
                print(i+1, k+1)
            for i in range(n - 1):
                print(n - i, n - i - 1)
        else:
            for i in range(n):
                if a[i] == maxa:
                    break
            for k in range(n):
                print(i + 1, k + 1)
            for i in range(n - 1):
                print(i + 1, i + 2)
    return


#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 999999797
#define N 100001

int n, k, ar[100001][2];
ll dp[100001][101];

ll solve(int idx, int mx) {
        if (idx == n) {
                if (mx < 0)
                        return -1e9;
                else return 0;
        }
        ll &ret = dp[mx][idx];
        if (ret != -1)
                return ret;
        ret = -1e9;
        if (ar[idx][0] <= mx) {
                ret = max(ret, solve(idx + 1, mx - ar[idx][0]) + ar[idx][1]);
        }
        ret = max(ret, solve(idx + 1, mx));
        return ret;
}

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        cin >> n>> k;
        for (int i = 0; i < n; i++)
                for (int j = 0; j < 2; j++)
                        cin >> ar[i][j];
        memset(dp, -1, sizeof dp);
        cout << solve(0, k)*1ll;
return 0;
}


Measured memory_bytes: 79232
#include <stdio.h>

int main() {
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if (((x - r) >= 0 && (x + r) <= w) && ((y - r) >= 0 && (y + r) <= h)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)


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

vector<int> a(n);
bool flag=true;
r(i,n)cin>>a.at(i);

ll cnt=0,cnt1=0,sum=0;

r(i,n){
  sum+=a.at(i);
  if(i%2==0){
    if(sum<0)continue;
    else{
      cnt+=abs(sum+1);
      sum=-1;
    }
  }else{
    if(sum>0)continue;
    else{
      cnt+=abs(sum-1);
      sum=1;
    }
  }
}
sum=0;
r(i,n){
  sum+=a.at(i);

  if(i%2!=0){
    if(sum<0)continue;
    else{
      cnt1+=abs(sum+1);
      sum=-1;
    }
  }else{
    if(sum>0)continue;
    else{
      cnt1+=abs(sum-1);
      sum=1;
    }
  }
  //cout<<sum<<endl;
}

//cout<<cnt1<<" "<<cnt<<endl;
cout<<min(cnt1,cnt)<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] aa = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++)
			sum += aa[i] = sc.nextInt();
		int cnt = 0;
		for (int i = 0; i < n; i++)
			if (aa[i] * 4 * m >= sum)
				cnt++;
		println(cnt >= m ? "Yes" : "No");
	}
}


Measured memory_bytes: 23124
c = [list(map(int,input().split())) for _ in range(3)]

for a1 in range(100):
    b1 = c[0][0] -a1
    b2 = c[0][1] -a1
    b3 = c[0][2] -a1

    a2 = c[1][0] -b1
    a3 = c[2][0] -b1

    if (a2+b2)==c[1][1] and (a2+b3)==c[1][2] and (a3+b2)==c[2][1] and (a3+b3)==c[2][2]:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 3064
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
#import random


def I(): return int(input())
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N = I()
    restrants = [None] * N

    for i in range(N):
        S, P = MS()
        restrants[i] = (S, int(P), i+1)

    restrants.sort(key=lambda x: (x[0], -x[1]))

    for i in range(N):
        print(restrants[i][2])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public class dice
    {
        private int n, e, w, s, t, b;
        public dice(int t, int s, int e, int w, int n, int b)
        {
            this.n = n;
            this.e = e;
            this.w = w;
            this.s = s;
            this.t = t;
            this.b = b;
        }
        public void roll(char r)
        {
            int buf;
            switch (r)
            {
                case 'N':
                    buf = t;
                    t = s;
                    s = b;
                    b = n;
                    n = buf;
                    break;

                case 'E':
                    buf = t;
                    t = w;
                    w = b;
                    b = e;
                    e = buf;
                    break;

                case 'W':
                    buf = t;
                    t = e;
                    e = b;
                    b = w;
                    w = buf;
                    break;

                case 'S':
                    buf = t;
                    t = n;
                    n = b;
                    b = s;
                    s = buf;
                    break;
            }
        }
        public int top()
        {
            return t;
        }
    }
    static void Main(string[] args)
    {
        int[] d = io.r<int>(' ');
        dice dice = new dice(d[0], d[1], d[2], d[3], d[4], d[5]);
        string s = io.r<string>();

        foreach (char c in s)
        {
            dice.roll(c);
        }
        io.w(dice.top());
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

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

using namespace std;

#define mod 1000000007
#define inf 1e18

int main()
{
	int t;
	cin >> t;
	int time[t], copyTime[t];
	for (int i = 0; i < t; ++i)
	{
		cin >> time[i];
	}

	copy(time, time + t, copyTime);

	int m;
	cin >> m;
	pair<int, int> drink[m];
	for (int i = 0; i < m; ++i)
	{
		cin >> drink[i].first >> drink[i].second;
	}

	for (int i = 0; i < m; ++i)
	{
		int fir = drink[i].first;
		int sec = drink[i].second;

		time[fir - 1] = sec;
		long long sum = 0;
		for (int j = 0; j < t; ++j)
		{
			sum += time[j];
		}

		cout << sum << endl;
		copy(copyTime, copyTime + t, time);
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    vector<int> b(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        cin >> b[i];
    }
    long long mx = 0;

    long long sm = 0;
    for (int j = 0; j < N; ++j) {
        if ((K | a[j]) == K)
            sm += b[j];
    }
    mx = max(mx, sm);

    for (int i = 1; i < 32; ++i) {
        if (K & (1u << i)) {
            int k = K & ~(1u << i) | ((1u << i) - 1);
            long long sm = 0;
            for (int j = 0; j < N; ++j) {
                if ((k | a[j]) == k)
                    sm += b[j];
            }
            mx = max(mx, sm);
        }
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio> 
using namespace std; //This makes the code much more cleaner

int main()
{
	
/*
	int a, b, c, d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int area = a*b;
	int areatwo = c*d;
		if (area>=areatwo)
		{
			printf("%d", area);
		}
		else
		{
			printf("%d",areatwo);
		}
		*/
	//--------------------------------------------

	/*
	int a,b;
	scanf("%d %d", &a, &b);
	if (a==1 and b!=1)
	{

		printf("Alice");

	}
	else if (b == 1 and a!=1)
	{

		printf("Bob");

	}
	else if (a>b)
	{

		printf("Alice");

	}
	else if (a == b)
	{

		printf("Draw");
	}
	else
	{

		printf("Bob");
	}

	*/


	int a, b, c;
	scanf("%d %d %d",&a,&b,&c);

	if(b-a==c-b)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}




















	return 0;

}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int pow(int base, int n) {
    assert(n >= 0);
    if (n == 0) return 1;
    else return base * pow(base, n - 1);
}

int cnt = 0;

bool check(ll v) {
    bool appeared[3] = {false, false, false}; // for 3, 5, and 7
    while (v != 0) {
        int d = v % 10;
        if (d == 3) appeared[0] = true;
        if (d == 5) appeared[1] = true;
        if (d == 7) appeared[2] = true;
        v /= 10;
    }
    return appeared[0] && appeared[1] && appeared[2];
}

void solve(ll acc, const ll N) {
    if (acc > N) return;

    if (check(acc)) {
        // printf("acc: %lld\n", acc);
        cnt++;
    }

    solve(acc * 10 + 7, N);
    solve(acc * 10 + 5, N);
    solve(acc * 10 + 3, N);
}

int main(void) {
    int N;
    cin >> N;
    solve(0, N);
    cout << cnt << endl;
    return 0;
}


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

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

inline void Main() {
  // code
  int n,m;
  priority_queue<int> a;
  cin>>n>>m;
  rep(i, n) {
    int x;
    cin>>x;
    a.push(x);
  }

  rep(i, m) {
    int x = a.top();
    a.pop();
    a.push(x/2);
  }

  long long r = 0;
  while (!a.empty()) {
    r += a.top();
    a.pop();
  }

  cout << r << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    
    
    int main() {
     int n,m,l;
     cin >> n >> m >> l;
     int a[n][m];
     int b[m][l];
     
     rep(i,n){
     	rep(j,m){
     		cin >> a[i][j];
     	}
     }
     
     rep(i,m){
     	rep(j,l){
     		cin >> b[i][j];
     	}
     }
     
     long long sum = 0;
     rep(i,n){
     	rep(j,l){
     		rep(k,m){
     		sum += a[i][k]*b[k][j];
     		}
     		cout << sum;
     		sum=0;
     		if(j!=l-1) cout <<' ';
     	}
     	
     	cout <<'\n';
     }
     
     
     
     return 0;
    }


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A;
  cin >> N >> A;
  int b;
  b= N % 500;
  if (b <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  int A[210];
  for(int i =0;i<a;i++) cin >> A[i];
  int res = 0;
  while(true){
    bool exist_odd = false;
    for(int i = 0;i<a;i++){
      if(A[i]%2!=0) exist_odd=true;
    }
    if(exist_odd) break;
    for(int i=0;i<a;i++){
      A[i]/=2;
    }
    ++res;
  }
  cout << res << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()

int main(){
	int M, N;
	cin >> N >> M;
	vector<int> A(N);
	for(auto &a : A) cin >> a;
	int sum = 0;
	for(auto &a : A) sum += a;
	int cnt = 0;
	for(auto &a : A) {
		if(a >= ((double)sum / (4 * M) ) ) {
			cnt++;
		}
	}
	cout << ((cnt >= M) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
#include <time.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	long long int a, z;
	for (int i = 0; i < s.size()-1; i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = s.size()-1; i >= 0; i--) {
		if (s[i] == 'Z') {
			z = i;
			break;
		}
	}
	cout << z - a + 1 << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned uint;
typedef pair<uint, uint> pairUInt;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

int main(int argc, char *argv[])
{
    uint N, W, w, v;
    unordered_map<uint, uint> table;

    cin >> N >> W;
    FOR(i,N) {
        cin >> w >> v;
        if (w > W) continue;

        unordered_map<uint, uint> table2=table;
        for(auto x : table2) {
            if (x.first + w <= W) {
                auto it = table.find(x.first + w);
                if (it == table.end() || it->second < x.second + v)
                    table[x.first + w] = x.second + v;
            }
        }
        
        auto it = table.find(w);
        if (it == table.end() || it->second < v)
            table[w] = v;
    }

    if (table.size() != 0) {
        auto max_it = max_element(table.begin(), table.end(),
                                  [](pairUInt a, pairUInt b) {
                                      return a.second < b.second;
                                  });
        cout << max_it->second << endl;
    }
    else cout << 0 << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 3e2 + 48, mod = 1e9 + 7, maxn = 102;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;



int n, c1, c2, c3;
double dp[N][N][N];

double rec (int i, int j, int k) {
    if (!i && !j && !k)
    	return 0;
    double &res = dp[i][j][k];
	if (res != -1)
		return res;

	res = (n + 0.0) / (i + j + k);
	int nn = i + j + k;
	if (i)
		res += rec(i - 1, j, k) * (i + 0.0) / nn;
	if (j)
		res += rec(i + 1, j - 1, k) * (j + 0.0) / nn;
	if (k)
		res += rec(i, j + 1, k - 1) * (k + 0.0) / nn;
										
	return res;
}

main () {

	cin >> n;
	forn (i, 1, n) {
		int x;
		cin >> x;
		if (x == 1)
			++c1;
		else if (x == 2)
			++c2;
		else
			++c3;
	}
	forn (i, 0, n)
		forn (j, 0, n)
			forn (k, 0, n)
				dp[i][j][k] = -1;

	cout << setprecision(11) << fixed;
	cout << rec(c1, c2, c3);
		
}                       

Measured memory_bytes: 284672
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

int main() {
    int x, y;
    cin >> x >> y;
    int ans = mod;
    FOR(i, 2)FOR(j, 2) {
        int a = x, b = y, c = 0;
        FOR(k, i) {
            a *= -1;
            c++;
        }
        FOR(k, j) {
            b *= -1;
            c++;
        }
        if (a <= b) {
            chmin(ans, b - a + c);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll n;
    cin>>n;
    string s;
    cin>>s;
    for(auto it:s){
        char a = 'A';
        auto diff = it - a;
        diff+=n;
        diff%=26;
        char t = a+diff;
        cout<<t;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cassert>
#include <functional>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define dump(x)  cerr << #x << " = " << (x) << endl;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 



//ここから書き始める
int main(int argc, char const *argv[])
{
	int N,M;
	cin >> N >> M;

	LL x[N], y[N], z[N];
	LL sum[N];
	REP(i,N)
	{
		cin >> x[i] >> y[i] >> z[i];
	}

	LL kouho[8]; //ppp,ppn,pnp,pnn,npp,npn,nnp,nnn
	REP(i,8)
	{
		kouho[i] = 0;
	}

	//ppp
	REP(i,N)
	{
		sum[i] = x[i] + y[i] + z[i];
	}
	sort(sum, sum+N, greater<LL>());
	REP(i,M)
	{
		kouho[0] += sum[i];
	}

	//ppn
	REP(i,N)
	{
		sum[i] = x[i] + y[i] - z[i];
	}
	sort(sum, sum+N, greater<LL>());
	REP(i,M)
	{
		kouho[1] += sum[i];
	}


	//pnp
	REP(i,N)
	{
		sum[i] = x[i] - y[i] + z[i];
	}
	sort(sum, sum+N, greater<LL>());
	REP(i,M)
	{
		kouho[2] += sum[i];
	}

	//pnn
	REP(i,N)
	{
		sum[i] = x[i] - y[i] - z[i];
	}
	sort(sum, sum+N, greater<LL>());
	REP(i,M)
	{
		kouho[3] += sum[i];
	}


	//npp
	REP(i,N)
	{
		sum[i] = -x[i] + y[i] + z[i];
	}
	sort(sum, sum+N, greater<LL>());
	REP(i,M)
	{
		kouho[4] += sum[i];
	}

	//npn
	REP(i,N)
	{
		sum[i] = -x[i] + y[i] - z[i];
	}
	sort(sum, sum+N, greater<LL>());
	REP(i,M)
	{
		kouho[5] += sum[i];
	}

	
	//nnp
	REP(i,N)
	{
		sum[i] = - x[i] - y[i] + z[i];
	}
	sort(sum, sum+N, greater<LL>());
	REP(i,M)
	{
		kouho[6] += sum[i];
	}

	//nnn
	REP(i,N)
	{
		sum[i] = -x[i] - y[i] - z[i];
	}
	sort(sum, sum+N, greater<LL>());
	REP(i,M)
	{
		kouho[7] += sum[i];
	}


	sort(kouho, kouho+8, greater<LL>());

	cout << kouho[0] << endl;

}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> c(N);
  for (int i = 0; i < N; i++) {
    cin >> c[i];  
  }
  
  int a_sum, b_sum;
  a_sum = b_sum = 0;
  
  bool is_a = true;
  
  while (!c.empty()) {
    // 一番大きいのを探す
    int max_arg = -1;
    int max = -1;
    for (int i = 0; i < c.size(); i++) {
      if (max < c[i]) {
        max = c[i];
        max_arg = i;
      }
    }
    // 得点をいれる
    if (is_a) {
      a_sum += max;
    } else {
      b_sum += max;
    }
    // カード除去
    c.erase(c.begin() + max_arg);
    // 攻守交代
    is_a = !is_a;
  }
  
  cout << (a_sum - b_sum) << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include<cstdio>
#include<string>

using namespace std;
int main() {
	int a=1;
	int n, k;
	cin >> n >> k;
	
	for (int i = 0; i < n; i++) {
		if (a * 2 < a + k) {
			a = a * 2;
		}
		else {
			a += k;
		}
	}
	cout << a <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF ((int)1e9)
int abc(int a) {return ((a<0)?-a:a);}
int min(int a, int b) {return ((a<b)?a:b);}
int main() {
	int dp[45][4],RB[45][2],f[45][4],n,i,j;while (scanf("%d",&n)!=EOF && n) {
		for (i=0;i<4;i++) for (j=0;j<45;f[j][i]=INF,dp[j++][i]=INF);dp[0][0]=0;
		for (i=1;i<=n;scanf("%d %d",&RB[i][0],&RB[i][1]),i++);
		if (RB[1][1]<RB[1][0]) {puts("NG 1");continue;}
		dp[1][1]=RB[1][1];f[1][1]=RB[1][0];
		for (i=2;i<=n;i++) {
			for (j=2;j<4;j++)
				if (RB[i][1]>=dp[i-1][j-1]+abc(RB[i][0]-RB[i-1][0])*j)
					dp[i][j]=RB[i][1],
					f[i][j]=f[i-1][j-1]+abc(RB[i][0]-RB[i-1][0]);
			for (j=1;j<4;j++)
				if (RB[i][1]>=dp[i-1][j]+RB[i-1][0]*(j+1)+RB[i][0])
					if (f[i][1]>f[i-1][j]+RB[i-1][0]+RB[i][0])
						dp[i][1]=RB[i][1],
						f[i][1]=f[i-1][j]+RB[i-1][0]+RB[i][0];
			for (j=1;j<4;j++) if (dp[i][j]==RB[i][1]) break;
			if (j==4) {printf("NG %d\n",i);break;}
		}
		if (i>n) printf("OK %d\n",min(min(f[n][1],f[n][2]),f[n][3])+RB[n][0]);
	}
	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    long long a=1,ans=0;
    for(int i=0;i<n;i++) {
        long long tmp; cin>>tmp;
        while(tmp%2==0){
            tmp/=2; ans++;
        }
    }
    
    cout<<ans<<endl;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int h, n; cin >> h >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        sum += a;
    }

    if(h <= sum) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3556
n = int(input())
a = list(map(int,input().split()))
dp = [[0 for i in range(3)] for j in range(n+1)]
for i in range(1,n+1):
  ai = a[i-1]
  dp[i] = dp[i-1][:]
  if i%2:
    dp[i][0] += +ai
    dp[i][1] = max(dp[i-1][0],dp[i-1][1])
  if i%2 == 0:
    dp[i][1] += ai
    dp[i][2] = max(dp[i-1][1],dp[i-1][2])
  if i >= 3 and i%2:
    dp[i][2] += ai
if n%2 == 0:
  print(max(dp[-1][0],dp[-1][1]))
else:
  print(max(dp[-1][1],dp[-1][2]))

Measured memory_bytes: 131004
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int A, B; cin >> A >> B;
  int M = max(A, B), m = min(A, B);
  cout << M + max(M - 1, m) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input().split() for _ in range(n)]

for i in range(n):
  s[i].insert(0, i+1)

for i in range(1, n):
  tmp = s[i][:]
  for j in range(1, i+1):
    if tmp[1] < s[i-j][1]:
      s[i-j+1], s[i-j] = s[i-j], s[i-j+1]
    elif tmp[1] == s[i-j][1]:
      if int(tmp[2]) > int(s[i-j][2]):
        s[i-j+1], s[i-j] = s[i-j], s[i-j+1]

for i in range(n):
  print(s[i][0])

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll dp[6010][6010];

int main() {
	int N; ll M;
	cin >> N >> M;
	int n = N * 3;

	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (i >= 3) {
			for (int j = 0; j <= n; ++j) {
				(dp[i][j+1] += dp[i-3][j] * (i-1) % M * (i-2)) %= M;
			}
		}
		if (i >= 2) {
			for (int j = 0; j <= n; ++j) {
				(dp[i][j+1] += dp[i-2][j] * (i-1)) %= M;
			}
		}
		for (int j = 0; j <= n; ++j) {
			(dp[i][j] += dp[i-1][j]) %= M;
		}
	}
	ll ans = 0;
	for (int i = 0; i <= N; ++i) {
		ans = (ans + dp[n][i]) % M;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 281984
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N,D;
    cin >> N >> D;

    vector<ll> X(N), Y(N);
    REP(i,N) cin >> X[i] >> Y[i];

    int ans = 0;

    REP(i, N){
        if(D*D>=((X[i]*X[i])+(Y[i]*Y[i])))ans++;
    }
    pr(ans);
    
}

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

int main() {
  int n, m, c; cin >> n >> m >> c;
  int b[m];
  for (auto &v : b) cin >> v;
  int a[n][m];
  for (auto &v : a) for (auto &u : v) cin >> u;
  int ans = 0;
  for (auto &v : a) {
    int tmp = c;
    for (int i=0; i<m; ++i) {
      tmp += v[i] * b[i];
    }
    if (tmp > 0) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 55;
const double g = 9.8;   //重力加速度
const double EPS = 1e-10;
int N;
double V, X, Y;
double L[maxn], B[maxn], R[maxn], T[maxn];

//&#35745;算以vy的速度&#31446;直向上射出t秒后的位置
double calc(double vy, double t)
{
    return vy * t - g * t * t / 2;
}

//a相&#23545;lb和ub的位置
int cmp(double lb, double ub, double a)
{
    return a < lb + EPS ? -1 : a > ub - EPS ? 1 : 0;
}

//判断当射出路径&#32463;&#36807;点(qx, qy)&#26102;，卵是否能&#20987;中猪
bool check(double qx, double qy)
{
    //&#35774;初速度在x方向和y方向的分量分&#21035;&#20026;vx和vy，&#35774;通&#36807;(qx, qy)的&#26102;&#38388;&#20026;t
    //&#35774;解&#32852;立方程式vx^2 + vy ^2 = V^2, vx * t = 1x, vy * t - 1/2 g t^2 = qy
    double a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
    double D = b * b - 4 * a * c;
    if (D < 0 && D > -EPS)
        D = 0;
    if (D < 0)
        return false;
    for (int d = -1; d <= 1; d += 2){       //&#39564;&#35777;&#32852;立方程式上的&#20004;个解的循&#29615;
        double t2 = (-b + d * sqrt(D)) / (2 * a);
        if (t2 <= 0)
            continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = (qy + g * t * t / 2) / t;

        //判断是否通&#36807;猪的正上方
        double yt = calc(vy, X / vx);
        if (yt < Y - EPS)
            continue;

        bool ok = true;
        for (int i = 0; i < N; i++){
            if (L[i] >= X)
                continue;
            //判断在猪正上方的&#40479;和猪之&#38388;是否有障碍物
            if (R[i] == X && Y <= T[i] && B[i] <= yt)
                ok = false;
            //判断在&#39134;到猪的正上方之前是否会撞到障碍物
            int yL = cmp(B[i], T[i], calc(vy, L[i] / vx));   //左&#20391;的相&#23545;位置
            int yR = cmp(B[i], T[i], calc(vy, R[i] / vx));   //右&#20391;的相&#23545;位置
            int xH = cmp(L[i], R[i], vx * (vy / g));      //最高点的相&#23545;位置
            int yH = cmp(B[i], T[i], calc(vy, vy / g));
            if (xH == 0 && yH >= 0 && yL < 0)
                ok = false;
            if (yL * yR <= 0)
                ok = false;
        }
        if (ok)
            return true;
    }
    return false;
}

void solve()
{
    //截掉猪以右的障碍物
    for (int i = 0; i < N; i++){
        R[i] = min(R[i], X);
    }
    bool ok = check(X, Y);      //直接撞上猪的情况
    for (int i = 0; i < N; i++){
        ok |= check(L[i], T[i]);     //&#32463;&#36807;左上角的情况
        ok |= check(R[i], T[i]);     //&#32463;&#36807;右上角的情况
    }
    puts(ok ? "Yes" : "No");
}

int main()
{
    while (scanf("%d%lf%lf%lf", &N, &V, &X, &Y) != EOF){
        for (int i = 0; i < N; i++){
            scanf("%lf%lf%lf%lf", &L[i], &B[i], &R[i], &T[i]);
        }
        solve();
    }
    return 0;
}

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

using namespace std;

int main(){
    vector<pair<int, int> > pic;
    int N;

    while(cin >> N, N){
        int maxHeight = 1, minHeight = 1, maxWidth = 1, minWidth = 1;
        pic.push_back(pair<int, int>(1, 1));
        for(int i=0; i < N-1; i++){
            int n, d;
            cin >> n >> d;
            switch (d){
                case 0:
                    pic.push_back(pair<int, int>(pic[n].first-1, pic[n].second));
                    break;
                case 1:
                    pic.push_back(pair<int, int>(pic[n].first, pic[n].second-1));
                    break;
                case 2:
                    pic.push_back(pair<int, int>(pic[n].first+1, pic[n].second));
                    break;
                case 3:
                    pic.push_back(pair<int, int>(pic[n].first, pic[n].second+1));
                    break;
            }
            maxWidth = max(maxWidth, pic[i+1].second);
            minWidth = min(minWidth, pic[i+1].second);
            maxHeight = max(maxHeight, pic[i+1].first);
            minHeight = min(minHeight, pic[i+1].first);
        }
        cout << maxHeight-minHeight+1 << " " << maxWidth-minWidth+1 << endl;

        pic.clear();
    }
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
using namespace std;
int a[111], wi[111];
long long dp[111111];
bool d[111111];
int main() {
	int n,w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> wi[i] >> a[i];
	}
	d[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = w; j >= 0; j--) {
			if (d[j] == 1 && j+wi[i]<=w) {
				d[j+wi[i]] = 1;
				dp[j+wi[i]] = max(dp[j+wi[i]], dp[j] + a[i]);
			}
		}
	}
	long long m = 0;
	for (int i = 1; i <= w; i++) {
		m = max(dp[i], m);
	}
	cout << m;
}

Measured memory_bytes: 4492
#include<bits/stdc++.h>
using namespace std;
char a[10];
int main()
{
	scanf("%s",a);
	for(int i=0;i<=2;i++)
		if(a[i]=='7')
		{
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3652
# include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
using ll = long long;
const ll INF = ll(1e18) + 1;

bool search(int n, ll k, vector<ll> a, ll mid)
{
  ll tot = 0;
  rep(i, n) {
    int l = -1, r = n;

    if(a[i] < 0) {
      while(l+1 < r) {
        int m = (l+r) / 2;
        if (a[m] * a[i] < mid) r = m; else l = m;
      }
      tot += n - r;
    } else {
      while(l+1 < r) {
        int m = (l+r) / 2;
        if (a[m] * a[i] < mid) l = m; else r = m;
      }
      tot += r;
    }
    if (a[i] * a[i] < mid) tot--;
  }
  return (tot / 2 < k);
}

int main()
{
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  
  ll l = -INF, r = INF;
  while(l+1 < r) {
    ll mid = (l + r) / 2;
    
    // K未満の値が見つかるかをチェック
    if (search(n, k, a, mid)) l = mid; else r = mid; 
  }
  
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 3428