akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
ll a;
double b;
#define eps 1e-6
int main()
{
	while(cin>>a>>b)
	{
		b+=eps;
		ll c=b*100;
		c=a*c/100;
		cout<<c<<endl;
	}
	
} 

Measured memory_bytes: 3724
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t)(N));
    foreach (i; 0 .. cast(size_t)(N))
    {
        A[i] = input.front.to!long;
        input.popFront;
    }

    solve(N, A);
}

void solve(long N, long[] A)
{
    long[long] d;
    foreach (a; A)
    {
        auto f = factorize(a);
        foreach (key, value; f)
        {
            d[key] = d.get(key, 0) + 1;
        }
    }
    if (d.values.all!"a==1")
    {
        writeln("pairwise coprime");
        return;
    }
    if (A.reduce!gcd == 1)
    {
        writeln("setwise coprime");
        return;
    }
    writeln("not coprime");
}

T[U] factorize(T = long, U = long)(T x)
{
    assert(0 < x, "x is negative");
    long[long] ps;
    while ((x & 1) == 0)
        x /= 2, ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
            x /= i, ps[i] = (i in ps) ? ps[i] + 1 : 1;
    if (x != 1)
        ps[x] = (x in ps) ? ps[x] + 1 : 1;
    return ps;
}


Measured memory_bytes: 57832
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
vector<pii> vx, vy;

struct Elem {
    int u, v, cost;
};

bool operator<(const Elem &a, const Elem &b) {
    return a.cost > b.cost;
}

// Union-Find 木 (Verified: AtCoder Typical Contest 001 B)
struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
    }
};

