akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    int N;
    int ans = 1;
    cin >> N;
    while((ans<<1)<=N) ans = ans<<1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int size = s.length();
	vector<int> v;
	

	int count = 0;
	for (int i = 0; i < size; i++) {
		for (int j = i; j < size; j++) {
			char z = s.at(j);
			if (z == 'A' || z == 'T' || z == 'G' || z == 'C') count++;
			else break;
		}
		v.push_back(count);
		count = 0;
	}

	vector<int>::iterator itr = max_element(v.begin(), v.end());
	size_t ind = distance(v.begin(), itr);

	cout << v[ind] << endl;
	return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace std::chrono;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///find_by_order, order_of_key

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

map<ll, ll> m;
ll n, a, b, c, d;

ll dfs(ll n)
{
    if(n == 0)
        return 0LL;
    if(n == 1)
        return d;
    if(m.count(n))
        return m[n];

    ll dole2 = (n/2)*2LL;
    ll gore2 = ((n+1)/2)*2LL;
    ll dole3 = (n/3)*3LL;
    ll gore3 = ((n+2)/3)*3LL;
    ll dole5 = (n/5)*5LL;
    ll gore5 = ((n+4)/5)*5LL;

    ll res = 1e18;
    if(n < res / d)
        res = n * d;
    res = min(res, llabs(dole2 - n) * d + a + dfs(dole2 / 2));
    res = min(res, llabs(gore2 - n) * d + a + dfs(gore2 / 2));
    res = min(res, llabs(dole3 - n) * d + b + dfs(dole3 / 3));
    res = min(res, llabs(gore3 - n) * d + b + dfs(gore3 / 3));
    res = min(res, llabs(dole5 - n) * d + c + dfs(dole5 / 5));
    res = min(res, llabs(gore5 - n) * d + c + dfs(gore5 / 5));

    m[n] = res;

    if(res < 0)
    {
        cout << "GRESKA, n je " << n << '\n';
    }

    return res;
}

void solve()
{
    m.clear();
    cin >> n >> a >> b >> c >> d;

    cout << dfs(n) << '\n';
}

int main()
{
    #ifdef ljuba
    auto pocetakChronoSata123 = high_resolution_clock::now();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);       
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    cin >> t;
    while(t--)
        solve();
    
    #ifdef ljuba
    auto krajChronoSata123 = high_resolution_clock::now();
    auto trajanje = duration_cast<microseconds>(krajChronoSata123 - pocetakChronoSata123);
    cout << "----------------------------------------------------\n";
    cout << "Vreme u milisekundama: " << (ld)trajanje.count() / 1000.00 << '\n';
    #endif
    return 0;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n; cin >> n;
	vl h(n);
	REP(i, n) cin >> h[i];
	ll b = 0, cnt = 0;
	while (true) {
		while (b < n && h[b] == 0) b++;
		if (b == n) break;
		ll mi = 1000, cur = b;
		while (cur < n && h[cur] != 0) {
			mi = min(mi, h[cur]);
			cur++;
		}
		FOR(i, b, cur) h[i] -= mi;
		cnt+=mi;
	}
	cout << cnt << endl;
}


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

const int mod = 1000000007;

vector <long long> dp[30];
vector <int> num[30];
int pos[2097160];
int a[30][30];

int count(int x){
	int res = 0;
	while (x){
		res += x & 1;
		x >>= 1;
	}
	return res;
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i < (1 << n); i++){
		int cnt = count(i);
		pos[i] = num[cnt].size();
		num[cnt].push_back(i);
	}
	for (int i = 0; i <= n; i++){
		dp[i].resize(num[i].size());
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < num[i].size(); j++){
			int p = num[i][j];
			for (int k = 0; k < n; k++){
				if ((p & (1 << k)) && a[i - 1][k]){
					int last = p ^ (1 << k);
					dp[i][j] = (dp[i][j] + dp[i - 1][pos[last]]) % mod;
				}
			}
		}
	}
	printf("%lld\n", dp[n][0]);
	return 0;
}


