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

public class Main
{
    public static void main(String[] args)
    {
        Scanner cin = new Scanner(System.in);
        int n = Integer.parseInt(cin.next());
        int[] array = new int [n];
        cin.nextLine();
        for (int i = 0; i < n; i++)
        {
            array[i] = cin.nextInt();
        }
        insertionSort(array, n);

    }

    public static void insertionSort(int[] A, int n)
    {
        int v;
        for(int i = 0; i < n; i++)
        {
            v = A[i];
            int j = i -1;

            while (j >= 0 && A[j] > v)
            {
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = v;

            // ?????????????????????
            for (int z = 0; z < n; z++)
            {
                System.out.print(A[z]);
                if (z != n - 1)
                    System.out.print(" ");
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 25920
import sys
import operator
import collections


Card = collections.namedtuple('Card', ('suit', 'value'))


def partition(a, p, r):
    x = a[r].value
    i = p - 1
    for j in range(p, r):
        if a[j].value <= x:
            i += 1
            a[i], a[j] = a[j], a[i]
    a[i + 1], a[r] = a[r], a[i + 1]
    return i + 1


def quick_sort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quick_sort(a, p, q - 1)
        quick_sort(a, q + 1, r)


n = int(sys.stdin.readline())
a = []
for _ in range(n):
    suit, value = sys.stdin.readline().split()
    a.append(Card(suit, int(value)))

stable = sorted(a, key=operator.itemgetter(1))
quick_sort(a, 0, n - 1)

print('Stable' if a == stable else 'Not stable')
for suit, value in a:
    print(f'{suit} {value}')



Measured memory_bytes: 19280
#include <iostream>
using namespace std;
int main(void){
    int a,b,max;
    cin>>a>>b;
    
    max=a+b;
    if(max<a-b)max=a-b;
    if(max<a*b)max=a*b;
    
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 256
open Array
let rec make_list n = if n = 0 then [] else n :: make_list (n-1)
let n,k = Scanf.scanf "%d %d\n" @@ fun a b -> a, b
let lst = to_list (init k @@ fun _ -> Scanf.scanf "%d\n" @@
  fun d -> to_list (init d @@ fun _ -> Scanf.scanf "%d " @@ fun x -> x))
let rec f arr lst = match arr with
  | [] -> lst
  | hl :: t -> f t (List.filter (fun x -> not (List.mem x hl)) lst)
let () = print_int (List.length (f lst (make_list n)))

Measured memory_bytes: 5988
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


vector <pair <ll, ll>> as;
ll yaru(ll left, ll right, vector<vector<ll>> &dp){
    ll *memo = &(dp[left][right]);
    ll val = as[right - left].first;
    ll idx = as[right - left].second;
    if (*memo != -1){
        return *memo;
    }
    if (left == right){
        *memo = val * abs(idx - left);
        return *memo;
    }
    ll l = val * abs(idx - left);
    l += yaru(left+1, right, dp);
    ll r = val * abs(idx - right);
    r += yaru(left, right-1, dp);
    *memo = max(l, r);
    return *memo;
}


int main(void){
    ll n; cin >> n;
    REP(i, n){
        ll a; cin >> a;
        as.push_back({a, i});
    }
    sort(as.begin(), as.end());
    ll left = 0;
    ll right = n-1;
    vector<vector<ll>> dp(n, vector<ll>(n, -1));
    cout << yaru(left, right, dp) << endl;
    return 0;
}

Measured memory_bytes: 34872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int nums[N];
  bool allEven = true;
  int result = 0;
  for(int i = 0; i < N; i++){
    cin >> nums[i];
    //cout << nums[i] << endl;
  }
  while(allEven){
    for(int i = 0; i < N; i++){
      if(nums[i] % 2 == 0){
        //cout << i << ':' << nums[i] << ' ';
      }else if(nums[i] == 0){
        allEven = false;
      }else{
        allEven = false;
      }
    }
    if(allEven){
      for(int i = 0; i < N; i++){
        nums[i] = nums[i] / 2;
      }
      result++;
    }
    //cout << "allEven" << allEven << endl;
  }
  
  cout << result << endl;
}

Measured memory_bytes: 640
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
	

int main(){
	FIO
	
	int q;
	cin >> q;
	int first = 0, second = 0;
	while(q--){
		string s, t;
		cin >> s >> t;
		if(s < t)first += 3;
		else if(s > t)second += 3;
		else first++, second++;
	}
	cout << second << " " << first << '\n';
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  std::vector<ll> v;
  ll s = 0;
  for(int i = 1; i < 1e6; i++){
    s += i;
    v.pb(s);
  }

  ll n, ans = 0;
  cin >> n;
  for(ll p = 2; p * p <= n; p+= 2){
    ll po = 0;
    while(n % p == 0){
      n /= p; po++;
    }
    if(po){
      auto it = upper_bound(v.begin(), v.end(), po);
      ans += ll(it - v.begin());
    }
    if(p == 2)p--;
  }
  if(n > 2) ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 11440
using System;

namespace ABC097_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            var A = int.Parse(N[0].ToString());
            var B = int.Parse(N[1].ToString());
            var C = int.Parse(N[2].ToString());
            var D = int.Parse(N[3].ToString());
            var s = "";
            if (A + B + C + D == 7) s = $"{A}+{B}+{C}+{D}=7";
            if (A - B + C + D == 7) s = $"{A}-{B}+{C}+{D}=7";
            if (A + B - C + D == 7) s = $"{A}+{B}-{C}+{D}=7";
            if (A + B + C - D == 7) s = $"{A}+{B}+{C}-{D}=7";
            if (A - B - C + D == 7) s = $"{A}-{B}-{C}+{D}=7";
            if (A - B + C - D == 7) s = $"{A}-{B}+{C}-{D}=7";
            if (A + B - C - D == 7) s = $"{A}+{B}-{C}-{D}=7";
            if (A - B - C - D == 7) s = $"{A}-{B}-{C}-{D}=7";
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	private class Node {
		int id;
		Node left = null, right = null;
		boolean visited = false;
		public Node(int id) {this.id = id;}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		Node root = null;
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			String cmd = st.nextToken();
			if (cmd.equals("insert")) {
				root = insert(root, Integer.parseInt(st.nextToken()));
			} else if (cmd.equals("print")){
				inOrder(root);
				preOrder(root);
			}
		}
		reader.close();
	}

	private void preOrder(Node root) {
		Stack<Node> stack = new Stack<Node>();
		stack.push(root);
		while (!stack.isEmpty()) {
			Node cur = stack.pop();
			System.out.print(" " + cur.id);
			cur.visited = false;
			if (cur.right != null) stack.push(cur.right);
			if (cur.left != null) stack.push(cur.left);
		}
		System.out.println();
	}

	private void inOrder(Node root) {
		Stack<Node> stack = new Stack<Node>();
		stack.push(root);
		while (!stack.isEmpty()) {
			Node cur = stack.peek().left;
			while (cur != null && !cur.visited) {
				stack.push(cur);
				cur = cur.left;
			}
			cur = stack.pop();
			System.out.print(" " + cur.id);
			cur.visited = true;
			if (cur.right != null && !cur.right.visited) {
				stack.push(cur.right);
			}
		}
		System.out.println();
	}

	private Node insert(Node root, int id) {
		if (root == null) {
			return new Node(id);
		}
		Stack<Node> stack = new Stack<Node>();
		stack.push(root);
		while (!stack.isEmpty()) {
			Node cur = stack.pop();
			if (id < cur.id) {
				if (cur.left == null) {
					cur.left = new Node(id);
					return root;
				}
				stack.push(cur.left);
			} else {
				if (cur.right == null) {
					cur.right = new Node(id);
					return root;
				}
				stack.push(cur.right);
			}
		}
		return null;
	}
}



Measured memory_bytes: 125560
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0] < s[1]) {
      s[0] = s[0] + 1;
      s[1] = s[0];
      s[2] = s[0];
    } else if (s[0] > s[1]){
      s[1] = s[0];
      s[2] = s[0];
    } else if (s[0] < s[2]){
      s[0] = s[0] + 1;
      s[1] = s[0];
      s[2] = s[0];
    } else {
      s[1] = s[0];
      s[2] = s[0];
    }

     cout << s << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<queue>
#define mp(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,m;
  cin >> n >> m;
  int t[100005]={};
  priority_queue<P,vector<P> > q;
  int i,j,k;
  for(i=0;i<n;i++){
    cin >> k;
    q.push(mp(k,i));
  }
  int o=0,time;
  while(!q.empty()){
    P f=q.top();q.pop();
    if(f.second==0){
      time=t[1];
    }else if(f.second==n-1){
      time=t[n-2];
    }else{
      time=max(t[f.second-1],t[f.second+1]);
    }
    t[f.second]=time+m-f.first;
    o=max(o,t[f.second]);
  }
  cout << o << endl;
  return 0;
}

Measured memory_bytes: 2440
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<pair<int, int>> A(N);
    REP(i, N) {
        int a;
        cin >> a;
        A[i] = {a, i + 1};
    }

