akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll a,b,c,d[100005] = {},n,m;
string s,t;

int main(){

    cin >> n;

    if(n&1){
	int c = 0;
	rep(i,1,n+1)if(i&1)c++;
	printf("%.10lf\n",(double)c/n);
    }else{
	P(0.500000000000);
    }
    
    return  0;
}


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

sum1 = sum(B)

cn = 0
SUM = 0

for i in range(N-1):
    if A[i] + 1 == A[i+1]:
        SUM = SUM + C[A[i]-1]
        




print(sum1 + SUM)

Measured memory_bytes: 61624
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps=1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.answer"

int main() {
	string st; getline(cin, st);
	string ans;
	for (int i = 0; i < st.size(); ++i) {
		string aa = st.substr(i, 5);
		if (aa == "apple") {
			ans += "peach";
			i += 4;
		}
		else if (aa == "peach") {
			ans += "apple";
			i += 4;

		}
		else {
			ans += st[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int x, y;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> y;
	if(y < 2 * x || (y - 2 * x) % 2){
		cout << "No\n";
		return 0;
	}
	int b = (y - 2 * x) / 2;
	if(x - b < 0){
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;
}

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

int main() {
	int N, x;
	cin >> N >> x;
	int a[N];
	for(int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N);
	int i = 0, ans = 0;
	while(i < N - 1){
		if(x >= a[i]){
			x -= a[i];
			ans++;
		}
		i++;
	}
	if(x == a[N - 1]) ans++;
				
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import static java.lang.System.*;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		long min = 1000000;
		long max = -1000000;
		long sum = 0;
		for(int a = 1; a <= count; a++) {
			int num = sc.nextInt();
			if(num < min) {
				min = num;
			}
			if(num > max) {
				max = num;
			}
			sum += num;
		}
		out.println(min + " " + max + " " + sum);
	}
}


Measured memory_bytes: 40988
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, k, ans;
int a[200000];

int main() {
    scanf(" %d", &n);
    rep(0,n) scanf(" %d", &a[i]);
    int sumxor = a[0];
    rep(1,n) sumxor ^= a[i];
    rep(0,n) printf("%d ", a[i]^sumxor);
    printf("\n");
}

Measured memory_bytes: 4472
#include<iostream>
#include<cstring>
using namespace std;
char s[100000];

int main(){
	cin>>s;
	int len=strlen(s);
	for(int i=0;i<len;i++){
		char trans;
		switch(s[len-i-1]){
			case 'b':
				trans='d';
				break;
			case 'd':
				trans='b';
				break;
			case 'p':
				trans='q';
				break;
			case 'q':
				trans='p';
				break;
		}
		if(s[i]!=trans){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;

int main() {
    string s;
    int ans = 0;
    cin >> s;
    if(s.size() % 2 == 0) {
        rep(i,s.size()/2) {
            if(s[i] != s[s.size()-i-1]) ans++;
        }
    } else {
        rep(i,s.size()/2) {
            if(s[i] != s[s.size()-i-1]) ans++;
        }
    }
    cout << ans;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<vl> edge(n);
  vector<pll> input(n-1);
  REP(i,n-1){
    ll a,b;
    cin >> a >> b;
    a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
    input[i] = {a,b};
  }
  ll k = 0;
  REP(i,n){
    CHMAX(k,(ll)edge[i].size());
  }
  cout << k << endl;

  map<pll,ll> color;
  queue<pll> que;
  REP(i,edge[0].size()){
    que.push({edge[0][i],i});
    color.insert({{0ll,edge[0][i]},i});
  }
  //for (auto it = color.begin();it!=color.end();it++){
  //  cout << it->first.first << "," << it->first.second << ":" << it-> second << endl;
  //}

  while(!que.empty()){
    pll node = que.front();
    //DEBUG(node.first);
    que.pop();
    ll ed = 0;
    REP(i,edge[node.first].size()){
      ll child = edge[node.first][i];
      pll key = {min(node.first,child),max(node.first,child)};
      if(color.find(key) != color.end()) continue;
      //cout << node.first << "," << child << endl;
      if(node.second==ed) ed++;

      color[key] = ed;
      que.push({child,ed});
      ed++;
    }
  }

  REP(i,n-1){
    ll a = input[i].first;
    ll b = input[i].second;
    if(a>b) swap(a,b);
    pll key = {a,b};
    cout << color[key]+1 << endl;
  }
  
  return 0;
}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int n, m;
    cin >> n;
    map<string, int> s;
    REP(i, n) {
        string _s;
        cin >> _s;
        if(s.find(_s) == s.end()) s[_s] = 0;
        s[_s]++;
    }
    cin >> m;
    REP(i, m) {
        string _t;
        cin >> _t;
        if(s.find(_t) != s.end()) s[_t] = max(0, s[_t]-1); 
    }
    int ans = 0;
    for(auto &x : s) {
        ans = max(ans, x.second);
    }
    cout << ans << "\n";
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

const double eps = 1e-6;
typedef complex<double> point;
struct circle { point c; double r; };
struct line { point s, t; };
struct segment { point s, t; };
struct ray { point s, t; };
double   dot(point p, point q) { return real(p * conj(q)); }
double cross(point p, point q) { return imag(conj(p) * q); }
int ccw(point a, point b, point c) { double z = cross(b - a, c - a); return z > eps ? 1 : z < - eps ? -1 : 0; }
bool does_intersect(point a, line b) {
    return ccw(0, a - b.s, b.t - b.s) == 0;
}
bool does_intersect(line a, point b) {
    return does_intersect(b, a);
}
bool is_parallel(line a, line b) {
    return ccw(0, a.t - a.s, b.t - b.s) == 0;
}
bool is_overwraped(line a, line b) {
    return does_intersect(a.s, b)
        and does_intersect(a.t, b);
}
bool does_intersect(line a, line b) {
    return not is_parallel(a, b)
        and not is_overwraped(a, b);
}
point intersection(line a, line b) {
    assert (does_intersect(a, b));
    double p = cross(a.t - a.s, b.t - b.s);
    double q = cross(a.t - a.s, a.t - b.s);
    return (q / p) * (b.t - b.s) + b.s;
}
bool does_intersect(point a, segment b) {
    return abs(cross(b.t - b.s, a - b.s)) < eps
        and dot(b.t - b.s, a - b.s) > - eps
        and dot(b.s - b.t, a - b.t) > - eps;
}
bool does_intersect(segment a, point b) {
    return does_intersect(b, a);
}
template <typename T, typename U>
bool does_intersect_linelikes(T const & a, U const & b) {
    if (not does_intersect(to_line(a), to_line(b))) return false;
    point c = intersection(to_line(a), to_line(b));
    return does_intersect(a, c)
        and does_intersect(b, c);
}
line to_line(segment a) {
    return { a.s, a.t };
}
bool does_intersect(segment a, segment b) {
    return does_intersect_linelikes(a, b);
}
point intersection(segment a, segment b) {
    assert (does_intersect(a, b));
    return intersection(to_line(a), to_line(b));
}

int main() {
    int testcase; scanf("%d", &testcase);
    while (testcase --) {
        segment a; { int ax, ay, bx, by; scanf("%d%d%d%d", &ax, &ay, &bx, &by); a = { point(ax, ay), point(bx, by) }; }
        int n; scanf("%d", &n);
        vector<pair<double, bool> > events;
        repeat (i, n) {
            segment b; { int ax, ay, bx, by; scanf("%d%d%d%d", &ax, &ay, &bx, &by); b = { point(ax, ay), point(bx, by) }; }
            int o, t; scanf("%d%d", &o, &t);
            if (does_intersect(a, b)) {
                point p = intersection(to_line(a), to_line(b));
                events.emplace_back(abs(p - a.s), o ^ t);
            }
        }
        whole(sort, events);
        int last = -1;
        int result = 0;
        for (auto event : events) {
            bool type = event.second;
            if (last != -1 and last != int(type)) {
                result += 1;
            }
            last = int(type);
        }
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 2600
//参考: https://qiita.com/drken/items/4a7869c5e304883f539b
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
vector<int> ans;
vector<int> add;

void dfs(const Graph &G, int v, int val) {
    seen[v] = true; // v を訪問済にする
    val += add[v];
    ans[v] = val;

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v, val); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, Q; cin >> N >> Q;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    add.assign(N, 0);
    for(int i =0; i<Q; i++){
        int a, b;
        cin >> a >> b;
        a--;
        add[a] += b;
    }

    // 頂点 0 をスタートとした探索
    seen.assign(N, false); // 全頂点を「未訪問」に初期化
    ans.assign(N, 0);
    dfs(G, 0, 0);
    for(auto a : ans){
        cout << a << endl;
    }
}

Measured memory_bytes: 25080
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {

		Scanner sc = new Scanner(System.in);

		int dir[][] = { { 0, -1 }, { 0, 1 }, { 1, 0 } };

		while (true) {
			final int w = sc.nextInt();
			final int h = sc.nextInt();

			if (w == 0 && h == 0) {
				break;
			}

			final int amount = sc.nextInt();
			final int capacity = sc.nextInt();
			final int init = sc.nextInt();

			int[][] map = new int[h][w];

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = sc.nextInt();
				}
			}

			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			for (int i = 0; i < w; i++) {
				boolean[][] b = new boolean[h][w];
			
				queue.offer( new Walk(0, init-1, 0, i, b));
			}

			boolean flag = false;
			while (!queue.isEmpty()) {
				Walk walk = queue.poll();
				int y = walk.y;
				int x = walk.x;

				if (walk.sanso <= 0) {
					continue;
				} else if (walk.y >= h) {
					flag = true;
					System.out.println(walk.cost);
					break;
				}

				walk.visited[y][x] = true;

				if (map[y][x] <= 0) {
					walk.cost += (-map[y][x]);
				} else {
					walk.sanso = Math.min(map[y][x] + walk.sanso, capacity);
				}

				if (walk.cost > amount) {
					continue;
				}

				for (int i = 0; i < 3; i++) {
					int ny = y + dir[i][0];
					int nx = x + dir[i][1];
					if (nx >= 0 && nx < w && ny >= 0 && ny <= h - 1
							&& !walk.visited[ny][nx]) {
						boolean[][] nb = new boolean[h][w];
						for(int j = 0;j<h;j++){
							nb[j] = Arrays.copyOf(walk.visited[j], w);
						}
						queue.offer(new Walk(walk.cost, walk.sanso-1, ny, nx, nb));
					} else if (i == 2 && walk.y == h - 1) {
						Walk wa = new Walk(walk);
						wa.y++;
						queue.add(wa);
					}
				}
			}

			if (!flag) {
				System.out.println("NA");
			}

		}
	}
}

class Walk implements Comparable<Walk> {
	int cost;
	int sanso;
	int x, y;
	boolean[][] visited;

	public Walk(int cost, int sanso, int y, int x, boolean[][] visited) {
		super();
		this.cost = cost;
		this.sanso = sanso;
		this.x = x;
		this.y = y;
		this.visited = visited;
	}

	public Walk(Walk w) {
		this.cost = w.cost;
		this.sanso = w.sanso;
		this.x = w.x;
		this.y = w.y;
		visited = new boolean[w.visited.length][w.visited[0].length];
		for (int i = 0; i < w.visited.length; i++) {
			visited[i] = Arrays.copyOf(w.visited[i], w.visited[0].length);
		}
	}

	@Override
	public int compareTo(Walk arg0) {
		return this.cost - arg0.cost;
	}
}

Measured memory_bytes: 77780
#include <stdio.h>
#include <stdlib.h>

int sortInt(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int main(void)
{
	int N;
	int *X, *nX;
	int i, j;
	int m1, m2;

	scanf("%d", &N);

	X = (int *)malloc(sizeof(int) * N);
	nX = (int *)malloc(sizeof(int) * N);

	for(i = 0; i < N; i++)
	{
		scanf("%d", &X[i]);
		nX[i] = X[i];
	}

	qsort(nX, N, sizeof(int), sortInt);

	m1 = nX[N / 2];
	m2 = nX[(N / 2) - 1];

	for(i = 0; i < N; i++)
	{
		if(X[i] > m2)
			printf("%d\n", m2);
		else
			printf("%d\n", m1);
	}

		return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <cstdio>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

class RMQ
{
  int n;
  vector<int> dat;
public:
  RMQ(int n_)
  {
    n = 1;
    while (n < n_)
      {
	n *= 2;
      }
    dat.resize(2 * n - 1);
    for (int i = 0; i < 2 * n - 1; ++i)
      {
	dat[i] = INT_MAX;
      }
  }
  void update(int k, int a)
  {
    k += n - 1;
    dat[k] = a;
    while (k > 0)
      {
	k = (k - 1) / 2;
	dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
      }
  }
  int query(int a, int b, int i = 0, int l = 0, int r = 0)
  {
    if (r <= l)
      {
	r = n;
      }
    if (r <= a || b <= l)
      {
	return(INT_MAX);
      }
    if (a <= l && r <= b)
      {
	return(dat[i]);
      }
    int vl = query(a, b, 2 * i + 1, l, (l + r) / 2);
    int vr = query(a, b, 2 * i + 2, (l + r) / 2, r);
    return(min(vl, vr));
  }
};

void solve()
{
  int n, q;
  cin >> n >> q;
  RMQ r(n);
  for (int j = 0; j < q; ++j)
    {
      int com, x, y;
      scanf("%d%d%d", &com, &x, &y);
      if (com == 0)
	{
	  r.update(x, y);
	}
      else
	{
	  printf("%d\n", r.query(x, y + 1));
	}
    }
}

int main()
{
  solve();
  return(0);
}



Measured memory_bytes: 3824
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t K, S;

	scanf("%zu %zu", &K, &S);

	size_t count = 0;

	for (size_t i = 0; i <= K && i <= S; i++) {
		const size_t left = S - i;

		if (left <= K) {
			count += left + 1;
		}
		else if (left <= 2 * K) {
			count += 2*K - left + 1;
		}
	}

	printf("%zu\n", count);

	return 0;
}


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

int main(){
  int N,H;
  cin >> N >> H;
  vector<int> a(N);
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin >> a[i] >> b[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int sum=0;
  while(H>0){
    if(!b.empty() && b.back()>=a.back()){
      H-=b.back();
      b.pop_back();
    }
    else{
      H-=a.back();
    }
    sum++;
  }
  cout << sum <<endl;
} 



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

int main()
{
  int y1, y2;
  bool first = true;
  while (cin >> y1 >> y2)
  {
    bool na = true;
    if (y1 == 0 && y2 == 0) return 0;
    if (first) { first = false; }
    else cout << endl;
    for (int year = y1; year <= y2; year++)
    {
      if (year % 400 == 0)
      {
        cout << year << endl;
        na = false;
      }
      else if ((year % 4 == 0) && (year % 100 != 0))
      {
        cout << year << endl;
        na = false;
      }
    }
    if (na) cout << "NA" << endl;
  }
}

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


int32_t main() {

	int a, b, c; 
	cin >> a >> b >> c;

	int k; cin >> k;

	while(b <= a) {
		b *= 2;
		k --;
	}

	while(c <= b) {
		c *= 2;
		k --;
	}

	if(k >= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define N 25
#define M 25
using namespace std;
int n,m;
int dis[N][M];
int mx[4]={-1,1,0,0};
int my[4]={0,0,1,-1};
char map1[N][M];

void bs(int y, int x, int sy,int sx){
  for(int i=0;i<4;i++){
    int ny = y+my[i], nx = x+mx[i];
    if(sy == ny && sx == nx) continue;
    if(ny >=0 && nx >=0 && ny <n && nx <m ){
      if(map1[ny][nx] == '.'){
        if(dis[ny][nx] == 0 || (dis[ny][nx] > dis[y][x] +1)){
          dis[ny][nx] = dis[y][x] + 1;
          bs(ny,nx,sy,sx);
        }
      }
    }
  }
}
  

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>map1[i][j];
    }
  }
  for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
          dis[i][j] = 0;
        }
      }
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(map1[i][j]=='#') continue;
      bs(i,j,i,j);
      int maxnum = 0;
      for(int k=0;k<n;k++){
        for(int l=0;l<m;l++){
          if(dis[k][l]>maxnum) maxnum = dis[k][l];
          dis[k][l] = 0;
        }
      }
      if(ans<maxnum) ans = maxnum;
    }
  }
  cout<<ans<<endl;
}

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



int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int N, W;
    cin >> N >> W;
    //vector<int> v(N + 1), w(N + 1);
    int v[110], w[110];
    for (int i = 1; i <= N; i++) {
        cin >> v[i] >> w[i];
    }
    
    //vector<vector<int>> Value(N + 1, vector<int>(W + 1, 0));
    int Value[110][10010] = {0};
    
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= W; j++) {
            Value[i][j] = Value[i - 1][j];
            if (j >= w[i]) {
                
                for (int k = 1; j - k * w[i] >= 0; k++) {
                    if (Value[i][j - k * w[i]] + k*v[i] <= Value[i][j]) {
                        break;
                    }
                    Value[i][j] = Value[i][j - k * w[i]] + k*v[i];
                }
                
            }
        }
    }
    
    cout << Value[N][W] << endl;
    
    return 0;
}



