akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <utility>
#include <cmath>
#include <iomanip>
using P = pair<ll, ll>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> point(n);
    REP(i, 0, n) {
        cin >> point[i].first >> point[i].second;
    }
    sort(point.begin(), point.end(), [&](P p1, P p2) {
        //return (p1.first * p2.second - p2.first * p1.second) > 0;
        return atan2(p1.second, p1.first) < atan2(p2.second, p2.first);
    });
    double ans = 0.0;
    REP(i, 0, n) {
        ll x = 0, y = 0;
        REP(j, 0, n) {
            int index = (i + j) % n;
            x += point[index].first;
            y += point[index].second;
            chmax(ans, hypot(x, y));
        }
    }
    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <array>
#include <climits>
#include <iostream>
using namespace std;

const int D = 10, P = 100, C = 1E6;
array<int, D+1> p, c;
array<array<long long, D*P+1>, D+1> f;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  int d, g; cin >> d >> g; int res = INT_MAX;
  for (int i = 1; i <= d; ++i) cin >> p[i] >> c[i];
  for (int i = 1, prev = 0, cnt = p[i]; i <= d; prev = cnt, cnt += p[++i])
    for (int j = 1; j <= cnt; ++j)
      for (int x = max(j - prev, 0), lim = min(p[i], j); x <= lim; ++x)
        if ((f[i][j] = max(f[i][j], f[i-1][j-x] + (100*i*x + (x == p[i] ? c[i] : 0)))) >= g)
          res = min(res, j);
#ifdef _DEBUG
  for (int i = 0, cnt = p[i]; i <= d; cnt += p[++i], cout << '\n')
    for (int j = 0; j <= cnt; ++j, cout << '\t')
      cout << f[i][j];
#endif
  cout << res;
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
 
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
 
int n;
vector<int> g[202020];
bool fav[202020];
int far[202020];
int second_farthest[202020];
int closest[202020];
bool in_fav[202020];
long long ans = 0;
 
static const int INF = 0x3f3f3f3f;
 
void dfs1(int v, int prev) {
        if (fav[v]) in_fav[v] = true;
        for (auto u : g[v]) if (u != prev) {
                dfs1(u, v);
                in_fav[v] |= in_fav[u];
                far[v] = max(far[v], far[u] + 1);
        }
}
 
void dfs2(int v, int ma, bool par_fav, int prev) {
        vector<pair<pii, bool>> children;
        children.emplace_back(mp(mp(0, -1), false));
        for (auto u : g[v]) {
                if (u == prev) children.emplace_back(mp(mp(ma + 1, u), par_fav));
                else children.emplace_back(mp(mp(far[u] + 1, u), in_fav[u]));
        }
        vector<int> fav_children;
        for (auto c : children) if (c.second) fav_children.emplace_back(c.first.first);
        closest[v] = INF;
        for (int i = 0; i < fav_children.size(); i ++) closest[v] = min(closest[v], fav_children[i]);
        sort(all(children), greater<pair<pii, bool>>());
        second_farthest[v] = children[1].first.first;
        for (auto u : g[v]) if (u != prev) { 
                int maa = children[u == children[0].first.second ? 1 : 0].first.first;
                bool par_f = fav[v] || par_fav;
                if (!in_fav[u]) par_f |= !fav_children.empty();
                else par_f |= fav_children.size() > 1;
                ans += (maa < far[u] && par_f) || (maa > far[u] && in_fav[u]) || (maa == far[u] && (par_f || in_fav[u]));
                dfs2(u, maa, par_f, v);
        }
}
 