    sort(ALL(A));

    REP(i, N) {
        if (i > 0) cout << " ";
        cout << A[i].se;
    }

    cout << endl;
    
}


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

int N;
typedef long long ll;
ll A[10010];

ll min()
{
    ll min = A[0];
    for (int i = 0; i < N; i++)
    {
        if (A[i] < min)
        {
            min = A[i];
        }
    }
    return min;
}
ll max()
{
    ll max = A[0];
    for (int i = 0; i < N; i++)
    {
        if (A[i] > max)
        {
            max = A[i];
        }
    }
    return max;
}

ll sum()
{
    ll sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += A[i];
    }

    return sum;
}

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

    ll a = min();
    ll b = max();
    ll c = sum();
    cout << a << ' ' << b << ' ' << c << endl;
}


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

#define ll long long

int cnt_dights(ll N){
    int digits = 0;
    while(N > 0){
        N /= 10;
        digits++;
    }

    return digits;
}

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

    int ans = cnt_dights(N);

    for(ll A = 1LL; A*A <= N; A++){
        if(N%A != 0) continue;
        const ll B = N / A;

        const int cur = max(cnt_dights(A), cnt_dights(B));

        if(ans > cur) ans = cur;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    int cnt = 0;
    if ( s[0] == '1' ) ++cnt;
    if ( s[1] == '1' ) ++cnt;
    if ( s[2] == '1' ) ++cnt;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] counter = new int[100];
        int maxIdx = 0;
        int maxCnt = 0;
        
        for (int i = 0; i < counter.length; i++) {
            counter[i] = 0;
        }
        
        while (scanner.hasNext()) {
            int n = scanner.nextInt() - 1;
            counter[n]++;
            if (counter[n] > counter[maxIdx]) {
                maxIdx = n;
                maxCnt = counter[n];
            } 
        }
        
        for (int i = 0; i < counter.length; i++) {
            if (counter[i] == maxCnt) {
                System.out.println(i+1);
            }
        }
    }
}