Measured memory_bytes: 7528
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> PII;

int main(){
  int A,B;
  cin>>A>>B;
  if(A>=13) cout<<B<<endl;
  else if(A>=6) cout<<B/2<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
//const int N = 1000006;
//////////////////////////////

int N;
vector<int> e[1000];
int X[1000];

int dfs(int n, int p) {
	int dp[2][5500];
	int cur = 0, tar = 1;
	REP(i, 5500) dp[cur][i] = INF;
	dp[cur][0] = 0;

	for(int m : e[n]) {
		if (m == p) continue;
		REP(i, 5500) dp[tar][i] = INF;
		int w = dfs(m, n);
		int b = X[m];
		for (int i = 0; i < X[n] + 1; i++) {
			if (dp[cur][i] != INF) {
				if (i + w <= X[n]) {
					dp[tar][i + w] = min(dp[tar][i + w], dp[cur][i] + b);
				}
				if (i + b <= X[n]) {
					dp[tar][i + b] = min(dp[tar][i + b], dp[cur][i] + w);
				}
			}
		}
		cur ^= 1, tar ^= 1;
	}

	int ret = INF;
	REP(i, 5500) ret = min(ret, dp[cur][i]);
	return ret;
}

void solve()
{
	cin >> N;
	RREP(i, N - 1) {
		int x; cin >> x; x--;
		e[x].push_back(i);
		e[i].push_back(x);
	}
	REP(i, N) cin >> X[i];
	cout << (dfs(0, -1) != INF ? "POSSIBLE" : "IMPOSSIBLE") << endl;	
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}

Measured memory_bytes: 22096
#include<stdio.h>

int main(void){
	
	int r,g,b,s;
	
	
	scanf("%d %d %d",&r,&g,&b);
	s=100*r+10*g+b;
	if(s%4==0){
		printf("YES\n");
	}else {
		printf("NO\n");
	}
	
	return 0;
}

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

using namespace std;

int main(){
        int x, a, b;
        cin>>x>>a>>b;
        if(a+x+1<=b){
                cout<<"dangerous"<<endl;
        }
        else if(a>=b){
                cout<<"delicious"<<endl;
        }
        else{
                cout<<"safe"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    int n;
    int l, r;
    int ans = 0;
    
    public static void main(String args[])
    {
	new Main().run();
    }
    
    void run()
    {
	in();

	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);

	n = sc.nextInt();
	for(int i = 0; i < n; i++) {
	    l = sc.nextInt();
	    r = sc.nextInt();
	    ans += r - l + 1;
	}
    }

    void out()
    {
	System.out.println(ans);
    }
}


Measured memory_bytes: 23532
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll) 1000000007
#define P pair<ll, ll>


