akhauriyash/Code-Regression huggingface dataset:
// 中国人郵便配達問題
// 参照: https://gist.github.com/tjkendev/898454acfc4961b5bdd09b4088b75de3
//      https://ja.wikipedia.org/wiki/%E4%B8%AD%E5%9B%BD%E4%BA%BA%E9%83%B5%E4%BE%BF%E9%85%8D%E9%81%94%E5%95%8F%E9%A1%8C
// 方針:
//   すべての頂点の次数が偶数のとき、すべての辺を一度だけ通って一周できる（オイラー閉路）。
//   奇数次数の頂点はかならず偶数個ある。この頂点を適当に二つずつ組み合わせる。
//   このペアとなった頂点組について、最短経路を見つけて、最短経路上にある辺をそれぞれ1本増やすことで、
//   奇数次数の頂点が2個減らせる。
//   頂点の組み合わせの取り方のうち、もっともよいペアリングをbitDPで見つける。

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

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

#define pb push_back
#define mp make_pair

ll INF = 1e18;

const int MAX_V = 15;
ll memo[(1 << MAX_V)]; // memo

// まだペアリングされていない奇数次数の頂点について、最適なペアリングを行ったときに
// 増加する辺コストの和を返す。
// state: 各ビットが、奇数次数の頂点がすでにペアリングされたか否かを表す
ll dfs(int state, vector<int>& odd, vector<vector<ll>>& e) {
    if (memo[state] >= 0) return memo[state];
    ll res = INF;
    // 頂点uと頂点vがまだペアリングされていなければペアリングする
    REP(i, SIZE(odd)) {
        auto u = odd[i];
        if (state & (1 << i)) {
            continue;
        }
        REP(j, SIZE(odd)) {
            auto v = odd[j];
            if (u == v || state & (1 << j) || e[u][v] == INF) {
                continue;
            }
            res = min(res, dfs(state | (1 << i) | (1 << j), odd, e) + e[u][v]);
        }
    }
    memo[state] = res;
    return res;
}

int main(void) {
    int V, E;
    cin >> V >> E;

    ll INF = 1e9;
    vector<vector<ll>> e(V, vector<ll>(V, INF));  // 全2点間の最小距離
    vector<ll> deg(V);
    ll su = 0;
    REP(i, E) {
        int s, t; ll d;
        cin >> s >> t >> d;
        e[s][t] = e[t][s] = min(e[s][t], d);
        deg[s] += 1;
        deg[t] += 1;
        su += d;
    }

    // 次数が奇数の頂点を格納。必ず奇数個となる
    vector<int> odd;
    REP(v, V) {
        if (deg[v] % 2) odd.pb(v);
    }

    memset(memo, -1, sizeof(memo));
    memo[(1 << SIZE(odd)) - 1] = 0;

    // Warshall–Floyd Algorithm
    REP(k, V) REP(i, V) REP(j, V) e[i][j] = min(e[i][j], e[i][k] + e[k][j]);

    cout << dfs(0, odd, e) + su << endl;
    return 0;
}



Measured memory_bytes: 3428
#include <stdio.h>

