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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,m;cin>>n>>m;
  vector<vector<int>>g(n), rg(n);
  vector<int> in_count(n);
  rep(i, n-1+m){
    int a,b; cin>>a>>b; a--;b--;
    g[a].push_back(b);
    rg[b].push_back(a);
    in_count[b]++;
  }

  vector<int> sorted_nodes;
  queue<int> count0;
  rep(i, n)if(in_count[i]==0)count0.push(i);
  int root = count0.front();
  while(count0.size()){
    int p = count0.front();count0.pop();
    sorted_nodes.push_back(p);
    for(auto c:g[p]){
      in_count[c]--;
      if(in_count[c]==0)count0.push(c);
    }
  }

  vector<int>parent(n);

  for(auto c:sorted_nodes){
    for(auto chi: g[c]){
      parent[chi]=c;
    }
  }

  parent[root]=-1;

  rep(i, n)cout<<parent[i]+1<<endl;

  return 0;
}


Measured memory_bytes: 15356
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;
using pli = pair<ll, int>;

ll dp[2020][2020];

int main(){
  int n;
  cin >> n;
  vector<pli> A;
  for(int i = 0; i < n; ++i){
  	int a;
  	cin >> a;
  	A.push_back({a, i});
  }

  fill((ll*)dp, (ll*)dp + sizeof(dp) / sizeof(ll), 0);
  sort(A.rbegin(), A.rend());

  ll ans = 0;
  for(int l = 0; l < n; ++l){
  	for(int r = 0; r < n; ++r){
  		if(l + r >= n){
  			ans = max(ans, dp[l][r]);
  			break;
  		}
  		int idx = A[l + r].second;
  		ll ac = A[l + r].first;
  		dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + ac * abs(idx - l));
  		dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + ac * abs(idx - (n - r - 1)));
  	}
  }

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


Measured memory_bytes: 35556
n = int(input())
# = map(int, input().split())
p = list(map(int, input().split()))
# = [int(input()) for _ in range()]
cnt = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
        cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
namespace io{
    const int L = (1 << 20) + 1;
     
    char buf[L], *S , *T, c;
      
    char getchar() {
        if(S == T) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }
     
    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;
         
        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;
         
        if(x)
            *--outs = x;
         
        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};
  
using io :: print;
using io :: inp;
using io :: inp_ll;
const int INF = 1e9 ;
const int maxN = 1e6 + 10; 

int main()
{
		
	int x,y;
	x = inp();
	y = inp();
	printf("%d\n",x + y/2);
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations as comb


def main():
    n, m = map(int, input().split())

    n_list = list(range(n))
    m_list = list(range(m))
    n_pair = list(comb(n_list, 2))
    m_pair = list(comb(m_list, 2))
    ans = len(n_pair) + len(m_pair)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3700
n = int(input())
H = list(map(int, input().split()))
C = [0] * n
C[1] = abs(H[0] - H [1])
for i in range(n-2):
  C[i+2] = min(C[i+1] + abs(H[i+2] - H[i+1]), C[i] + abs(H[i+2] - H[i]))
print(C[-1])

Measured memory_bytes: 52336
#include<stdio.h>
int main(){
  int n,m,q,i,j,d[510][510]={};
  int s[510][510]={};
  scanf("%d %d %d",&n,&m,&q);
  while(m--){
    scanf("%d %d",&i,&j);
    d[i][j]++;
  }
  for(i=505;i--;){
    for(j=1;j<505;j++)s[i][j]=d[i][j]-s[i+1][j-1]+s[i+1][j]+s[i][j-1];
  }
  while(q--){
    scanf("%d %d",&i,&j);
    printf("%d\n",s[i][j]);
  }
  return 0;
}


Measured memory_bytes: 2816
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s;
  cin >> s;

  int len = s.length();
  REP(i,len - 1){
    if(s[i] == 'S' && s[i + 1] == 'T'){
      s.erase(s.begin() + i); 
      s.erase(s.begin() + i); 
      //cout << s << endl;
      len -= 2;
      i -= 2;
    }
  }

  cout << len << "\n";
  return 0;
}



