akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int k;
	cin >> k;
	vector<ll> a(k);
	rep(i,k) cin >>a[i];
	
	

	ll cmx=2, dmx =2;
	repr(i, k-1, 0){
		ll x = (cmx + a[i] -1) / a[i];
		ll y = dmx / a[i];
		if( x > y){ puts("-1");return 0;}
		cmx = x * a[i];
		dmx = y * a[i] + a[i] -1;
		//dbg(i,cmx, dmx);
	}
	

	
	cout << cmx <<" " << dmx <<"\n";
	return 0;
}


Measured memory_bytes: 1024
// @DateTime:    2020-04-27 18:43:21
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast", "-funroll-all-loops", "-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(), (x).end()
#define trav(a, x) for (auto &a : x)
#define close \
    std::ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c)         \
    (sort(c.begin(), c.end()), \
     c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define CASET    \
    int ___T;    \
    cin >> ___T; \
    for (int __CS = 1; __CS <= ___T; __CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6 + 10;
constexpr int mod = 1e9 + 7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base = 2333, P_1 = 19260811, P_2 = 999998639;
void add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}
void dec(int &a, int b) {
    a -= b;
    if (a < 0) a += mod;
}
int a[maxn];
int main() {
    int n;
    cin >> n;
    int fl = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    a[0] = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i - 1] - a[i] == 1) {
            a[i - 1]--;
        } else if (a[i] == a[i - 1] && a[i] > a[i - 2]) {
            a[i - 1]--;
        } else if (a[i] < a[i - 1] && a[i - 1] - a[i] > 1) {
            fl = 1;
            break;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] < a[i - 1]) {
            fl = 1;
            break;
        }
    }
    puts(fl ? "No" : "Yes");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "Yes";
const string NO  = "No";

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

    int k, x;

    cin >> k >> x;

    cout << (500 * k >= x ? YES : NO) << endl;

    return 0;
}



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

int main(){
    int X;
    cin>>X;
    int ans=1;
    for(int i=1;i<32;i++){
        for(int j=2;j<11;j++){
            if(ans<=pow(i,j) && pow(i,j)<=X){
                ans=pow(i,j);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
#define h_max 20000

int main() {
    int h;
    int n;
    vector<int> a;
    vector<int> b;
    int tmp_a;
    int tmp_b;
    int ans=0;

    cin >> h >> n;
    vector<int> dp(h_max, -1);
    for(int i=0; i<n; i++){
        cin >> tmp_a >> tmp_b;
        a.push_back(tmp_a);
        b.push_back(tmp_b);
    }
    dp[0]=0;
    //cout << "start" << endl;
    for(int i=0; i<h; i++){
        for(int j=0; j<n; j++){
            if(dp[i]!=-1 && (dp[i+a[j]]==-1 || dp[i+a[j]]>dp[i]+b[j])){
                dp[i+a[j]] = dp[i]+b[j];
                //cout << i+a[j] << " " << dp[i+a[j]] << endl;
            }
        }
    }
    for(int i=h; i<h_max; i++){
        if(dp[i]!=-1 && (dp[i]<ans || ans==0)){
            ans = dp[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
// これはなに?
#include<iostream>
#include<random>
using namespace std;

int main(){
    int n;
    cin >> n;
    char s[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> s[i][j];
        }
    }
    int e = rand()%n+1;
    for(int i = 0; i < 1000; i++){
        cout << e << endl;
        int x;  cin >> x;
        if(s[e-1][x-1] == 'x')  e = rand()%n+1;
    }
    return 0;
}


Measured memory_bytes: 3376
import sys
from collections import namedtuple
from itertools import starmap
readline = sys.stdin.readline
EPS = 1e-9
class Segment(namedtuple('Point', ('fi', 'se'))):
    __slots__ = ()
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
def ccw(p1, p2, p3):
    a = p2 - p1
    b = p3 - p1
    if cross(a, b) > EPS: return 1
    if cross(a, b) < -EPS: return -1
    if dot(a, b) < -EPS: return 2
    if norm(a) < norm(b): return -2
    return 0
def intersect4(p1, p2, p3, p4):
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)
def intersect2(s1, s2):
    return intersect4(s1.fi, s1.se, s2.fi, s2.se)
def getDistance(a, b):  return abs(a - b)
def getDistanceLP(l, p):
    return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))
def getDistanceSP(s, p):
    if dot(s.se - s.fi, p - s.fi) < 0.0: return abs(p - s.fi)
    if dot(s.fi - s.se, p - s.se) < 0.0: return abs(p - s.se)
    return getDistanceLP(s, p)
def getDistances(s1, s2):
    if intersect2(s1, s2): return 0.0
    return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se),
               getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))
n = int(readline())
for _ in [0] * n:
    p0, p1, p2, p3 = starmap(complex, zip(*[map(int, input().split())] * 2))
    s1 = Segment(p0, p1)
    s2 = Segment(p2, p3)
    print("{0:.10f}".format(getDistances(s1, s2)))

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

int main() {
  int N;
  cin >> N;
  int A , B;
  cin >> A >> B;
  vector <int> P(N);
  for(int i = 0; i < N; i++){
    cin >> P.at(i);
  }
  int an = 0;
  int sw = 0;
  int er = 0;
  for(int i = 0; i < N; i++){
    if(P.at(i) <= A){
      an++;
    }
    if(P.at(i) > A && P.at(i) <= B){
      sw++;
    }
    if(P.at(i) > B){
      er++;
    }
  }
  cout << min({ an , sw , er}) << endl;
}



Measured memory_bytes: 256
import sys
from bisect import bisect_right, bisect_left


def calculate_score(c):
    global D, last, S
    rst = 0
    _last = last[c]
    for d in range(1, D + 1):
        down = C[c] * (d - _last[d])
        up = S[d][c] if _last[d] == d else 0
        rst += up - down
    return rst


Z = 26
D = int(input())
C = list(map(int, input().split()))

S = [tuple([0] * Z)] + [tuple(map(int, input().split())) for _ in range(D)]
T = [None] + [int(input()) - 1 for _ in range(D)] # 

M = int(input())
Q = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]