int main(void){
    char a,b;
    scanf("%c %c",&a,&b);
    if(a == 'H' && b == 'H'){
        printf("H\n");
    }else if(a == 'D' && b == 'H'){
        printf("D\n");
    }else if(a == 'H' && b == 'D'){
        printf("D\n");
    }else{
        printf("H\n");
    }
    return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappop, heappush
import itertools

"""
・最小費用流。流量2を流せばよい。
・頂点xをx_in,x_outに拡張。x_inからx_outにcapacity1で、価値 a と 0 の辺を貼る
・このままだと最大化問題になっているので、辺のコストをX - a_{ij}とする感じで
"""

class MinCostFlow:
    """
    最小費用流。負辺がないと仮定して、BellmanFordを省略している。
    """
    def __init__(self, N, source, sink):
        self.N = N
        self.G = [[] for _ in range(N)]
        self.source = source
        self.sink = sink
        
    def add_edge(self, fr, to, cap, cost):
        n1 = len(self.G[fr])
        n2 = len(self.G[to])
        self.G[fr].append([to, cap, cost, n2])
        self.G[to].append([fr, 0, -cost, n1])

    def MinCost(self, flow, negative_edge = False):
        if negative_edge:
            raise ValueError
        N = self.N; G = self.G; source = self.source; sink = self.sink
        INF = 10 ** 18
        prev_v = [0] * N; prev_e = [0] * N # 経路復元用
        H = [0] * N # potential
        mincost=0
        while flow:
            dist=[INF] * N
            dist[source]=0
            q = [source]
            mask = (1 << 20) - 1
            while q:
                x = heappop(q)
                dv = (x >> 20); v = x & mask
                if dist[v] < dv:
                    continue
                if v == sink:
                    break
                for i,(w,cap,cost,rev) in enumerate(G[v]):
                    dw = dist[v] + cost + H[v] - H[w]
                    if (not cap) or (dist[w] <= dw):
                        continue
                    dist[w] = dw
                    prev_v[w] = v; prev_e[w] = i
                    heappush(q, (dw << 20) + w)
            if dist[sink] == INF:
                raise Exception('No Flow Exists')
            # ポテンシャルの更新
            for v,d in enumerate(dist):
                H[v] += d
            # 流せる量を取得する
            d = flow; v = sink
            while v != source:
                pv = prev_v[v]; pe = prev_e[v]
                cap = G[pv][pe][1]
                if d > cap:
                    d = cap
                v = pv
            # 流す
            mincost += d * H[sink]
            flow -= d
            v = sink
            while v != source:
                pv = prev_v[v]; pe = prev_e[v]
                G[pv][pe][1] -= d
                rev = G[pv][pe][3]
                G[v][rev][1] += d
                v = pv
        return mincost

H,W = map(int,readline().split())
A = list(map(int,read().split()))

N = 2 * H * W + 2
source = N-2; sink = N-1

G = MinCostFlow(N,source,sink)
add = G.add_edge
X = 10 ** 6

# スタート地点
add(fr=source, to=0, cap=2, cost=0)
# ゴール
add(2*H*W-1, sink, 2, 0)

# x_in to x_out
for x,a in enumerate(A):
    add(x+x,x+x+1,1,X) # とらない
    add(x+x,x+x+1,1,X - a) # とる

# 左から右への辺
for i,j in itertools.product(range(H),range(W-1)):
    x = W * i + j; y = x + 1
    add(x+x+1,y+y,1,0)
# 上から下への辺
for i,j in itertools.product(range(H-1),range(W)):
    x = W * i + j; y = x + W
    add(x+x+1,y+y,1,0)

cost = G.MinCost(2)

# 1点通るごとに、X - costになっている。2人合わせて、(H+W-1) * 2個のXが足されている

answer = 2 * (H+W-1) * X -cost
print(answer)

Measured memory_bytes: 74164
#include<iostream>
using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
    
   int s,w;
   cin>>s>>w;
   
   if(s<=w)
   cout<<"unsafe"<<endl;
   else
   cout<<"safe"<<endl;
   
   return 0;
}


Measured memory_bytes: 3648
a = int(input())
b = int(input())

if len(str(a)) > len(str(b)):
    print("GREATER")
elif len(str(a)) < len(str(b)):
    print("LESS")
else:
    if a > b:
        print("GREATER")
    elif a < b:
        print("LESS")
    else :
        print("EQUAL")


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()
#define PI acos(-1)

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n)
  {
    if(i%2==0 && a[i]%2 == 1)
    {
      ans++;
    }
  }
  cout << ans << "\n";
  
}


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