int main() {
        cin >> n;
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].emplace_back(b);
                g[b].emplace_back(a);
        }
        string s;
        cin >> s;                                            
        for (int i = 0; i < n; i ++) fav[i] = s[i] == '1' ? true : false;
        dfs1(0, -1);
        dfs2(0, 0, fav[0], -1);
        for (int i = 0; i < n; i ++) {
                if (fav[i]) ans += 1 + second_farthest[i];
                else ans += max(0, 1 + (second_farthest[i] - closest[i]));
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 54660
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
#include <string>
#include <algorithm>
using namespace std;

int main(){
string data;
string d;
int m;
int h[100];

while(1){

cin >> data >> m;
if(data == "-")break;

for(int i = 0; i < m; i++){
  cin >> h[i];
  d = data.substr(0, h[i]);
  data.insert( data.length(), d );  
  data.erase(0, h[i]);
}
cout << data <<endl;
data.clear();
}
return 0;
}


Measured memory_bytes: 3224
fun main(args: Array<String>){
    var count = 0
    val r = readLine()!!.toInt()
    val s = readLine()!!.split("").filter { it != ""}
    var result = "No"
    if (r % 2 == 0) {
        if (s.size == r) {
            var a = 0
            for (i in a..r / 2 - 1) {
                if (s[i] != s[r / 2 + i]) {
                    count++
                }
            }
            if (count == 0) {
                println("Yes")
                return
            }
        }
    }
    println(result)
}

Measured memory_bytes: 37864
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
   vector<int>a(3);
  REP(i,3)cin>>a[i];
  SORT(a);
cout <<a[2]-a[0];  
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
graph = [0] + [[] for _ in range(n)]
for _ in range(m):
    n1, n2 = map(int, input().split())
    graph[n1].append(n2)
    graph[n2].append(n1)

from collections import deque

def bfs(graph, queue, dist):
    while queue:
        current = queue.popleft()

        for _next in graph[current]:
            if dist[_next] != -1:
                continue
            else:
                dist[_next] = dist[current] + 1
                queue.append(_next)

dist = [0] + [-1] * n
part = 0
for i in range(1, n + 1):
    if dist[i] != -1:
        continue
    else:
        queue = deque([i])
        dist[i] = 0
        bfs(graph, queue, dist)
        part += 1
print(part - 1)


Measured memory_bytes: 83012
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    s = 0
    r = 0
    res = 0
    for l in range(N):
        while N > r:
            if s & A[r] != 0: break
            s += A[r]
            r += 1

        s -= A[l]
        res += r - l

    print(res)
if __name__ == '__main__':
    main()

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

int main() 
{
  int n;
  cin>>n;
  double a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  double sum=(a[0]+a[1])/2;
  for(int i=2;i<n;i++)
  {
    sum=(sum+a[i])/2;
  }

  cout<<sum;
  return 0;
}
  

Measured memory_bytes: 256
from itertools import accumulate


def solve():
    N, *A = map(int, open(0).read().split())
    
    ans, l = 0, 0
    sum_lr, xor, length = 0, 0, 0
    for r in range(N):
        sum_lr += A[r]
        xor ^= A[r]
        length += 1
        while sum_lr != xor:
            sum_lr -= A[l]
            xor ^= A[l]
            l += 1
            length -= 1
        ans += length
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 24540
from sys import stdin
n = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in range(0,n-2):
    #print(data[i:i+3])
    if sorted(data[i:i+3])[1] == data[i+1]:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;;i++)
    {
        sum+=i;
        if(sum>=n)
        {
            cout<<i<<endl;
            return 0;
        }
    }
  system("pause");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>

#define rep(i,n) REP(i,0,n)
#define REP(i,a,n) for(int i = a; i < (int)n; i++)
#define pb push_back
#define NIF le9

using namespace std;

struct Node{
  int data;
  Node *parent,*left,*right;
};

Node *root;

void insert(int a){
  Node *root_tmp = root;
  Node *elem;

  elem = (Node *)malloc(sizeof(Node));
  elem->data = a;
  elem->left = NULL;
  elem->right = NULL;

  Node *prev = NULL;

  while(root_tmp != NULL){
    prev = root_tmp;
    if(elem->data < root_tmp->data){
      root_tmp = root_tmp->left;
    }
    else {
      root_tmp = root_tmp->right;
    }
  }

  elem->parent = prev;

  if(elem->parent == NULL){
    root = elem;
  }
  else {
    if(elem->parent->data < elem->data){
      elem->parent->right = elem;
    }
    else {
      elem->parent->left = elem;
    }
  }
}

void preorder(Node *u){
  if(u == NULL) return;
  cout << " " << u->data;
  preorder(u->left);
  preorder(u->right);
}

void inorder(Node *u){
  if(u == NULL) return;
  inorder(u->left);
  cout << " " << u->data;
  inorder(u->right);
}

signed main(){
  int n;
  string command;
  int elem;

  cin >> n;
  rep(i,n){
    cin >> command;
    if(command == "insert"){
      cin >> elem;
      insert(elem);
    }
    else{
      inorder(root);
      cout << "\n";
      preorder(root);
      cout << "\n";
    }
  }
}
      
  
  