Measured memory_bytes: 33340
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int calc(string A,string B){
	vector<vector<int>> dp(A.size()+1,vector<int>(A.size()+1,Inf));
	dp[0][0] = 0;
	
	vector<vector<int>> imos(605,vector<int>(A.size()+1,0));
	int offset = 302;
	for(int i=0;i<A.size();i++){
		for(int j=0;j<B.size();j++){
			if(A[i]==B[j]){
				imos[i-j+offset][0] ++;
				imos[i-j+offset][A.size()-i]--;
			}
		}
	}
	
	for(int i=0;i<imos.size();i++){
		for(int j=1;j<imos[i].size();j++)imos[i][j] += imos[i][j-1];
	}
	
	for(int i=0;i<A.size()+B.size();i++){
		for(int j=0;j<A.size();j++){
			int x = j;
			int y = i-j;
			if(y<0||y>=B.size())continue;
			dp[x+1][y] = min(dp[x+1][y],dp[x][y]+imos[y-x+offset][x]);
			dp[x][y+1] = min(dp[x][y+1],dp[x][y]+imos[y-x+offset][x]);
		}
	}
	
	int ret = Inf;
	for(int i=0;i<=A.size();i++){
		ret = min(ret,dp[i][A.size()]);
		ret = min(ret,dp[A.size()][i]);
	}
	return ret;
	
}

int main(){
	
	int H,W;
	cin>>H>>W;
	
	vector<string> S(W,"");
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			char c;
			cin>>c;
			S[j]+=c;
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<W-1;i++){
		ans += calc(S[i],S[i+1]);
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 1568
h, w = map(int, input().split())

A = []
for i in range(h):
    s = list(input())
    if '#' in s:
        A.append(s)
        
B = [[0] * w for i in range(len(A))]
for i in range(len(A)):
    for j in range(w):
        if A[i][j] == '#':
            B[i][j] += 1
            
C = [0] * w
for i in range(len(A)):
    for j in range(w):
        C[j] += B[i][j]
        
D = [[] for i in range(len(A))]
for i in range(len(A)):
    for j in range(w):
        if C[j] != 0:
            D[i].append(A[i][j])
            
for i in range(len(A)):
    print(''.join(D[i]))        

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	Int n; cin >> n;
	cout <<(Int) lcm(2, n);

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,min=1000000001,max=0,i;
	int a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(min>a[i]){
			min=a[i];
		}
		if(max<a[i]){
			max=a[i];
		}
	}
	printf("%d",max-min);
	return 0;
}


Measured memory_bytes: 128
n=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))
import bisect as bi
t=0
for i in b:
  x=n-bi.bisect_right(c,i)
  y=bi.bisect_left(a,i)
  t+=x*y
print(t)