signed main() {
    cin >> N;
    rep(i,0,N) {
        int x, y; cin >> x >> y;
        vx.push_back(pii(x, i));
        vy.push_back(pii(y, i));
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());

    priority_queue<Elem> q;
    UnionFind uf(N);
    rep(i,0,N-1) {
        int u = vx[i].second, v = vx[i+1].second, c1 = abs(vx[i].first - vx[i+1].first);
        int z = vy[i].second, w = vy[i+1].second, c2 = abs(vy[i].first - vy[i+1].first);

        q.push(Elem{u, v, c1});
        q.push(Elem{z, w, c2});
    }

    int ans = 0;
    while(!q.empty()) {
        Elem t = q.top(); q.pop();
        if(uf.same(t.u, t.v)) continue;
        ans += t.cost;
        uf.unite(t.u, t.v);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13792
s = gets.chomp
v1 = s[0..1].to_i
v2 = s[2..3].to_i

result = 'NA'
if (1 <= v1 && v1 <= 12) && (0 <= v2 && v2 <= 99)
  result = 'MMYY'
end

if (1 <= v2 && v2 <= 12) && (0 <= v1 && v1 <= 99)
  if result == 'MMYY'
    result = 'AMBIGUOUS'
  else
    result = 'YYMM'
  end
end

puts(result)


Measured memory_bytes: 1788
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
H = inpl()

cnt = 0
for i in range(N):
    for j in range(i):
        if H[i] < H[j]:
            break
    else:
        cnt += 1
print(cnt)


Measured memory_bytes: 6752
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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




int main() {

	ll H, W;
	cin >> H >> W;

	char a[200][200];

	repn(i, H) repn(j, W) cin >> a[i][j];

	ll c[200] = {};

	repn(i, H) {


		repn(j, W) {
			if (a[i][j] == '.') { c[i]++; }
		}

		if(c[i]==W){
			repn(j, W) a[i][j] = 'x';
		}
	}

	repn(j, W) {

		ll ch = 0;

		repn(i, H) {
			if (a[i][j] == '.' || a[i][j] == 'x') { ch++; }
		}

		if (ch == H) {
			repn(i, H) a[i][j] = 'x';
		}
	}

	repn(i, H) {

		if (c[i] != W) {
			repn(j, W) {
				if (a[i][j] != 'x') { cout << a[i][j]; }
			}

			cout << endl;
		}
	}

	system("PAUSE");
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a;
  in(n);
  a = 0;
  rep2(i, 1, n + 1){
    if(i % 3 != 0 && i % 5 != 0)
      a += i;
  }
  out(a);
  memi;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  int N; cin >> N;
  cout << N * (N+1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;

struct target {
	int index;
	int p;
	int y;
};

bool ycmp(const struct target &first, const struct target &second) {
	return first.y < second.y;
}
bool icmp(const struct target &first, const struct target &second) {
	return first.index < second.index;
}

int main(int argc, char *argv[])
{
	int i, j;
	int tmp;
	int n, m;
	cin >> n >> m;
	vector<target> inp(m);
	int ind[n];

	for (i = 0; i < n; i++)
		ind[i] = 1;

	for (i = 0; i < m; i++) {
		inp[i].index = i;
		cin >> inp[i].p >> inp[i].y;
	}
	
    sort(inp.begin(), inp.end(), ycmp);

	for (i = 0; i < m; i++) {
		inp[i].y = ind[inp[i].p - 1];
		ind[inp[i].p - 1]++;
	}
	sort(inp.begin(), inp.end(), icmp);

	for (i = 0; i < m; i++) {
		printf("%06d", inp[i].p);
		printf("%06d", inp[i].y);

		cout << endl;
	}
	
		
	return 0;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (auto &x : a)
    cin >> x;
  sort(a.begin(), a.end(), ::greater<int>());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0)
      ans += a[i];
    else
      ans -= a[i];
  }
  cout << ans << endl;
}

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

const int INF = 1e9;
struct P {
  int x, y;
};

int H, W;
vector<vector<char>> s;
vector<vector<int>> d;
vector<P> dir = {P{1,0}, P{-1,0}, P{0,1}, P{0,-1}};

int main () {
  cin >> H >> W;
  s.resize(H, vector<char>(W));
  d.resize(H, vector<int>(W, INF));

  int nb = 0;
  rep(i,H)rep(j,W) {
    cin >> s[i][j];
    if(s[i][j] == '#') nb++;
  }

  d[0][0] = 0;
  queue<P> q;
  q.push(P{0,0});
  while(!q.empty()) {
    P p = q.front();
    q.pop();
    for(auto dr: dir) {
      int nx = p.x + dr.x;
      int ny = p.y + dr.y;
      if(0 <= nx && nx < W && 0 <= ny && ny < H && s[ny][nx] != '#' && d[ny][nx] == INF) {
        d[ny][nx] = d[p.y][p.x] + 1;
        q.push(P{nx,ny});
      }
    }
  }

  if(d[H-1][W-1] == INF) {
    cout << -1 << endl;
  } else {
    cout << W*H - 2 - nb - (d[H-1][W-1] - 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
    int n;cin>>n;
    int sum=0,a=0;
    vector<pair<string,int>> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first;
        cin>>v[i].second;
        sum+=v[i].second;
    }
    string s;cin>>s;
    for(int i=0;i<n;i++){
        a+=v[i].second;
        if(s==v[i].first)break;
    }
    cout<<sum-a;
    
}

Measured memory_bytes: 888
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const ll MOD = 1000000007;

ll dp[310][310][310];
ll N, M;

int main () {
  cin >> N >> M;
  for (auto d = 0; d <= M; ++d) {
    for (auto i = 1; i <= d+1; ++i) {
      for (auto j = 0; i+j <= d+1; ++j) {
        dp[d][i][j] = 0;
      }
    }
  }
  dp[0][1][0] = 1;
  for (auto d = 0; d <= M; ++d) {
    for (auto i = 1; i <= d+1; ++i) {
      for (auto j = 0; i+j <= d+1; ++j) {
        dp[d+1][i][j+1] += (dp[d][i][j] * (N-i-j))%MOD;
        dp[d+1][i][j+1] %= MOD;
        dp[d+1][i][j] += (dp[d][i][j] * j)%MOD;
        dp[d+1][i][j] %= MOD;
        dp[d+1][i+j][0] += (dp[d][i][j] * i) %MOD;
        dp[d+1][i+j][0] %= MOD;
      }
    }
  }
  cout << dp[M][N][0] << endl;
}


Measured memory_bytes: 225536
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,s,ss;
  while(1){
    cin >> a >> b >> c;
    if(a<0 or b<0 or c<0){
      return 0;
    }
    s=7200-a*3600-b*60-c;
    ss=(7200-a*3600-b*60-c)*3;
    cout << 0 << s/3600 << ":";
    s%=3600;
    cout << ((s<600)?"0":"") << s/60 << ":";
    s%=60;
    cout << ((s<10)?"0":"") << s << endl;
    cout << 0 << ss/3600 << ":";
    ss%=3600;
    cout << ((ss<600)?"0":"") << ss/60 << ":";
    ss%=60;
    cout << ((ss<10)?"0":"") << ss << endl;
  }
}



Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (H, W) = Slice2<long>();
            var Si = new string[H + 2];
            Si[0] = new string('.', (int)W + 2);
            for (var i = 0; i < H; ++i)
                Si[i + 1] = "." + ReadLine() + ".";
            Si[H + 1] = new string('.', (int)W + 2);
            var nums = Enumerable.Repeat(0, (int)H + 2).Select(_ => new char[W + 2]).ToArray();
            var dx = new int[] { -1, -1, -1, 0, 0, 0, 1, 1, 1 };
            var dy = new int[] { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
            for (var i = 1; i <= H; ++i)
                for (var j = 1; j <= W; ++j)
                {
                    if ('.' == Si[i][j])
                    {
                        var cnt = 0;
                        for (var k = 0; k < 9; ++k)
                            if ('#' == Si[i + dy[k]][j + dx[k]])
                                ++cnt;
                        nums[i][j] = cnt.ToString()[0];
                    }
                    else
                        nums[i][j] = '#';
                }
            for (var i = 1; i <= H; ++i)
                WriteLine(string.Join("", nums[i]).Substring(1, (int)W));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28588
#include <stdio.h>

#define N 100000
#define NIL -1

int BinarySearch(int *, int, int);

int main() {

  int s[N];
  int t[N];
  int n, q;
  int cnt = 0;
  int i;

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

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

  for (i = 0; i < q; i++) {
    if(BinarySearch(s, n, t[i]) != NIL) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  
  return 0;
}


int BinarySearch(int s[], int n, int k) {
  int i;
  int left, right, mid;

  left = 0;
  right = n;
  
  while(left < right) {
    mid = (left + right)/2;

    if (s[mid] == k) {
      return mid;
    }
    else if (s[mid] < k) {
      left = mid + 1;
    }
    else {
      right = mid;
    }
  }
  return NIL;
}



Measured memory_bytes: 2292
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) (v).erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vl prime = { 2 };
	FOR(i, 3,114514) {
		int flag = 1;
		REP(j, prime.size()) {
			if (prime[j] * prime[j] > i)break;
			if (i%prime[j] == 0)flag = 0;
		}
		if (flag)prime.push_back(i);
	}
	int n, p;
	while (1) {
		cin >> n >> p;
		if (n == -1)break;
		int c = upper_bound(ALL(prime), n) - prime.begin();
		vl v(p*(p+1)/2);
		REP(i, p) {
			FOR(j,i, p) {
				v[p*(p-1)/2-(p-i)*(p-i-1)/2 + j] = prime[i+c] + prime[j+c];
			}
		}
		sort(ALL(v));
		cout << v[p - 1] << endl;
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	ll adj[N][N];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> adj[i][j];
		}
	}
	vector<tuple<ll, int, int>> edges;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			edges.push_back(make_tuple(adj[i][j], i, j));
		}
	}
	sort(edges.begin(), edges.end());
	ll dist[N][N];
	ll bil = 3000000000;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dist[i][j] = bil;
		}
		dist[i][i] = 0;
	}
	bool poss = true;
	ll ans = 0LL;
	for (int i = 0; i < edges.size(); i++) {
		ll len = get<0>(edges[i]);
		int a = get<1>(edges[i]);
		int b = get<2>(edges[i]);
		ll curd = bil;
		for (int j = 0; j < N; j++) {
			if (j == a || j == b) continue;
			if (adj[a][j] + adj[j][b] < curd) {
				curd = adj[a][j] + adj[j][b];
			}
		}
		if (curd == len) continue;
		if (curd < len) {
			// cout << a << " " << b <<  " " << len << endl;
			poss = false;
		}
		ans += len;
		// dist[a][b] = len;
		// dist[b][a] = len;
		// for (int j = 0; j < N; j++) {
		// 	dist[a][j] = min(dist[a][j], dist[b][j] + len);
		// 	dist[j][a] = dist[a][j];
		// 	dist[b][j] = min(dist[b][j], dist[a][j] + len);
		// 	dist[j][b] = dist[b][j];
		// }
	}
	if (!poss) cout << -1 << endl;
	else cout << ans << endl;
	// cin >> ans;

}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;