ll h, w, a, b, s[510][510], cnt;
int main() {
	cin >> h >> w >> a >> b;
	REP(i, h) {
		REP(j, w) {
			if (i % a == a - 1 and j % b == b - 1)s[i][j] = (a * b - 1) * -3999 - 1;
			else s[i][j] = 3999;
			cnt += s[i][j];
		}
	}
	if (cnt <= 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	REP(i, h) {
		REP(j, w) {
			if (j != 0)cout << " ";
			cout << s[i][j];
		}
		cout << endl;
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<P> bridge(M);
    REP(i, M) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        bridge[i] = P(A, B);
    }
    reverse(ALL(bridge));
    vector<ll> ans(M+1);
    UnionFind uf(N);
    REP(i, M) {
        if (uf.issame(bridge[i].first, bridge[i].second)) {
            ans[i+1] = ans[i];
            continue;
        }
        ll tmp = uf.size(bridge[i].first);
        tmp = max(0LL, (tmp * (tmp-1))/2);
        ll tmp_ = uf.size(bridge[i].second);
        tmp_ = max(0LL, (tmp_ * (tmp_-1))/2);
        uf.merge(bridge[i].first, bridge[i].second);
        ll tmp2 = uf.size(bridge[i].first);
        tmp2 = max(0LL, (tmp2 * (tmp2-1))/2);
        ans[i+1] = ans[i] + tmp2 - tmp - tmp_;
    }
    REPR(i, M) PRINT((N*(N-1))/2 - ans[i]);
    return 0;
}


Measured memory_bytes: 5248
#include <stdio.h>
 
int main(void)
{
    int c, a, b, d=0, e=0;
    while(scanf("%d\n", &c), !!c) {
        for(d=e=0;c!=0;scanf("%d %d\n",&a, &b), d+=(a==b)?a:(a>b)?a+b:0,e+=(a==b)?a:(a>b)?0:a+b, c--) {}   
        printf("%d %d\n",d,e );
    }
    return 0;
}

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

typedef long long int ll;
using namespace std;

int main() {
	ll X;
	cin >> X;

	ll happy = (X / 500) * 1000;
	X %= 500;
	happy += (X / 5) * 5;

	cout << happy << endl;

	return 0;
}

Measured memory_bytes: 256
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(L[int(input())-1])


Measured memory_bytes: 3316
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  string s, t;
  cin>>s>>t;
  int cnt = 0;
  rep(i,3) {
    if (s[i]==t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 888
def check(s, indx)
  indx1 = s.index("ABC", indx)
  unless (indx1.nil?)
    $cnt += 1
    check(s, indx1 + 1)
  end
end

$cnt = 0
n = gets.to_i
s = gets.chomp

check(s, 0)
puts $cnt

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))

N, Q = mi()
S = input()
lr = li2(Q)

num = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        num[i] = 1

num = [0] + list(accumulate(num))

for s, t in lr:
    print(num[max(t-1, 0)]-num[max(s-1, 0)])


Measured memory_bytes: 32756
#include<iostream>
using namespace std;
const int M=0x3f3f3f3f;
int main()
{
     int n,t; 
     int a,b,ans=M;
     while(cin>>n>>t)
     {
     	for(int i=0;i<n;++i)
     	{
     		scanf("%d%d",&a,&b);
			if(b<=t&&a<ans)
			{
				ans=a;
			}
		 }
		 if(ans!=M)cout<<ans<<endl;
		 else cout<<"TLE\n";
	 }
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;
int dp[4][112345];
int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int s,t;
  cin>>t>>s;
  dp[0][0]=1;
  rep(i,3)rep(j,i*t+1)rep(k,t+1) dp[i+1][j+k]+=dp[i][j];
  cout<<dp[3][s]<<endl;
  return 0;
}


Measured memory_bytes: 384
# ABC090D - Remainder Reminder (ARC091D)
def main():
    N, K = tuple(map(int, input().split()))
    if K == 0:
        print(N ** 2)
        return
    ans = 0
    for i in range(K + 1, N + 1):
        ans += N // i * (i - K) + max(0, (N % i) - K + 1)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  priority_queue<int> q;
  rep(i, n) {
    cin >> a[i];
    q.push(a[i]);
  }

  int x;
  ll ans = 0;
  rep(i, m){
    x = q.top();
    q.pop();
    x /= 2;
    q.push(x);
  }
  rep(i, n) {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  return 0;
}


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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan =new Scanner(System.in);

		String a = scan.next();
		String b = scan.next();


if(a.equals(b.substring(0,b.length()-1))) {
	System.out.println("Yes");
}else {
	System.out.println("No");
}
		scan.close();
	}

}


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

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