Measured memory_bytes: 640
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long
	int n;
	cin >> n;
	vector < tuple<long long,long long,long long>> input;
	REP(i, n) {
		int c, d;
		cin >> c >> d;
		input.push_back(make_tuple(c+d,c,d));
	}
	sort(input.begin(), input.end());
	reverse(input.begin(), input.end());
	long long ans = 0;
	for (int i = 0; i < input.size(); ++i) {
		if (i % 2 == 0) {
			ans += get<1>(input[i]);
		}
		else {
			ans -= get<2>(input[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
 {  ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
            int n;
            cin>>n;
            int a[n];
            ll s=0,ss=0,s2=0,ss2=0;
            for(int i=0;i<n;i++){
                cin>>a[i];
                 s+= a[i];
            }
            s /= n;
            s2 = s+1;
            for(int i=0;i<n;i++){
                ss += pow((a[i]-s),2);
                ss2 += pow((a[i]-s2),2);
            }
            cout<<min(ss,ss2)<<"\n";
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

ll gcd(ll a, ll b) { return a < b ? gcd(b, a) : b == 0 ? a : gcd(b, a % b); }

ll solve(const vector<ll> &A, int i, int N) {
  return i + 1 == N ? gcd(A[N - 2], A[N - 1]) : gcd(A[i], solve(A, i + 1, N));
}

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) { cin >> A[i]; }

  const ll answer = solve(A, 0, N);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		int d = a - b;

		System.out.println((c - d > 0) ? c - d : 0);
	}
}

Measured memory_bytes: 21972
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int T, X;
  std::cin >> T >> X;

  std::cout << static_cast<double>(T) / X << std::endl;
}


Measured memory_bytes: 256
#include <deque>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> dist(n, 1 << 30); dist[1] = 1;
	deque<int> que; que.push_back(1);
	while (!que.empty()) {
		int u = que.front(); que.pop_front();
		if (dist[u * 10 % n] > dist[u]) {
			dist[u * 10 % n] = dist[u];
			que.push_front(u * 10 % n);
		}
		if (dist[(u + 1 == n ? 0 : u + 1)] > dist[u] + 1) {
			dist[(u + 1 == n ? 0 : u + 1)] = dist[u] + 1;
			que.push_back(u + 1 == n ? 0 : u + 1);
		}
	}
	cout << dist[0] << '\n';
	return 0;
}

Measured memory_bytes: 896
N = int(input())
hon = '24579'
pon = '0168'
bon = '3'
n = str(N)[::-1]
for i in n:
    if i in hon:
        print ("hon")
        break
    if i in pon:
        print ("pon")
        break
    if i in bon:
        print ("bon")
        break

Measured memory_bytes: 9180
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef struct union_find {
  int32_t *parent;
  int32_t size;
} union_find;

void init_union_find (union_find * const u) {
  for (int32_t i = 0; i < u->size; ++i){
    u->parent[i] = -1;
  }
}

union_find* new_union_find (const int32_t size) {
  union_find * const u = (union_find *) calloc (1, sizeof (union_find));
  u->parent = (int32_t *) calloc (size, sizeof (int32_t));
  u->size = size;
  init_union_find (u);
  return u;
}

void free_union_find (union_find * const u) {
  free (u->parent);
  free (u);
}

int32_t root (union_find * const u, int32_t x) {
  int32_t index[32];
  int32_t top = 0;
  while (u->parent[x] >= 0) {
    index[top++] = x;
    x = u->parent[x];
  }
  while (top > 0) {
    u->parent[index[--top]] = x;
  }
  return x;
}

int same (union_find * const u, const int32_t x, const int32_t y) {
  return root (u, x) == root (u, y);
}

int32_t get_size (union_find * const u, const int32_t x) {
  return - (u->parent[root (u, x)]);
}

void unite (union_find * const u, int32_t x, int32_t y) {
  x = root (u, x);
  y = root (u, y);
  if (x == y) return;
  if (u->parent[x] > u->parent[y]) {
    const int32_t swap = x;
    x = y;
    y = swap;
  }
  u->parent[x] += u->parent[y];
  u->parent[y] = x;
}

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))
#define SORT(a,num,cmp) qsort((a),(num),sizeof(*(a)),cmp)

typedef struct point {
  i32 x, y;
} point;