int main() {
  ll n, cnt = 0, X, l;
  cin >> n;
  vector<pair<ll, ll>> x(n);
  rep(i, n) {
    cin >> X >> l;
    x[i].first = X - l;
    x[i].second = X + l;
  }
  sort(x.begin(), x.end());

  ll mx = x[0].second;

  for (int i = 1; i < n; ++i) {
    if (x[i].first < mx) {
      cnt++;
      mx = min(mx, x[i].second);
    } else {
      mx = x[i].second;
    }
  }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,a,b;
  
  cin >> x >> a >> b;
  if(b <= a) cout << "delicious" << endl;
  else if(b <= a+x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
  }

Measured memory_bytes: 256
n,m=list(map(int,input().split(" ")))
ka=[]
for i in range(n):
    ka.append(list(map(int,input().split(" "))))
for i in range(n):
    ka[i].pop(0)
counter=0
i=1
while i<=m:
    j=0
    while j<=n-1:
        if i in ka[j]:
            j+=1
        else:
            break

        if j==n:
            counter+=1
    i+=1
print(counter)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define debug(n) cout<<"# "<<#n<<": "<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	for(int n;cin>>n;){
		deque<bool> is_prime(n+1,true);
		is_prime[0]=is_prime[1]=false;
		repi(i,2,is_prime.size()){
			if(is_prime[i])
				for(int j=i+i;j<is_prime.size();j+=i)
					is_prime[j]=false;
		}
		cout<<count(allof(is_prime),true)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1900
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  double L;
  cin>>L;
  cout<<fixed<<setprecision(9);
  cout<<L*L*L/27.0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s; cin>>s;
  deque<char> s1,s2;
  for(auto& i:s){ s1.push_front(i); s2.push_back(i);}
  int cnt=0,q; cin>>q;
  for(int i=0; i<q; ++i){
    int Q; cin>>Q;
    if(Q==1) cnt^=1;
    else{
      int f; char c;
      cin>>f>>c;
      if(f-1==cnt){ s1.push_back(c); s2.push_front(c);}
      else{ s1.push_front(c); s2.push_back(c);}
    }
  }
  if(cnt) for(auto i:s1){ cout<<s2.back(); s2.pop_back();}
  else for(auto i:s2){ cout<<s1.back(); s1.pop_back();}
  return 0;
}

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