last = [[0] * (D + 1) for _ in range(Z)]  # last[i][d]
V = [0] * Z  # 各コンテストiごとの得点を保管しておく

# 初期状態でのlastを求める
for d in range(1, D + 1):
    t = T[d]
    for p in range(Z):
        last[p][d] = last[p][d - 1]
    last[t][d] = d
# 各コンテストpごとに得点を求める
for p in range(Z):
    V[p] = calculate_score(p)

# 初期状態での得点
score = sum(V)

for d, q in Q:
    d += 1  # Qだけ0-indexなので補正
    p = T[d]

    # d日目の開催が p -> q に変わる
    # まず, last[p]を更新する. 更新箇所はd日目 ~ 次の開催日直前
    e = bisect_right(last[p], d)
    for j in range(d, e):
        last[p][j] = last[p][j - 1]

    # 次に, last[q]を更新する. 更新箇所はd日目 ~ 次の開催日直前
    old = last[q][d]
    e = bisect_right(last[q], old)
    for j in range(d, e):
        last[q][j] = d

    score -= V[p] + V[q]
    V[p] = calculate_score(p)
    V[q] = calculate_score(q)
    score += V[p] + V[q]
    print(score)

    T[d] = q

Measured memory_bytes: 100572
a,b,k = map(int, input().split())
ans=[]
for i in range(a,min(a+k,b)):
    ans.append(i)
for j in range(max(a,b-k+1),b+1):
    ans.append(j)
ans=list(set(ans))
ans.sort()
l=len(ans)
for i in range(l):
    print(ans[i])

Measured memory_bytes: 9160
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
#include<bitset>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)