int main(){
  long long a, b;
  cin >> a >> b;
  long long n = gcd(a, b);
  
  int ans = 1;
  for(long long i = 2; i*i <= n; i++){
  
  	if(n%i == 0){
    
    	ans++;
    	while(n%i == 0) n /= i;
    
    }
  
  }
  
  if(n != 1) ans++;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int selectionSort(int A[100],int N);

void show(int A[100],int N);

int selectionSort(int A[100],int N){

  int i=0,j=0,k,c=0,temp,min;
    for (i = 0; i < N - 1; i++) {
                    /* i 番目の要素を暫定的に最小値とし */
        k = i;                        /* 添字を保存 */
        for (j = i + 1; j < N; j++) {
            if (A[j] < A[k]) {       /* より小さい値が現れたら */
                        /* 最小値の入れ替え */
                k = j;                /* 添字を保存 */
                
            }
        }  /* このループを抜けるとk に最小値の添字が入っている */
    if(i!=k){
        c++;
        temp = A[i];                /* i 番目の要素と最小値の交換 */
        A[i] = A[k];
        A[k] = temp;
    }
        
    }
    return c;
}

void show(int A[100],int N){

 int i;

 for(i=0;i<N;i++){
     printf("%d",A[i]);
     if(i+1!=N){
         printf(" ");
     }
 }
 printf("\n");

}

int main(){

    int n,i;
    int a[100];

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

   int x;
   x = selectionSort(a,n);

    show(a,n);

    printf("%d\n",x);
   
return 0;

}


Measured memory_bytes: 2140
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as C

parseInt :: C.ByteString -> Int
parseInt = fst . fromJust . C.readInt

work :: (Bool, String, String) -> [C.ByteString] -> (Bool, String, String)
work (o, ls, rs) (b : bs) =
  if 1 == parseInt b
    then (not o, rs, ls)
    else let [b1, b2] = bs
             c = C.index b2 0
         in case parseInt b1 of
           1 -> (o, c : ls, rs)
           otherwise -> (o, ls, c : rs)

main :: IO ()
main = do
  s <- C.getLine
  q <- fmap parseInt C.getLine
  qs <- replicateM q $ fmap C.words C.getLine
  let (o, ls, rs) = foldl' work (True, "", "") qs
      s' = (if o then id else C.reverse) s
  C.putStrLn $ C.concat [C.pack ls, s', C.reverse $ C.pack rs]

Measured memory_bytes: 79868
# problem a
# score 300
from collections import defaultdict
N = int(input())
A = []
for i in range(N):
    x = float(input())
    x = "{:.9f}".format(x)
    x=int(x[:-10]+x[-9:])
    A.append(x)
remove = 0
for i in range(N):
    if (A[i]**2) % (10**18) == 0:
        remove += 1
D = defaultdict(int)
data = []
for x in A:
    order2 = 0
    order5 = 0
    K = x
    while K % 2 == 0:
        order2 += 1
        K = K//2
    while K % 5 == 0:
        order5 += 1
        K = K//5
    data.append((order2, order5))
    for i in range(order2+1):
        for j in range(order5+1):
            D[2**i*5**j] += 1
ans = 0
for ord2, ord5 in data:
    new_ord2 = max(0, 18-ord2)
    new_ord5 = max(0, 18-ord5)
    ans += D[(2**new_ord2)*(5**new_ord5)]
ans-=remove
ans = ans//2
print(ans)

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll f(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}

ll g(ll a,ll n)
{
  if(a<0)return ((a%n)+n)%n;
  else return a%n;
}
char A[51][51]={0};
char B[51][51]={0};

ll solve(ll x,ll y,ll na,ll ma,ll nb,ll mb)
{
  ll cnt=0;
  for(int i=1;i<=na;i++)
  {
    //ll temp1=x+i;
    if(x+i<=0)continue;
    else if(x+i>nb)break;
    else 
      {
        for(int j=1;j<=ma;j++)
        {
          if(y+j<=0)continue;
          else if(y+j>mb)break;
          else 
            {
              cnt+=A[i][j]=='1'&&B[i+x][j+y]=='1';
            }
        }
      }
  }
  return cnt;
}

int main()
{
string s,t;cin>>s>>t;
ll cnt=0;
for(int i=0;i<3;i++)cnt+=s[i]==t[i];
  cout<<cnt<<"\n";
  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
void bubble_sort(int m[]);
int m[10],i,j,temp;
int main()
{
    for(i=0;i<10;i++){
        scanf("%d",&m[i]);
    }
    bubble_sort(m);
    return 0;
}
 
void bubble_sort(int m[])
{
    for(j=0;j<10-1;j++){
            for(i=0;i<10-j-1;i++){
                if(m[i]<m[i+1]){
                    temp=m[i+1];
                    m[i+1]=m[i];
                    m[i]=temp;
                }
            }
        }
    for(i=0;i<3;i++){
        printf("%d\n",m[i]);
    }
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n=scanner.nextInt();
    int k=scanner.nextInt();
    String S=scanner.next();

    String[] strArray = new String[S.length()];

    for (int i = 0; i < S.length(); i++) {
      String str = String.valueOf(S.charAt(i));
      strArray[i] = str;
    }

    String lower_str2 = strArray[k-1].toLowerCase();
    strArray[k-1]=lower_str2;

    for (int i = 0; i < S.length(); i++) {
      System.out.print(strArray[i]);
    }

    System.out.println("");
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sol = 0;
    while (n--)
    {
        int a, b;
        cin >> a >> b;
        sol += b - a + 1;
    }
    cout << sol;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
using namespace std;
using vpii = vector<pair<int, int>>;

int		main(void)
{
	int N, T, A;

	cin >> N >> T >> A;
	vpii lower;
	vpii higher;
	float x = (T - A) / 0.006;

	for (int i = 1; i <= N; i++)
	{
		int h;
		
		cin >> h;
		pair<int, int> tmp(h, i);

		if (h < x)
			lower.push_back(tmp);
		else
			higher.push_back(tmp);
	}
//	cout << "x: " << x << endl;
	sort(all(lower));
	sort(all(higher));
	if (lower.empty())
	{
		cout << higher[0].second << endl;
		return (0);
	}
	else if (higher.empty())
	{
		cout << lower.back().second << endl;
		return (0);
	}
	float L, H;

	L = lower.back().first;
	H = higher[0].first;
	if (abs(x - L) < abs(x - H))
		cout << lower.back().second << endl;
	else
		cout << higher[0].second << endl;
//	for (pair<int, int> p : lower)
//		printf("%d %d\n", p.second, p.first);
//	for (pair<int, int> p : higher)
//		printf("%d %d\n", p.second, p.first);
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for _ in range(m):
  a.append(int(input()))
a.append(0)
dp=[0]*(n+1)
dp[0]=1
if a[0]!=1:
  dp[1]=1
  tmp=0
else:
  tmp=1
for i in range(2,n+1):
  if i==a[tmp]:
    tmp+=1
  else:
    dp[i]=(dp[i-2]+dp[i-1])%(10**9+7)
print(dp[n])

Measured memory_bytes: 7824
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n,h,w,a,b,cnt=0;
	cin>>n>>h>>w;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>=h&&b>=w){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}



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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N;cin>>N;
    vector<ll> S(N);
    int minus=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
        if(S[i]<0) minus++;
    }
    sort(all(S));
    if(minus==N){
        ll ans=S[N-1];
        for(int i=0;i<N-1;i++){
            ans-=S[i];
        }
        cout<<ans<<endl;
        ll now=S[N-1];
        for(int i=0;i<N-1;i++){
            cout<<now<<" "<<S[i]<<endl;
            now-=S[i];
        }
    }else if(minus==0){
        ll ans=-S[0];
        for(int i=1;i<N;i++){
            ans+=S[i];
        }
        cout<<ans<<endl;
        ll now=S[0];
        for(int i=1;i<N-1;i++){
            cout<<now<<" "<<S[i]<<endl;
            now-=S[i];
        }
        cout<<S[N-1]<<" "<<now<<endl;
    }else{
        ll ans=S[N-1];
        for(int i=0;i<minus;i++){
            ans-=S[i];
        }
        for(int i=minus;i<N-1;i++){
            ans+=S[i];
        }
        cout<<ans<<endl;
        ll now=S[0];
        for(int i=minus;i<N-1;i++){
            cout<<now<<" "<<S[i]<<endl;
            now-=S[i];
        }
        cout<<S[N-1]<<" "<<now<<endl;
        ll last=S[N-1]-now;
        for(int i=1;i<minus;i++){
            cout<<last<<" "<<S[i]<<endl;
            last-=S[i];
        }
    }
}


Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	long double N, M, d;
	cin >> N >> M >> d;
	long double p;
	if(d != 0)p = 2*(N-d);
	else p = N;
	cout << fixed << setprecision(10) << p*(M-1)/N/N << endl;
	return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
 
typedef pair<double,double> P;
typedef pair<P,double> P2;
 
P rot(P p, double a){
  a=a*M_PI/180.0;
  return P(p.first*cos(a)+p.second*(-sin(a)),
  p.first*sin(a)+p.second*cos(a));
}
 
double abss(P a,P b){
  return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
 
double x,y,r;int tt;
vector<P2>v;
int main(){
 
  int n;
  while(cin >> n,n){
 
    double ans=1e13;
     
    v.clear();
   
    r(i,n){
      cin>>r>>x>>y;
      v.push_back(P2(P(x,y),r));
    }
 
    r(i,1){
      sort(v.begin(),v.end());
      r(j,n){
    for(int k=j+1,c=0;k<n;k++,c++){
      if(c>50)break;
      ans=min(ans,abss(v[k].first,v[j].first)-v[k].second-v[j].second);
    }
      }
      r(j,n)v[i].first=rot(v[i].first,0.5);
    }
 
    printf("%.9f\n",ans);
     
  }
   
  return 0;
}

Measured memory_bytes: 6220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
int n;
ll x[50];
ll y[50];

//p=b.x-a.xと置いたときのコスト
ll calc(int a,int b)
{
	ll p=x[b]-x[a];
	ll q=y[b]-y[a];
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==j)
				continue;
			if(x[j]-p==x[i] && y[j]-q==y[i])
				cnt++;
		}
	}
	return n-cnt;
}
int main()
{
	ll ans=1e8-1;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>x[i]>>y[i];
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ans=min(ans,calc(i,j));
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題160

            long x = long.Parse(Console.ReadLine());

            long ans = 0;

            ans += x / 500 * 1000;

            x = x % 500;

            ans += x / 5 * 5;

            //ans %= 50;

            Console.WriteLine(ans);

           

        }

    }





    
}


Measured memory_bytes: 27344