int main(void){
	int n, x, cnt=0;
	while(1){
		cin >>n >>x;
		if(n==0 && x==0){
			break;
		}
		for(int i=1; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				for(int k=j+1; k<n+1; k++){
					if(i+j+k==x){
						cnt++;
					}
				}
			}
		}
		cout <<cnt <<endl;
		cnt=0;
	}
    return 0;
}

Measured memory_bytes: 1160
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
e=0
for i in range(1,n+1):
  t=min(a[-i],b[-i])
  u=min(a[--~i],b[-i]-t)
  e+=t+u
  a[--~i]-=u
print(e)

Measured memory_bytes: 19116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String n = scanner.next();
		int n4 = n.charAt(0)-'0';
		int n3 = n.charAt(1)-'0';
		int n2 = n.charAt(2)-'0';
		int n1 = n.charAt(3)-'0';
		if((n4==n3 && n3==n2 )||(n3==n2 && n2==n1) ){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 21844
s = input()
k = int(input())

sl = [s]
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if j - i > k:
            break
        ss = s[i:j]
        sl.append(ss)
sl = sorted(list(set(sl)))
print(sl[k-1])

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

int main(){
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    H -= A.at(i);
  }
  if(H > 0) cout << "No";
  else cout << "Yes";
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  string str;
  cin >> n >> str;
  int num = 'z' - 'a' + 1;
  vector<ll> cnt(num,0);
  rep(i,n) {
    cnt[str[i] - 'a']++;
  }
  mint ans(1);
  rep(i,num) {
    if (cnt[i] > 0) ans *= cnt[i]+1;
  }
  ans -= 1;
  cout << ans << endl;
  return 0;
}

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

