akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class MinCostFlow:
    """ 最小費用流(ダイクストラ版)：O(F*E*logV) """

    INF = 10 ** 18

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap, cost):
        G = self.G
        G[fr].append([to, cap, cost, len(G[to])])
        G[to].append([fr, 0, -cost, len(G[fr])-1])

    def flow(self, s, t, f):
        from heapq import heappush, heappop

        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0] * N
        prv_v = [0] * N
        prv_e = [0] * N

        while f:
            dist = [INF] * N
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                for i, (to, cap, cost, _) in enumerate(G[v]):
                    if cap > 0 and dist[to] > dist[v] + cost + H[v] - H[to]:
                        dist[to] = r = dist[v] + cost + H[v] - H[to]
                        prv_v[to] = v; prv_e[to] = i
                        heappush(que, (r, to))
            if dist[t] == INF:
                return INF

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, G[prv_v[v]][prv_e[v]][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = G[prv_v[v]][prv_e[v]]
                e[1] -= d
                G[v][e[3]][1] += d
                v = prv_v[v]
        return res

M, N, K = MAP()
A = LIST(N)
B = [b-1 for b in LIST(K)]

# 隣り合う同値を取り除いておく
B2 = [B[0]]
for i in range(1, K):
    if B[i-1] != B[i]:
        B2.append(B[i])
K2 = len(B2)

# 同じ値が次に出現する位置を調べておく
nxt = [INF] * K2
D = defaultdict(lambda: INF)
total = 0
for i in range(K2-1, -1, -1):
    b = B2[i]
    nxt[i] = D[b]
    D[b] = i
    total += A[b]

mcf = MinCostFlow(K2)
# 負コストを避けるための調整用
MAX = 10 ** 4
for i in range(K2-1):
    b = B2[i]
    # 残さない場合は利得0とする
    mcf.add_edge(i, i+1, M-1, MAX)
    j = nxt[i]
    if j != INF:
        # 残しておくと、残さない場合にかかるコスト分の利得があるとみなす
        mcf.add_edge(i+1, j, 1, MAX*(j-i-1) - A[b])

res = MAX*(K2-1)*(M-1) - mcf.flow(0, K2-1, M-1)
print(total - res)



Measured memory_bytes: 14944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll n, k;
    cin>>n>>k;
    if(n >= 13){
        cout<<k<<endl;
    } else if (n <= 5){
        cout<<0<<endl;
    } else {
        cout<<k/2<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    
    int b;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(a[i] < a[j]){
                b = a[i];
                a[i] = a[j];
                a[j] = b;
            }
        }
    }

    int point_A = 0;
    int point_B = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            point_A += a[i];
        }
        if(i % 2 == 1){
            point_B += a[i];
        }
    }
    printf("%d\n",point_A - point_B);

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  long long B=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    B^=A.at(i);
  }
  for(int i=0;i<N;i++){
    int X=B^A.at(i);
    cout << X;
    if(i==N-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}

Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
  int m,f,b,a;
  cin>>m>>f>>b;
  if(b>m+f){
    cout<<"NA"<<endl;
  }else if(b>m && m+f>=b){
    cout<<b-m<<endl;
  }else{
    cout<<0<<endl;
  }

  return 0;
}



Measured memory_bytes: 3076
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;


void main() {
    immutable long MAX = 2*10^^6+1;
    immutable long MOD = 10^^9+7;

    auto modinv = new long[](MAX);
    modinv[0] = modinv[1] = 1;
    foreach(i; 2..MAX) {
        modinv[i] = modinv[MOD % i] * (MOD - MOD / i) % MOD;
    }

    auto f_mod = new long[](MAX);
    auto f_modinv = new long[](MAX);
    f_mod[0] = f_mod[1] = 1;
    f_modinv[0] = f_modinv[1] = 1;

    foreach(i; 2..MAX) {
        f_mod[i] = (i * f_mod[i-1]) % MOD;
        f_modinv[i] = (modinv[i] * f_modinv[i-1]) % MOD;
    }

    long nck(long n, long k) {
        return f_mod[n] * f_modinv[n-k] % MOD * f_modinv[k] % MOD;
    }


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

    long ans = 0;
    foreach (i; 0..H-A) {
        ans = (ans + nck(B-1+i, i) * nck(W-B+H-i-2, H-i-1) % MOD) % MOD;
    }

    writeln( ans >= 0 ? ans : ans+MOD);
}


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

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

    int h1, s1, h2, s2;
    cin >> h1 >> s1 >> h2 >> s2;

    int need1=(h2+s1-1)/s1,
        need2=(h1+s2-1)/s2;

    cout << (need1<=need2 ? "Yes" : "No");

    return 0;
}


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