Measured memory_bytes: 26496
#include<stdio.h>

void swap(int *a,int *b)
{
	int tmp;
	tmp=*a;
	*a=*b;
	*b=tmp;
}

int main()
{
	int data[100];
	int count[100];
	int i,j,youso,tmp;
	
	for(i=0;i<100;i++)
	{
		count[i]=0;
	}
	i=0;
	while(scanf("%d",data+i)!=EOF)
	{
		i++;
	}

	youso=i;
	for(i=0;i<youso;i++)
	{
		tmp=data[i];
		for(j=i;j<youso;j++)
		{
			if(data[j]==tmp)count[j]++;
		}
	}

	for(i=0;i<youso-1;i++)
	{
		for(j=i+1;j>0;j--)
		{
			if(count[j-1]<count[j])
			{
				swap(data+j-1,data+j);
				swap(count+j-1,count+j);
			}
		}
	}

	youso=0;
	for(i=0;count[i]==count[0];i++)
	{
		youso++;
	}
	for(i=0;i<youso-1;i++)
	{
		for(j=i+1;j>0;j--)
		{
			if(data[j-1]>data[j])
			{
				swap(data+j-1,data+j);
				swap(count+j-1,count+j);
			}
		}
	}

	for(i=0;i<youso;i++)
	{
		printf("%d\n",data[i]);
	}
	return 0;
}

Measured memory_bytes: 0
flagY = 0
flagN = 0
a,b,c = [int(i) for i in input().split(" ")]
if a==7:
  if b==5 and c==5:
    flagY = 1
  else:
    flagN = 1
if b==7:
  if a==5 and c==5:
    flagY = 1
  else:
    flagN = 1
if c==7:
  if b==5 and a==5:
    flagY = 1
  else:
    flagN = 1
if flagY ==1:print("YES")
elif flagY == 0:print("NO")

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

int main(void) {
    long long A, B, N;
    cin >> N >> A >> B;
    if (A % 2 == B % 2) {
        cout << (B - A) / 2 << endl;
    } else {
        cout << min(A - 1, N - B) + (B - A - 1) / 2 + 1 << endl;
    }
    return 0;
}

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

int main() {  
    char c;
    cin >> c;

    if ( c == 'a' || c == 'i' || c == 'u'|| c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    
}

Measured memory_bytes: 256
q, h, s, d = map(int, input().split())
n = int(input())
m = 0
l = [q, min(q*2, h), min(q*4, h*2, s), min(q*8, h*4, s*2, d)]

m += (n // 2) * l[3] + (n % 2) * l[2]

print(int(m))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N, K;
double p[200001];
double sum[200001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> p[i];
    for(int i = 1; i <= N; i++) sum[i] = sum[i-1]+p[i-1];
    double ans = 0.0;
    for(int i = 0; i+K <= N; i++){
        double tmp = (sum[i+K]-sum[i]+K)/2.0;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	String st = scan.next();
	int a = Integer.parseInt(st);
	st = scan.next();
	int b = Integer.parseInt(st);

	if(a > b)
	    {System.out.println("a > b");
	    }
	else if(a < b)
	    {System.out.println("a < b");
	    }
	else System.out.println("a == b");
    }
}



Measured memory_bytes: 26132
a = input()
b = input()

days,home = [int(i) for i in a.split(" ")]
cost = [int(n) for n in b.split(" ")]
#print(days,home)
#print(cost)

validdate = int(days) - sum(cost)
if validdate >= 0:
    print(validdate)
else:
    print(-1)

Measured memory_bytes: 9904
#include<bits/stdc++.h>
using namespace std;
void func(vector<double>&p,double &sum,int n,int i,double mult){
	int sz=p.size();
	if(i==sz){if(n>=ceil(double(sz)/2.0)){sum+=mult;}return;}
	func(p,sum,n+1,i+1,mult*p[i]);
	func(p,sum,n,i+1,mult*(1-p[i]));
}
int main(){
	int n;cin>>n;
	vector<double>p;
	for(int i=0;i<n;i++){double x;cin>>x;p.push_back(x);}
	double sum=0.0;
	//func(p,sum,0,0,1);
	double dp[n+1][n+1];
	for(int i=0;i<n+1;i++){
		for(int j=0;j<n+1;j++){dp[i][j]=0;}
		//dp[0][i]=0;
	}
	dp[0][0]=1.0;
	for(int i=1;i<n+1;i++){
		for(int j=0;j<=i;j++){
			if(j==0){dp[i][j]=dp[i-1][j]*(1.0-p[i-1]);}
			else{dp[i][j]=dp[i-1][j]*(1.0-p[i-1])+dp[i-1][j-1]*p[i-1];}
		}
	}
	for(int i=ceil(double(n)/2.0);i<n+1;i++){
		sum+=dp[n][i];
	}
	cout.precision(16);
	cout<<sum<<endl;
}


Measured memory_bytes: 70656
n = int(input())
a = list(map(int, input().split()))
def tat(t,a,n):
  ans = 0
  ssu = 0
  for x in a:
    ssu += x
    if ssu*t <= 0:
      ans += abs(ssu-t)
      ssu = t
    t *= -1
  return ans
print(min(tat(1,a,n),tat(-1,a,n)))

Measured memory_bytes: 14332
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	int a,b,k;
    	
    	a = in.nextInt();
    	b = in.nextInt();
    	k = in.nextInt();
    	
//    	int div = Math.abs(a-b);
//    	if (div == 0) {
//    		div = a;
//    	}
    	int counter = 0;
    	
    	for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    	
    }

  }


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