Measured memory_bytes: 18108
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;


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

	vector<int> w(N, 0), v(N, 0);
	long long w_base = 0;
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
		if (i == 0) {
			w_base = w[i] - 1;
		}
		w[i] -= w_base;
	}

	int w_limit = 1 + N * 4;
	// i個目をチェック・j個格納・価値k
	VVVI dp(N+1, VVI(N+1, VI(w_limit, -99)));
	dp[0][0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = w_limit - 1; k >= 0; k--) {
				if (dp[i][j][k] < 0) {
					continue;
				}


				dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);

				int nw = k + w[i];
				long long real_nw = w_base * (j + 1) + nw;
// printf("  ijk: %d %d %2d: dp %3d, nw %3d, real %3lld\n", i, j, k, dp[i][j][k], nw, real_nw);

				if (real_nw <= W && nw < w_limit) {
// printf("  ok:  %3d %3d\n", dp[i+1][j+1][nw], dp[i][j][k] + v[i]);
					dp[i+1][j+1][nw] = max(dp[i+1][j+1][nw], dp[i][j][k] + v[i]);
				}
			}
		}
	}

	int ans = 0;
	for (auto v: dp[N]) {
		for (auto x: v) {
			ans = max(ans, x);
		}
	}

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


Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> A(n,0);
    for(ll i=0;i<n;++i)cin>>A[i];
    deque<ll> ans;
    for(ll i=0;i<n;++i){
        if(i%2)ans.emplace_back(A[i]);
        else ans.emplace_front(A[i]);
    }
    if(n%2==0)reverse(ans.begin(), ans.end());
    for(ll i=0;i<n;++i)cout<<ans[i]<<" ";cout<<endl;fl

    return 0;
}


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