int main(){
  int64_t N; string bufM;
  cin >> N >> bufM;
  int64_t M100= stol(bufM.at(0)+ bufM.substr(2));

  int64_t ans= (N*M100)/100;
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    string s;
    cin>>s;
    int l=s.length();
    int sc=0;
    int tc=0;
    int mat=0;
    rep(i,l)
    {
        if(s[i]=='S')
        {
            sc++;
        }
        else
        {
            if(sc>0)
            {
                sc--;
                mat++;
            }
            
        }
        
    }
    cout<<l-2*mat;
}


Measured memory_bytes: 640
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, dp[N], used[N];
vector <int> g[N], order;

void dfs (int v) {
   used[v] = 1;
   for (auto to : g[v])
      if (!used[to])
         dfs (to);
   order.pb (v);
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> m;
   for (int i = 1; i <= m; i ++) {
      int x, y;
      cin >> x >> y;
      g[x].pb (y);
   }
   for (int i = 1; i <= n; i ++)
      if (!used[i])
         dfs (i);
   reverse (all (order));
   for (auto v : order) {
      for (auto to : g[v])
         dp[to] = max (dp[to], dp[v] + 1);
   }
   cout << *max_element (dp + 1, dp + n + 1);
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 13432
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){

	while(1){
		int n,r;
		cin>> n>> r;
		if(n==0 && r==0) break;
		vector<vector<int> > a(2, vector<int> (n));
		for(int i=0;i<n;i++){
			a[0][i] = n-i;
			a[1][i] = n-i;
		}
		
		for(int i=0;i<r;i++){
			int p, c;
			cin>> p>> c;
			for(int j=0;j<c+p-1;j++){
				if(j<c){
					a[1][j] = a[0][j+p-1];
				}else{
					a[1][j] = a[0][j-c];
				}
			}
			for(int j=0;j<n;j++){
				a[0][j] = a[1][j];
			}
		}
		
		cout<< a[0][0]<< endl;
	}
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1220
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


ll table[33][MAX]={};

int main(void) {
    ll N, C;
    cin >> N >> C;
    ll i, j;
    
    for(i=0; i<N; i++) {
        ll s, t, c;
        cin >> s >> t >> c;
        s--; c--;
        table[c][s]++;
        table[c][t]--;
    }
    
    for(i=0; i<C; i++)
        for(j=0; j<MAX; j++)
            table[i][j+1]+=table[i][j];
    
    for(i=0; i<C; i++)
        for(j=0; j<MAX; j++)
            if(table[i][j]>1) table[i][j]=1;
    
    ll ans=0;
    for(j=0; j<MAX; j++) {
        ll cnt=0;
        for(i=0; i<C; i++) cnt+=table[i][j];
        chmax(ans, cnt);
    }
    
    pt(ans);
    
}



Measured memory_bytes: 24832
import math


def main():
    n, k = [int(x) for x in input().split()]
    r, s, p = [int(x) for x in input().split()]
    t = input()
    win = {"r": "p", "s": "r", "p": "s"}
    lose = {"r": "s", "s": "p", "p": "r"}
    score = {"r": r, "s": s, "p": p}
    machine = list(t)
    man = [win[x] for x in machine]

    changed = set()
    for i in range(n - k):
        ki = i + k
        if man[i] == man[ki]:
            if i in changed:
                man[i] = lose[machine[i]]
            elif score[man[i]] < score[man[ki]]:
                man[i] = machine[i]
            else:
                man[ki] = machine[ki]
                changed.add(ki)

    total = 0
    for i in range(n):
        if man[i] == win[machine[i]]:
            total += score[man[i]]

    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8560
N, K = map(int, input().split())
A = list(map(int, input().split()))

blist = [0] * 50
for i in range(N):
  bn = bin(A[i])
  for j in range(len(bn)):
    if bn[len(bn) - 1 - j] == '1':
      blist[j] += 1
      
K = bin(K)[2::]
digit = len(K)
dp = [[0, 0] for i in range(digit)]
t = 0
for i in range(digit, 45):
  t += blist[i] * (2 ** i)
if K != '0':
  dp[digit - 1][0] = t + blist[digit - 1] * 2 ** (digit - 1)
  dp[digit - 1][1] = t + (N - blist[digit - 1]) * 2 ** (digit - 1)
else:
  dp[digit - 1] = [t, t]
for i in reversed(range(0, digit - 1)):
  if K[len(K) - i - 1] == '1':
    dp[i][1] = dp[i + 1][1] + (N - blist[i]) * (2 ** i)
    dp[i][0] = max([dp[i + 1][1] + blist[i] * (2 ** i),
                    dp[i + 1][0] + max([blist[i], N - blist[i]]) * (2 ** i)])
  else:
    dp[i][1] = dp[i + 1][1] + blist[i] * (2 ** i)
    dp[i][0] = dp[i + 1][0] + max([blist[i], N - blist[i]]) * (2 ** i)
    
print(max(dp[0]))

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

#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>

using namespace std;
typedef long long ll;

int N, M, a, b, c[100000],g[100000];
pair<int, int>d[100000];
vector<pair<int,int>>v[100000];
bool B[100000],vis[100000];

void f(int x);

bool func(int x) {
	for (auto i : v[x]) {
		if (!B[i.second])return true;
	}
	return false;
}

void dfs1(int x,int y) {
	vis[x] = true;
	g[x] = y;
	for (auto i : v[x]) {
		if (!B[i.second] && i.first != y) {
			d[x] = i;
			if (vis[i.first]) {
				B[i.second] = true;
				f(i.first);
				vis[x] = false;
				return;
			}
			dfs1(i.first, x);
			vis[x] = false;
			return;
		}
	}
}

void f(int x) {
	int t = x;
	while (d[t].first != x) {
		B[d[t].second] = true;
		t = d[t].first;
	}
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> a >> b;
		--a;
		--b;
		++c[a];
		++c[b];
		v[a].push_back(mkp(b,i));
		v[b].push_back(mkp(a,i));
	}
	int k = 0;
	for (int i = 0; i < N; ++i) {
		if (c[i] & 1) {
			cout << "No" << endl;
			return 0;
		}
		if (c[i] == 4)++k;
		if (c[i] >= 6)k = 3;
	}
	if (k >= 3) {
		cout << "Yes" << endl;
		return 0;
	}
	int t = 0;
	for (int i = 0; i < N; ++i) {
		if (func(i)) {
			++t;
			if (t >= 3) {
				cout << "Yes" << endl;
				return 0;
			}
			dfs1(i, i);
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 8576
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

using edge = PII;
using node = vector<edge>;
using graph = vector<node>;

int main() {
	int n;
	cin >> n;
	vector<PII> xi(n), yi(n);
	REP(i, n) {
		int x, y;
		scanf("%d%d", &x, &y);
		xi[i] = MP(x, i);
		yi[i] = MP(y, i);
	}
	SORT(xi);
	SORT(yi);
	graph g(n);
	REP(i, n-1) {
		g[xi[i].second].PB(edge(xi[i + 1].first - xi[i].first, xi[i + 1].second));
		g[xi[i + 1].second].PB(edge(xi[i + 1].first - xi[i].first, xi[i].second));
		g[yi[i].second].PB(edge(yi[i + 1].first - yi[i].first, yi[i + 1].second));
		g[yi[i + 1].second].PB(edge(yi[i + 1].first - yi[i].first, yi[i].second));
	}
	vector<bool> visit(n, false);
	priority_queue<edge, vector<edge>, greater<edge> > q;
	REP(i, g[0].size())q.push(g[0][i]);
	visit[0] = true;
	LL ret = 0;
	while (!q.empty()) {
		auto e = q.top();
		q.pop();
		if (visit[e.second])continue;
		visit[e.second] = true;
		REP(i, g[e.second].size())if(!visit[g[e.second][i].second])q.push(g[e.second][i]);
		ret += e.first;
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;

int n, arr[100001][3], memo[100001][3] = {};

long long dp(int day, int a);

int main(void)
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i][0]);
        scanf("%d", &arr[i][1]);
        scanf("%d", &arr[i][2]);
    }
    long long res = -1;
    for (int i = 0; i < 3; i++)
    {
        res = max(res, dp(0, i));
    }
    printf("%d\n", res);
}

long long dp(int day, int a)
{
    if (day == n - 1)
        return arr[n - 1][a];
    if (memo[day][a] > 0)
        return memo[day][a];
    long long best = -1;
    for (int i = 0; i < 3; i++)
    {
        if (i == a)
            continue;
        best = max(best, arr[day][a] + dp(day + 1, i));
    }
    memo[day][a] = best;
    return best;
}

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

int main() {
  int n;
  cin>>n;
  bool ada = 1;
  for(int i = 0;i < n;i++) {
    int x;
    cin>>x;
    if(x % 2 == 0) {
      if(x % 3 && x % 5) ada = 0;
    }
  }
  cout<<((ada == 0)?"DENIED":"APPROVED")<<endl;
}

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

int n;
vector<double> p;
vector<vector<double>> DP;

int main()
{
	cin >> n;
	p.resize(n+1);
	for (int i = 1; i < n+1; i++)
		cin >> p[i];

	// DP[i][j] means getting no less than i heads on first j tosses.
	int mid = (n) / 2 + 1; //mid is not ceiling for this case, more heads than tails
	DP.resize(mid+1);

	for (int i = 1; i < mid + 1; i++)
	{
		DP[i].resize(n + 1);
	}
	DP[0].resize(n + 1, (double)1.0);
	for (int i = 1; i < mid + 1; i++)
		DP[i][0] = 0;
	for (int i = 1; i < mid + 1; i++)
	{
		for (int j = 1; j < n + 1; j++)
		{
			// head on jth or tails on jth
			DP[i][j] = DP[i][j - 1] * ((double)1.0 - p[j]) + DP[i - 1][j - 1] * p[j];
		}
	}
	cout << setprecision(10) << DP[mid][n] << endl;
}

Measured memory_bytes: 39040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {

	s := nextText()

	if s[2] == s[3] && s[4] == s[5] {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}

}

func nextInt() int {
	i, _ := strconv.Atoi(nextText())
	return i
}

func nextText() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
#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 <cctype>

using namespace std;

#define Int int64_t

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;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

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

int main() {
	int n; cin >> n;
	vector<int> d(n);

	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

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

	int to, from;

	from = d.size() / 2;
	to = d.size() / 2 - 1;

	cout << d[from] - d[to] ;

	cout << endl;
	return 0;
}

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

int main(){
  string n;
  cin >> n;
  for(int i = 0; i < 3; i++){
    if( n.at(i) == '1') cout << 9;
    else if(n.at(i) == '9') cout << 1;
  }  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N ; i++){
			A[i] = scan.nextInt();
		}
		for(int i = 2 ; i <= M ; i++){
			for(int j = 0 ; j < N-1 ; j++){
				if(A[j] % i > A[j+1] % i){
					int koukann = A[j];
					A[j] = A[j+1];
					A[j+1] = koukann;
				}
			}
		}
		for(int i = 0; i < N ; i++){
			System.out.println(A[i]);
		}
	}
}