void fnInput(vector<int>& rvnNum)
{
  string sNum;
  cin >> sNum;

  for (int i = 0; i < rvnNum.size(); i++)
    rvnNum[i] = sNum[i] - '0';                 // char → int 変換
}

int fnBitFullSch(const vector<int>& cnrvnNum)
{
  for (int n = 0; n < (1 << 3) - 1; n++)
  {
    int nSum = cnrvnNum[0];
    for (int i = 0; i < 3; i++)
      if (n & (1 << i)) nSum += cnrvnNum[i + 1];
      else              nSum -= cnrvnNum[i + 1];

    if (nSum == 7)  return n;
  }
  return (1 << 3) - 1;
}
    
void fnResult(const vector<int>& cnrvnNum, int nReslt)
{
  cout << cnrvnNum[0];
  for (int i = 0; i < 3; i++)
  {
    if (nReslt & (1 << i)) cout << "+";
    else                   cout << "-";

    cout << cnrvnNum[i + 1];
  }
  cout << "=7" << endl;
}

int main()
{
  vector<int> vnNum(4);
  
  fnInput(vnNum);
  int nReslt = fnBitFullSch(vnNum);
  fnResult(vnNum, nReslt);

  return 0;
}

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

public class Main {
	
	static long[] sumLengthOfDigitNumber = new long[19];
	static long[] digit10 = new long[19];
				
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int[] h = new int[N];
		for(int i = 0; i < N; i++) h[i] = sc.nextInt();
		int num = 0;
		
		while(true){
			int L = -1, R = -1;
			int min = 101;
			for(int i = 0; i < N; i++){
				if(h[i] != 0){
					if(L == -1){
						L = i;
						R = i;
						min = h[i];
					}else{
						R = i;
						min = Math.min(min, h[i]);
					}
				}else{
					if(L != -1) break;
				}
			}
			if(L == -1) break;
			
			for(int i = L; i <= R; i++){
				h[i] -= min;
			}
			num += min;
		}
		System.out.println(num);
		
	}//end main
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define ppb pop_back
#define all(x) (x).begin(), (x).end()

template <typename T>
using pr = array <T, 2>;