int main() {

  int h, w;
  while(1){
    cin >> h >> w;
    if(h == 0 && w == 0){
      break;
    }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(1 <= i && i <= h-2){
          if(1 <= j && j <= w-2){
            cout << ".";
            continue;
          }
        }
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}



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

int main() {
    int n;
    cin >> n;
    int b0 = 0, b1 = 0, b2 = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        int cnt = 0;
        while (1) {
            if (a % 2 == 0) {
                cnt++;
                a /= 2;
            }
            else break;

            if (cnt == 2) break;
        }

        if (cnt == 0) b0++;
        else if (cnt == 1) b1++;
        else b2++;
    }

    if (b1 == 0) {
        if (b0 <= b2 + 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        if (b0 <= b2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int e[101]={};
  for(int i=a;i<b;i++){
    e[i]++;
  }
  for(int i=c;i<d;i++){
    e[i]++;
  }
  int f=0;
  for(int i=0;i<101;i++){
    if(e[i]==2)
      f++;
  }
  cout<<f;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String slist[] = s.split(",");;
        for(int i = 0 ; i < 3 ; ++i){
            System.out.print(slist[i] + " ");
        }
    }
}


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

int main(){
    int n;
    ll k;
    ll a[100005];
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    int zero[70];
    int one[70];
    int keta=0;//0,1は0桁
    ll dketame[70]={0};
    while(k>0){
        dketame[keta]=k%2;
        k/=2;
        if(k>0) keta++;
    }
    for(int i=0;i<51;i++){
        for(int j=0;j<n;j++){
            
            if(a[j]%2==0) zero[i]++;
            else one[i]++;
            a[j]/=2;
        }
    }
    ll res=0;
    for(int d=40;d>=-1;d--){
        if(d!=-1 && dketame[d]==0) continue;
        
        ll tmp=0;
        
        for(int i=0;i<40;i++){
            ll mask=1LL<<i;
            if(i<d){
                tmp+=max(zero[i],one[i])*pow(2,i);
            }
            else if(i==d){
                tmp+=one[i]*pow(2,i);
            }
            else{
                if(dketame[i]==1) tmp+=zero[i]*mask;
                else tmp+=one[i]*mask;
            }
        }
        res=max(res,tmp);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(void) {
  int n;
  float x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> n;
  while (n--) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    if ((y1 - y2) / (x1 - x2) == (y3 - y4) / (x3 - x4)) {
      cout << "YES";
    } else {
      cout << "NO";
    }
    cout << endl;
  }
  return 0;
}

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

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<=b; i++)
#define nl cout<<"\n";
#define sp cout<<" ";

int main()
{
    op();
    int n,cnt,r,sum=0;
    cin>>n;
    lo(i,1,n)
    {
        cnt=0;
        r=i;
        while(r>0)
        {
            cnt++;
            r=r/10;
        }
        if(cnt%2!=0)
            sum++;
    }
    cout<<sum;
    nl;
    return 0;
}



Measured memory_bytes: 256
s=int(input())
s1=s/100
s2=s%100
if((1<=s1<=12)and(1<=s2<=12)):
    print('AMBIGUOUS')
elif(((s1<1) or (12<s1)) and(1<=s2<=12)):
    print('YYMM')
elif(((s2<1) or (12<s2)) and(1<=s1<=12)):
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 3060
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

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

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n, id = 1;
char s[N];
vector <int> g[N];
void go(int v, int p, int size) {
	if (p) {
		g[v].pb(p);
		g[p].pb(v);
	}
	if (p && s[size] == '0') {
		cout << -1, ioi
	}
	if (!p && s[size] == '1') cout << -1, ioi
	
	while (size > 1) {
		if (s[size - 1] == '1') {
			go(++id, v, size - 1);
			return;
		} else if (s[1] == '1') {
			go(++id, v, 1);
			--size;
		} else break;
	}
}
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	cin >> (s + 1);
	n = strlen(s + 1);
	rep(i, 1, n - 1) if (s[i] != s[n - i]) cout << -1, ioi
	go(1, 0, n);
	if (id != n) cout << -1, ioi
	rep(i, 1, n) {
		sort(all(g[i]));
		g[i].erase(unique(all(g[i])), g[i].end());
		for (auto to : g[i]) if (i < to) cout << i << ' ' << to << nl;
	}
	ioi
}


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

int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  
  int count=0;
  for(int i=0; i<min(K,A); i++){
    count++;
  }

  int S=K-A-B;
  if(S>0){
    for(int i=0; i<S; i++){
      count--;}
  }
  
  cout<<count<<endl;
    

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

long long powerMod(long long number,long long power)
{
    LL ret=0;

    if(power==0) return 1;
    if(power==1) return number;
    if(power%2==0)
    {
        ret=powerMod(number,power/2);
        ret=(ret*ret);
        return ret;
    }
    else
    {
        ret=powerMod(number,power/2);
        ret=(ret*ret*number);
        return ret;
    }
}


set<int> st[26];

int main()
{
    //boost;

    int n;
    cin>>n;

    S s;
    cin>>s;

    for(int i=0;i<s.size();i++)
    {
        int ch=s[i]-'a';
        st[ch].insert(i);
    }

    int q;
    cin>>q;

    while(q--)
    {
        int option;
        cin>>option;

        if(option==1)
        {
            int pos;
            cin>>pos;

            char c;
            cin>>c;

            pos--;

            st[s[pos]-'a'].erase(pos);
            s[pos]=c;
            st[c-'a'].insert(pos);
        }

        else
        {
            int l,r;

            cin>>l>>r;

            l--;
            r--;
            int count=0;

            for(int i=0;i<26;i++)
            {
                set<int>::iterator itr;
                itr=st[i].lower_bound(l);
                if(itr!=st[i].end() && *itr<=r)
                    count++;
            }
            cout<<count<<nl;
        }


    }


    return 0;
}


Measured memory_bytes: 24196
/*Filename: aoj0011.cpp
 *Author: Mushiyo
 */

#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
	int w = 0;

    while(cin >> w){
    	int num[w + 1];
    	for(int i = 1; i <= w; ++i){
    		num[i] = i;
    	}

        int n = 0;
        cin >> n;

        while(n > 0){
        	int a = 0, b = 0;
        	scanf("%d, %d", &a, &b);

        	int tmp = num[a];
        	num[a] = num[b];
        	num[b] = tmp;

        	--n;
        }
        
        for(int i = 1; i <= w; ++i){
        	cout << num[i] << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cmath>

using namespace std;
typedef long long lld;

int main(void)
{
	cin.tie(0);	ios_base::sync_with_stdio(0);
	lld a, b, c;	cin >> a >> b >> c;
	if(c - a - b <= 0)
		cout << "No";
	else if(4*a*b < (c-a-b)*(c-a-b))
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define  MN                           INT_MIN
#define  MX                           INT_MAX

const int nmax = 100001; 

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int minCost(int a[],int n)
{
	int dp[nmax];
	for(int i =0;i<=n;i++)
		dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i = 0;i<n;i++)
	{
		if(i+1< n)dp[i+1] = min(dp[i+1], dp[i] + abs(a[i] - a[i+1]));
		if(i+2 < n)dp[i+2] = min(dp[i+2], dp[i] + abs(a[i] - a[i+2]));
	}
	return dp[n-1];
}
int32_t main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i =  0;i<n;i++)
		cin >> a[i];
	cout << minCost(a, n) << endl;
}
	

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct RangeMinQuery{
  ll dat[(1<<13)-1];
  int size;

  void init(int n_){
    size=1;
    while(size<n_) size*=2;
    for(int i=0;i<2*size-1;i++)dat[i]=INF;
  }

  void update(int k,ll a){
    k+=size-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }

  ll subquery(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return dat[k];
    else{
      return min(subquery(a,b,k*2+1,l,(l+r)/2),subquery(a,b,k*2+2,(l+r)/2,r));
    }
  }
  
  ll query(int a,int b){
    return subquery(a,b,0,0,size);
  }
};

ll N;
ll p[4001],d[4001];
ll dp[2][4001];
RangeMinQuery sgt;

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

  while(1){
    cin>>N;
    if(N==0)break;
    ll dsum=0;
    rep(i,N){
      cin>>p[i]>>d[i];
      dsum+=d[i];
    }
    if(dsum<2*(N-1)){
      cout<<-1<<endl;
      continue;
    }
    vector<P> vs0;
    vector<ll> vs1;
    rep(i,N){
      if(d[i]>1){
        vs0.push_back(P(p[i],d[i]));
      }else vs1.push_back(p[i]);
    }
    sort(all(vs0)); sort(all(vs1));
    ll crt=0,nxt=1;
    ll n0=vs0.size(),n1=vs1.size();
    ll res=0;
    if(n0>1){
      rep(i,n0){
        if(i==0||i==n0-1) vs0[i].se-=1;
        else vs0[i].se-=2;
      }
    }
    if(n0==0&&n1==2){
      cout<<vs1[1]-vs1[0]<<endl;
      continue;
    }
    rep(i,n0-1)res+=vs0[i+1].fi-vs0[i].fi;
    rep(i,2)rep(j,n1+1)dp[i][j]=INF;
    dp[crt][0]=0;
    rep(i,n0){
      sgt.init(n1+1);
      ll sum=0;
      rep(j,n1+1){
        sgt.update(j,dp[crt][j]-sum);
        dp[nxt][j]=sgt.query(j-vs0[i].se,j+1)+sum;
        if(j<n1)sum+=llabs(vs0[i].fi-vs1[j]);
      }
      swap(crt,nxt);
    }
    cout<<res+dp[crt][n1]<<endl;
  }

  return 0;
}