int main() {
  ll N;
  cin >> N;
  map<ll, ll> res;
  for (int i = 2; i <= N; i++) {
    ll n = i;
    for (int j = 2; j * j <= n; j++) {
      while (n % j == 0) {
        res[j]++;
        n /= j;
      }
    }
    if (n != 1) res[n] += 1;
  }
  ll ans = 1;
  for (auto p : res) {
    ans = (ans * (p.second + 1)) % MOD;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
implicit none
integer,parameter :: PREC = 16
integer :: n
integer(PREC),allocatable :: t(:)
integer :: i
integer(PREC) :: lcm,p,q,r

read *,n
allocate(t(n))
do i = 1, n
   read *, t(i)
enddo

lcm = t(1)
do i= 2, n
 p = min(lcm,t(i))
 q = max(lcm,t(i))
 r = 1
 do while (r > 0)
    r = mod(q,p)
    q = p
    p = r
 enddo
 lcm = lcm*t(i)/q
enddo

print '(i0)',lcm
end

Measured memory_bytes: 256
import numpy as np
import itertools
H , W , K = map(int,input().split())
C = [['' for i in range(W)] for j in range(H)]
c = [[0 for i in range(W)] for j in range(H)]
c = np.array(c) 
for i in range(H):
  C[i] = list(str(input()))
  
C = np.array(C)  
for i in range(W):
  for j in range(H):
    if C[j,i] == '#':
      c[j,i] = 1
Y = [i for i in range(H)]
X = [i for i in range(W)]
S = 0
for n in range(0,len(X) + 1):
  for comb in itertools.combinations(X,n):
    cdum = np.array(c)
    for i in comb:
      for k in range(H):
        cdum[k,i] = 0
    cdumx = np.array(cdum)
    for m in range(0,len(Y) + 1):
      for Comb in itertools.combinations(Y,m):
        for j in Comb:
          for k in range(W):
            cdumx[j,k] = 0
        if np.sum(cdumx) == K:
          S += 1
        cdumx = np.array(cdum)
print(S)
  

Measured memory_bytes: 27260
//
//  main.c
//  Practice
//
//  Created by hoshino on 2015/10/19.
//  Copyright ?? 2015??´ hoshino. All rights reserved.
//

#include <stdio.h>

int main(void) {
    int i=1,x;
    while (1) {
        scanf("%d",&x);
        if (x==0)        {
            break;
        }else
        {  printf("Case %d: %d\n",i,x);
            i+=1;}
        
    }
   // for(i=0;i<1000;i++){
      //  printf("Hello World\n");
 //   }
    //scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
    //if(x-r<0 || x+r>W){
       // printf("No\n");
    //}else if(y-r<0 || y+r>H){
        //printf("No\n");
   // }else
     //{
      //   printf("Yes\n");
  //  }
    
    //insert code here...
    
    return 0;
}

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

namespace ABC042_B {
	class Program {
		static void Main() {
			int[] args = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
			int N = args[0];
			int L = args[1];
			List<string> Str = new List<string>();
			for (int i = 0; i < N; i++) {
				Str.Add(Console.ReadLine());
			}
			Str.Sort();
			Console.WriteLine(string.Join("", Str));
		}
	}
}


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

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

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

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B + C >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


double dist(double x1, double x2, double y1, double y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}
double dist(P &p1, P &p2) {
	double x1 = p1.first, x2 = p2.first, y1 = p1.second, y2 = p2.second;
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}


void solve() {
	int H, W; cin >> H >> W;
	int mx = max(H, W);
	int N; cin >> N;
	print((N + mx - 1) / mx);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        boolean first = false;
        for(int i=0; i<n; i++){
            a[i] = sc.nextLong();
            if(a[i] % 2 == 1) first = true;
        }
        sc.close();

        if(first){
            System.out.println("first");
        }else{
            System.out.println("second");
        }
    }
}

Measured memory_bytes: 62764
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
	int c[N + 1][N + 1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X; // X[0] に空白を挿入
	Y = ' ' + Y; // Y[0] に空白を挿入
	for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
	for ( int j = 1; j <= n; j++ ) c[0][j] = 0;
	
	for ( int i = 1; i <= m; i++ ) {
		for ( int j = 1; j <= n; j++ ) {
			if ( X[i] == Y[j] ) {
				c[i][j] = c[i - 1][j - 1] + 1;
			} else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}
	
	
	return maxl;
}


int main() {
	string s1, s2;
	int n; cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	
	return 0;
}


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


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

int main() {
	ll n, d, a;
	cin >> n >> d >> a;
	
	d = d * 2;
	vector< pair<ll, ll> > p;

	rep (i, n) {
		int x, h;
		cin >> x >> h;

		p.pb(make_pair(x, (h + a - 1) / a));
	}
	sort(p.begin(), p.end());
	ll ans = 0;
	queue<pair<ll,ll> > que;

	ll attack = 0;
	for (auto cur : p) {
		ll cur_x = cur.first;
		ll cur_h = cur.second;
		//cout << "x:" << cur_x << " h:" << cur_h << endl;
		while(true) {
			if (que.empty()) break;
			auto q = que.front();
			int q_x = q.first;
			if (cur_x <= q_x) {
				break;
			}
			que.pop();
			attack -= q.second;
			if (attack < 0) {
				cout << "error attacl minue" << endl;
			}
		}


		//cout << "attack:" << attack << endl;
		if (cur_h <= attack) {
			continue;
		}
		int cur_bomb = cur_h - attack;

		//cout << "cur_bomb:" << cur_bomb << endl;
		
		que.push(make_pair(cur_x + d,cur_bomb));
		attack += cur_bomb;
		ans += cur_bomb;
		//cout << "attack:" << ans << endl;
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back

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

const int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    vector<int> a(9);
    rep (i, 9) cin >> a[i];
    
    int n; cin >> n;
    rep (i, n) {
        int b; cin >> b;
        rep (j, 9) {
            if (b == a[j]) {
                a[j] = 0;
            }
        }
    }
    
    //yoko
    for (int i = 0; i < 9; i += 3) {
        if (a[i] == 0 && a[i+1] == 0 && a[i+2] == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    //tate
    for (int i = 0; i < 3; i++) {
        if (a[i] == 0 && a[i+3] == 0 && a[i+6] == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    //naname
    if (a[0] == 0 && a[4] == 0 && a[8] == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    
    if (a[2] == 0 && a[4] == 0 && a[6] == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
} 


Measured memory_bytes: 256
program main
integer(16) :: l,r,i,j,m,mo,tmp,a
m=2019
read(*,*)l,r

if((r-l) > 2019) then
m = 0
end if

l = mod(l,2019)
r = mod(r,2019)

if (r < l) then
tmp = r
r = l
l = tmp
end if

if (l /= r) then
do i = l,r-1
do j = i+1,r
mo = mod(i*j,2019)
if (m > mo) m = mo
end do
end do
write(*,*)m

else
write(*,*)l
end if

end program main

Measured memory_bytes: 256
X,N=map(int, input().split())
if N==0:
  print(X)
else:
  p_list=list(map(int, input().split()))

  i=0
  while(True):

    Xi = X - i
    if Xi not in p_list:
      break

    Xi = X + i
    if Xi not in p_list:
      break

    i = i + 1

  print(Xi)

Measured memory_bytes: 9184
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> w(n),v(n);
	LL dp[200020][2]={};
	FOR(i,0,n)cin>>w[i]>>v[i];
	int idx=0;
	FOR(i,0,n){
		FORQ(j,0,m){
			dp[j+w[i]][idx^1]=max(dp[j+w[i]][idx^1],dp[j][idx]+v[i]);
			dp[j][idx^1]=max(dp[j][idx^1],dp[j][idx]);
		}
		FOR(j,0,200002){
			dp[j][idx]=0;
		}
		idx^=1;
	}

	LL ans=0;
	FOR(i,0,m+1){
		ans=max(ans,dp[i][idx]);
	}
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n; ll d; cin >> n >> d;
    int ans = 0;
    FOR(i, 0, n) {
        ll x, y; cin >> x >> y;
        if (x * x + y * y <= d * d)++ans;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int gcd(int x,int y){return x%y?gcd(y,x%y):y;}
int main()
{
    //freopen("abbreviation.in","r",stdin);
    //freopen("abbreviation.out","w",stdout);
    int n,k,i,ans,mx;
    cin>>n>>k>>ans;mx=ans;
    for(i=1;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        mx=max(mx,x);
        ans=gcd(ans,x);
    }
    if(k>mx)printf("IMPOSSIBLE");
    else
        if(k%ans)printf("IMPOSSIBLE");
        else printf("POSSIBLE");
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int n,i;
cin>>n;
int a[n],b[n],k=0;
for(i=0;i<n;i++)
{
cin>>a[i];
b[i]=a[i];
}
sort(b,b+n);
for(i=0;i<n;i++)
if(a[i]!=b[i])
k++;
if(k==2 || k==0)
cout<<"YES";
else
cout<<"NO";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll h[100001];
ll d[100001];
int  main() {
	ll n; cin >> n;
	repe(i, 1, n)cin >> h[i];

	rep_r(i, 1, n) {
		if (h[i] >= h[i + 1]) {
			d[i] = d[i + 1] + 1;
		}
		else {
			d[i] = 0;
		}
	}
	ll maxV = 0;
	rep(i, 1, n) {
		maxV = max(maxV, d[i]);
	}
	cout << maxV << endl;

	return 0;
}

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

public class Main{
	public static void main(String []args)
	{
		int n,x,y;
		int []moto=new int [1005];
		Scanner cin=new Scanner(System.in);
		while(cin.hasNext())
		{
			n=cin.nextInt();
			x=cin.nextInt();
			long  sum=0;
			int min=0x6FFFF;
			for(int i=0;i<n;i++)
			{
				moto[i]=cin.nextInt();
				sum+=moto[i];
				if(min>moto[i])
					min=moto[i];
			}
			int ans=n;
			x-=sum;
			ans+=x/min;
			System.out.println(ans);
			
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int flag = 0;
    if(S[2]==S[3] && S[4]==S[5])
        flag = 1;
    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;cin>>N;
  bool F=false;
  for(int X=N.size()-1;X>0;X--){
    if(N[X]!='9'){
      F=true;
    }
  }
  if(!F){
    cout<<((int)N[0])-48+9*(N.size()-1)<<endl;
  }
  else{
    cout<<(int)N[0]-49+9*(N.size()-1)<<endl;
  }
}

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

int main(){
    int a;
    int aa[4];
    int p;
    int pa[4];
    while(scanf("%d %d", &a, &p)){
        if(a == 0 && p == 0) break;
        int c = 1000;
        for(int i=0; i<4; ++i){
            aa[i] = a / c;
            a = a % c;
            pa[i] = p / c;
            p = p % c;
            c /= 10;
        }
        int hit = 0;
        int blow = 0;
        for(int i=0; i<4; ++i){
            for(int j=0; j<4; ++j){
                if(aa[i] == pa[j]){
                    if(i == j) ++hit;
                    else ++blow;
                }
            }
        }
        cout << hit << " " << blow << endl;
    }
    return 0;
}

Measured memory_bytes: 892
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
	int N;
	cin >> N;
	int X[N];
	for (int i = 0; i < N; ++i) cin >> X[i];
 
	// 解法
	int sortX[N];
	for (int i = 0; i < N; ++i) sortX[i] = X[i];
 
	sort(sortX, sortX + N);
	int med1 = sortX[N/2-1];
	int med2 = sortX[N/2];
	
	//出力
	for (int i = 0; i < N; ++i){
		if (X[i]<=med1) printf("%d\n", med2);
		else printf("%d\n", med1);
	}
}
 


Measured memory_bytes: 3712
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s2 = sc.nextInt();
   int s3 = sc.nextInt();
   if(s1<=s3&&s2>=s3)System.out.println("Yes");
   else System.out.println("No");
 }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#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++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	int A, B, M; cin >> A >> B >> M;
	vi a(A); rep(i, A) cin >> a.at(i);
	vi b(B); rep(i, B) cin >> b.at(i);
	vi x(M), y(M), c(M);
	rep(i, M) {
		cin >> x.at(i) >> y.at(i) >> c.at(i);
	}
	int min_a = 100000, min_b= 100000;
	rep(i, A) min_a = min(min_a, a.at(i));
	rep(i, B) min_b = min(min_b, b.at(i));
	int ans = min_a + min_b;
	rep(i, M) {
		ans = min(ans, a.at(x.at(i) - 1) + b.at(y.at(i) - 1) - c.at(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll x, y; cin >> x >> y;
    int ct = 0;
    while (y >= x) {
        ct++;
        x *= 2;
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int n,teamnum;
const int NMAX = 1000;
struct team{
  int i,u,a,p,ur;
} t[NMAX];

map<int,int> area;

bool operator < (team a, team b){
  if(a.a == b.a){
    if(a.p == b.p){
      return a.i > b.i;
    }else{return a.p > b.p;}
  }else{return a.a < b.a;}
}

template<class T>
bool greater(const T &a, const T &b){
  return b < a;
}

int main(){
  while(1){
    area.clear();
    teamnum = 0;
    cin >> n;
    if(n == 0)return 0;
    for(int i = 0;i < n;i++){
      cin >> t[i].i >> t[i].u >> t[i].a >> t[i].p;
    }
    sort(t,t+n);
    //reverse(t, t + n);

    for(int i = n-1;i >= 0;i--){
      if(teamnum < 10 && area[t[i].u] < 3){
	teamnum++;
	area[t[i].u]++;
	cout << t[i].i << endl;
      }
      else if(teamnum < 20 && area[t[i].u] < 2){
	teamnum++;
	area[t[i].u] ++;
	cout << t[i].i << endl;
      }else if(teamnum < 26 && area[t[i].u] < 1){
	teamnum++;
	area[t[i].u]++;
	cout << t[i].i << endl;
      }
    }
  }

  return 0;
}

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

int main() {
    string s;
    cin >> s;
    
    int len = (int)s.size();
    // このやり方は微妙
    for(int i = 0; i < len; ++i) {
        if(i % 2 == 0) {
            cout << s[i] << flush;
        }
    }
    cout << endl;
}


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

int n, q;
string era[1000]; int offset[1000]; int year[1000];

int main() {
	while (cin >> n >> q) {
		if (!n) break;
		int i, j;
		
		for (i = 0; i < n; i++) cin >> era[i] >> offset[i] >> year[i];
		for (i = 0; i < q; i++) {
			int y;
			vector<int> ansId;
			
			cin >> y;
			for (j = 0; j < n; j++) {
				int firstYear = year[j] - offset[j] + 1;
				if (firstYear <= y && y <= year[j]) {
					ansId.push_back(j);
				}
			}
			if (ansId.size() != 1) { cout << "Unknown" << endl; }
			else { cout << era[ansId[0]] << " " << offset[ansId[0]] - year[ansId[0]] + y << endl; }
		}
	}
	return 0;
}

Measured memory_bytes: 3288
def main():
    #入力
    n, a = map(int,input().split())
    x = [0] + list(map(int,input().split()))

    sum_max = (n)*(max(x))+1

    #dp[i][j][k]:x1-xiからj枚選んで、合計をkにする選び方の数
    dp = [[[0]*2501 for _ in range(n+1)] for _ in range(n+1)]

    dp[0][0][0] = 1

    for i in range(1,n+1):
        for j in range(n+1):
            for k in range(50*j+1):
                #xi>kのとき
                if x[i]>k:
                    dp[i][j][k] = dp[i-1][j][k]
                elif j>=1 and x[i]<=k:
                    #xi<=kのとき
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]]

    count = 0
    for j in range(1,n+1):
        count += dp[n][j][j*a]
    
    print(count)


if __name__ == "__main__":
    main()

Measured memory_bytes: 62964
#include<stdio.h>
int main(void)
{
	int A,B,K,flg,i;
	flg=0;
	scanf("%d %d %d",&K,&A,&B);
	for(i=A;i<=B;i++){
	if(i%K==0){
	flg=1;
	}
	}
	if(flg==0){
		printf("NG\n");
	}
	else{
		printf("OK\n");
	}
	return 0;
}
		
		
		

Measured memory_bytes: 1580
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void) {
	string s, t, u;
	cin >> s >> t >> u;
	cout << s[0] << t[0] << u[0] << endl;
	return 0;
}

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

using namespace std;

int getAlphabetIndex(char ch)
{
	if (isalpha(ch))
	{
		if (isupper(ch))
		{
			ch = tolower(ch);
		}
		return ch - 'a';
	}
	else
	{
		return -1;
	}
}

int main()
{
	string sentence(1201, '\0');
	vector<int> num_of_char(26, 0);
	int alpha_i;
	while (getline(cin, sentence), sentence[0] != '\0')
	{
		for (int i = 0; i < sentence.size(); i++)
		{
			alpha_i = getAlphabetIndex(sentence[i]);
			if (alpha_i >= 0)
			{
				num_of_char[alpha_i]++;
			}
		}
	}
	for (int i = 0; i < num_of_char.size(); i++)
	{
		cout << (char)('a' + i) << " : " << num_of_char[i] << endl;
	}
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(unsigned i=0;i<n;i++)
#define repr(i,n) for(unsigned i=n-1;i>=0;i--)
#define rep1(i,n) for(unsigned i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define cins(s,n) rep(i,n)cin>>s.at[i];
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}
int Digits(unsigned x)
{
    int ans=0;
    while(x!=0)
    {
        x/=10;
        ans++;
    }
    return ans;
}
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}


int main()
{
    cin.tie(0);
ios_base::sync_with_stdio(false);
string s,t,z="";cin>>s>>t;
rep(i,s.length())
{
    z+=s[i];
    if(i!=s.length()-1||s.length()==t.length())
    z+=t[i];
    
}
cout<<z;

}    

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

vector<int> suffix_array(const string &s){
    const int n=s.size();
    vector<int> rank(n+1),sa(n+1),tmp(n+1);
    for(int i=0; i<=n; ++i){
        sa[i]=i;
        rank[i]=i<n?s[i]:-1;
    }
    for(int k=1; k<=n; k*=2){
        auto compare=[&](int i,int j){
            if(rank[i]!=rank[j]) return rank[i]<rank[j];
            else{
                int ri=i+k<=n?rank[i+k]:-1;
                int rj=j+k<=n?rank[j+k]:-1;
                return ri<rj;
            }
        };
        sort(sa.begin(),sa.end(),compare);
        tmp[sa[0]]=0;
        for(int i=1; i<=n; ++i){
            tmp[sa[i]]=tmp[sa[i-1]]+(compare(sa[i-1],sa[i])?1:0);
        }
        for(int i=0; i<=n; ++i){
            rank[i]=tmp[i];
        }
    }
    return sa;
}

int lower_bound(const string& s,const vector<int>& sa,const string t){
    int lb=0,ub=sa.size();
    while(ub-lb>1){
        int m=(lb+ub)/2;
        if(s.substr(sa[m],t.size())>=t) ub=m;
        else lb=m;
    }
    return ub;
}

int upper_bound(const string& s,const vector<int>& sa,const string t){
    int lb=0,ub=sa.size();
    while(ub-lb>1){
        int m=(lb+ub)/2;
        if(s.substr(sa[m],t.size())>t) ub=m;
        else lb=m;
    }
    return ub;
}

void solve(){
    string S;
    int q;
    cin >> S >> q;
    auto sa=suffix_array(S);
    rep(i,0,q){
        string T;
        cin >> T;
        if(upper_bound(S,sa,T)-lower_bound(S,sa,T)>=1) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 15840
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int N, Q;
	string S;

	cin >> N >> Q;
	cin >> S;

	vector<int> l(Q), r(Q);
	for (int i = 0; i < Q; i++)
	{
		cin >> l[i] >> r[i];
	}


	vector<int> sum(N + 1, 0);

	for (int i = 0; i < N - 1; i++)
	{
		sum[i + 1] = sum[i];
		if (S[i] == 'A' && S[i + 1] == 'C') {
			sum[i + 1]++;
		}
	}


	for (int i = 0; i < Q; i++)
	{
		int ans = sum[r[i] - 1] - sum[l[i] - 1];
		cout << ans << endl;
	}
}



Measured memory_bytes: 2176
n = gets.to_i
lines = gets.split.map(&:to_i)

sorted_lines = lines.sort

answer = 0

(0...n - 2).each do |a|
  (a + 1...n - 1).each do |b|
    max = sorted_lines[a] + sorted_lines[b] - 1
    over_index = sorted_lines.bsearch_index { |c| c > max }

    if over_index
      answer += over_index - b - 1
    else
      answer += n - b - 1
    end
  end
end

puts answer


Measured memory_bytes: 14404
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
Point a[50];
int main(){
	cout << fixed << setprecision(10);
	int n; cin >> n;
	rep(i, n) {
		ld x, y; cin >> x >> y;
		a[i] = { x,y };
	}
	bool out = true;
	Point ans;
	if (n % 2)out = false;
	else {
		int d = n / 2;
		ans = a[0] + a[d];
		ans = { real(ans) / 2.0,imag(ans) / 2.0 };
		rep(i, d) {
			Point mid = a[i] + a[i + d];
			mid = { real(mid) / 2.0,imag(mid) / 2.0 };
			if (abs(mid - ans) > eps)out = false;
		}
	}
	if (!out) {
		cout << "NA" << endl;
	}
	else {
		cout << real(ans) << " " << imag(ans) << endl;
	}
	return 0;
}


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


int main() {
    int N;
    cin >> N;
    vector<int> num(0);
    rep(i,N){
        num.push_back(i+1);
    }
    vector<int> P(N),Q(N);
    rep(i,N){
        cin >> P[i];
    }
    rep(i,N){
        cin >> Q[i];
    }
    int cnt = 0;
    int numP = 0,numQ = 0;
    do{
        cnt++;
        if(num==P){
            numP = cnt;
        }
        if(num==Q){
            numQ = cnt;
        }
    }while(next_permutation(num.begin(),num.end()));
    cout << abs(numP-numQ) << endl;

    return 0;
}

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

int main() {
  string S;
  cin >> S;
 
  vector<char> s(S.size());
  for (int i = 0; i < S.size(); i++) {
    s.at(i) = S.at(i);
  }
  
  int w = 0;
  for (int i = 0; i < S.size(); i++) {
    if (s.at(i) == 'W'){
      w++;
    }
  }
  int n = 0;
  for (int i = 0; i < S.size(); i++) {
    if (s.at(i) == 'N'){
      n++;
    }
  }
  int s1 = 0;
  for (int i = 0; i < S.size(); i++) {
    if (s.at(i) == 'S'){
      s1++;
    }
  }
  int e = 0;
  for (int i = S.size()-1; i >= 0; i--) {
    if (s.at(i) == 'E'){
      e++;
    }
  }
  if (w > 0 && e == 0){
    cout << "No" << endl;
  }
  else if (w == 0 && e > 0){
    cout << "No" << endl;
  }
  else if (s1 > 0 && n == 0){
    cout << "No" << endl;
  }
  else if (s1 == 0 && n > 0){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}
      

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

template<typename T>
vector<T> eratosthenes(T n) {
	vector<T> ret;
	vector<bool> v;
	v.reserve(n + 1);
	for (T i = 0; i < n + 1; ++i)v.push_back(true);
	ret.push_back(2);
	for (T i = 2; i <= n; i += 2) v[i] = false;
	for (T i = 3; i <= n; ++i) {
		if (v[i]) {
			ret.push_back(i);
			for (T j = i; j <= n; j += i) v[j] = false;
		}
	}
	return ret;
}

vector<ll> primes = eratosthenes<ll>(1e3);

template<typename T>
map<T, T> prime_fact(T n) {
	map<T, T> ret;
	for (T prime : primes) {
		while (n % prime == 0) {
			n /= prime;
			++ret[prime];
		}
		if (n == 1) break;
	}
	if (n != 1)++ret[n];
	return ret;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	map<ll, ll> m;
	for (ll i = 0; i < n; ++i)cin >> a[i];
	sort(a.begin(), a.end());
	bool flag_p = true;
	bool flag_s = true;
	for (ll i = 0; i < n; ++i) {
		auto mi = prime_fact(a[i]);
		for (auto p : mi)++m[p.first];
	}
	for (auto p : m) {
		if (p.second > 1)flag_p = false;
		if (p.second == n)flag_s = false;
	}
	if (flag_p) {
		cout << "pairwise coprime" << endl;
	}
	else if (flag_s) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
}


Measured memory_bytes: 15896
//code by: @thesagniksaha
    #include<bits/stdc++.h>
    #include "chrono"
    #include "random"

    #define ll long long int
    #define mkp make_pair
    #define pb push_back
    #define ff first
    #define ss second
    #define makefast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define rep(i,n) for(int i=0;i<n;i++)
    #define repre(i,a,b)for(int i=a;i<=b;i++)
    #define clr1(arr) memset(arr,-1,sizeof(arr));
    #define clr0(arr) memset(arr,0,sizeof(arr));

    using namespace std;

    int main()
    {
        makefast
        ll a, b, c, d; cin >> a >> b >> c >> d;
        ll e, g, k;
        e = max(a,b); g = max(c,d);
        if(a>0 && b>0 && c>0 && d>0) cout << e*g << endl;
        else{
        k = max(max(a*c, b*c), max(a*d, b*d));
        cout << k << endl;}
        return 0;
    }


Measured memory_bytes: 3644
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque
n,m=map(int,input().split())
s=input()
A=[0]*n
B=[0]*n
Edges=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if a==b:
        if s[a]=='A':
            A[a]+=1
        else:
            B[a]+=1
    else:
        Edges[a].append(b)
        Edges[b].append(a)
        if s[a]=='A':
            A[b]+=1
        else:
            B[b]+=1
        if s[b]=='A':
            A[a]+=1
        else:
            B[a]+=1
Del=[False]*n
q=deque()
for i in range(n):
    if A[i]*B[i]==0:
        q.append(i)
        Del[i]=True
while q:
    u=q.pop()
    l=s[u]
    for v in Edges[u]:
        if Del[v]:
            continue
        if l=='A':
            A[v]-=1
        else:
            B[v]-=1
        if A[v]*B[v]==0:
            q.append(v)
            Del[v]=True
print('No' if sum(Del)==n else 'Yes')

Measured memory_bytes: 78028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(),(a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main() {
    int N,v; cin>>N;
    ULL ans=0;
    vector<ULL> A(N,0),B(N,0),C(N,0);
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];
    rep(i,N)cin>>C[i];

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    rep(i,N){
        auto ite1 = lower_bound(ALL(A), B[i]);
        auto ite2 = upper_bound(ALL(C), B[i]);
        ans+=(ite1-A.begin())*(C.end()-ite2);
    }
    c(ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int64_t A, B, C, D;
    cin >> A >> B >> C >> D;
    while (A > 0 && C > 0) {
        C = C - B;
        if (0 >= C) {
            break;
        }

        A = A - D;
        if (0 >= A) {
            break;
        }
    }

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

    return 0;
}

Measured memory_bytes: 3596
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            int kazu = 0;

            for (int c = 0; c < 3; c++)
            {
                if(a[c] == b[c])
                {
                    kazu++;
                }
            }
            Console.WriteLine(kazu);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#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'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  outl("2018" + s.substr(4, s.size()));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main()
{
	char N[10];
	scanf("%s", N);

	int i, j, k;
	int n;
	for (i = 0, n = 0; i < strlen(N); i++) {
		char tmp[2];
		tmp[0] = N[i];
		tmp[1] = '\0';
		n += atoi(tmp);
	}

	printf(atoi(N) % n == 0 ? "Yes\n" : "No\n");

	return 0;
}


Measured memory_bytes: 128