Measured memory_bytes: 26292
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int n;
    cin >> n;
    vector<int> V(n);
    vector<Pint> Odd(100000), Even(100000);
    for (int i = 0; i < 100000; i++) {
        Even.at(i).first = 0;
        Odd.at(i).first = 0;
        Even.at(i).second = i;
        Odd.at(i).second = i;
    }
    for (int i = 0; i < n; i++) {
        cin >> V.at(i);
        if (i % 2 == 0) {
            Even.at(V.at(i) - 1).first++;
        }
        else {
            Odd.at(V.at(i) - 1).first++;
        }
    }
    sort(rALL(Even));
    sort(rALL(Odd));
    if (Even.at(0).second != Odd.at(0).second) {
        cout << n - Even.at(0).first - Odd.at(0).first << endl;
    }
    else {
        cout << min(n - Even.at(0).first - Odd.at(1).first, n - Even.at(1).first - Odd.at(0).first) << endl;
    }

}


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

typedef struct Cell Cell;
struct Cell
{
  Cell *car;
  Cell *cdr;
} heap[ 256 ];
size_t heap_n;
const char *e;

Cell*
buildTree (
  void
  )
{
  Cell *res = NULL;

  switch ( *e )
  {
    case '(':
      ++e;
      res = &heap[ heap_n++ ];
      res->car = buildTree ( );
      ++e;
      res->cdr = buildTree ( );
      ++e;
      break ;
  }

  return ( res );
}