Measured memory_bytes: 3424
import java.util.Scanner;

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

		for (int j = 1; j < N + 1; j = j + 2) {
			int yakusu = 0;
			for (int i = 1; i < N + 1; i++) {
				if(j<i)break;
				if (j % i == 0) {
					yakusu++;
				}
			}
			if (yakusu == 8) {
				cnt++;
			}
		}

		System.out.println(cnt);

		sc.close();
	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

int main() {
  kyun;
  int a,b;
  cin >> a >> b;
  int ans = 0;
  int plug = 1;
  while(1) {
    if(plug >= b) break;
    plug += a - 1;
    ans++;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
  int N, A, B;
  while (cin >> N >> A >> B) {
    int maxi = min(A, B);
    int mini = max(A + B - N, 0);
    cout << maxi << " " << mini << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    d = collections.defaultdict(list)
    n, m = list(map(int, input().rstrip('\n').split()))
    for i in range(m):
        a, b = list(map(int, input().rstrip('\n').split()))
        d[a] += [1]
        d[b] += [1]
    for i in range(1, n + 1):
        print(sum(d[i]))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))



char v[]="AKIHABARA@";

char s[100];

int main(void){
	scanf("%s",s);
	int ls=strlen(s);
	int t=0;
	
	rep(i,ls){
		if(v[t]==s[i])t++;
		else if(v[t]=='A' && s[i]==v[t+1]){
			t+=2;
		}
		else{
			puts("NO");
			return 0;
		}
	}
	
	//printf("%c\n",v[t]);
	puts((v[t]=='@' || t==8)?"YES":"NO");
	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    vector <int> H(N);
    unordered_map <int, int> counter;

    long long ans = 0;

    for (int i = 0; i < N; ++i) {
        cin >> H[i];
        ans += counter[(i+1)-H[i]-1];
        ++counter[i+H[i]];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19368
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    double D_H = 30 * H + 0.5 * M;
    double D_M = 6 * M;

    double T = abs(D_H - D_M);
    T = min(T, 360 - T);
    dump(T);

    double R = T * (M_PI / (double)(180));
    dump(R);
    double X = pow(A * A + B * B - 2 * A * B * cos(R), 0.5);
    cout << setprecision(20) << X << endl;
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
long long a[maxn],b[maxn];
long long f(long long t,long long*a,int A){
    int p=lower_bound(a,a+A,t)-a;
    if(p>=A)p--;
    long long ans=1e13;
    ans=abs(a[p]-t);
    if(p>=1)ans=min(ans,abs(a[p-1]-t));
}
int main()
{
    int A,B,q;
    cin>>A>>B>>q;
    for(int i=0; i<A; i++)
    {
        scanf("%lld",&a[i]);
        //cout<<a[i]<<endl;
    }
    for(int i=0; i<B; i++)
    {
        scanf("%lld",&b[i]);
    }
    sort(a,a+A),sort(b,b+B);
    while(q--)
    {
        long long t;
        scanf("%lld",&t);
        int p1=lower_bound(a,a+A,t)-a;
        int p2=lower_bound(b,b+B,t)-b;
        if(p1>=A)p1--;
        if(p2>=B)p2--;
        long long ans=1e18;
        for(int i=-1;i<=0;i++){
            for(int j=-1;j<=0;j++){
                 if(p1+i<0||p2+j<0)continue;
                ans=min(ans,abs(a[p1+i]-t)+abs(b[p2+j]-a[p1+i]));
                ans=min(ans,abs(b[p2+j]-t)+abs(a[p1+i]-b[p2+j]));
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 2944
#include <stdio.h>
int main()
{
	int W;
	int H;
	int x;
	int y;
	int r;
	scanf("%d",&W);
	scanf("%d",&H);
	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&r);
	W=W-r;
	H=H-r;
	if(W>=x && x>=0 && H>=y && y>=0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>L(m),R(m);
  rep(i,m)cin>>L[i]>>R[i];
  int maxL=1;
  int minR=n;
  rep(i,m){
    maxL=max(maxL,L[i]);
    minR=min(minR,R[i]);
  }
  int ans=minR-maxL+1;
  ans=max(ans,0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
while True:
  n = int(input())
  if n == 0:
    break
  lst = [list(map(int, input().split())) for _ in range(n)]
  lp, lq, lr, lc = map(int, input().split())
  flag = True
  for s, p, q, r in lst:
    if p <= lp and q <= lq and r <= lr and 4 * p + 9 * q + 4 * r <= lc:
      print(s)
      flag = False
  if flag:
    print("NA")


Measured memory_bytes: 5968
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll dp[110][110][330];//dp[i][j][k] i番目までj個選ぶ　k増えた の価値の最大値


int main(){cout<<fixed<<setprecision(10);
		   //ナップサックdp
           //0<= wi-w1 <=3を利用すればok
           ll n,W;
           cin>>n>>W;
           vll w(n+1),v(n+1);
           ll p;
           rep(i,1,n+1){
            cin>>w[i]>>v[i];
             if(i==1)p=w[i];
             else{
               w[i]-=w[1];
             }
           }
           w[1]-=p;
           rep(i,1,n+1){
            rep(j,0,i+1){
             rep(k,0,3*i+1){
               //選ばない
               dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k]);
               //i番目選ぶ
               if(j-1>=0&&k-w[i]>=0)chmax(dp[i][j][k],dp[i-1][j-1][k-w[i]]+v[i]);
             }
            }
           }
           ll ans=0;
           rep(i,0,n+1){
             rep(j,0,3*n+1){
               ll cnt=dp[n][i][j];
               if(W>=i*p+j)
               chmax(ans,cnt);
             }
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 17136
#include <bits/stdc++.h>
using namespace std;
 
#define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
 
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
 
#define LOWBIT(x) ((x)&(-x))
 
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
 
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))
 
#define MP make_pair
#define PB push_back
#define ft first
#define sd second
 
template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}
 
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}
 
template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}
 
inline int gc(){
	static const int BUF = 1e7;
	static char buf[BUF], *bg = buf + BUF, *ed = bg;
	
	if(bg == ed) fread(bg = buf, 1, BUF, stdin);
	return *bg++;
} 
 
inline int ri(){
	int x = 0, f = 1, c = gc();
	for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
	for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
	return x*f;
}
 
typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-10;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;
 
LL pow2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072};
 
int N, K;
double ans;
 
int main(){
	//INIT(); 
	cin >> N >> K;
	For(i, 1, N) {
		if(i < K) {
			int tmp = lower_bound(pow2, pow2 + 18, 1.0 * K / i) - pow2;
			ans += 1.0 / pow2[tmp];
		}
		else {
			ans += N - i + 1;
			break;
		}
	}
	ans /= N;
	printf("%.12f", ans);
    return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int n(s.length()), m(t.length());
  //cout << n << m << endl;
    int ans(m);
    for (int i = 0; i <= n - m; ++i) {
        int a(0);
        for (int j = 0; j < m; ++j) {
            if (s[i+j] != t[j]) a++;
        }
        ans = min(ans, a);
    }
    cout << ans << endl;
    return 0;
};

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	return (b == 0) ? a : gcd(b, a % b);
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	char ch;
	scanf("%c",&ch);
	if(ch == 'A')	puts("T");
	else if(ch == 'G')	puts("C");
	else if(ch == 'T')	puts("A");
	else	puts("G");
	return 0;
}


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

signed main()
{
  int n;
  cin >> n;
  int a[n + 5] = {0};

  for (int i = 1; i < n + 1; i++) {
    int cnt = 0;
    int kanade = i;
    if (i % 2 == 0) {
      while (true) {
        if (kanade == 1 || kanade == 0) {
          break;
        }
        kanade = kanade / 2;
        cnt++;
      }
      a[i] = cnt;
    }
  }

  int m = -100;
  int res = 0;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] > m) {
      m = a[i];
      res = i;
    }
  }

  cout << res << endl;

  return (0);
}

Measured memory_bytes: 256
n=input()
for i in range(n):
    hh,mm=map(int,raw_input().split(":"))
    angleh=(60*hh+mm)*0.5
    anglem=6*mm
    diff=abs(angleh-anglem)
    if diff>180:diff=360-diff
    if 0<=diff<30:
        print "alert"
    elif 90<=diff<=180:
        print "safe"
    else:
        print "warning"

Measured memory_bytes: 4260
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>

using namespace std;
int main(void){
    int a,n,tmp=-1,count=0;
    vector<int> array;

    cin >> n;

    for(int i=0; i<n;i++){
        cin >> a;
        array.push_back(a);
    }

    sort(array.begin(),array.end());

    for(int i=0; i<n ;i++){
        if(!(tmp==array.at(i)))count++;
        tmp=array.at(i);
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
dict = {}
for i in a:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1
ans = 0
for i in dict:
    if dict[i]%2==0:
        continue
    else:
        ans += 1
print(ans)

Measured memory_bytes: 16268