int main(){
    string S;
    cin>>S;
    long long int now=1;
    long long int cnt=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='W'){
            cnt+=i+1-now;
            now++;
        }
    }
    
    cout<<cnt<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        System.out.println(solve(N, K));

        sc.close();
    }

    static long solve(int N, int K) {
        int[] counts = new int[K];
        for (int i = 1; i <= N; ++i) {
            ++counts[i % K];
        }

        return computeTripleNum(counts[0]) + ((K % 2 == 0) ? computeTripleNum(counts[K / 2]) : 0);
    }

    static long computeTripleNum(int count) {
        return (long) count * count * count;
    }
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if((a+b) < (c+d)){
    cout << "Right" << endl;
  }
  else if((a+b) > (c+d)){
    cout << "Left" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
x,y,a,b,c = map(int,input().split())
lst_r = list(map(int,input().split()))
lst_g = list(map(int,input().split()))
lst_n = list(map(int,input().split()))
lst_r = sorted(lst_r, reverse=True)[:x]
lst_g = sorted(lst_g, reverse=True)[:y]
lst_all = sorted(lst_r + lst_g + lst_n, reverse=True)[:x+y]
print(sum(lst_all))

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N;
vec<int> b;

signed main() {
  cin >> N;
  b.resize(N);
  rep (i, N) {
    cin >> b[i];
  }

  vec<int> ans;

  for (int i = 0; i < N; i++) {
    bool ok = false;
    for (int j = b.size()-1; j >= 0; j--) {
      if (b[j] == j+1) {
        ok = true;
        ans.push_back(b[j]);
        b.erase(b.begin() + j);
        break;
      }
    }
    if (!ok) {
      cout << -1 << endl;
      return 0;
    }
  }

  reverse(all(ans));
  rep (i, N) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a = 0;
int b = 0;
int c = 0;
int k = 0;

int sum = 0;

scanf("%d %d %d %d", &a, &b, &c, &k);

if(k - a > 0){
    sum = a;
    if((k - a - b) > 0){
        sum = sum - (k - a - b);
    }
}else {
    sum = k;
}

printf("%d", sum);

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n;
ll a[101010],b[101010],c[101010];
ll sa,sb;

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

  ll cnt1=0,cnt2=0;
  rep(i,n){
    c[i]=b[i]-a[i];
    if(c[i]>0)cnt1+=c[i]/2;
    if(c[i]<0)cnt2+=-c[i];
  }
  if(cnt1>=cnt2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 512
n,k=map(int, input().split())
ad=[list(map(int,input().split()))  for _ in range(k*2)]
d=[]
a=[]
ans=0
kashi=[1 for _ in range(n)]

for i in range(0,len(ad),2):
    d.append(ad[i])
for j in range(1,len(ad),2):
    a.append(ad[j])

for i in range(len(a)):
    for j in range(len(a[i])):
        kashi[a[i][j]-1]=0

ans=sum(kashi)
print(ans)

Measured memory_bytes: 67876
#include<stdio.h>

int main(void)
{
    int ball[10];
    int i,j,n,N,b,c,flag;

    scanf("%d",&N);
    for(n=0;n<N;n++){

        flag=0;
        b=11;
        c=11;

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

        for(i=9;i>=0;i--){
            if(b>ball[i]){
                b=ball[i];
            } else if(c>ball[i]){
                c=ball[i];
            } else {
                printf("NO\n");
                flag=1;
                break;
            }
        }
        if(flag) continue;

        printf("YES\n");
    }
    return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define X first
#define Y second
 
using namespace std;
typedef long long llint;
 
const int maxn = 2e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int d, t, s;
int main() {
	cin >> d >> t >> s;
	if ((d + s - 1) / s <= t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3640
n = int(input())
data = []
dp = [[0 for i in range(3)] for j in range(n)]
for i in range(n):
    data.append(list(map(int, input().split())))
dp[0][0] = data[0][0]
dp[0][1] = data[0][1]
dp[0][2] = data[0][2]
for i in range(1, n):
    for j in range(3):
        k = {j}
        set = {0, 1, 2} - k
        dp[i][j] = data[i][j] + max(dp[i - 1][k] for k in list(set))
print(max(dp[n - 1]))


Measured memory_bytes: 51956
from collections import Counter


N = int(input())
C = input()
C_cntr = Counter(C)

all_R_cnt = 0
all_W_cnt = 0
R_W_cnt = 0
for i in range(N):
    if C[i] == "W":
        all_R_cnt += 1
    elif C[i] == "R":
        all_W_cnt += 1
    if i < C_cntr.get("R", 0) and C[i] == "W":
        R_W_cnt += 1

print(min(all_R_cnt, all_W_cnt, R_W_cnt))


Measured memory_bytes: 9764
import sys
input = sys.stdin.readline

k,n = map(int,input().split())
a = list(map(int,input().split()))

ma = 0

for i in range(1,n):
    if a[i]-a[i-1] > ma:
        ma = a[i]-a[i-1]
if a[0]+k-a[-1] > ma:
    ma = a[0] + k - a[-1]
print(k-ma)


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

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

    int cnt = 0;
    int max_cnt = 0;

    for(int i=0; i<3; i++){
        if(str[i]=='R'){
            cnt++;
            if(max_cnt < cnt){
                max_cnt = cnt;
            }
        }
        else
            cnt = 0;
    }
    cout << max_cnt << endl;
}


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

 public:
  int find(int x) {
    if (parent[x] != x) {
      parent[x] = find(parent[x]);
    }
    return parent[x];
  }

  UnionFindTree(int size) {
    parent = vector<int>(size);
    rank = vector<int>(size, 0);
    for (int i = 0; i < size; i++) parent[i] = i;
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
      parent[x] = y;
    } else {
      parent[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }
};

int N, M;

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

  UnionFindTree t(N);

  rep(i, M) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    t.unite(x, y);
  }

  set<int> s;
  rep(i, N) s.insert(t.find(i));

  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int main() {
	int H, W, c[10][10], A[200][200];
	int d[10][10],ans;

	scanf("%d %d", &H, &W);
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			scanf("%d", &c[i][j]);
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			scanf("%d", &A[i][j]);
		}
	}

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			d[i][j] = c[i][j];
		}
	}

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				if (d[j][k] > d[j][i] + d[i][k])
					d[j][k] = d[j][i] + d[i][k];
			}
		}
	}
	ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A[i][j] > -1) { ans = ans + d[A[i][j]][1]; }
		}
	}

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


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int a,b,i,n,t=0;
    string s;
    cin>>a>>b;
    cin>>s;
    n= s.size();
    if((n==(a+b+1)) && (s[a]=='-') )
    {
        for(i=0;i<n;i++)
        {
            if(i==a)
            {continue;}
            if(s[i]=='0'||s[i]=='1'||s[i]=='2'||s[i]=='3'||s[i]=='4'||s[i]=='5'||s[i]=='6'||s[i]=='7'||s[i]=='8'||s[i]=='9')
                t++;
        }
        if(t==(n-1))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

#define debug(x) cout << #x << "::" << x << endl;
#define debug2(x, y) cout << #x << "::" << x << " " << #y << "::" << y << endl;
#define debug3(x, y, z) cout << #x << "::" << x << " " << #y << "::" << y <<" "<< #z << "::" << z << endl;

#define For(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
const ll mod = 1e9 + 7;
const int MAX = 5 * 1e3 + 5;
typedef pair<int, int> pii;

void add(ll &a, ll b)
{
    a = (a + b) % mod;
    if (a < 0) a += mod;
}

int main() {

    int r,c;
    cin>>r>>c;

    vector<string> v(r);

    For(i,0,r) cin>>v[i];

    vector<vector<ll>> dp(r,vector<ll>(c));
    
    for(int i=r-1;i>=0;i--){
        if(v[i][c-1] == '.') dp[i][c-1] = 1;
        else break;
    }

    for(int j=c-1;j>=0;j--){
        if(v[r-1][j] == '.') dp[r-1][j] = 1;
        else break;
    }

    for(int i=r-2;i>=0;i--){
        for(int j=c-2;j>=0;j--){
            if(v[i][j] == '.'){
                add(dp[i][j],dp[i+1][j]);
                add(dp[i][j],dp[i][j+1]);
            }
        }
    }

    cout<<dp[0][0]<<endl;
    
    return 0;

}

Measured memory_bytes: 9216
import numpy as np
N,K = map(int,input().split())
H = np.array(list(map(int,input().split())))
dp = np.zeros(N,dtype=int)

for i in range(1,N):
  x = max(0,i-K)
  dp[i] = np.min(dp[x:i] + abs(H[x:i] - H[i]))

print(dp[-1])


Measured memory_bytes: 22780
#include <iostream>
#include <set>
using namespace std;
#define rep(i, b) for (int i = 0; i < int(b); i++)

int main(){
    int n;
    while (cin >> n, n){
        set<int> know[100];
        rep(i, n){
            int m; cin >> m;
            rep(j, m){
                int t; cin >> t;
                t--;
                know[i].insert(t);
            }
        }

        int k; cin >> k;
        bool bad[100] = {};
        rep(i, k){
            int t; cin >> t;
            t--;
            rep(j, n){
                if (know[j].count(t) == 0) bad[j] = true;
            }
        }
        int ans;
        int c = 0;
        rep(i, n){
            if (!bad[i]){
                ans = i + 1;
                c++;
            }
        }
        if (c == 1) cout << ans;
        else cout << -1;
        cout << endl;
    }
}

Measured memory_bytes: 1620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int a=0,b=0,c=0,n, m, k = 0;
	int str[5],str2[5];
	
	scanf("%d%d%d", &str[0],&str[1],&str[2]);
	
	if (str[0] == str[1]) { printf("%d", str[2]); }
	else if (str[0] == str[2]) { printf("%d", str[1]); }
	else{ printf("%d", str[0]); }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdint.h>
using namespace std;

int main()
{
    char result[20];
    int count = 0;
    while (true)
    {
        char N;
        cin >> N;
        if (std::cin.eof())
        {
            break;
        }

        switch (N)
        {
        case '0':
        case '1':
            result[count] = N;
            ++count;
            break;
        case 'B':
            count = max(--count, 0);
            break;
        }
    }
    result[count] = 0;
    cout << result << endl;

    return 0;
}

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

int main(){
	char a[3];
	int okane=700;
	scanf("%s\n",&a);
	for (int i = 0; i < 3;i++) {
		if (a[i] == 'o') {
			okane = okane + 100;
		}
	}
	printf("%d\n",okane);
	return 0;
}

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

using namespace std;

int n , k;
void work () {
	scanf ( "%d%d" , &n , &k );
	if ( k * 2 - 1 <= n ) printf ( "YES\n" );
	else printf ( "NO\n" );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if((a*b) % 2 == 0)
    cout << "Even" << endl;
  else
    cout << "Odd" << endl;
  return 0;
}


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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    rep(i,n) cin>>p[i], p[i]++;
    int sum[n+1];
    sum[0] = 0;
    rep(i,n) sum[i+1] = p[i] +sum[i];
    int ans = 0;
    rep(i,n-k+1){
        ans = max(sum[i+k] -sum[i], ans);
    }
    cout << fixed << setprecision(10) << (double)(ans)/2.0 << endl;
    return 0;
}