void
writeTree (
  Cell *s
  )
{
  if ( s == NULL )
    return ;

  putchar ( '(' );
  writeTree ( s->car );
  putchar ( ',' );
  writeTree ( s->cdr );
  putchar ( ')' );

  return ;
}

Cell*
intersectTree (
  Cell *a,
  Cell *b
  )
{
  if ( a == NULL || b == NULL )
    return ( NULL );

  a->car = intersectTree ( a->car, b->car );
  a->cdr = intersectTree ( a->cdr, b->cdr );
  return ( a );
}

Cell*
unionTree (
  Cell *a,
  Cell *b
  )
{
  if ( a == NULL )
    return ( b );
  if ( b == NULL )
    return ( a );

  a->car = unionTree ( a->car, b->car );
  a->cdr = unionTree ( a->cdr, b->cdr );
  return ( a );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  for ( ; ; )
  {
    char s[ BUFSIZ ];
    char mode;
    Cell *a, *b;

    if ( scanf ( " %c", &mode ) == EOF )
      break ;

    heap_n = 0;
    scanf ( " %s", s ); e = s;
    a = buildTree ( );
    scanf ( " %s", s ); e = s;
    b = buildTree ( );

    switch ( mode )
    {
      case 'i':
        writeTree ( intersectTree ( a, b ) );
        break ;
      case 'u':
        writeTree ( unionTree ( a, b ) );
        break ;
    }
    puts ( "" );
  }

  return ( EXIT_SUCCESS );
}

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