Measured memory_bytes: 23744
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n;
  cin >> n;

  ostringstream oss;
  oss << n;
  string s = oss.str();

  REP(i,s.length()){
    if(s[i] == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P){
    int i=0;
    for(int j=0; j<k; j++){
        llong s = 0;
        while(s + T[i] <= P){
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000*10000;
    llong mid;
    while(right - left > 1){
        mid = (left+right)/2;
        int v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    
    return right;
}

int main(){
    cin >> n >> k;
    for(int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3896
<?php
# B - Bounding

fscanf(STDIN, "%d %d", $N, $X);

$count = 1;
$distance = 0;
$distance_array = explode(' ', fgets(STDIN));
for ( $i = 0 ; $i < $N ; $i++ ) {
    $distance += $distance_array[$i];
    if ($distance > $X) {
        break;
    }
    $count++;
}
echo $count . PHP_EOL;



Measured memory_bytes: 4728
a, b = map(int,input().split())
a_l = list(str(a)*b)
b_l = list(str(b)*a)
c = 0
for i in range(0,min(len(a_l),len(b_l))):
    if c == len(a_l)-1:
        print(int(str(b)*a))
        break
    if a_l[i] == b_l[i]:
        c += 1
        continue
    if a_l[i] > b_l[i]:
        print(int(str(b)*a))
        break
    if a_l[i] < b_l[i]:
        print(int(str(a)*b))
        break

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
bool f(pair<int,int> &a, pair<int,int> &b){return a.second>b.second;}
int main() {
    long int n, k;
    cin>> k>>n;
    long int houses[n];
    for(int i=0;i<n;++i){cin>>houses[i];}
    vector<pair<int, int>> diff;
    for(int i=0;i<n-1;i++){
        diff.push_back(pair<int, int>(i, min(k-houses[i+1]+houses[i], houses[i+1]-houses[i])));
    }
    diff.push_back(pair<int, int>(n-1, min(k-houses[n-1]+houses[0], houses[n-1]-houses[0])));
   sort(diff.begin(), diff.end(), f);
   cout<<k -diff[0].second<<endl;


    return 0;
}


Measured memory_bytes: 3956
#include <stdio.h>

int main(void){
	int t,a[1000],n,A,i;
	while(1){
		for(t=0;t<10;t++){
			a[t]=0;
		}
	scanf("%d",&n);
	if(n==0){
		return 0;
	}
	for(t=0;t<n;t++){
		scanf("%d",&A);
		a[A]++;
	}
	for(t=0;t<10;t++){
		for(i=0;i<a[t];i++){
			printf("*");
		}
		if(a[t]==0){
			printf("-");
		}
		printf("\n");
	}
	}
}
	

Measured memory_bytes: 576
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200005;
int n,sum;
struct node {
	int a,b;
}p[N];
bool cmp(node x,node y) {
	return x.b<y.b;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d %d",&p[i].a,&p[i].b);
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;i++) {
		sum+=p[i].a;
		if(sum>p[i].b) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int ans = 0;
            long tmp = 1;
            int i = 1;
            while (tmp <= n) {
                tmp = (long) Math.pow(k, i);
                i++;
                ans++;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22612
n,k = map(int,input().split())
x = list(map(int,input().split()))
proto = []
for i in range(n-k+1):
  left = x[i]
  right = x[i+k-1]
  al = abs(left)
  ar = abs(right)
  if left * right < 0:
    now = al + ar + min(al,ar)
  else:
    now = max(al,ar)
  proto.append(now)
print(min(proto))

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

int main(){
  int N,i,a,b,cnt=1;
  bool Pa=true,Qb=true;
  cin >> N;
  vector<int> P(N),Q(N),R(N);

  for(i=0;i<N;i++)
  cin >> P.at(i);
  for(i=0;i<N;i++)
  cin >> Q.at(i);
  for(i=0;i<N;i++)
  R.at(i) = i+1;
  

  do{
    for(i=0;i<N;i++){
      if(P.at(i)!=R.at(i)){
        Pa = false;
        break;
      }
    }
    for(i=0;i<N;i++){
      if(Q.at(i)!=R.at(i)){
        Qb = false;
        break;
      }
    }
    if(Pa)
    a = cnt;
    if(Qb)
    b = cnt;
    cnt++;
    Pa = true;
    Qb = true;
  }while(next_permutation(R.begin(),R.end()));

  cout << abs(a-b) << endl;

  
}

Measured memory_bytes: 256
import math
import itertools

N = int(input())

x, y = [0] * N, [0] * N
for i in range(N):
	x[i], y[i] = map(int, input().split())

ans = 0
for i in itertools.permutations(range(0, N), N):
	for j in range(1, N):
		ans += ((x[i[j]] - x[i[j - 1]]) ** 2 + (y[i[j]] - y[i[j - 1]]) ** 2) ** 0.5

print(ans / math.factorial(N))

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

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		Items[] a = new Items[n];
		for(int i = 0; i < n; i++) a[i] = new Items();
		for(int i = 0; i < n; i++){
			str = br.readLine().split(" ");
			a[i].value = Integer.parseInt(str[0]);
			a[i].weight = Integer.parseInt(str[1]);
			a[i].type = str[2].charAt(0);
			a[i].date = Long.parseLong(str[3]);
			a[i].name = str[4];
		}
		Arrays.sort(a);
		for(int i = 0; i < n; i++) System.out.println(a[i].value + " " + a[i].weight + " " + a[i].type + " " + a[i].date + " " + a[i].name);
	}
}

class Items implements Comparable<Items>{
	int value;
	int weight;
	char type;
	long date;
	String name;
	@Override
	public int compareTo(Items b){
		if(this.value != b.value) return this.value - b.value;
		if(this.weight != b.weight) return this.weight - b.weight;
		if(this.type != b.type) return Character.compare(this.type, b.type);
		if(this.date != b.date) return (this.date - b.date < 0 ? -1 : 1);
		return this.name.compareTo(b.name);
	}
}



Measured memory_bytes: 102112
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000010;
char str[maxn];//原字符串
char tmp[maxn<<1];//转换后的字符串
int Len[maxn<<1];
//转换原始串
int INIT(char *st)
{
    int i,len=strlen(st);
    tmp[0]='@';//字符串开头增加一个特殊字符，防止越界
    for(i=1;i<=2*len;i+=2)
    {
        tmp[i]='#';
        tmp[i+1]=st[i/2];
    }
    tmp[2*len+1]='#';
    tmp[2*len+2]='$';//字符串结尾加一个字符，防止越界
    tmp[2*len+3]=0;
    return 2*len+1;//返回转换字符串的长度
}
//Manacher算法计算过程
long long MANACHER(char *st,int len,int L)
{
     int mx=0,po=0;//mx即为当前计算回文串最右边字符的最大值
     long long ans=(1LL*L*(L-1))/2+1;
     for(int i=1;i<=len;i++)
     {
         if(mx>i)
         Len[i]=min(mx-i,Len[2*po-i]);//在Len[j]和mx-i中取个小
         else
         Len[i]=1;//如果i>=mx，要从头开始匹配
         while(st[i-Len[i]]==st[i+Len[i]])
         Len[i]++;
         if(Len[i]+i>mx)//若新计算的回文串右端点位置大于mx，要更新po和mx的值
         {
             mx=Len[i]+i;
             po=i;
         }
         ans-=(Len[i]-1)/2;
     }
     return ans;//返回Len[i]中的最大值-1即为原串的最长回文子串额长度
  }
  int cnt[128];
  int main()
  {

      scanf("%s",str);
      int len=strlen(str);
      for (int i=0;i<len;i++){
        cnt[str[i]]++;
      }
      long long ans=(1LL*len*(len+1))/2+1;
      for (int i=0;i<128;i++)ans-=1LL*cnt[i]*(cnt[i]+1)/2;
      cout<<ans<<endl;
      return 0;
  }


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

vector<int> binary(int i, int n, int N){
    int x = 1;
    rep(j,N){
        x *= n;
    }
    vector<int> vec(N);
    rep(j,N){
        x /= n;
        vec[j] = i / x;
        i -= x * vec[j];
    }
    return vec;
}

int main(){
    int N;
    cin >> N;
    int ans = 100000;
    for(int i = 0; i <= N; i++){
        int ans_sub = 0;
        vector<int> binary_6 = binary(i,6,7);
        rep(j,7){
            ans_sub += binary_6[j];
        }
        vector<int> binary_9 = binary(N - i, 9, 6);
        rep(j,6){
            ans_sub += binary_9[j];
        }
        ans = min(ans, ans_sub);
    }
    cout << ans << endl;
}


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

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

  int ans=0;

  rep(i,n){
      ll x,y;
      cin >> x >> y;
      
        ll xx = x*x;
      ll yy = y*y;
      ll dd = d*d;
      if(xx + yy <= dd) ans++;
      
      

  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/predicate.hpp>

using namespace std;

#if 0
// memo
abs()

start_with(str, "hoge");
ends_with(str, "hoge");

std::sort(d.begin(), d.end());
d.erase(std::unique(d.begin(), d.end()), d.end());
#endif

using namespace boost;
using namespace boost::algorithm;

static inline bool isOdd(int v)
{
    return v & 0x01;
}

int main()
{
    string str;
    cin >> str;

    int v[4];
    v[0] = lexical_cast<int>(str[0]);
    v[1] = lexical_cast<int>(str[1]);
    v[2] = lexical_cast<int>(str[2]);
    v[3] = lexical_cast<int>(str[3]);

//    cerr << A << B << C << D << endl;

    for (size_t i = 0; i < 2*2*2; ++i) {
        std::string str;
        size_t sum = v[0];
        str += lexical_cast<char>(v[0]);
        for (size_t j = 0; j < 3; ++j) {
            bool isPlus = (i >> j) & 0x01;
            if (isPlus) {
                str.push_back('+');
                sum += v[j+1];
            }
            else {
                str.push_back('-');
                sum -= v[j+1];
            }
            str += lexical_cast<char>(v[j+1]);
        }
        if (sum == 7) {
            str += "=7\n";
            cout << str;
            break;
        }
        cerr << "cand: " << str << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 256;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

vector<int> rs;
int path[MAX][MAX];

void solve(void){
    int N, M, R;
    cin >> N >> M >> R;
    rep(R, i) {
        int r;
        scanf("%d", &r);
        r--;
        rs.pb(r);
    }
    rep(N, i) rep(N, j) path[i][j] = (i==j?0:INF);
    rep(M, i) {
        int A, B, C;
        scanf("%d %d %d\n", &A, &B, &C);
        A--; B--;
        path[A][B] = path[B][A] = C;
    }
    rep(N, k) rep(N, i) rep(N, j) path[i][j] = min(path[i][j], path[i][k] + path[k][j]);
    int ans = INF;
    sort(all(rs));
    do {
        int tmp = 0;
        rep(R-1, r) tmp += path[rs[r]][rs[r+1]];
        ans = min(ans, tmp);
    } while(next_permutation(all(rs)));
    
    cout << ans << '\n';
}

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


Measured memory_bytes: 512
import sys
stdin = sys.stdin
import numpy as np

 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

a, b = na()

print(a+b if a+b <10 else "error")

Measured memory_bytes: 17968
N, K = map(int,input().split())
a, b = 0, 0
for i in range(1, N+1):
  if(i%K == 0):
    a += 1
if(K%2 == 0):
  for i in range(1, N+1):
    if(i%K == K//2):
      b += 1
print(a**3 + b**3)

Measured memory_bytes: 3060
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {

    int A, B;
    scanf("%d %d", &A, &B);

    int C[3];
    C[0] = A + B;
    C[1] = A - B;
    C[2] = A * B;

    int ans = -1001;
    REP(0, i, 3) {
        if (ans < C[i]) ans = C[i];
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
n,k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)

if n <= k
  puts 0.to_i
  exit
end

h_sort = h.sort{|a, b| b.to_i <=> a.to_i  }

i = k
sum = 0
while i < n
  sum += h_sort[i]
  i += 1
end

puts sum.to_i

Measured memory_bytes: 19312
x = input()
N = int(x)

if N % 10 == 2 or N % 10 == 4 or N % 10 == 5 or N % 10 == 7 or N % 10 == 9:
    print('hon')
elif N % 10 == 3:
    print('bon')
else:
    print('pon')

Measured memory_bytes: 9068
//    https://youtu.be/zRIbf6JqkNc

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,temp,sum=0,flag,ans,h;
    cin>>h>>n;
    while(n--){
        cin>>temp;
        sum+=temp;
    }
    if(h<=sum) cout<<"Yes";
    else cout<<"No";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int N){
    vector<int>S;
    rep(i,N)if(bit & (1<<i))S.push_back(i);
    return S;
}

int main(){
    int a,b;cin>>a>>b;
    cout<<a*b/2;
}



Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    sums = [None]*(n-1)
    s = 0
    ans = 0
    for i in range(n-1):
        s += a[i]
        s %= mod
        sums[i] = s
    for i in range(n-1):
        ans += a[n-1-i]*sums[n-2-i]
        ans %= mod
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 31608
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	int res;
	res += N*(N-1)/2;
	res += M*(M-1)/2;
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

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

        long x = sc.nextLong();

        double a = 100;
        long k = 0;
        int count = 0;

        double rate = 1.01;
        
        while(x > a){
            a = rate * a;
            k = (long)a;
            a = (double)k;
            count++;
        }
        System.out.println(count);


        
        






    }
}

Measured memory_bytes: 35808
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  std::string S, T; std::cin >> S >> T;
  int A, B; std::cin >> A >> B;
  std::string U; std::cin >> U;
  if (U == S) {
    std::cout << A-1 << " " << B << std::endl;
  } else {
    std::cout << A << " " << B-1 << std::endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a1,a2,a3;
    int sum = 0 ;
    scanf("%d %d %d",&a1,&a2,&a3);
    sum += a1+a2+a3;
    if(sum >= 22){
        printf("bust");
    }else{
        printf("win");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<ll>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll n;
	cin>>n;
	vl a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	ll t=n/2;
	ll ans=0;
	vl q,w;
	
	
	rep(i,n){
	    if(i<t)q.push_back(a[i]);
	    else w.push_back(a[i]);
	}
	if(t==n-t){
	    ll v=accumulate(all(w),0ll)*2-w.front();
	    ll z=accumulate(all(q),0ll)*2-q.back(); //-(q.size()>1?q[q.size()-2]:0)
	    ans=v-z;
	    //cout<<v<<","<<z<<endl;
	}else{
	    {
    	    ll v=accumulate(all(q),0ll)*2;
    	    ll z=accumulate(all(w),0ll)*2-w.front()-(w.size()>1?w[1]:0);
    	    ans=z-v;
	    }
	    {
	        q.clear(); w.clear();
	        rep(i,n){
        	    if(i<t+1)q.push_back(a[i]);
        	    else w.push_back(a[i]);
        	}
    	    ll v=accumulate(all(w),0ll)*2;
    	    ll z=accumulate(all(q),0ll)*2-q.back()-(q.size()>1?q[q.size()-2]:0);
    	    ans=max(ans,v-z);
	    }
	}
	if(ans<0)cout<<w[INF];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2168
// 2015/06/01 Tazoe

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	char S[20];
	cin >> S;

	int N;
	cin >> N;

	int cnt = 0;

	for(int i=0; i<N; i++){
		char R[20];
		cin >> R;

		char R2[40];		// 文字列Rを2回くっつけたもの
		strcpy(R2, R);
		strcat(R2, R);

		if(strstr(R2, S)!=0){
			cnt++;
		}
	}

	cout << cnt << '\n';

	return 0;
}

Measured memory_bytes: 1184
#[allow(non_snake_case)]

fn main() {
    read_line();
    let mut A = read_line_split::<u32>(' ');
    let mut i = 0;
    while A.iter().all(|a| a%2 == 0) {
        A = A.iter().map(|a| a/2).collect();
        i += 1;
    }

    println!("{}", i);
}


use ioutils::*;
#[allow(dead_code)]
mod ioutils {
    use std;
    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.pop();
        s
    }

    pub fn read_line_num<T>() -> T
        where T: std::str::FromStr, <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.pop();
        s.parse::<T>().unwrap()
    }

    pub fn read_line_split<T>(sep: char) -> Vec<T>
    where T: std::str::FromStr, <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.pop();
        s.split(sep).map(|s| s.parse::<T>().unwrap()).collect()
    }
}

Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var n int64
	fmt.Scan(&n)
	ar := make([]int64, 5)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	min := ar[0]
	for i := 1; i < 5; i++ {
		if ar[i] < min {
			min = ar[i]
		}
	}
	ans := n / min
	if n%min != 0 {
		ans++
	}
	fmt.Println(ans + 4)
}


Measured memory_bytes: 512
n = int(input())

for i in range(n):
    l = list(map(int, input().split()))
    b, c, flag = 0, 0, 0
    for seq in l:
        if seq > b:
            b = seq
        elif seq > c:
            c = seq
        else:
            flag = 1
    if flag == 0:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;


int bfs(int N,int M,vector<vector<char>> field,int sx,int sy,int gx, int gy){
    int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
    int d[N][M];//距離の配列
    for (int i = 0;i < N;i++){
        for (int j = 0;j < M;j++){
            d[i][j] = INF;//初期化
        }
    }
    queue<P> que;
    que.push(P(sx,sy));
    d[sx][sy] = 0;

    //キューが空になるまでループ
    while(que.size()){
        P p = que.front();
        que.pop();//先頭を取り出す
        if (p.fs == gx && p.sc == gy){
            break;//探索終わり
        }
        for (int i = 0;i < 4;i++){
            int nx = p.fs + dx[i], ny = p.sc + dy[i];
            //nx,nyが進めるマスか、行ったことのないマスかどうかを判定
            if (0 <= nx && nx < N && 0 <= ny && ny < M && field[nx][ny] != '#' && d[nx][ny] == INF){
                que.push(P(nx,ny));//追加
                d[nx][ny] = d[p.fs][p.sc] + 1;//距離を確定 
            }
        }
    }
    return d[gx][gy];
}

int main(){ 
    int h,w,i,j;
    
    cin >> h;
    cin >> w;
    vector<vector<char>> field(h,vector<char>(w));
    int res = 0;
    int sx,sy,gx,gy;
    for (i = 0;i < h;i++){
        for (j = 0;j < w;j++){
            cin >> field[i][j]; 
        } 
    }
    int ans = 0;
    for (i = 0;i < h;i++){
        for (j = 0;j < w;j++){
            if (field[i][j] == '.'){
                sx = i;
                sy = j;
            }
            for (int k = 0;k < h;k++){
                for (int l = 0;l < w;l++){
                    if (field[k][l] == '.' && field[i][j] == '.'){
                        gx = k;
                        gy = l;
                        ans = max(ans,bfs(h,w,field,sx,sy,gx,gy));
                    }
                } 
            }
        } 
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    std::string s;
    cin >> s;
    
    int cnt = 0;
    int n = s.size();
    //cout << n << endl;
    for(int i=0; i<n/2; i++){
        //cout << s[i] << ":" << s[n-(i+1)] << endl;
        if(s[i] != s[n-(i+1)]){
            cnt++;
        }
    }

    cout << cnt << endl; 
    return 0;
}

Measured memory_bytes: 256
import math

N = int(input())

data = [0 for i in range(6)]

for l in range(N):
    n = float(input())
    if n < 165.0:
        data[0] += 1
    elif n < 170.0:
        data[1] += 1
    elif n < 175.0:
        data[2] += 1
    elif n < 180.0:
        data[3] += 1
    elif n < 185.0:
        data[4] += 1
    else:
        data[5] += 1

for l in range(6):
    print(l+1, end="")
    print(":", end="")
    for i in range(data[l]):
        print("*", end="")
    print("")



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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int H = input[0];
            int W = input[1];

            int[,] dp = new int[H, W];
            int maxWidth = 0;

            for (int i = 0; i < H; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                for (int j = 0; j < W; j++)
                {
                    if (input[j] == 0)
                    {
                        dp[i, j] = 1;
                        maxWidth = 1;
                    }
                }
            }

            for (int i = 1; i < H; i++)
            {
                for (int j = 1; j < W; j++)
                {
                    if (dp[i, j] != 0)
                    {
                        dp[i, j] = Math.Min(dp[i - 1, j - 1], Math.Min(dp[i - 1, j], dp[i, j - 1])) + 1;
                        maxWidth = Math.Max(maxWidth, dp[i, j]);
                    }
                }
            }

            Console.WriteLine(maxWidth * maxWidth);
        }
    }
}

Measured memory_bytes: 23256
def inWall(x,y,x1,y1,r):
	return True if ((x-x1)**2+(y-y1)**2)**0.5 <= r + 1e-9 else False

def isHide(x,y,r,a,b,c):
	D = abs(a*x+b*y+c)/(a**2+b**2)**0.5
	return True if D <= r + 1e-9 else False

def isBetween(x,y,tx,ty,sx,sy):
	a,b,c = (x-tx)**2+(y-ty)**2,(x-sx)**2+(y-sy)**2,(sx-tx)**2+(sy-ty)**2
	if c > b and c > a: return True
	a,b,c = sorted([a,b,c])
	return True if c-a-b <= 0 else False

while 1:
	n = input()
	if n == 0: break
	wall = [map(int,raw_input().split()) for i in range(n)]
	for i in range(input()):
		tx,ty,sx,sy = map(int,raw_input().split())
		a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx
		for x,y,r in wall:
			t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r)
			if t_in != s_in or (not t_in and isHide(x,y,r,a,b,c) and isBetween(x,y,tx,ty,sx,sy)):
				print "Safe"
				break
		else:
			print "Danger"

Measured memory_bytes: 4400
#include <stdio.h>
#include <string.h>
#include <stack>
using namespace std;
char s[200];
stack <char> ss;
int main()
{
    while (fgets(s,150,stdin))
    {
        int len=strlen(s);
        s[len-1]=0;
        if (strcmp(s,".")==0) break;
        len--;
        while (!ss.empty()) ss.pop();
        bool ok=true;
        for (int i=0;i<len;i++)
        {
            if (s[i]=='(') ss.push('(');
            else if (s[i]=='[') ss.push('[');
            else if (s[i]==')')
            {
                if (ss.empty()||ss.top()!='(')
                {
                    ok=false;
                    break;
                }
                ss.pop();
            }
            else if (s[i]==']')
            {
                if (ss.empty()||ss.top()!='[')
                {
                    ok=false;
                    break;
                }
                ss.pop();
            }
        }
        if (ok)
            if (!ss.empty()) ok=false;
        if (ok) puts("yes");
        else puts("no");
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		int array[] = new int[N];
		for(int i = 0; i < N; i++)array[i] = scanner.nextInt();

		out_put(array);

		int base_value,loc;
		for(int i = 1; i < N; i++){
			base_value = array[i];
			loc = i-1;
			while(loc >= 0 && array[loc] > base_value){
				array[loc+1] = array[loc];
				loc--;
			}
			array[loc+1] = base_value;

			out_put(array);
		}
	}

	private static void out_put(int array[]){

		System.out.printf("%d", array[0]);

		for(int i = 1; i < array.length; i++){
			System.out.printf(" %d", array[i]);
		}
		System.out.printf("\n");
	}
}



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

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

    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    REP(i, N) a[i] = L + i;

    int result;
    int a_sum = accumulate(all(a), 0);
    if (a[0] <= 0 && a[N - 1] >= 0) {
        result = a_sum;
    } else if (a[0] > 0) {
        result = a_sum - a[0];
    } else {
        result = a_sum - a[N - 1];
    }
    cout << result << endl;
    return 0;
}



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

int main(void){
    int A, B, C, N;
    
    cin >> A >> B >> C >>N;
    
    int count = 0;
    int a, b, n;
    int c = C * 50;
    for(a = 0; a <= A; a++){
        for(b = 0; b <= B; b++){
            n = N - (a*500 + b*100);
            if( c >= n &&  n >= 0) count++;
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> v(N);
  std::vector<int> val(N);
  range(i, N) std::cin >> v[i];
  range(i, N) std::cin >> val[i];
  range(i, N) v[i] -= val[i];
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int ans = 0;
  range(i, N){
    if(v[i]>0) ans+=v[i];
    else break;
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int c0=0;
  int c1=0;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='0'){
      c0++;
    }
    else {
      c1++;
    }
  }
  cout << min(c0, c1) * 2 << endl;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
	string str;
	std::cin >> str;
	for (size_t i = 0; i < str.size(); i++) {
		if (str[i] == '9') {
			std::cout << "Yes" << '\n';
			return 0;
		}
	}
	std::cout << "No" << '\n';
	return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n, m;
	cin >> n >> m;
	vector<int>from;
	map<int,int>to;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (a == 0)from.pb(b);
		if (b == n - 1)to[a]++;
	}
	rep(i, from.size()) {
		if (to[from[i]] == 1) {
			print("POSSIBLE");
			return 0;
		}
	}
	print("IMPOSSIBLE");
}

Measured memory_bytes: 16356
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    forn (i, 0, n)
        cin >> a[i] >> b[i];
    sort(all(a)), sort(all(b));
    if (n % 2 == 0)
        cout << b[n / 2] + b[n / 2 - 1] - 
                (a[n / 2] + a[n / 2 - 1]) + 1;
    else
        cout << b[n / 2] - a[n / 2] + 1;
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      string s;
      cin >> s;
      int y = stoi(s.substr(0,4));
      int m = stoi(s.substr(5,2));
      int d = stoi(s.substr(8,2));
      if(y > 2019){
          cout << "TBD" << endl;
      }
      else if(y == 2019 && m > 4){
          cout << "TBD" << endl;
      }
      else{
          cout << "Heisei" << endl;
      }
}


Measured memory_bytes: 256
/*
 * B.cpp
 *
 *  Created on: 2020/06/27
 *      Author: 17k1028
 */





#include <iostream>
#include <string>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))


using namespace std;

int main(){
	string S,T;
	cin >> S >> T;
	long long count = 0;
	for (long long  i = 0; i < S.length(); i++){
		if(S[i] != T[i]){
			count++;
		}
	}
	cout << count <<endl;
}


Measured memory_bytes: 3916
x, n =map(int, input().split())  #複数数値入力
list_p = list(map(int, input().split()))  #リスト入力


if n == 0:
    print(x)
else:
    i = 0
    while True:
        if x - i not in list_p:
            print(x-i)
            break
        elif x + i not in list_p:
            print(x+i)
            break
        else:
            i += 1


Measured memory_bytes: 9168