using namespace std;
int n;
int a[20];
int x[20][20];
int y[20][20];
int ans;
int counter(int N){
    if(N==0)return 0;
    return counter(N>>1)+(N&1);
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        for(int j=1;j<=a[i];j++){
            cin>>x[i][j]>>y[i][j];
        }
    }
    for(int bit=0;bit<(1<<n);bit++){//0不親切 1親切
    //puts(bit);
        bool ok=true;
        for(int i=1;i<=n;i++){
            if(!(bit>>(i-1) & 1)) continue;//不親切なら都バス
            for(int j=1;j<=a[i];j++){
                if(((bit >> (x[i][j]-1)) & 1)^y[i][j]){
                    ok = false;
                } 
            }
        }
        if(ok){
            //puts(bitset<16>(bit))
            ans=max(ans,counter(bit));
        }
        
    }
    puts(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <utility>
#include <queue>

using namespace std;

#define C(X,Y) (0<=(X)&&(X)<(Y))

bool can[30][30][4],vst[30][30];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

struct State {
	int x,y;
	int turn;
	State(int _x,int _y,int _turn);
};

State::State(int _x,int _y,int _turn)
	:x(_x),y(_y),turn(_turn) {}

int main() {
	int w,h;
	while(cin>>w>>h,w||h) {
		memset(can,0,sizeof(can));
		for(int j=0;j<h;j++) {
			for(int i=0;i<w-1;i++) {
				cin>>can[i][j][0],can[i+1][j][2]=can[i][j][0];
			}
			if(j==(h-1)) break;
			for(int i=0;i<w;i++) {
				cin>>can[i][j][1],can[i][j+1][3]=can[i][j][1];
			}
		}
		queue<State> que;
		que.push(State(0,0,1));
		memset(vst,0,sizeof(vst));
		vst[0][0]=true;
		int ans=0;
		while(!que.empty()) {
			State S(que.front());que.pop();
			if(S.x==(w-1)&&S.y==(h-1)) {ans=S.turn;break;}
			for(int i=0;i<4;i++) {
				int nx=S.x+dx[i],ny=S.y+dy[i];
				if(C(nx,w)&&C(ny,h)&&!can[S.x][S.y][i]&&!vst[nx][ny]) {
					vst[nx][ny]=true;
					que.push(State(nx,ny,S.turn+1));
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using usize = size_t;

namespace chrono = std::chrono;
using namespace std::literals;

#define all(c) (c).begin(), (c).end()

__attribute__((constructor))
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
  i32 n, m;
  cin >> n >> m;
  std::vector<std::string> a(n);
  for (auto& s: a) {
    cin >> s;
  }
  for (i32 i = 0; i < n; ++i) {
    for (i32 j = 0; j < m; ++j) {
      if (a[i][j] == '#') continue;
      a[i][j] = '0';
      for (i32 x: {i - 1, i, i + 1}) {
        for (i32 y: {j - 1, j, j + 1}) {
          if (x < 0 or n <= x) continue;
          if (y < 0 or m <= y) continue;
          if (a[x][y] == '#') {
            a[i][j] += 1;
          }
        }
      }
    }
    cout << a[i] << endl;
  }
}


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

class Program
{
    static void Main(string[] args) {
        var list = new List<string>(Console.ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();

        if (list[1] % list[0] == 0)
            WriteLine(list[0] + list[1]);
        else
            WriteLine(list[1] - list[0]);


        Console.ReadLine();
    }
}


Measured memory_bytes: 13396
//#pragma GCC optimize(2)
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma comment(linker, "/STACK:102400000,102400000")
 
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int N = 1010;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
 
int p[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll n;
    cin >> n;
    ll m = n;
    int ans = 0;
    rep(i, 2, m / i + 1)
    {
        if (n % i == 0)
        {
            int j = i;
            while (n % j == 0)
            {
                ans++;
                n /= j;
                j *= i;
            }
            while (n % i == 0)
            {
                n /= i;
            }
        }
    }
 
    if (n > 1)
        ans++;
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3588
N = int(input())
S = input()
result = True
if N % 2 == 0:
    for i in range(N // 2):
        if S[i] != S[N // 2 + i]:
            result = False
            break
    if result:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 9172
import java.io.*;

public class Main {
    public static void main(String[] args){
        test2_1();

    }

    private static int test1_1(String i){
        int num = Integer.parseInt(i);
        int three_num = num*num*num;
        return three_num;
    }

    private static void test2_1(){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String word;
        String[] dat;
        try {
            //word = reader.readLine();
            dat = reader.readLine().split(" ");
            int r = Integer.parseInt(dat[0]);
            int c = Integer.parseInt(dat[1]);
            StringBuilder out=new StringBuilder();
            int g,p,gg=0;
            String str;
            int[] SumC=new int[c];
            for (int i=0;i<r;i++){
                str =reader.readLine();
                dat = str.split(" ");
                g=0;
                for (int j=0;j<c;j++){
                    p=Integer.parseInt(dat[j]);
                    g += p;
                    SumC[j] += p;
                }
                gg+=g;
                out.append(str+" "+g+"\n");
            }
            for (int j=0;j<c;j++) out.append(SumC[j]+" ");
            out.append(gg);
            System.out.println(out);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}

Measured memory_bytes: 27412
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
    int N, T, L, B;
    while(cin >> N >> T >> L >> B, N) {
        vector<int> v(N+1, 0);
        for(int i=0; i<L; ++i) {
            int l;
            cin >> l;
            v[l] = 1;
        }
        for(int i=0; i<B; ++i) {
            int b;
            cin >> b;
            v[b] = -1;
        }
        vector<vector<vector<double>>> dp(T+1, vector<vector<double>>(2, vector<double>(N+1, 0)));
        dp[0][0][0] = 1;

        for(int t=0; t<T; ++t) {
            for(int j=0; j<N; ++j) {
                if(v[j] == 1) {
                    dp[t+1][1][j] += dp[t][0][j];
                }
                for(int d=1; d<=6; ++d) {
                    int idx = v[j] == 1 ? 1 : 0;
                    int next = j + d;
                    if(next > N) {
                        next = N - (next - N);
                    }
                    if(v[next] == -1) {
                        next = 0;
                    }
                    dp[t+1][0][next] += dp[t][idx][j] / 6.0;
                }
            }
        }
        double ret = 0;
        for(int i=1; i<=T; ++i) {
            ret += dp[i][0][N];
        }
        cout << fixed << setprecision(6) << ret << endl;
    }
}


Measured memory_bytes: 3324
program pyramid
  implicit none
  integer              :: n, highest, idx, i, j, k, hc
  integer, allocatable :: x(:), y(:), h(:)
  logical              :: invalid
  read(*,*) n
  allocate(x(n),y(n),h(n))
  highest = 0
  idx = 0
  do i = 1, n
     read(*,*) x(i),y(i),h(i)
     if (h(i) .gt. highest) then
        highest = h(i)
        idx = i
     end if
  end do
  do i = 0, 100
     do j = 0, 100
        hc = highest + abs(i-x(idx)) + abs(j-y(idx))
        invalid = .false.
        do k = 1, n
           if (h(k) .ne. max(hc - abs(i-x(k)) - abs(j-y(k)),0)) then
              invalid = .true.
              exit
           end if
        end do
        if (invalid) cycle
        deallocate(x,y,h)
        write(*,'(i0,x,i0,x,i0)') i, j, hc
        stop
     end do
  end do
end program pyramid

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main(){
	string s;
	cin>>s;
	int l=s.size();
	int mx=0;
	int i;
	for(i=0;i<(1<<l);i++){
		int ok=3;
		int j;
		for(j=0;j<l;j++){
			if(i>>j&1^1)continue;
			if(s[j]=='i'||s[j]=='w')ok--;
		}
		if(ok!=0)continue;
		bool f=true;
		for(j=0;j<l;j++){
			if(i>>j&1^1)continue;
			int m=0,n,k;
			for(k=0;k<=j;k++){
				m+=i>>k&1;
			}
			n=m;
			int x;
			for(x=l-1;;x--){
				n-=i>>x&1;
				if(n==0)break;
			}
			if(!((s[j]==')'&&s[x]=='(')
			||(s[j]=='('&&s[x]==')')
			||(s[j]=='{'&&s[x]=='}')
			||(s[j]=='}'&&s[x]=='{')
			||(s[j]=='['&&s[x]==']')
			||(s[j]==']'&&s[x]=='[')
			||(s[j]=='i'&&s[x]=='i')
			||(s[j]=='w'&&s[x]=='w'))){
				f=false;
				break;
			}
		}
		if(!f)continue;
		int k=0;
		for(j=0;j<l;j++)
			if((i>>j)%2==1)k++;
		chmax(mx,k);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
int main()
{
  using namespace std;
  int count=0;
  string s;
  cin >> s;
  for(int i=0;i<(s.length()/2);i++)
  {
    if(s[i]!=s[s.length()-1-i])
    {
      count++;
    }
  }
  cout << count;
  return 0;
}

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

using namespace std;

int main(){
  int number;
  vector<int> BIGBMI;
  double weight, length, BMI;
  char c1, c2;

  while(cin >> number >> c1 >> weight >> c2 >> length){
    BMI = weight / (length * length);
    if(BMI >= 25)    
      BIGBMI.push_back(number);
  }

  for(vector<int>::size_type i=0; i != BIGBMI.size(); ++i)
    cout << BIGBMI[i] << endl;
  return 0;
}

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

int main()
{
  int N ;
  cin>>N ;
  vector<int>p(N) ;
  vector<int>S ;
  int count=0 ;
  cin>>p.at(0) ;
  if(p.at(0)==1) count++ ;
  for(int i=1;i<N;i++){
    cin>>p.at(i) ;
    if(i+1==p.at(i)) count++ ;
    else{
      if(count>0) S.push_back(count) ;
      S.push_back(0) ;
      count=0 ;
    }
    if(i==N-1&&i+1==p.at(i)) if(count>0) S.push_back(count);
  }
  int ans=0 ;
  for(int i=0;i<S.size();i++){
    if(S.at(i)>=2){
      if(S.at(i)%2==0) ans+=S.at(i)/2 ;
      else ans+=((S.at(i)+1)/2) ;
    }else if(S.at(i)==1) ans++ ;
  }
  cout<<ans<<endl ;
  
  return 0 ;
}

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

int main(){
    int n;
    string s[50], x;
    int t[50];
    cin >> n;
    for(int i=0;i<n;++i) cin >> s[i] >> t[i];
    cin >> x;

    for(int i=0;i<n;++i){
        if(s[i] == x){
            int64_t ans = 0;
            for(int j=i+1;j<n;++j){
                ans += t[j];
            }
            cout << ans << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
	int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++)cin >> a[i];
	a.resize(unique(a.begin(), a.end()) - a.begin());
	int cnt = 0;
	n = a.size();

	for(int i = 0; i < n; i++) {
		if(i + 1 < n && a[i] < a[i + 1])
			while(i + 1 < n && a[i] <= a[i + 1])i++;


		else if(i + 1 < n && a[i] > a[i + 1])
			while(i + 1 < n && a[i] >= a[i + 1])i++;
		cnt++;

	}
	cout << cnt << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h+2,vector<char>(w+2,'#'));
    int ans=0;
    rep(i,h) {
        rep(j,w) {
            cin >> s[i+1][j+1];
            if (s[i+1][j+1]=='.') ++ans;
        }
    }
    queue<pair<int,int>> q;
    q.push(make_pair(1,1));
    vector<vector<int>> cost(h+2,vector<int>(w+2,-1));
    cost[1][1]=0;
    vector<int> di={-1,0,1,0},dj={0,-1,0,1};
    while (!q.empty()) {
        pair<int,int> now=q.front();
        q.pop();
        int i=now.first,j=now.second;
        rep(k,4) {
            int ni=i+di[k],nj=j+dj[k];
            if (s[ni][nj]=='.' && cost[ni][nj]==-1) {
                cost[ni][nj]=cost[i][j]+1;
                q.push(make_pair(ni,nj));
            }
        }
    }
    if (cost[h][w]>=0) cout << ans-cost[h][w]-1 << endl;
    else cout << -1 << endl;

    return 0;   
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

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

char a[510][510];
int c[510][510];

void paint1(int x,int y,int t)
{
    while (x>=1&&!c[x][y])
    {
        if (a[x][y]=='.') c[x][y]=t;
        x--;
    }
}

void paint2(int x,int y,int t)
{
    while (y>=1&&!c[x][y])
    {
        if (a[x][y]=='.') c[x][y]=t;
        if (a[x-1][y]=='#') break;
        y--;
    }
}

int main()
{
	#ifdef waltz
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n,m;scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
	for (int i=2;i<n;i++)
        for (int j=2;j<m;j++)
            if (i&1) c[i][j]=1; else c[i][j]=2;
    for (int i=2;i<n;i++)
    {
        c[i][1]=1;c[i][m]=2;
    }
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++) if (c[i][j]==1||a[i][j]=='#') putchar('#'); else putchar('.');
        puts("");
    }
    puts("");
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++) if (c[i][j]==2||a[i][j]=='#') putchar('#'); else putchar('.');
        puts("");
    }
    puts("");
	return 0;
}


Measured memory_bytes: 1920
import numpy as np
import sys
read = sys.stdin.read
 

D = int(input())
CS = np.array(read().split(), np.int32)
C = CS[:26]
S = CS[26:].reshape((-1, 26))
del CS
 
last = np.zeros((26, ))


def getContestType_at_d(d, k):
    s = -10000000
    for i in range(26):
        mask = np.ones((26, ))
        mask[i] = 0
        score = S[d][i] - np.sum(C * (d + 1 - last) * mask)
        ps = score
        score -= np.sum(C * (min(365, d + k) + 1 - last))
        if s < score:
            s = score
            t = i
 
    last[t] = d + 1
 
    return t + 1, s, ps


#score = 0
#pscore = 0
ans = []
for d in range(D):
    t, _, _ = getContestType_at_d(d, 10)
    ans.append(t)
    #ans.append(getContestType_at_d(d, 10))
    #score += s
    #pscore += ps

#print('pscore:', pscore)
#print('score:', score)

 
print('\n'.join(map(str, ans)))

Measured memory_bytes: 27700
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

const int max_n=1e6;

int a[max_n];
int n,m,cnt;

vector<int> G;

void Insert_sort(int g)
{
    for(int i=g;i<n;++i)
    {
        int tmp=a[i];
        int j;
        for(j=i-g;j>=0 && tmp<a[j];j-=g)
        {
            a[j+g]=a[j];
            ++cnt;
        }
        a[j+g]=tmp;
    }
}

void Shell_sort()
{
    // 首先,要生成数列G.
    int g=1;
    m=0;
    while(g<=n)
    {
        G.push_back(g);
        ++m;
        g=3*g+1;
    }

    cnt=0;
    for(int i=G.size()-1;i>=0;--i)
    {
        Insert_sort(G[i]);
    }
}


int main()
{
    // 输入数据
    scanf("%d",&n);
    for(int i=0;i<n;++i)
    {
        scanf("%d",&a[i]);
    }
    // 希尔排序
    Shell_sort();

    printf("%d\n",m);
    for(int i=m-1;i>0;--i)
    {
        printf("%d ",G[i]);
    }
    printf("%d\n",G[0]);

    printf("%d\n",cnt);
    for(int i=0;i<n;++i)
    {
        printf("%d\n",a[i]);
    }

    return 0;
}



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

int main(){
  int N,K,x,dist;
  cin >> N >> K;
  for(int i = 0;i < N;i++){
    cin >> x;
    dist += min(x,abs(K - x));
  }
  cout << 2 * dist << endl;
}

Measured memory_bytes: 256
Program Insertion;
const   finput='Insertion.inp';
        foutput='Insertion.out';
var     n,tmp,k,j,i:longint;
        s,st:string;
begin
    //assign(input,finput);reset(input);
    //assign(output,foutput);rewrite(output);
    readln(n);
    readln(s);
    st:='(';
    k:=0;
    i:=1;
    repeat
        begin
        case s[i] of
                ')':dec(tmp);
                '(':inc(tmp);
        end;
        if tmp<0 then
                begin
                insert(st,s,k+1);
                inc(tmp);
                inc(i);
                end;
        end;
    inc(i);
    until i>length(s);
    st:=')';
    while tmp>0 do
        begin
        insert(st,s,length(s)+1);
        dec(tmp);
        end;
        write(s);
    //close(input);close(output);
end.


Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    h1 , m1, h2, m2, k = MAP()
    time = 60 * (h2 - h1) + (m2 - m1)
    print(max(0, time-k))



if __name__ == '__main__':
    main()


Measured memory_bytes: 10544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <map>
using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define SINV(t) greater<t>()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
#define vv(t) vector<t>

template<typename T>
void SV(vector<T> v){
    REP(i,v.size()){
        #ifdef LOCAL
            cout << i << " : " << v[i] << endl;
        #endif
    }
}

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


int main(){
    int N;
    cin >> N;
    ll sum = 0;
    REP2(i, N){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = 6 - (A + B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << 0.5000000000 << endl;
    return 0;
  }
  int k = n/2 + 1;
  double ans = (double)k / (double)n;
  printf("%.10lf\n", ans);
  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

set<int> st;
int mx = 0;
bool over = 0;

void solve() {
    int n;
    cin >> n;
    REP(i,n) {
        int num;
        cin >> num;
        // cout << mx << endl;
        if (over) {
            cout << "No" << endl;
            continue;
        }
        if (num < mx) {
            cout << "No" << endl;
            continue;
        }
        if (num == mx) {
            if (st.size() != mx) {
                cout << "No" << endl;
                continue;
            }
            over = 1;
            cout << "Yes" << endl;
            continue;
        }
        if (num == mx + 1) {
            mx++;
            st.insert(num);
// cout << "insert " << num << endl;
            cout << "Yes" << endl;
            while (st.count(mx + 1)) {
                mx++;
            }
            continue;
        }
        cout << "Yes" << endl;
        int tmp = num;
        while (st.count(tmp)) {
            tmp--;
        }
        for (int i = tmp + 1; i <= num; i++) {
            st.erase(i);
// cout << "erase " << i << endl;
        }
        st.insert(tmp);
// cout << "insert " << tmp << endl;
        if (tmp == mx + 1) {
            mx++;
            while (st.count(mx+1)) mx++;
        }
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}


Measured memory_bytes: 14812
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    vector<int> isGood(n, 1);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        if (h[a] > h[b]) {
            isGood[b] = false;
        } else if (h[b] > h[a]) {
            isGood[a] = false;
        } else {
            isGood[a] = isGood[b] = 0;
        }
    }

    int count = 0;
    for (auto &&i : isGood) {
        if (i) count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 4784
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
#define PI 3.14
#define Rad2Deg  57.29578
#define INF 1000000000000

using namespace std;

int MD(pair<int,int> a,pair<int,int> b){//ManhattanDisRance
    return abs(a.first-b.first) + abs(a.second-b.second);
}
int MOD(int a,int b){
    return abs(a%b);
}
template <typename T1,typename T2> bool Comp (pair<T1,T2> a,pair<T1,T2> b){
    if(a.first!=b.first){
        return a.first<b.first;//first昇順
    }
    if(a.second!=b.second){
        return a.second > b.second;
    }else{
        return  true;
    }
}
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    incin(n);
    Vector1 l(2*n);
    Rap(2*n,i){
        cin >> l.at(i);
    }
    sort(all(l));
    int sum = 0;
    for(int i=0;i<2*n;i+=2){
        sum+=min(l[i],l[i+1]);
    }
    Pr(sum); 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
最小要素が先頭に来るかどうかで場合分け
*/

struct Factorial{
	long long N,mod;
	vector<long long> fact,inv;
	long long mod_pow(long long x,long long n){
		long long res=1;
		while(n){
			if(n&1) (res*=x)%=mod;
			(x*=x)%=mod;
			n>>=1;
		}
		return res;
	}
	long long Inverse(long long n){
		return mod_pow(n,mod-2);
	}
	Factorial(){}
	Factorial(long long sn,long long smod){
		N=sn; mod=smod;
		fact.reserve(sn+1); inv.reserve(sn+1);
		//初期化
		fact[0]=1;
		for(int i=1;i<=sn;i++){
			fact[i]=(fact[i-1]*i) % mod;
		}
		inv[sn]=Inverse(fact[sn]);
		for(int i=sn;i>0;i--){
			inv[i-1]=(inv[i]*i) % mod;
		}
	}
	long long Fact(long long n){
		if(n<0)return 0;
		return fact[n];
	}
	long long Inv(long long n){
		if(n<0)return 0;
		return inv[n];
	}
	long long Combination(long long n,long long r){
		if(n<r)return 0;
		if(r<0)return 0;
		if(r==0)return 1;
		long long ans=1;
		ans = (ans*Fact(n)) % mod;
		ans = (ans*Inv(r)) % mod;
		ans = (ans*Inv(n-r)) % mod;
		return ans;
	}
};

ll n,x,s[210],dp[210][100010]={},mod=1e9+7;

Factorial ft(210,mod);

ll f(ll i,ll x){
	if(i==n)return x;
	if(dp[i][x]!=-1)return dp[i][x];
	ll ans=0;
	ans+=f(i+1,x%s[i]);
	ans+=f(i+1,x) * (n-1-i); 
	return dp[i][x]=ans%mod;
}

int main(void){
	cin>>n>>x;
	rep(i,n)cin>>s[i];
	sort(s,s+n);
	reverse(s,s+n);
	rep(i,210)rep(j,100010)dp[i][j]=-1;
	cout<<f(0,x)<<endl;
	return 0;
}

Measured memory_bytes: 164352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rep(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
inline double comb(int n, int r) {if (n == 0) { return 0; }if (r == 0) { return 1; }if (r == 1) { return n; }if (n == r) { return 1; }if (r > n / 2) { r = n / 2; }double result = 1;for (double i = 1; i <= r; i++) {result *= (n - i + 1) / i;}return(result);}
vector<pair<long long, long long> > prime_factorize(long long n) {vector<pair<long long, long long> > res;for (long long p = 2; p * p <= n; ++p) {if (n % p != 0) continue;int num = 0;while (n % p == 0) { ++num; n /= p; }res.push_back(make_pair(p, num));}if (n != 1) res.push_back(make_pair(n, 1));return res;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(15);


    int a,b;
    cin >> a>> b;
    int ans = 0;
    ans = a -(2*b);
    if(ans >= 0){
        cout << ans << endl;
    }
    else {
        cout << 0 << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int r[10];
int main(){
 map<PII,int>gg;
 DRIII(H,W,n);
 REP(i,n){
  DRII(x,y);x--;y--;
  REP(j,3)REP(k,3){
   int nx=x+j,ny=y+k;
   if(nx<2||ny<2||nx>=H||ny>=W)continue;
   gg[MP(nx,ny)]++;
  }
 }
 printf("%lld\n",(H-2LL)*(W-2)-SZ(gg));
 for(map<PII,int>::iterator it=gg.begin();it!=gg.end();it++)r[it->S]++;
 REPP(i,1,10)cout<<r[i]<<endl;
 return 0;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n, d;
  cin >> n >> d;
  ll count = 0;
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    ld dist = sqrt(x * x + y * y);
    if (dist <= d) {
      count++;
    }
  }
  COUT(count);
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
4 5
0 5
-2 4
3 4
4 -4
*/


Measured memory_bytes: 3608
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

/*考えを書くスペース

*/
//main.cpp----------------------------
#define max_n 100000

void solve();

ll n;
ll a[max_n+1];

int main() {
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }

  solve();

  return 0;
}

void solve() {
  sort(a, a+n);
  bool flag = true;
  ll now = a[0];
  while(flag) {
    flag = false;
    for(int i=0; i<n; ++i) {
      if(a[i]%now!=0) {
        now = a[i]%now;
        flag = true;
        break;
      }
    }
  }

  cout << now << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int k,s,x,y,z,c=0;
	scanf("%d%d",&k,&s);
	for(x=0; x<=k; x++){
		for(y=x; y<=k; y++){
			for(z=y; z<=k; z++){
				if(x+y+z==s){
					if(x==y && y==z){
						c=c+1;
					}else if(x!=y && x!=z && y!=z){
						c=c+6;
					}else{
						c=c+3;
					}
				}
			}
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>

int main(int argc, char const *argv[]) {
  int n,m,c;
  scanf("%d %d %d",&n,&m,&c);
  int a[n][m];
  int b[m];
  for(int i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  int ans=0;
  int check=0;
  for(int i=0;i<n;i++){
    check=0;
    for(int j=0;j<m;j++){
      check+=a[i][j]*b[j];
    }
    if(check+c>0)ans++;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main () {
  long long  a, b, k;
  cin >> a >> b >> k;
  if (k <= a) {
    cout << a-k << " "<< b; } 
  else if (k <= a + b ){
    cout << 0 << " " << a + b - k ;}
  else {
    cout << 0 << " " << 0 ; } }

    
  

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

int x[10], y[10];
double dist(int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

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

    vector<int> order(N);
    for (int i = 0; i < N; i++)
    {
        order[i] = i;
    }
    
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }
    
    double temp_dist = 0.0;
    do
    {
        for (int i = 1; i < N; i++)
        {
            temp_dist += dist(order[i], order[i-1]);
        }
    } while (next_permutation(order.begin(), order.end()));

    int a = 1;
    for (int i = 2; i <= N; i++)
    {
        a *= i;
    }
    
    double ans = temp_dist/a;
    
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

#define FOR(i,n) for(i=0;i<n;++i)

int i,j;

int main(void){
    int n,m;
    cin>>n>>m;
    string a[50],b[50];
    FOR(i,n)cin>>a[i];
    FOR(i,m)cin>>b[i];
    bool ans=false;
    int x,y;
    FOR(i,n-m+1){
        FOR(j,n-m+1){
            bool exit=true;
            
            FOR(y,m){
                FOR(x,m){
                    
                    if(a[y+i][x+j]!=b[y][x])exit=false;
                    
                }
            }
            if(exit)ans=true;
            
        }
    }
    
    if(ans)cout<<"Yes";
    else cout<<"No";
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[][] map = new long[N][3];
        for(int i = 0 ; i < N ; i++)
        {
            for(int j = 0 ; j < 3; j++)
                map[i][j] = sc.nextInt();
            if(i>0)
            {
                for(int j = 0 ; j < 3 ; j++)
                {
                    map[i][j] = Math.max(map[i-1][(j+1) % 3] + map[i][j], map[i-1][(j+2 )% 3]+map[i][j]);
                }
            }
        }
        System.out.println(Math.max(Math.max(map[N-1][0],map[N-1][1]),map[N-1][2]));

    }
}


Measured memory_bytes: 99760