Measured memory_bytes: 1920
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = II()
    x = LI()
    xb = x[::1]
    xb.sort()
    a = xb[n // 2 - 1]
    b = xb[n // 2]
    for i in range(n):
        if x[i] <= a:
            print(b)
        elif x[i] >= b:
            print(a)
        
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 27524
#include <bits/stdc++.h>
const int kN = 1e5+10;
struct Node {
	int x, y;
	char s[5];
}a[kN];
int cnt[2][3000];
int main() {
	// freopen("test.in", "r", stdin);
	int n, k; scanf("%d %d", &n, &k);
	int mini = 1e9+10, ind;
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d %s", &a[i].x, &a[i].y, a[i].s+1);
		if (a[i].x < mini) {
			mini = a[i].x; ind = i;
		}
	}
	// std::cerr << ind << std::endl;
	int ans = 0;
	for (int j = 1; j <= k; ++j) {
		memset(cnt, 0, sizeof(cnt));
		for (int i = 1; i <= n; ++i) {
			int dx = (a[i].x-a[ind].x)%(2*k);
			if (a[i].y > a[ind].y) {
				int dy = (a[i].y-(a[ind].y-j+1))%(2*k);
				if (dy < k) cnt[(a[i].s[1] == 'W')?0:1][dx]++;
				else cnt[(a[i].s[1] == 'W')?0:1][(dx+k)%(2*k)]++;
			} else {
				int dy = (a[ind].y+2*k-j-a[i].y)%(2*k);
				if (dy < k) cnt[(a[i].s[1] == 'W')?0:1][(dx+k)%(2*k)]++;
				else cnt[(a[i].s[1] == 'W')?0:1][dx]++;
			}
		}
		// for (int i = 0; i < 2*k; ++i) {
		// 	printf("%d ", cnt[0][i]);
		// }
		// printf("\n");
		// for (int i = 0; i < 2*k; ++i) {
		// 	printf("%d ", cnt[1][i]);
		// }
		// printf("\n");
		for (int i = 1; i < 2*k; ++i) cnt[0][i] += cnt[0][i-1], cnt[1][i] += cnt[1][i-1];
		for (int i = 0; i < k; ++i) {
			int size = 0;
			size += cnt[0][i+k-1]-((i == 0)?0:cnt[0][i-1]);
			if (i != 0) size += cnt[1][i-1];
			size += cnt[1][2*k-1]-cnt[1][i+k-1];
			size = std::max(size, n-size);
			ans = std::max(ans, size);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll m,v,a[100009];int n,p;
bool check(ll x){
	if(a[n-p+1]>x+m) return 0;
	ll sum=m*v-(p-1)*m;
	for(int i=1;i<=n-p+1;i++){
		ll t=x+m-a[i];
		if(t<=0) break;
		sum-=min(t,m);
		if(sum<=0) return 1;
	}
	if(sum>0) return 0;
	return 1;
}
int main() {
	scanf("%d%lld%lld%d",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	int l=1,r=n,ans;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(a[mid])) r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%d\n",n-ans+1);
	return 0;
}

Measured memory_bytes: 4560
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class B {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        int N;
        int K;
        int[] h;
        Input(out N, out K);
        InputArray(out h);
        int[] min = new int[N];
        min[0] = 0;
        for(int i = 1; i < N; i++) {
            int _min = int.MaxValue;
            for(int k = 1; k <= K && k <= i; k++) {
                int cost = Math.Abs(h[i - k] - h[i]) + min[i - k];
                if(cost < _min) {
                    _min = cost;
                }
            }
            min[i] = _min;
        }
        Print(min[N - 1]);
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 27868
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,ans=0,R;
  cin>>R;
  printf("%.12f",R*2.0*PI);
}


Measured memory_bytes: 3772
def comb(n, k, mod=10**9 + 7):
    from functools import reduce
    from operator import mul
    k = min(k, n - k)

    def calc(x, y):
        return x * y % mod

    x = reduce(calc, range(n - k + 1, n + 1), 1) % mod
    y = reduce(calc, range(1, k + 1), 1) % mod
    return x * pow(y, mod - 2, mod) % mod


def solve(string):
    n, m, k = map(int, string.split())
    mod = 10**9 + 7
    base = n * m * (n + m) * (n * m - 1) // 6 % mod
    return str(base * comb(n * m - 2, k - 2) % mod)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int n;vector<int>v;
int dp[100005];
int ans(int i){
	if(i>=n)return 2e9;
	if(i==n-2)return abs(v[i]-v[n-1]);
	if(i==n-3)return abs(v[i]-v[n-1]);
int &ret=dp[i];
	if(ret!=2e9)return ret;
	ret = min(ret,ans(i+1)+abs(v[i]-v[i+1]));
	ret = min(ret,ans(i+2)+abs(v[i]-v[i+2]));
	return ret;
}
int main() {
	cin>>n;
v.resize(n+1);
fill(dp,dp+n+1,2e9);
for(auto &t:v)cin>>t;
cout<<ans(0)<<endl;
return 0;
}

Measured memory_bytes: 4096
from fractions import gcd
N,K=map(int,input().split())
A=sorted(map(int,input().split()))

if A[-1]<K:
  print("IMPOSSIBLE")
  exit()
  
g=A[0]
for i in range(1,N):
  g=gcd(g,A[i])
  
if (A[-1]-K)%g==0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 16240
#include <bits/stdc++.h>
using namespace std;
#define fori(i, a, b) for(int i = (int) a; i <= (int) b; ++i)
#define rofi(i, b, a) for(int i = (int) b; i >= (int) a; --i)
#define foreach(tt, a) for(auto &tt: a)
#define all(a) begin(a), end(a)
#define csz(a) (int) a.size()
#define pb push_back
#define epb emplace_back
#define mp make_pair
#define load(a, v) fill(begin(a), end(a), v)
#define load_mem(a, v) memset(a, v, sizeof(a));
#define iostream_optimize() ios::sync_with_stdio(false); cin.tie(0);
using ll = long long;
const ll MOD = 1e9+7, LINF = 1e16+1;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const ll P1 = 31, P2 = 37, M1 = 1e9+7, M2 = 1e9+9;

// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<< END TEMPLATE >>>>>>>>>>>>>>>>>>>>>>>>>>> */

int main() {
	iostream_optimize();
	int n;
	string s;
	cin >> n >> s;
	vector<int> pref(n), suff(n);
	fori(i, 0, n-1) {
		pref[i] = (i ? pref[i-1] : 0) + (s[i] != 'E');
	}
	rofi(i, n-1, 0) {
		suff[i] = (i < n-1 ? suff[i+1] : 0) + (s[i] != 'W');
	}
	int ans = INF;
	fori(i, 0, n-1) ans = min((i ? pref[i-1] : 0) + (i < n-1 ? suff[i+1] : 0), ans);
	cout << ans;
}

Measured memory_bytes: 2964
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (H, W) = (input[0], input[1])
var line = [String]()
for _ in 0..<H {
    line += [readLine()!]
}

print((0..<W+2).map{_ in "#"}.joinWithSeparator(""))
for i in 0..<H {
    print("#\(line[i])#")
}
print((0..<W+2).map{_ in "#"}.joinWithSeparator(""))


Measured memory_bytes: 1152
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

for cx in range(101):
    for cy in range(101):
        candidates = set()
        for x, y, h in A:
            h += abs(x - cx) + abs(y - cy)
            candidates.add(h)
        for H in candidates:
            for x, y, h in A:
                if h != max(H - abs(x - cx) - abs(y - cy), 0):
                    break
            else:
                print(cx, cy, H)
                exit()

Measured memory_bytes: 75248
n = int(input())
a = list(map(int, input().split()))
ans = 'APPROVED'

aa = filter(lambda num: True if num % 2 == 0 else False, a)
for num in aa:
    if (num % 3 != 0) and (num % 5 != 0):
        ans = 'DENIED'

print(ans)


Measured memory_bytes: 38384
n,m,k = map(int, input().split())
al = list(map(int, input().split())) 
bl = list(map(int, input().split())) 

import itertools
al_su = list(itertools.accumulate(al))
bl_su = list(itertools.accumulate(bl))

import bisect
ka = bisect.bisect(al_su,k)

kc = 0

for i in range(ka):
    kk = k - al_su[i]
    kb = bisect.bisect(bl_su,kk)
    kc = max(kc,i+1+kb)

kb = bisect.bisect(bl_su,k)

for j in range(kb):
    kk = k - bl_su[j]
    ka = bisect.bisect(al_su,kk)
    kc = max(kc,j+1+ka)

print(kc)

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

int main() {
  int N;
  cin >> N;
  vector<int> l(N),r(N);
  for(int i=0;i<N;i++){
    cin >> l.at(i) >> r.at(i);
  }
  int sum = 0;
  for(int i=0;i<N;i++){
    sum += r.at(i)-l.at(i)+1;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256