template <typename T>
using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 123;
int n, dp[N], m[N];
int mn[1 << 26];
string s;
vector <int> v;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	v.pb(0);
	for (int i = 0; i < 26; i++) {
		v.pb(1 << i);
	}
	cin >> s;
	int n = s.size();
	memset(& dp, 0x3f, sizeof(dp));
	memset(& mn, 0x3f, sizeof(mn));
	dp[0] = 0, mn[0] = 0;
	for (int i = 1; i <= n; i++) {
		m[i] = m[i - 1] ^ (1 << (s[i - 1] - 'a'));
		for (int j : v) {
			dp[i] = min(dp[i], mn[m[i] ^ j] + 1);
		}
		mn[m[i]] = min(mn[m[i]], dp[i]);
	}
	cout << dp[n];
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    /**
     * 各辺について偶数回通るような木があれば条件を満たす
     */

    i32 n, m, a,b; cin >> n >> m;
    vec<int> cntr(n);
    rep(i,m) {
        cin >> a >> b;
        cntr[a] ^= 1;
        cntr[b] ^= 1;
    }
    bool can = 1;
    rep(i,n) if(cntr[i]) can = 0;

    cout << (can ? "YES" : "NO") << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    multiset<int> st;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    st.insert(-a[0]);
    for (int i = 1;i < n;++i) {
        auto it = st.upper_bound(-a[i]);
        if (it == st.end()) st.insert(-a[i]);
        else {
            st.erase(it);
            st.insert(-a[i]);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
def calc(N, h, n):
    base = 4 * h * n - N * n - N * h
    if base <= 0:
        return False, -1
    ret = (N*h*n) / base
    return ret == int(ret) and 0 <= ret <= 3500, int(ret)

N = int(input())

def f(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            judge, ret = calc(N,h,n)
            if judge:
                return h, n, ret
    return -1, -1, -1

print(*f(N))


Measured memory_bytes: 41580
#include<bits/stdc++.h>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n,k;
	double t=0,t2=0;
	cin>>n>>k;

	int s=1,e=0;
	double u=1;
	for(int i=1; i<n+1; i++){
		e=i;
		rep(j,k){
			if(e<k){
				e*=2;
				u*=0.5;
			}else break;
		}
		t=((double)s)/n*u;
		t2+=t;
		u=1;
	}
	cout<<setprecision(12)<<t2<<endl;

	return 0;

}


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

double res(int i, int k){
	double n = ceil(log2((double)k / i));
	if(n < 1)return 1.;
	return pow(0.5, n);
}

int main(void){
	double ans = 0;
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++)ans += res(i + 1, k);
	ans /= n;
	printf("%.10f\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N; cin>>N; int sum=0;
    std::vector<int> ind; std::vector<int> v; std::vector<int> c;
    for(int i=0; i<N ;i++){
      int vv; cin>>vv;
      v.push_back(vv);
    }
    for(int i=0; i<N ;i++){
      int cc; cin>>cc;
      c.push_back(cc);
    }
    for(int i=0; i<N ;i++){
      if(v[i]-c[i] > 0) ind.push_back(i);
    }
    for(int i=0; i<ind.size() ;i++){
      int t = v[ind[i]] - c[ind[i]];
      sum += t;
    }

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 25.06.2020 15:29:56
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#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 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 SORT(s) sort((s).begin(), (s).end())
#define SORTD(s) sort((s).rbegin(), (s).rend())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    int n, k;
    cin >> n >> k;

    int tmp, ans = 0, a[200000];
    MEMSET(a,0);

    REP(i, n)
    {
        cin >> tmp;
        ans++;
        a[tmp]++;
    }

    sort(a,a+200000,greater<int>());

    REP(i, k)
    {
        ans -= a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4412
// #include "debug.h"
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i = a; i < b; ++i)
#define rep_(i,a,b) for (ll i = a; i > b; --i)
#define endl '\n'
const ll mod = 1e9 + 7;

const ll maxn = 1e5;

ll n, m;
ll a[maxn];
vi g[maxn];

void solve() {
	cin >> n;
	if (n >= 30) cout << "Yes";
	else cout << "No";
}

void aux() {
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout<<fixed<<setprecision(10);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5996
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

struct mint {
  ll x; // typedef long long ll;
  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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> plus, minus;
  rep(i, n) {
    cin >> a[i];
    if (a[i] < 0) minus.push_back(a[i]);
    else plus.push_back(a[i]);
  }

  bool canPositive = false;

  if (plus.size() == 0) {
    if (k % 2 == 0) canPositive = true;
  } else {
    if (n == k) {
      if (minus.size() % 2 == 0) canPositive = true;
    } else {
      canPositive = true;
    }
  }

  mint ans = 1;
  if (canPositive) {
    sort(minus.rbegin(), minus.rend());
    sort(plus.begin(), plus.end());
    if (k % 2) {
      ans *= plus.back();
      plus.pop_back();
    }
    vector<ll> val;
    while (plus.size() >= 2) {
      ll value = plus.back(); plus.pop_back();
      value *= plus.back(); plus.pop_back();
      val.push_back(value);
    }

    while (minus.size() >= 2) {
      ll value = minus.back(); minus.pop_back();
      value *= minus.back(); minus.pop_back();
      val.push_back(value);
    }

    sort(val.rbegin(), val.rend());
    rep(i, k / 2) ans *= val[i];

  } else {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i, k) ans *= a[i];
  }

  cout << ans << endl;

}

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main(){
	ll a; double b;
	cin >> a >> b;
	b *= 100;
	trace(ll(b));
	ll res = (ll)(a * int(round(b)));
	cout << ll(res/100) << endl;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include<iostream>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i+1;j<n;j++)
#define Unique(v) vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define M 1000000007
#define PI acos(-1.0)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
void input(vector<ll>& v,ll n){ ll i,io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<ll> v) { ll i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<ll,int>  frequency(vector<ll> v){ ll i; map<ll,int> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }
int main() {
	fastio;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ll i,n,ans = 0;
	cin >> n;
	vector<ll> v;
	input(v,n);
	rep(i,n-1) {
		if (v[i] > v[i+1]) {
			ans += (v[i] - v[i+1]);
			v[i+1] += (v[i] - v[i+1]);
		}
	}
	cout << ans << endl;
}
// Check for corner cases
// Check for special case like n = 0 or n = INT_MAX
// Check for Buffer Overflow or use of unsigned variable if any
// Check if problem can be solved mathematically 



Measured memory_bytes: 5340
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    string a[500],r[500],b[500];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>a[i];
        r[i]=b[i]=a[i];
    }
    for(int j=0;j<w;j++){
        r[0][j]=b[h-1][j]='#';
    }
    for(int i=1;i<h-1;i++){
        for(int j=0;j<w;j++){
            if(j%2==0){
                r[i][j]='#';
            }else{
                b[i][j]='#';
            }
        }
    }
    for(int i=0;i<h;i++){
        cout<<r[i]<<endl;
    }
    cout<<endl;
    for(int i=0;i<h;i++){
        cout<<b[i]<<endl;
    }
    /*
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(r[i][j]=='#'&&b[i][j]=='#'){
                cout<<'#';
            }else{
                cout<<'.';
            }
        }
        cout<<endl;
    }
    */
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<string>

int main(){
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    int cnt_a = (c + b - 1) / b;
    int cnt_b = (a + d - 1) / d;
    if(cnt_a <= cnt_b){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3564
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int tmp = c/a;
        tmp *= b;
        System.out.println(tmp);
    }
}

Measured memory_bytes: 21844
import math
x = y = 0
theta = 90
while True:
    d, a = map(int, input().split(','))
    if d==a==0:
        break
    x += d * math.cos(theta * math.pi / 180)
    y += d * math.sin(theta * math.pi / 180)
    theta -= a
print(int(x))
print(int(y))

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

using namespace std;

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

typedef long long ll;

const ll Inf = 1e18;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m, r;
    cin >> n >> m >> r;
    vector<vector<int> > g(n, vector<int>(n, 1e9));
    vector<int> city(r);
    rep (i, r) {
        int c;
        cin >> c;
        city[i] = --c;
    }
    sort(city.begin(), city.end());
    rep (i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a][b] = g[b][a] = c;
    }
    rep (k, n) {
        rep (i, n) {
            rep (j, n) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
        }
    }
    ll res = Inf;
    do {
        ll tmp = 0;
        FOR (i, 1, r) tmp += g[city[i - 1]][city[i]];
        res = min(res, tmp);
    } while (next_permutation(city.begin(), city.end()));
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 384
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut ans = 0i64;
    let mut most = 0i64;
    for a in a {
        if a > most {
            most = a;
        } else {
            ans += most - a;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b,x;
    cin >> a >> b >> x;
    if(x>=a&&x<=a+b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

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

#define POS(i,j) ((i)*k+(j))

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);

  char *front=(char *)calloc(k*(n+1),sizeof(char));
  front[POS(0,0)]=1;
  for(i=0;i<n;i++){
    int j;
    for(j=0;j<k;j++) front[POS(i+1,j)]=front[POS(i,j)];
    for(j=k-1;j>=a[i];j--){
      if(front[POS(i,j-a[i])]==0) continue;
      front[POS(i+1,j)]=1;
    }
  }
  char *back=(char *)calloc(k*(n+1),sizeof(char));
  back[POS(n,0)]=1;
  for(i=n-1;i>=0;i--){
    int j;
    for(j=0;j<k;j++) back[POS(i,j)]=back[POS(i+1,j)];
    for(j=k-1;j>=a[i];j--){
      if(back[POS(i+1,j-a[i])]==0) continue;
      back[POS(i,j)]=1;
    }
  }
  int ans=n;
  for(i=0;i<n;i++){
    int l,r;
    l=0;
    r=k-1;
    while(l<k && r>=0){
      while(l<k && front[POS(i,l)]==0) l++;
      while(r>=0 && back[POS(i+1,r)]==0) r--;
      if(l<k && r>=0 && l+r<k && l+r+a[i]>=k){
	ans--;
	break;
      } else if(l+r>=k){
	r--;
      } else {
	l++;
      }
    }
  }
  printf("%d\n",ans);
}

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


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

def get_loop_num(start, last):
    x = start
    loops = [start]
    for i in range(K):
        x = A[x-1]
        loops.append(x)
        if x == last:
            return loops

loop_check = [False] * N
loop_check[0] = True
x = 1
for i in range(K):
    new_x = A[x-1]
    if loop_check[new_x-1]:
        start = new_x
        last = x
        loops = get_loop_num(start, last)
        l = (K-i-1) % len(loops)
        print(loops[l])
        exit()
    else:
        loop_check[new_x-1] = True
        x = new_x
print(x)

Measured memory_bytes: 32388
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int w; cin >> w;
  int sz = s.length();
  string ans = "";
  for (int i = 0; i < sz; i += w) ans += s[i];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric> //accumulate
#include <queue>
using namespace std;
typedef long long ll;

const int MAX_N = 1 << 17;
const int IMAX = ((1 << 30) - 1) * 2 + 1;

int n;
int dat[MAX_N * 4];

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

void update(int i, int x){
    i += n - 1;
    dat[i] = x;
    while(i > 0){
        i = (i - 1) / 2;
        dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
}

int query(int a, int b, int k, int l, int r){
    if (r <= a || b <= l) return IMAX;
    if (a <= l && r <= b) return dat[k];
    else{
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }

}

int main() {
    int q;
    cin >> n >> q;
    vector<int> com(q), x(q), y(q);
    for (int i = 0; i < q; i++){
        cin >> com[i] >> x[i] >> y[i];
    }

    init(n);
    for (int i = 0; i < q; i++){
        if (com[i] == 0){
            update(x[i], y[i]);
        }
        else{
            cout << query(x[i], y[i]+1, 0, 0, n) << endl;
        }
    }

}


Measured memory_bytes: 4916
package main

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

func main() {
	s := IOInitialize()
	S := String(s)
	K := Int(s)
	strs := strings.Split(S, "")
	if K == 1 {
		i, _ := strconv.Atoi(strs[0])
		fmt.Println(i)
		return
	}
	for i, str := range strs {
		if str == "1" {
			if i == K-1 {
				num, _ := strconv.Atoi(strs[i])
				fmt.Println(num)
				return
			}
		} else {
			num, _ := strconv.Atoi(strs[i])
			fmt.Println(num)
			return
		}
	}
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

int N;
vector<int> as, answers, table;
vector<vector<int>> tree;

void DFS(int u, int p) {
    // tableを二分探索
    int i = lower_bound(begin(table), end(table), as[u]) - begin(table);
    int old_value = table[i];

    table[i] = as[u];
    answers[u] = lower_bound(begin(table), end(table), (1 << 30)) - begin(table);

    for (int c : tree[u]) {
        if (c == p) continue;
        DFS(c, u);
    }

    table[i] = old_value;
}

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

    cin >> N;
    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    tree.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    answers.resize(N);
    table.resize(N, (1 << 30));
    DFS(0, -1);

    for (int i = 0; i < N; i++) {
        cout << answers[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 27584
#include <bits/stdc++.h>
using namespace std;
vector<long long> a;

long long check(long long x) {
  long long ret = 0, n = a.size();
  for (int i = 0; i < n; ++i) {
    if (a[i] == 0) {
      if (0 <= x) ret += n-1;
    } else if (a[i] < 0) {

      int l = 0, r = n - 1;
      while (l <= r) {
        int mid = (l + r) / 2;
        if (a[i] * a[mid] > x) l = mid + 1;
        else r = mid - 1;
      }
      ret += n - l;
      if (a[i] * a[i] <= x) ret--;  
    } else {
      int l = 0, r = n-1;
      while (l <= r) {
        int mid = (l + r) / 2;
        if (a[i] * a[mid] <= x) l = mid + 1;
        else r = mid - 1;
      }
      ret += l;
      if (a[i] * a[i] <= x)  ret--; 
    }
  } 
  assert(ret%2 == 0); 
  return ret / 2;
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  long long n, k;
  cin >> n >> k;

  a.resize(n);
  for (int i = 0; i < n; ++i) 
    cin >> a[i];

  sort(a.begin(), a.end());
  long long l = -1e18, r = 1e18;

  while (l < r) {
    long long mid = (l + r) >> 1;
    if (check(mid) >= k)  r = mid;
    else l = mid + 1;
  }

  cout << r << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
int dist[810][810];
int pass[810][810];
int used[810][810];
signed main(){
	int h,w,k;
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			dist[i][j]=inf;
		}
	}	
	queue<int> que;
	for(int i=0;i<h;i++){
		string str;
		cin>>str;
		for(int j=0;j<w;j++){
			if(str[j]=='#'){pass[i][j]=1;}
			else if(str[j]=='S'){
				dist[i][j]=0;
				que.push(i*w+j);
				used[i][j]=1;
			}
		}
	}
	int qsc[5]={+1,0,-1,0,+1};
	while(!que.empty()){
		int tmp = que.front(); que.pop();
		int ci = tmp/w;
		int cj = tmp%w;
		for(int i=0;i<4;i++){
			int di = ci + qsc[i];
			int dj = cj + qsc[i+1];
			if(0<=di && di<h && 0<=dj && dj<w && used[di][dj]==0 && pass[di][dj]==0){
				used[di][dj]=1;
				dist[di][dj]=min(dist[di][dj],dist[ci][cj]+1);
				que.push(di*w+dj);
			}
		}
	}
	int nst = inf;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(dist[i][j]<=k){
				int cdis = min(i,min(h-1-i,min(j,w-1-j)));
				if( nst > cdis )nst = cdis;
			}
		}
	}
	//for(int i=0;i<w*h;i++){cout<<"dis"<<i/h<<i%h<<" "<<dist[i/h][i%h]<<endl;}
	//cout<<nst<<endl;
	int ans = 1;
	ans += nst/k;
	if(nst%k!=0)ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = w/2.0;
    ans *= (double)h;
    printf("%.6f", ans);
    if(w == x+x && h == y+y){
        cout << " " << 1 << endl;
    }else{
        cout << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Author: Tyler Wang

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; ++i) {
    cin >> w[i] >> v[i];
  }
  vector<long long> dp(W + 1);
  for (int i = 0; i < n; ++i) {
    for (int j = W - w[i]; j >= 0; --j) {
      dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
    }
  }
  cout << dp[W] << '\n';
  return 0;
}

Measured memory_bytes: 1024
# 自分の
N = int(input())
a_arr = list(map(int, input().split()))

new_a_arr = sorted(a_arr)

for i in range(N-1):
    if new_a_arr[i]==new_a_arr[i+1]:
        print("NO")
        break
    elif i==N-2:
        print("YES")


Measured memory_bytes: 25936
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long W, long long H, long long x, long long y){
  double ans = static_cast<double>(H)*static_cast<double>(W)/2.0;
  std::cout << ans << " ";
  if (W%2 == 0 && H%2 == 0 && W/2 == x && H/2 == y) {
    std::cout << 1 << std::endl;
  } else {
    std::cout << 0 << std::endl;
  }
}

int main(){
  long long W;
  long long x;
  long long y;
  long long H;
  scanf("%lld",&W);
  scanf("%lld",&H);
  scanf("%lld",&x);
  scanf("%lld",&y);
  solve(W, H, x, y);
  return 0;
}


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

long long divisor(long long n) {
    long long ret = 0;
    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ++ret;
            if(i * i != n) ++ret;
        }
    }
    return ret;
}

int main(void){
    long N;

    cin >> N;

    long ans = 0;

    for (long i = 1; i < N + 1; i++){
        ans = ans + 0.5 * i * floor(N / i) * (floor(N / i) + 1);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 3168
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

int main() {
    init();
    sll x,y;
    cin >> x >> y;
    cout << x + (y/2) << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 256
/**
*    created: 13.05.2020 19:39:53
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int r, d, x;
    cin >> r >> d >> x;
    rep(i,10) {
        x = r * x - d;
        cout << x << endl;
    }
    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++)

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

    vector<vector<char>> grid(H, vector<char>(W));

    rep(i, H) {
        string line;
        cin >> line;
        rep(j, W) {
            grid.at(i).at(j) = line.at(j);
        }
    }

    vector<int> not_white_line;
    rep(i, H) {
        bool is_white_line = true;
        rep(j, W) {
            if (grid.at(i).at(j) == '#') {
                is_white_line = false;
                break;
            }
        }
        if (!is_white_line) {
            not_white_line.push_back(i);
        }
    }

    vector<int> not_white_row;
    rep(j, W) {
        bool is_white_row = true;
        rep(i, H) {
            if (grid.at(i).at(j) == '#') {
                is_white_row = false;
                break;
            }
        }
        if (!is_white_row) {
            not_white_row.push_back(j);
        }
    }

    for (int i : not_white_line) {
        for (int j : not_white_row) {
            cout << grid.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, n - 2) {
        if (s.substr(i, 3) == "ABC") ans += 1;
    }

    print(ans);

    return 0;
}



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

int main() {
    int n,m,q;cin>>n>>m>>q;
    int a[n+1][n+1]{};
    for (int i=0;i<m;i++) {
        int b,c;cin>>b>>c;
        a[b][c]++;
    }
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            a[i][j]+=a[i][j-1];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            a[i][j]+=a[i-1][j];
    for (int i=0;i<q;i++) {
        int b,c;cin>>b>>c;
        cout<<a[c][c]-a[c][b-1]-a[b-1][c]+a[b-1][b-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1920
N = int(input())
T,A = map(int, input().split())
H = [int(h) for h in input().split()]

for i in range(N):
    H[i] = T - H[i] * 0.006

c = 10**9
for j in range(N):
    if abs(H[j]-A) <= c:
        ans = j+1
        c = abs(H[j]-A)
        
print(ans)

Measured memory_bytes: 3064
package main

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

func main() {
	s := wordScanner(100)
	n, v := scanNAndIntSlice(s)

	sort.Ints(v)

	ans := float64(v[0])
	for i := 1; i < n; i++ {
		ans = (ans + float64(v[i])) / 2.0
	}
	fmt.Println(ans)
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanNAndIntSlice(s *bufio.Scanner) (int, []int) {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n, scanIntSlice(s, n)
}

func scanIntSlice(s *bufio.Scanner, n int) []int {
	vals := make([]int, n)
	for i := range vals {
		s.Scan()
		m, _ := strconv.Atoi(s.Text())
		vals[i] = m
	}
	return vals
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

struct UnionFind{

    vector<int> par;

    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return ;
        par[rx] = ry;
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};

int main()
{
    int n, m;
    cin >> n >> m;

    UnionFind tree(n);

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

    for(int i = 0; i< m; i++){
        int x, y;
        cin >> x >> y;
        tree.unite(x-1, y-1);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(tree.same(i, p[i]-1)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3972