#define pb push_back
#define ff first
#define ss second

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

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    ll ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			ans += (a[i] * a[j]);
		}
	}
	cout << ans;
}

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

public class Main {
    public static void main(String[] args) {
    	
    	final int INF = 10000;
    	
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int min = INF;
        int sum = 0;
        boolean canGetPoint = false;
        
        for(int n=0;n<N;n++){
        	int point = sc.nextInt();
        	sum += point;
        	if(point%10 !=0){
        		canGetPoint = true;
        		if(min>point) min = point;
        	}
        }
        
        if(!canGetPoint)System.out.println(0);
        else if(sum%10 ==0) System.out.println(sum-min);
        else System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;


int count(long n){
	int c=0;
	while(n!=0){
		if(n%10==4 || n%10==7){
			c++;
			n=n/10;
		}else{
			n=n/10;
		}
	}
	return c;
}

int main(){
	int a;
	int b;
	cin >> a;
	cin >> b;
	if(b%a==0){
		cout << a+b << endl;
	}else{
		cout << b-a << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    int i,len,count=0,j;

    char st[105],str[105];

    char temp,temp1,temp2;

    scanf("%s",st);
    scanf("%s",str);

    len=strlen(st);

    for(i=0;i<len;i++){
        if (strcmp(st,str)==0){
             printf("Yes\n");
             count=1;
             return 0;
        }

        else{
            temp=st[0];
            st[0]=st[len-1];
            for(j=1;j<len;j++){
                temp1=st[j];
                st[j]=temp;
                temp=temp1;
            }

        }

    }
    if(count==0){
        printf("No\n");
    }
    return 0;



}


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

int main(void){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int diffX = x2 - x1;
    int diffY = y2 - y1;
    cout << x2 - diffY << " " << y2 + diffX << " " << x1 - diffY << " " << y1 + diffX;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e18;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
const double pi=acos(-1);

string s;
int main(){
	TB
	ll n;
	cin>>n;
	ll ans=n/500;
	ans*=1000;
	ll k=n%500;
	k/=5;
	ans+=k*5;
	cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256