int cmp_x (const void *a, const void *b) {
  i32 d = ((point *)a)->x - ((point *)b)->x;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

int cmp_y (const void *a, const void *b) {
  i32 d = ((point *)a)->y - ((point *)b)->y;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  const i32 m = 100001;
  point *p = ALLOC (n, point);
  for (i32 i = 0; i < n; ++i) {
    i32 x, y;
    scanf ("%" SCNi32 "%" SCNi32, &x, &y);
    p[i] = (point) {x, y};
  }
  SORT (p, n, cmp_x);
  union_find *uy = new_union_find (m);
  for (i32 i = 0; i < n;) {
    for (++i; i < n && p[i - 1].x == p[i].x; ++i) {
      unite (uy, p[i].y, p[i - 1].y);
    }
  }
  SORT (p, n, cmp_y);
  union_find *ux = new_union_find (m);
  for (i32 i = 0; i < n;) {
    for (++i; i < n && p[i - 1].y == p[i].y; ++i) {
      unite (ux, p[i].x, p[i - 1].x);
    }
  }
  i32 *used = ALLOC (m, i32);
  i64 ans = 0;
  for (i32 i = 0; i < n; ++i) {
    i32 r = root (ux, p[i].x);
    if (used[r]) continue;
    used[r] = 1;
    ans += (i64) get_size (ux, p[i].x) * get_size (uy, p[i].y);
  }
  ans -= n;
  printf ("%" PRIi64 "\n", ans);
}

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


Measured memory_bytes: 2160
n,a,b = map(int,input().split())
lis = [int(input()) for i in range(n)]
more = a-b

def tansaku(x):
  cou = 0
  normal = b * x
  for hp in lis:
    r = hp -normal
    if r <= 0:continue
    cou += r // more
    
    if r % more != 0:
      cou += 1
  return cou <= x

left = 1
right = max(lis)
while right - left > 1:
  mid = (right + left)//2
  if tansaku(mid):
    right = mid
  else:
    left = mid
print(right)


Measured memory_bytes: 50520
X, N = (int(i) for i in input().split())  
if N == 0:
  print(X)
  exit()
P = [int(i) for i in input().split()] 

d = 0

while True:
  num = X - d
  if num not in P:
    print(num)
    exit()
    
  num = X + d
  if num not in P:
    print(num)
    exit()
  
  d += 1

  

Measured memory_bytes: 9204
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a && c<=b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main(){
    bool t[10];
    int c1, c2, c3, temp;
    while(cin >> c1 >> c2 >> c3){
        for(int i = 0;i<10;i++){
            t[i] = false;
        }
        t[c1-1] = true;
        t[c2-1] = true;
        t[c3-1] = true;
        temp = 0;
        for(int i = 0;i<10;i++){
            if(!t[i] && (c1 + c2 + i + 1) <= 20){
                temp++;
            }
        }
        cout << ((temp >= 4) ? "YES" : "NO") << endl;
    }
    return 0;
}

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

using namespace std;

long long n, a[200005], pos[200005], it[800005], tmp;

void update(long long k, long long l, long long r, long long i){
    if(l > i || r < i) return;
    if(l == r){
        it[k] = min(it[k], a[i]);
        return;
    }
    long long m = (l + r) / 2;
    update(2 * k, l, m, i);
    update(2 * k + 1, m + 1, r, i);
    it[k] = min(it[2 * k], it[2 * k + 1]);
}

void get(long long k, long long l, long long r, long long u, long long v){
    if(l > v || r < u) return;
    if(u <= l && r <= v){
        tmp = min(tmp, it[k]);
        return;
    }
    long long m = (l + r) / 2;
    get(2 * k, l, m, u, v);
    get(2 * k + 1,m + 1, r, u, v);
}

long long tinh(long long x, long long y){
    if(x > y) return 0;
    if(x == y) return a[x];
    tmp = LONG_LONG_MAX;
    get(1, 1, n, x, y);
    long long vt = pos[tmp];
    long long kq = ((vt - x) * (y - vt) + (vt  - x) + (y - vt) + 1) * tmp;
    return kq + tinh(x, vt - 1) + tinh(vt + 1, y);
}

int main()
{
    cin >> n;
    for(long long i = 1; i <= 4 * n; i++) it[i] = LONG_LONG_MAX;
    for(long long i = 1; i <= n; i++){
        cin >> a[i];
        pos[a[i]] = i;
        update(1, 1, n, i);
    }
    cout << tinh(1, n);
}


Measured memory_bytes: 18944
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;


int main()
{
    int p, X, N;
    cin >> X >> N;

    vector<int> arr;

    for (int i = 0; i < N; i++) {
        cin >> p;
        arr.push_back(p);
    }

    
    int ans;
    int res = 103;
   
    for(int i=0;i<=101;i++){
            if (find(begin(arr), end(arr),i)==end(arr)) {
                if (res > abs(i - X)) {
                    res = abs(i - X);
                    ans = i;
                }
            }

        }

    cout << ans << endl;
    return 0;

    
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


using Graph = vector<vector<int>>;

int pos = -1;
stack<int> hist;

void dfs(int v, int p, vi &color , const Graph &G) {
    color[v] = 1;
    hist.push(v);
    for (auto nv : G[v]) {
        if (nv == p) continue; // 逆流禁止 有向グラフに対してはコメントアウトせよ
        if (color[nv] == 2) continue;
        if (color[nv] == 1) {
            pos = nv;
            return;
        }
        dfs(nv, v, color, G);
        if (pos != -1) return;
    }
    hist.pop();
    color[v] = 2;
}


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

    Graph G(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vi color(N, 0);
    pos = -1;
    dfs(0, -1, color, G);

    // サイクルを復元
    set<int> cycle;
    while (!hist.empty()) {
        int t = hist.top();
        cycle.insert(t);
        hist.pop();
        if (t == pos) break;
    }

    
    int Q; cin >> Q;
    for (int _ = 0; _ < Q; ++_) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (cycle.count(a) && cycle.count(b)) cout << 2 << endl;
        else cout << 1 << endl;
    }
}





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

int main(){
  int x, count = 1;
  while(1){
    cin >> x;
    if(x == 0) break;
    else{
      printf("Case %d: %d\n", count, x);
      count++;
    }
  }

  return 0;
}



Measured memory_bytes: 3188
def BinarySearchLowerBound(_arr, _ele): # arr is strictly increasing
    low_ind = 0
    up_ind = len(_arr) - 1
    if _arr[low_ind] >= _ele:
        return low_ind
    if _arr[up_ind] <= _ele:
        return up_ind + 1
    found = None
    while (up_ind - low_ind) > 1:
        mid = (up_ind + low_ind) / 2
        if _arr[mid] < _ele:
            low_ind = mid
        elif _arr[mid] > _ele:
            up_ind = mid
        elif _arr[mid] == _ele:
            found = mid
            break
    if found is not None:
        cnt = found
    else:
        cnt = up_ind
    return cnt

def solve():
    N, Q = [int(_) for _ in raw_input().split()]
    STX = []
    for i in range(N):
        Si, Ti, Xi = [int(_) for _ in raw_input().split()]
        STX.append((Si - Xi, Ti - Xi, Xi))
    D = []
    for i in range(Q):
        D.append(int(raw_input()))
    STX.sort(key = lambda x:x[2])
    # D have already been sorted based on settings on problem
    ans = [-1] * Q
    l = [None] * Q
    for i in range(N):
        Li, Ri, Xi = STX[i]
        if len(D) == 0:
            break
        lit = BinarySearchLowerBound(D, Li)
        rit = BinarySearchLowerBound(D, Ri)
        while lit < rit:
            if l[lit] is not None:
                lit = l[lit]
            else:
                ans[lit] = Xi
                l[lit] = rit
                lit += 1
    for i in range(Q):
        print ans[i]

if __name__ == '__main__':
    solve()


Measured memory_bytes: 83228
N, Q = map(int, input().split(" "))
S = input()
LR = [input() for _ in range(Q)]

rightmax = [0 for i in range(N+1)]
before = S[0]
nowAC = 0
for i, c in enumerate(S):
    if before == "A" and c == "C":
        nowAC += 1
    before = c
    rightmax[i+1] = nowAC
for query in LR:
    l, r = map(int, query.split(" "))
    print(rightmax[r] - rightmax[l])


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int a, b, c, d, ans = 0;
    cin >> a >> b >> c >> d;
    int x = (c + b - 1) / b;
    int y = (a + d - 1) / d;
    cout << (x <= y? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3632
N, M = map(int, input().split())
skip = [False] * (N+1)
for _ in range(M):
  skip[int(input())] = True

div = 1e9 + 7
path = 0
prev1 = 1
prev2 = 0

for n in range(1, N+1):
  if skip[n]:
    path = 0
  else:
    path = int((prev1 + prev2) % div)

  prev1, prev2 = path, prev1

print(path)

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

namespace CSharpSample01
{
    
    class Program
    {

        static List<string> ss;

        //kは何個目の値か
        //k番目の文字はstr
        static void Me(int k, string str)
        {
            if (k == 10)
            {
                ss.Add(str);
                return;
            }

            Me(k + 1, str + "1");

            Me(k + 1, str + "0");            

        }
        
        

        static void Main(string[] args) 
        {

            int N = int.Parse(Console.ReadLine());
            int[,] f = new int[N, 10];
            int[,] p = new int[N, 11];
            int[] kaburi = new int[N];

            for(int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                for(int j = 0; j < 10; j++)
                {
                    f[i, j] = int.Parse(str[j]);
                }
            }

            for (int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                for (int j = 0; j < 11; j++)
                {
                    p[i, j] = int.Parse(str[j]);
                }
            }


            ss = new List<string>();

            Me(0, "");
           
            int max = int.MinValue;
            for(int i = 0; i < ss.Count; i++)
            {
                if (ss[i] == "0000000000") continue;

                for(int j = 0; j < N; j++)
                {
                    kaburi[j] = 0;
                }

                string s = ss[i];
                int sum = 0;
                for(int j = 0; j < s.Length; j++)
                {
                    //k番目の店とかぶっているか
                    for(int k = 0; k < N; k++)
                    {
                        if (f[k, j] == 1 && s[j] == '1') kaburi[k]++;
                    }                 
                }

                //j番目の店のかぶり状況
                for(int j = 0; j < N; j++)
                {
                    //Console.WriteLine($"j = {j} kaburi[{j}] = {kaburi[j]}");
                    sum += p[j, kaburi[j]];
                }
                //Console.WriteLine($"{s}：{sum}");
                if (max < sum) max = sum;

            }

            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');

            Console.WriteLine (int.Parse (str[0]) * int.Parse (str[1]));
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27392
using System;
using System.Collections.Generic;
using System.Linq;
class abc165_d{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    ulong a = ulong.Parse(str[0]);
    ulong b = ulong.Parse(str[1]);
    ulong n = ulong.Parse(str[2]);
    ulong ans;
    if(b-1 > n) ans = a*n/b;
    else ans = a*(b-1)/b;
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 17844
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	ll ans = 1;
	while (true) {
		ans *= 2;
		if (ans > n) {
			cout << ans / 2 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
h,w=map(int,input().split())
S=[list(input()) for i in range(h)]
for i in range(h+2):
  for j in range(w+2):
    if i in [0,h+1] or j in [0,w+1]:
      print("#",end="")
    else:
      print(S[i-1][j-1],end="")
  print("")

Measured memory_bytes: 74100
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 200010
using namespace std;
typedef long long ll;
int n;
int a[MAXN],b[MAXN];
ll ans;
bool flag=0;
int main(){
	SF("%d",&n);
	for(int i=0;i<n;i++){
		SF("%d%d",&a[i],&b[i]);
		if(a[i]!=b[i])
			flag=1;
	}
	if(flag==0){
		PF("0");
		return 0;
	}
	for(int i=0;i<n;i++)
		if(a[i]<b[i]){
			ans+=1ll*a[i];
			b[i]-=a[i];
			a[i]=0;
		}
	int minid=-1;
	for(int i=0;i<n;i++)
		if(a[i]>b[i]&&(minid==-1||b[i]<b[minid]))
			minid=i;
	for(int i=0;i<n;i++)
		ans+=1ll*b[i];
	ans-=1ll*b[minid];
	PF("%lld",ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define SUP INT_MAX
#define INF INT_MIN
#define SSUP LLONG_MAX
#define IINF LLONG_MIN
#define W while
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define all(v) v.begin(),v.end()
#define in insert
//#define For(i,n) for(ll i=0;i<n;i++)
//#define FOR(i,a,b) for(ll i=a;i<b;i++)
//#define Rev(i,n) for(ll i=n-1;i>=0;i--)
using namespace std;
const ll M = 1e9+7;
int main()
{
	/*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif*/
	FIO
	ll a;
	cin>>a;
	ll k5 = a/500;
	ll sum = 1000 * k5;
	a=a-(500 * k5);
	k5 = a/5;
	sum+=(5*k5);
	cout<<sum<<"\n";
	return 0;
}

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

int main()
{
  string s,ans;
  int c,p,n;
  c=0;
  cin>>s;
  n=s.size();
  ans="AC";
  if(s.at(0)!='A')
    ans="WA";
  else
  {
    s.at(0)='a';
    for(int i=2;i<n-1;i++)
    {
      if(s.at(i)=='C')
      {
        c++;
        p=i;
      }
    }
    if(c!=1)
      ans="WA";
    else
    {
      s.at(p)='a';
      for(int i=0;i<n;i++)
      {
        if((s.at(i)<=96)||(s.at(i)>=123))
        {
          ans="WA";
          break;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 2010

int H, W;
char S[SIZE][SIZE];
int x[SIZE][SIZE], y[SIZE][SIZE];

int main() {

  scanf("%d%d", &H, &W);

  for (int i=0; i<H; i++) {
    scanf("%s", S[i]);
  }

  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (S[i][j] != '#') {
        x[i][j] = j == 0 ? 1 : x[i][j-1] + 1;
        y[i][j] = i == 0 ? 1 : y[i-1][j] + 1;
      }
    }
  }

  for (int i=H-1; i>=0; i--) {
    for (int j=W-1; j>=0; j--) {
      if (S[i][j] != '#') {
        if (j < W-1) x[i][j] = max(x[i][j], x[i][j+1]);
        if (i < H-1) y[i][j] = max(y[i][j], y[i+1][j]);
      }
    }
  }

  int ans = 0;

  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (S[i][j] != '#') {
        ans = max(ans, x[i][j] + y[i][j] - 1);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35712
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
 
using namespace std;
 
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
 
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}
 
#define int long long
#define left left228
#define right right228
#define prev prev228
#define list list228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int N = 200 * 1000 + 228;

int p[N];
int a[N], b[N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
    }
    int K = n + 2;
    for (int i = 1; i <= n; ++i) {
        a[i] = i * K;
        b[i] = K * (n - i + 1);
    }

    for (int i = 1; i <= n; ++i) {
        a[p[i]] += i;
    }
    for (int i = 1; i <= n; ++i) {
        cout << a[i] << ' ';
    }
    cout << '\n';
    for (int i = 1; i <= n; ++i) {
        cout << b[i] << ' ';
    }
    cout << '\n';
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define PI 3.1415926535

int main(void)
{
    int a, b, c, k;
    cin >> a >> b >> c>> k;

    int sum = 0;
    if(a>=k){
        cout << k << endl;
        return 0;
    }

    if(a+b >= k){
        cout << a << endl;
        return 0;
    }

    sum = a;
    int n = k-a-b;
    sum -= n;
    cout << sum << endl;
    

    return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

long long Otime(int N, int T, int t[]) {
	long long ans=0;

	for (int i = 0;i < N-1;i++) {//tNの分は含まない
		ans += min(T, t[i+1]-t[i]);
	}

	//tNの分だけ足す
	ans += T;

	return ans;
}

int main() {
	int N, T;
	int t[200005];

	cin >> N >> T;
	for (int i = 0;i < N;i++) {
		cin >> t[i];
	}

	long long ans = Otime(N, T, t);

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

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string s;cin>>s;
  int ans=0;
  for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-i-1]){
      ans++;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int D = scanner.nextInt();
        
        int answer = N / (2 * D + 1);
        if (N % (2 * D + 1) > 0) {
            answer++;
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 35736
#include <stdio.h>

int main(){
	int n,x;
    int l[100];
    int i;
    int d=0;
    int count=1;
	scanf("%d %d",&n,&x);
    for(i=0; i<n; i++){
        scanf("%d",&l[i]);
    }
	for(i=0; i<n; i++){
    	d = d + l[i];
        if(d>x) break;
        count++;
    }
    printf("%d",count);
	return 0;
}

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

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int N = 2e5 + 7;
const ll mod = 998244353;

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

int n;
ll x[N];
ll y[N];

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

    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin >> n;
    vector < int > v(2 , 0);
    for( int i = 1; i <= n; i++ ){
        cin >> x[i] >> y[i];
        v[(abs(x[i]) + abs(y[i])) % 2] += 1;
    }
    if( v[0] && v[1] ){
        cout << "-1\n";
        return 0;
    }
    vector < ll > jav;
    if( v[0] ){
        for( int i = 1; i <= n; i++ ){
            y[i] += 1;
        }
        jav.push_back(1);
    }
    for( int i = 0; i <= 30; i++ ){
        jav.push_back((1ll << i));
    }
    cout << (int)jav.size() << "\n";
    for( auto xx : jav ){
        cout << xx << " ";
    }
    cout << "\n";
    for( int i = 1; i <= n; i++ ){
        vector < char > res;
        for( int j = 30; j >= 0; j-- ){
            ll x1 = x[i] + (1ll << j);
            ll x2 = x[i] - (1ll << j);
            ll y1 = y[i] + (1ll << j);
            ll y2 = y[i] - (1ll << j);
            if( abs(x[i]) + abs(y1) < (1 << j) ){
                res.push_back('D');
                y[i] += (1 << j);
            }
            else if( abs(x[i]) + abs(y2) < (1 << j) ){
                res.push_back('U');
                y[i] -= (1 << j);
            }
            else if( abs(x1) + abs(y[i]) < (1 << j) ){
                res.push_back('L');
                x[i] += (1 << j);
            }
            else if( abs(x2) + abs(y[i]) < (1 << j) ){
                res.push_back('R');
                x[i] -= (1 << j);
            }
        }
        if( jav[0] == jav[1] ){
            res.push_back('D');
        }
        reverse( res.begin() , res.end() );
        for( auto x : res ){
            cout << x;
        }
        cout << "\n";
    }
}


Measured memory_bytes: 3692
//uses crt;
var n,i,o,p,k,l,j,m,x,z,count,max:longint;
used:array[1..16] of boolean;
type persoana = record
        testi:integer;
        saidabout:array[1..16] of integer;
        heis:array[1..16] of boolean;
        sincere:boolean;
        someonesaid:boolean;
        used:boolean;
        end;
var om:array[1..16] of persoana;
procedure backtrack(step:longint);
var i,o,p,k,j,curent:longint;
contradiction:boolean;
begin
if step=n+1 then begin
        contradiction:=false;
        k:=0;
        for i:=1 to n do
                om[i].sincere:=false;
                om[i].someonesaid:=false;
        for i:=1 to n do
                if used[i] then begin
                        inc(k);
                        om[i].sincere:=true;
                        om[i].someonesaid:=true;
                        //write(i,' ');
                        end;
               // writeln;
        for i:=1 to n do begin
                if contradiction then break;
                if om[i].sincere then
                        for j:=1 to om[i].testi do begin
                                curent:=om[i].saidabout[j];
                              //  writeln(curent);
                                if (om[curent].someonesaid) and (om[i].heis[j] <> om[curent].sincere) then begin
                                      //  writeln('omul',curent,' nu a zis nimeni si omul', i,' spune ca el este ',om[i].heis[j],' ceea ce este diferit de ',om[curent].sincere);
                                        contradiction:=true;
                                        break;
                                        end;
                                if (om[curent].someonesaid=false) and (om[curent].sincere <> om[i].heis[j]) then begin
                                        om[curent].sincere:=om[i].heis[j];
                                      //  writeln(curent);
                                        inc(K);
                                        end;
                                        end;
                                end;
      //  writeln(k,contradiction);
        if not contradiction then if k>max then max:=k;
        end
else begin
        used[step]:=true;
        backtrack(step+1);
        used[step]:=false;
        backtrack(step+1);
        end;
end;
begin
read(n);
for i:=1 to n do begin
        read(l);
        for j:=1 to l do begin
                read(x,z);
                om[i].saidabout[j]:=x;
                if z=1 then om[i].heis[j]:=true
                else om[i].heis[j]:=false;
              //  writeln(om[i].saidabout[j],' ',om[i].heis[j]);
                om[i].testi:=l;
                end;
        end;
backtrack(1);
writeln(max);
readln;
readln;
end.


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(0);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int x;
    cin>>x;
    YES(x==7||x==5||x==3);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <set>
#include <cctype>

using namespace std;

typedef int (*pred)(int);

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

  const int E = count_if(s.begin(), s.end(), (pred)isupper);
  const int e = count_if(s.begin(), s.end(), (pred)islower);
  const int d = count_if(s.begin(), s.end(), (pred)isdigit);
  const int l = s.size();

  if(E * e * d == 0 || l < 6) printf("IN");
  puts("VALID");

  return 0;
}

Measured memory_bytes: 1168
#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()
#define ll int long long

int main(){
   int n,m;
   cin>>n>>m;int p=1;
   rep(i,m){p*=2;}
   cout<<p*((n-m)*100+m*1900)<<endl;
}

Measured memory_bytes: 256
using System.Collections.Generic;
class p0002
{
    static void Main(string[] args)
    {
        string s;
        List<string> l = new List<string>();
        while ( (s = System.Console.ReadLine()) !=null)
            l.Add(s);
        foreach (var v in l)
        {
            var x = v.IndexOf(" ");
            System.Console.WriteLine(
                (int.Parse(v.Substring(0, x)) + int.Parse(v.Substring(x))).ToString().Length);
        }
       
    }
}

Measured memory_bytes: 6232
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 110
#define EPS 1e-7
using namespace std;
const double Pi=acos(-1);
struct node{
	double x,y;
	int id;
	node(){}
	node(double xx,double yy):x(xx),y(yy) {}
	node operator + (const node &a) const {
		return node(x+a.x,y+a.y);
	}
	node operator - (const node &a) const {
		return node(x-a.x,y-a.y);
	}
	node operator * (const double &t) const {
		return node(x*t,y*t);
	}
	double operator *(const node &a) const{
		return x*a.x+y*a.y;
	}
	double operator ^(const node &a) const{
		return x*a.y-y*a.x;
	}
	bool operator <(const node &a) const {
		return fabs(y-a.y)<EPS?x<a.x:y<a.y;
	}
}p[MAXN],l1[MAXN];
stack<node> s1,s;
double ans[MAXN];
int n,cnt1;
void solve(node a1[],int &cnt){
	s.push(p[1]);
	s1.push(p[1]);
	s1.push(p[2]);
	for(int i=3;i<=n;i++){
		while(!s.empty()&&((p[i]-s.top())^(s1.top()-s.top()))<-EPS){
			s.pop();
			s1.pop();
		}
		s.push(s1.top());
		s1.push(p[i]);
	}
	while(!s1.empty()){
		a1[++cnt]=s1.top();
		s1.pop();
	}
	while(!s.empty())
		s.pop();
}
bool cmp(node a,node b){
	return b<a;
}
double len(node a){
    return sqrt(a.x*a.x+a.y*a.y);
}
pair<long long,long long> b[MAXN];
bool check(){
    for(int i=1;i<=n;i++){
        b[i].first=(long long)(p[i].x);
        b[i].second=(long long)(p[i].y);
    }
    for(int i=2;i<n;i++){
        long long xx1=b[i].first-b[i-1].first;
        long long xx2=b[i+1].first-b[i].first;
        long long yy1=b[i].second-b[i-1].second;
        long long yy2=b[i+1].second-b[i].second;
        if(yy1*xx2!=yy2*xx1)
            return 0;
    }
    return 1;
}
int main(){
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
	SF("%d",&n);
	for(int i=1;i<=n;i++){
		SF("%lf%lf",&p[i].x,&p[i].y);
        p[i].id=i;
	}
	sort(p+1,p+1+n);
	if(n==2){
        PF("0.50000\n");
        for(int i=2;i<n;i++)
            PF("0.00000\n");
        PF("0.50000\n");
        return 0;
	}
	solve(l1,cnt1);
	sort(p+1,p+1+n,cmp);
	cnt1--;
	solve(l1,cnt1);
	cnt1--;
	for(int i=1;i<=cnt1;i++){
        int las,nxt;
        if(i==1)
            las=cnt1;
        else
            las=i-1;
        if(i==cnt1)
            nxt=1;
        else
            nxt=i+1;
        double d=((l1[nxt]-l1[i])*(l1[las]-l1[i]))/(len(l1[nxt]-l1[i])*len(l1[las]-l1[i]));
        //PF("[%lf]",fabs((l1[nxt]-l1[i])*(l1[i]-l1[las])));
        d=acos(-d);
        ans[l1[i].id]=d/(2.0*Pi);
	}
	for(int i=1;i<=n;i++)
        PF("%.20lf\n",ans[i]);
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> vec(N);
    for(int n=0; n<N; n++) {
        cin >> vec[n];
    }
    
    long long int ans=1e9;
    for(int i=-100; i<=100; i++) {
        long long int tmp=0;
        for(int n=0; n<N; n++) {
            tmp += (vec[n]-i)*(vec[n]-i);
        }
        if(tmp<ans) {
            ans = tmp;
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

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

int main(){
    int num_list,num_query;
    int command,list_idx,val;
    scanf("%d %d" ,&num_list,&num_query);
    vector<list<int>> list_array(num_list);
    
    for(int i = 0;i < num_query;i++){
        scanf("%d %d",&command,&list_idx);
        if(command == 0){
            scanf("%d",&val);
            list_array[list_idx].push_back(val);
        }else if(command == 1){
            if(!list_array[list_idx].empty()){
                for(list<int>::iterator itr = list_array[list_idx].begin();itr != list_array[list_idx].end();itr++){
                    cout << *itr;
                    if(next(itr) != list_array[list_idx].end()) cout << " ";
                    else cout << "\n";
                }
            }else{
                cout << "\n";
            }
        }else{
            scanf("%d",&val);
            list_array[val].splice(list_array[val].end(),list_array[list_idx]);
        }
    }


    return 0;   
}


Measured memory_bytes: 18792
#include <iostream>
#include <vector>
#include <map>

using namespace std;

struct uf_tree {
    vector<int> par, sizes;
    uf_tree(int n) : par(n), sizes(n, 1) {
        for (int i = 0; i < n; i++) { par[i] = i; }
    }
    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) { swap(x, y); }
        par[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return sizes[find(x)]; }
};

int main() {
    int N, K, L;

    cin >> N >> K >> L;

    uf_tree uf_1(N+1);
    uf_tree uf_2(N+1);

    while (K--) {
        int p, q;
        cin >> p >> q;
        uf_1.unite(p, q);
    }
    while (L--) {
        int r, s;
        cin >> r >> s;
        uf_2.unite(r, s);
    }

    map<pair<int, int>, int> mp;

    for (int i = 1; i <= N; i++) {
        mp[make_pair(uf_1.find(i), uf_2.find(i))]++;
    }

    for (int i = 1; i <= N; i++) {
        cout << mp[make_pair(uf_1.find(i), uf_2.find(i))];
        cout << ((i != N) ? " " : "\n");
    }

    return 0;
}

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

#define pb push_back
#define int long long
#define sz size()

using namespace std;

const int N = 1e5 + 1;
const int inf = 1e9 + 7;

string s, z;

vector <char> ans;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>> s>> z;
    int a[s.sz + 10][z.sz + 10];
    for(int i = 0; i <= s.sz; i++){
        for(int j = 0; j <= z.sz; j++){
            if(i == 0 || j == 0){
                a[i][j] = 0;
                continue;
            }
            if(s[i - 1] == z[j - 1])a[i][j] = a[i - 1][j - 1] + 1;
            else a[i][j] = max(a[i - 1][j], a[i][j - 1]);
        }
    }
    int x = s.sz, y = z.sz;
    if(a[x][y] == 0)return 0;
    while(a[x][y] != 0){
        if(a[x][y] > a[x - 1][y] && a[x][y] > a[x][y - 1]){
            x--;
            y--;
            ans.pb(s[x]);
            continue;
        }
        if(a[x - 1][y] >= a[x][y - 1])x--;
        else y--;
    }
    for(int i = ans.sz - 1; i >= 0; i--)cout<< ans[i];
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,l,r;
  cin>>n;
  vector<int> v(n),copy(n);
  rep(i,n){
    cin>>v[i];
    copy[i]=v[i];
  }
  sort(copy.begin(),copy.end());
  r=copy[n/2];
  l=copy[n/2-1];
  rep(i,n){
    if(v[i]<=l){
      cout<<r<<endl;
    }else{
      cout<<l<<endl;
    }
  }
  
  
  
}
///////////////////////////






Measured memory_bytes: 3712