akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    LL(n);
    out(32*n);
}


Measured memory_bytes: 3220
O = input()
E = input()
answer = ""
i = 1
o = 0
e = 0
while i < len(E)+len(O)+1:
  if i % 2 != 0:
    answer += O[o]
    o += 1
  else:
    answer += E[e]
    e += 1
  i += 1

print(answer)

Measured memory_bytes: 3060
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
int n,m,par[N],dir[N];

void init() 
{
    for (int i=1;i<=n;i++)
	   par[i]=i,dir[i]=0;
}

int fd(int x) 
{
    if (x==par[x])
	   return x;
    int t=par[x];
    par[x]=fd(par[x]);
    dir[x]+=dir[t];
    return par[x];
}

void unite(int x,int y,int c) 
{
    int a=fd(x),b=fd(y);
    if (a==b) 
	   return;
    dir[a]=-dir[x]+c+dir[y];
    par[a]=b;
}

int main()
{
    cin>>n>>m;
    int l,r,d;
	init();
    bool ok=true;
    for (int i=1;i<=m;i++)
	{
        cin>>l>>r>>d;
        if (fd(l)!=fd(r)) 
		   unite(l,r,d);
        else if (dir[l]-dir[r]!=d) 
		   ok=false;
    }
    if (ok)
       cout<<"Yes";
    else
       cout<<"No";
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#define MAX 500000
#define swap(x, y, type) do{type t = x; x = y; y = t;}while(0)
void upheap(int, int, int*);
void downheap(int, int, int, int*);
void heap_sort(int, int, int*);
void delete(int*, int, int, int*);
void insert(int*, int, int, int*);
main()
{
        int i, first = 0, count, a[MAX];
        scanf("%d", &count);
        for (i = 0; i < count; i++) {
                scanf("%d", &a[i]);
        }
        for (i = (count - first) / 2 - 1 + first; i >= first; i--) {
        downheap(first, i, count - 1, a);
    }
        for (i = 0; i < count; i++) {
        printf(" %d", a[i]);
    }
        putchar('\n');
}
void upheap(int first, int right, int *table)
{
        int child, parent, bottom = table[right];
        for (child = right; child > first; child = parent) {
                parent = (child - first + 1) / 2 - 1 + first;
                if (table[parent] >= bottom) break;
                table[child] = table[parent];
        }
        table[child] = bottom;
}
void downheap(int first, int left, int right, int *table)
{
        int child, parent, root = table[left];
        for (parent = left; parent < (right - first + 1) / 2 + first;
                 parent = child) {
                int l = 2 * parent - first + 1, r = l + 1;
                if (r <= right && table[r] > table[l]) {
                        child = r;
                } else {
                        child = l;
                }
                if (root >= table[child]) break;
                table[parent] = table[child];
        }
        table[parent] = root;
}
void heap_sort(int n, int first, int *a)
{
        int i;
        for (i = (n - first) / 2 - 1 + first; i >= first; i--) {
                downheap(first, i, n - 1, a);
        }
        for (i = n - 1; i > first; i--) {
                swap(a[first], a[i], int);
                downheap(first, first, i - 1, a);
        }
}
void delete(int *n, int first, int k, int *a)
{
        int pre = a[k];
        a[k] = a[(*n) - 1];
        (*n)--;
        if (pre > a[k]) {
                downheap(first, k, (*n) - 1, a);
        } else {
                upheap(first, k, a);
        }
}

void insert(int *n, int first, int data, int *a)
{
        (*n)++;
        a[(*n) - 1] = data;
        upheap(first, (*n) - 1, a);
}


Measured memory_bytes: 3736
#include <iostream>
#define N_MAX 20
#define Q_MAX 200
#define A_MAX 2000
#define M_MAX 2000
using namespace std;
bool chkPossible(int *A, int i, int n, int m) {
    if (m == 0) return true;
    if (i >= n) return false;
    return chkPossible(A, i+1, n, m) or chkPossible( A, i+1, n, m - A[i] );
}
void solve(int *A, int n, int *M, int q) {
    for (int i=0; i<q; i++) {
        int m = M[i];
        if ( chkPossible(A, 0, n, m) ) cout << "yes";
        else cout << "no";
        cout << endl;
    }
}
int main() { // <- solve
    int n;
    cin >> n;
    int A[N_MAX];
    for (int i=0; i<n; i++) {
        cin >> A[i];
    }
    int q;
    cin >> q;
    int M[Q_MAX];
    for (int i=0; i<q; i++) {
        cin >> M[i];
    }
    solve(A, n, M, q);
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200)cout << s;
    else cout << "red";
    


}

/*

北極に住んでるAtCoder AtPolar

 */



Measured memory_bytes: 256
open Scanf
open Printf
open String;;

(* sscanf (read_line ()) "%d %d" 
   (fun x y -> printf "%d" ((x-1)*(y-1)));; *)



(* let abb s = (sub s 0 1) 
            ^ (string_of_int (length s - 2))
            ^ (sub s (length s - 1) 1);;

sscanf (read_line ()) "%s"
          (fun s -> printf "%s" (abb s));; *)

let judge l =
  let len = List.length l in
  let f l = List.fold_left 
              (fun (x,l') y -> if y mod 4==0 then (x+1,l') else (x,y::l')) (0,[]) l in
  let g l = List.fold_left (fun x y -> x + if y mod 2!=0 then 1 else 0) 0 l in
  let (four, fourl) = f l in
  four >= len/2 || g fourl <= four

let usage n = 
  let list = ref [] in
  for i = 1 to n do
    list := (scanf (if i < n then "%d " else "%d") (fun x -> x))::!list
  done; !list;;

sscanf (read_line ()) "%d" 
   (fun x -> printf "%s" (if judge (usage x) then "Yes" else "No"));;



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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  map<ll,ll> m;
  rep(i,n){
    m[a[i]-1]++;
    m[a[i]]++;
    m[a[i]+1]++;
  }
  ll cnt=0;
  for(auto e: m){
    chmax(cnt,e.second);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 7040
A, B, C = map(int, input().split())
K = int(input())
counter = 0

while C <= B or C <= A:
    C = 2*C
    counter += 1

while B <= A:
    B = 2*B
    counter += 1

while C <= B:
    C = 2*C
    counter += 1

if counter > K:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9180
R, G, B, N  = list(map(int, input().split()))

counter = 0
for r in range(int(N / R) + 1):
    for g in range(int((N - R * r) / G) + 1):
        if (N - R * r - G * g) % B ==0:
            counter += 1
print(counter)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fast_read ios::sync_with_stdio(0);cin.tie(0);
#define ll long long
using namespace std;
int main() {
  fast_read;
  int n,rx=0,ry=0,tm=0;
  cin>>n;
  int t[n],x[n],y[n];
  for (int i = 0;i<n;i++)cin>>t[i]>>x[i]>>y[i];
  for (int i = 0;i<n;i++) {
    int dist = abs(rx - x[i]) + abs(ry - y[i]);
    if (tm + dist == t[i]) {
      tm = t[i];
      rx = x[i];
      ry = y[i];
    }
    else if (tm + dist > t[i]) {
      cout<<"No"<<endl;
      return 0;
    }
    else if (tm + dist < t[i]) {
      if ((t[i]  - tm - dist) % 2 == 0) {
        tm = t[i];
        rx = x[i];
        ry = y[i];
      }
      else {
        dist = abs(rx - (x[i] - 1)) + abs(ry - y[i]);
        if (tm + dist < t[i] && (t[i] - tm - dist) % 2 == 1) {
          tm = t[i];
          rx = x[i];
          ry = y[i];
          continue;
        }
        dist = abs(rx - (x[i] + 1)) + abs(ry - y[i]);
        if (tm + dist < t[i] && (t[i] - tm - dist) % 2 == 1) {
          tm = t[i];
          rx = x[i];
          ry = y[i];
          continue;
        }
        dist = abs(rx - x[i]) + abs(ry - (y[i]-1));
        if (tm + dist < t[i] && (t[i] - tm - dist) % 2 == 1) {
          tm = t[i];
          rx = x[i];
          ry = y[i];
          continue;
        }
        down:
        dist = abs(rx - x[i]) + abs(ry - (y[i]+1));
        if (tm + dist < t[i] && (t[i] - tm - dist) % 2 == 1) {
          tm = t[i];
          rx = x[i];
          ry = y[i];
          continue;
        }
        else {
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1408
import math

input_line = input().split()
N = int(input_line[0])
D = int(input_line[1])

input_list = []
cnt = 0
for i in range(N):
    input_list = input().split()
    if math.sqrt(int(input_list[0]) ** 2 + int(input_list[1]) ** 2) <= D:
        cnt += 1

print(cnt)


Measured memory_bytes: 9184
#include <stdio.h>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int, int> pii;

int m, n, flag[50];
vector<pii> vec[50];

void dfs(int a, int b) {
  int i;
  flag[a] = 0;
  for(i = 0; i < vec[a].size(); ++i) 
    if(vec[a][i].second != b && flag[vec[a][i].first]) dfs(vec[a][i].first, b);
}

int main(void) {
  int i, j, k, a, b, ans = 0;
  scanf("%d%d", &n, &m);
  for(i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    a--, b--;
    vec[a].push_back(make_pair(b, i));
    vec[b].push_back(make_pair(a, i));
  }
  for(i = 0; i < m; ++i) {
    for(j = 0; j < n; ++j) flag[j] = 1;
    dfs(0, i);
    for(j = 0; j < n; ++j) if(flag[j]) {
      ans++; break;
    }
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
a,b,x = map(int, input().split())
if a >= b*2:
    print(((x-1)//500+1)*b)
elif x%1000 > 500:
    print(((x-1)//1000+1)*a)
else:
    print(min(((x-1)//1000+1)*a, x//1000*a+b))


Measured memory_bytes: 5600
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

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

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

using namespace std;

int main() {
    int n;
    cin >> n;
    const int a[7] = { 1,2,4,8,16,32,64 };

    for (int i = n; i > 0; i--) {
        for (int j = 6; j >=0; j--) {
            if (i - a[j] == 0) {
                cout << a[j] << endl;
                return 0;
            }
        }
    }
}

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

int main() {
	int c[101][101], x, y, num = 0;
	cin >> x >> y;
	for (int i = 0; i<x; i++) {
		for (int j = 0; j<y; j++) {
			cin >> c[i][j];
			num += c[i][j];
		}
		c[i][y] = num;
		num = 0;
	}
	for (int j = 0; j<=y; j++) {
		for (int i = 0; i<x; i++) {
			num += c[i][j];
		}
		c[x][j] = num;
		num = 0;
	}
	for (int i = 0; i<=x; i++) {
		for (int j = 0; j<=y; j++) {
			cout << c[i][j];
			if (j != y)cout << " ";
		}
		cout << endl;
	}


	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  ll N,M;cin>>N>>M;
  if (N>M) swap(N,M);

  // どちらかが１なら、端っこ以外裏
  // それ以外の場合
  // 外側に面していないカードは全部裏になるので、(N-2)*(M-2)は確定
  // 外側に面しているカードは、全て表になる
  if (N==1 && M==1) {
    OUT(1);
  } else if (N==1) {
    OUT(M-2);
  } else {
    OUT((N-2)*(M-2));
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
	int W=0;
	int H =0;

	while(scanf("%d %d",&W,&H)==2 && (W!=0 || H!=0)){
		if(W==0 && H==0){
			break;
		}else{
			for(int i=0;i<W;i++){
				if(i%2==0){
					for(int j=0;j<H;j++){
						if(j%2==0){
							printf("#");
						}else{
							printf(".");
						}
					}
				printf("\n");
				}else{
					for(int j=0;j<H;j++){
						if(j%2==0){
							printf(".");
						}else{
							printf("#");
						}
					}
					printf("\n");
				}
			fflush(stdout);
		    }
	    }
	printf("\n");
    }
}



Measured memory_bytes: 2040
h,w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

cn = 0
ope = []
for i in range(h):
    for j in range(w):
        if A[i][j]%2 != 0:
            if i != h-1:
                A[i+1][j] += 1
                cn += 1
                ope.append("{0} {1} {2} {3}".format(i+1,j+1,i+2,j+1))
            elif j != w-1:
                A[i][j+1] += 1
                ope.append("{0} {1} {2} {3}".format(i+1,j+1,i+1,j+2))
                cn += 1
            A[i][j] -= 1
print(cn)
for i in ope:
    print(i)


Measured memory_bytes: 16348
#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
const int MOD=1e9+7;
int P(LL a,LL n)
{
  if(n==0)return 1;
  else if(n==1)return a%MOD;
  else if(n%2==0)return P((LL)a*a%MOD,n/2)%MOD;
  else return (a*P(a,abs(n-1)))%MOD;
}
int C(LL n,LL k)
{
  LL x=1,y=1;
  k=min(k,n-k);
  if(n<0||k<0||n<k)return 0;
  if(n==0||k==0)return 1;
  for(int i=0;i<k;i++)
  {
    x*=abs(n-i),x%=MOD;
    y*=(i+1),y%=MOD;
  }
  return (x*P(y,MOD-2))%MOD;
}
int main()
{
  int N,A,B,z;
  cin>>N>>A>>B;
  z=P(2,N)-1;
  z-=C(N,A)%MOD;if(z<0)z+=MOD;
  z-=C(N,B)%MOD;if(z<0)z+=MOD;
  return cout<<z<<endl,0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<cstring>
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,cnt = 0;
	map<string,ll> mp;
	queue<string> que; 
	string s;
	cin >> n;
	rep(i,n){
		cin >> s;
		sort(all(s));
		mp[s]++;
		if(mp[s] == 1){
			que.push(s);
			++cnt;
		}
	}
	ll ans = 0;
	while(que.size()){
		for(int j = mp[que.front()] - 1;j > 0;--j){
          ans+=j;
        }
		que.pop();
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int partition(int A[],int p,int r){
  int x=0,i=0,j=0,tmp=0;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      tmp=A[j];
      A[j]=A[i];
      A[i]=tmp;
    }
  }
  tmp=A[r];
  A[r]=A[i+1];
  A[i+1]=tmp;
  return i+1;
}

int main(){
  int n=0;
  int A[1001000]={};
  int Par=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  Par=partition(A,0,n-1);
  //cout<<Par<<endl;
  for(int i=0;i<n;i++){
    if(i!=0)cout<<" ";
    if(i==Par)cout<<"[";
    cout<<A[i];
    if(i==Par)cout<<"]";
    
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 6996
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc119/editorial.pdf
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

A,B,Q=MAP()

S=[-INF]*(A+2)
for i in range(A):
    S[i+1]=INT()
T=[-INF]*(B+2)
for i in range(B):
    T[i+1]=INT()
S[-1]=T[-1]=INF

for i in range(Q):
    dist1=dist2=dist3=dist4=INF
    x=INT()
    # 地点xから左に一番近い神社
    idx1=bisect_right(S, x)-1
    # 右に一番近い神社
    idx2=bisect_left(S, x)
    idx3=bisect_right(T, x)-1
    idx4=bisect_left(T, x)
    # idx番目の神社に行く
    dist1=x-S[idx1]
    # idx番目の神社から一番近い寺に行く
    dist1+=min(abs(S[idx1]-T[idx3]), abs(S[idx1]-T[idx4]))
    dist2=S[idx2]-x
    dist2+=min(abs(S[idx2]-T[idx3]), abs(S[idx2]-T[idx4]))
    dist3=x-T[idx3]
    dist3+=min(abs(T[idx3]-S[idx1]), abs(T[idx3]-S[idx2]))
    dist4=T[idx4]-x
    dist4+=min(abs(T[idx4]-S[idx1]), abs(T[idx4]-S[idx2]))
    print(min(dist1, dist2, dist3, dist4))


Measured memory_bytes: 14504
#include<bits/stdc++.h>
using namespace std;
main(){
  const int N=[]{int x;cin>>x;return x;}();
  const int x=[N]{
    int x=0;
    for(int i=1;i<=N;++i)x+=800;
    return x;
  }();
  const int y=[N]{
    int y=0;
    for(int i=1;i<=N;++i)if(i%15==0)y+=200;
    return y;
  }();
  cout<<(x-y)<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int s[14],a,b;
  for(int i=2;i<=13;i++)
    s[i]=i-1;
  s[1]=13;
  scanf("%d %d",&a,&b);
  if(a==b)
    printf("Draw\n");
  else if(s[a]>s[b])
    printf("Alice\n");
  else
    printf("Bob\n");
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int A, B;
    


    //入力
    cin >> A >> B;

    if( (B-A)%2 ==0) cout << (A+B)/2 << endl;
    else             cout << "IMPOSSIBLE" << 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)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<LL> line(n);
    foreach(i, line)cin>>i;
    LL sum=0;
    foreach(i, line)sum+=i;
    for(int i=1;i<n;i+=2)sum-=line[i]*2;
    vector<LL> ans(n);
    ans[0]=sum;
    line[0]-=ans[0]/2;
    REPA(i, n){
        ans[i]=line[i-1];
        line[i]-=ans[i];
        ans[i]*=2;
    }
    REP(i, n){
        cout << ans[i] << (i+1==n?"\n":" ");
    }
    return 0;
}

//


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main()
{
 	string s;
  	cin>>s;
	if(s.length() == 2 && s[0] == s[1])
    { 
      cout<<"1 2";
      return 0;
    }
  	for(int i=0; i<s.length()-2; i++)
    {
      if(s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2])
      { cout<<i+1<<" "<<i+3;
     	return 0;
      }
    }
  	cout<<"-1 -1";
}

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

int kaijo(int n){
    int a = 1;
    for(int i=n; i>1; i--){
        a *= i;
    }
    return a;
}

int main()
{
    int n;
    long double x[9], y[9];

    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> x[i] >> y[i];
    }

    long double ans = 0;
    int cnt = 0;
    long double tmp[30];
    for(int i=1; i<n; i++){
        for(int j=i+1; j<=n; j++){
            tmp[cnt++] = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
        }
    }

    int k = kaijo(n);
    long double f = k / cnt;
    rep(i, cnt){
        ans += 2 * tmp[i];
    }
    ans /= n;
    cout << fixed << setprecision(7) << ans;

    return 0;
}

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

int main(void){
  int N;
  double v,t,y;
  while((scanf("%lf",&v))!=EOF){
    t=v/9.8;
    y=4.9*t*t;
    N=(int)ceil((y+5)/5);
    printf("%d\n",N);
  }
  return 0;
}

Measured memory_bytes: 632
package main

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

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	k := scanInt()

	fmt.Printf("%d", int(math.Log(float64(n))/math.Log(float64(k))+1))
}

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}


Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

int main()
{
	ll N,W;
	cin>>N>>W;
	vector<pair<ll,ll> >vp(N+1);
	FOR(i,1,N+1)
	{
		cin>>vp[i].ff>>vp[i].ss;
	}
	vp[0] = {0,0};
	sort(all(vp));
	ll knap[W+1][N+1];
	
    memset(knap,0,sizeof(knap));
    //cout<<knap[0][3]<<endl;
    FOR(i,1,W+1)
    {
        FOR(j,1,N+1)
        {
            if(vp[j].ff > i)
            {
                knap[i][j] = knap[i][j-1]; 
            }
            else{
                knap[i][j] = max(knap[i][j-1] ,
								vp[j].ss + knap[max(i-vp[j].ff,0LL)][j-1]);
            }
        }
    }
	cout<<knap[W][N];
    
	return 0;
}


Measured memory_bytes: 82540
void main()
{
    dchar[] s = readln.chomp.to!(dchar[]);
    dchar[] t = readln.chomp.to!(dchar[]);

    long last = t.length - 1;
    bool ok;
    foreach_reverse (i, x; s)
    {
        if (x == t[last] || x == '?')
        {
            bool check = true;
            if (i.to!long - last >= 0)
            {
                foreach (j; 0 .. last)
                {
                    if (s[i-last+j] != t[j] && s[i-last+j] != '?')
                    {
                        check = false;
                        break;
                    }
                }
            }
            else check = false;

            if (check)
            {
                ok = true;
                foreach (j; 0 .. last+1)
                {
                    s[i-last+j] = t[j];
                }
                foreach (j; 0 .. s.length)
                {
                    if (s[j] == '?') s[j] = 'a';
                }
                break;
            }
        }
    }

    if (ok) s.writeln;
    else "UNRESTORABLE".writeln;

}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

ll H, W;

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

	cin >> H >> W;

	//double n = H * W;

	ll ans = (H*W+1)/2;

	if(H == 1 || W == 1)
		cout << 1 << "\n";
	else
		cout << ans << "\n";

	return 0;		
}

Measured memory_bytes: 256
from itertools import combinations

INF = float("inf")
data = {d: [-INF, INF, -INF, INF] for d in 'RLUD'}

_, *XYD = open(0).read().split()
X = map(int, XYD[::3])
Y = map(int, XYD[1::3])
D = map(data.get, XYD[2::3])

for x, y, d in zip(X, Y, D):
    if d[0] < x:
        d[0] = x
    if d[1] > x:
        d[1] = x
    if d[2] < y:
        d[2] = y
    if d[3] > y:
        d[3] = y

X = [
    (data["L"][0], -1), (data["L"][1], -1),
    (data["R"][0], 1), (data["R"][1], 1),
    (data["U"][0], 0), (data["U"][1], 0),
    (data["D"][0], 0), (data["D"][1], 0),
]
Y = [
    (data["L"][2], 0), (data["L"][3], 0),
    (data["R"][2], 0), (data["R"][3], 0),
    (data["U"][2], 1), (data["U"][3], 1),
    (data["D"][2], -1), (data["D"][3], -1),
]

X = [(x, dx) for x, dx in X if abs(x) < INF]
Y = [(y, dy) for y, dy in Y if abs(y) < INF]

T = set(
    [0] +
    [max(0, (x - y) / (dy - dx)) for (x, dx), (y, dy) in combinations(X, 2) if dx != dy] +
    [max(0, (x - y) / (dy - dx)) for (x, dx), (y, dy) in combinations(Y, 2) if dx != dy]
)


def area(t):
    XX = [t * dx + x for x, dx in X]
    YY = [t * dy + y for y, dy in Y]

    dx = max(XX) - min(XX)
    dy = max(YY) - min(YY)

    return dx * dy


print(min(map(area, T)))

Measured memory_bytes: 20452
#include<bits/stdc++.h>
using namespace std;
int n,m,s,i,j;
char l[1001][1001];
int main(void)
{
	scanf("%d%d\n",&n,&m);
	for(i=0;i<n;i++) for(j=0;j<m;j++) cin>>l[i][j];
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			s=0;
			if(l[i][j]!='#')
			{
				if(l[i][j+1]=='#') s++;
				if(l[i][j-1]=='#') s++;
				if(l[i+1][j]=='#') s++;
				if(l[i-1][j]=='#') s++;
				if(l[i+1][j+1]=='#') s++;
				if(l[i+1][j-1]=='#') s++;
				if(l[i-1][j+1]=='#') s++;
				if(l[i-1][j-1]=='#') s++;
				printf("%d",s);
			}
			else putchar('#');
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

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


class Cell{
public:
	int g;
	int a;
	Cell(){g=0;a=0;};
};

int main(){
	while(true){
		int rL,cL,ecL;
		cin >> rL >> cL >> ecL;			if(!rL&&!cL&&!ecL) return 0;
		
		int rS[rL];
		FOR(rI,0,rL) cin >> rS[rI];
		
		Cell cS[cL+1];
		FOR(ecI,0,ecL){
			int cI,g,a;
			cin >> cI >> g >> a;
			cS[cI].g = g;
			cS[cI].a = a;
		}

		double n2m2fp[cL+1][cL*100+1]; // ci==n no cell ni okane m dake motte saikoro de kuru kakuritsu
		double n2m2ep[cL+1][cL*100+1]; // ci==n no cell ni okane m dake motte tobasarete kuru kakuritsu
		FOR(n,0,cL+1) FOR(m,0,cL*100+1) {n2m2fp[n][m] = 0; n2m2ep[n][m] = 0;};
		n2m2fp[0][0]=1.0;

		FOR(n,0,cL){
			FOR(m,0,n*100+1){
				double fp = n2m2fp[n][m], ep=n2m2ep[n][m];
				Cell c = cS[n];
				//if((fp==0)&&(ep==0)) continue;
				//if((fp!=0)||(ep!=0)) cout<<"n:"<<n<<" m:"<<m<<" fp:"<<fp<<" ep:"<<ep<<endl;
				FOR(rI,0,rL){
					int r = rS[rI];
					n2m2fp[min(cL,n+r)][m] += ep / rL;
				}

				if(c.g==0){
					FOR(rI,0,rL){
						int r = rS[rI];
						n2m2fp[min(cL,n+r)][m] += fp / rL;
					}
				}
				if(c.g==1){
					n2m2ep[min(cL,n+c.a)][m] += fp;
				}
				if(c.g==2){
					FOR(rI,0,rL){
						int r = rS[rI];
						n2m2fp[min(cL,n+r)][m+c.a] += fp / rL;
					}
				}
				if(c.g==3){
					FOR(rI,0,rL){
						int r = rS[rI];
						n2m2fp[min(cL,n+r)][max(0,m-c.a)] += fp / rL;
					}
				}
			}
		}

		double res = 0.0;
		int n = cL;
		FOR(m,0,cL*100+1){
			double fp = n2m2fp[n][m], ep=n2m2ep[n][m];
			//if((fp!=0)||(ep!=0)) cout<<"n:"<<n<<" m:"<<m<<" fp:"<<fp<<" ep:"<<ep<<endl;
			res += m*(fp+ep);
		}
		cout << int(res) << endl;


	}


}

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 3e3 + 5;

int arr [MAX_N];
Modint dp [MAX_N][MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;

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

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (arr[i] > arr[j]) {
        dp[i][j] = Modint(1);
      }
    }
  }

  Modint i2 = inv(Modint(2));
  for (int t = 0; t < q; t++) {
    int x, y;
    cin >> x >> y;

    vector<pair<pair<int, int>, Modint>> upd;
    for (int i = 1; i <= n; i++) {
      if (i != x && i != y) {
        Modint avg = i2 * (dp[i][x] + dp[i][y]);
        upd.push_back({{i, x}, avg});
        upd.push_back({{i, y}, avg});

        avg = i2 * (dp[x][i] + dp[y][i]);
        upd.push_back({{x, i}, avg});
        upd.push_back({{y, i}, avg});
      }
    }

    Modint avg = i2 * (dp[x][y] + dp[y][x]);
    upd.push_back({{x, y}, avg});
    upd.push_back({{y, x}, avg});

    for (auto pr : upd) {
      dp[pr.first.first][pr.first.second] = pr.second;
    }
  }

  Modint ans (0);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      ans += dp[i][j];
    }
  }

  ans = ans * exp(Modint(2), q);
  cout << ans << endl;
}


Measured memory_bytes: 71424
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel par;
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
signed main() {
	int n; cin >> n; int m; cin >> m;
	V<bool> can_use(n, true);
	rep(i, m) {
		int a; cin >> a; can_use[a] = false;
	}
	vel dp(n + 10, 0); dp[0] = 1;
	rep(i, n) {
		dp[i] %= p;
		if (can_use[i]) { dp[i + 2] += dp[i]; dp[i + 1] += dp[i]; }
	}
	cout << dp[n]%p << endl;
	return 0;
}


Measured memory_bytes: 1024
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list[i];
  }
  sort(all(list));
  cout << list[N / 2] -list[N / 2-1];
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<string,int> mp;//mp[string]
int num,n;
string s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(mp[s]) mp[s]++;//出现次数
		else
		{
			num++;
			mp[s]=1;	
		} 
	}
	cout<<num;	
return 0;
}


Measured memory_bytes: 19260
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		Pair[] p = new Pair[n];
		for(int i = 0 ; i < n ; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			p[i] = new Pair(a, b);
		}
		Arrays.sort(p, new Comparator<Pair>() {
			public int compare(Pair p1, Pair p2) {
				return p1.a - p2.a;
			}
		});
		for(int i = 0 ; i < n ; i++) {
			k -= p[i].b;
			if(k <= 0) {
				System.out.println(p[i].a);
				return;
			}
		}
	}

	public static class Pair {
		int a, b;
		public Pair(int a, int b) {
			this.a = a;
			this.b = b;
		}
	}

}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for(int i = 0; i < n; ++i) cin >> h.at(i);
  vector<bool> ans(n, 1);
  for(int i = 0; i < m; ++i){
    int a, b;
    cin >> a >> b;
    int ah = h.at(a-1), bh = h.at(b-1);
    if(ah >= bh) ans.at(b-1) = false;
    if(ah <= bh) ans.at(a-1) = false;
  }
  
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    if(ans.at(i)) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
    /*
    long a,b,c;
    cin >> a >> b >> c;

    long double ab = sqrt(a) + sqrt(b);
    long double c_s = sqrt(c);

    if(ab < c_s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

*/

    long double a,b,c;
    cin >> a >> b >> c;

    long double left = (long double)2.0 * (long double)sqrt(a*b);
    //long long left = (long long)((long long)4.0*a)*b;
    long double right = c-a-b;


    if(left< right){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i;
	char c1,c2,c3;
	scanf("%c%c%c",&c1,&c2,&c3);
	if((c1=='a'||c1=='b'||c1=='c')&&(c2=='a'||c2=='b'||c2=='c')&&c2!=c1&&(c3=='a'||c3=='b'||c3=='c')&&c3!=c2&&c3!=c1)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct node{
	int a,b;
	inline bool operator<(node x)const{
	return a<x.a;
	}
}x[1000005];
priority_queue<int> q;
int main(){
	int j=1,s=0;
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>x[i].a>>x[i].b;
	}
	sort(x+1,x+n+1);
	for(int i=1;i<=m;i++){
		for(;x[j].a==i&&j<=n;j++){
			q.push(x[j].b);
		}
		if(!q.empty()){
			s+=q.top();
			q.pop();
		}
	}
	cout<<s;
}


Measured memory_bytes: 1660
import sys
from collections import deque

input = sys.stdin.readline


def main():
    n, q = map(int, input().split())
    nt = [None] * n
    for i in range(n):
        line = input().split()
        nt[i] = [line[0], int(line[1])]

    queue = deque(nt)
    time = 0
    ans = []
    while queue:
        p = queue.popleft()
        if p[1] <= q:
            time += p[1]
            ans.append((p[0], time))
        else:
            p[1] -= q
            time += q
            queue.append(p)

    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()



Measured memory_bytes: 18808
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

using tl = tuple<ll, ll, ll>;

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

    ll h, w; cin>>h>>w;
    vector<string> ss(h); cin>>ss;

    vvl ds(h, vl(w, LINF));
    queue<tl> q;
    q.emplace(0, 0, 1);

    vvl dist;
    dist.push_back(vl{0, 1});
    dist.push_back(vl{0, -1});
    dist.push_back(vl{1, 0});
    dist.push_back(vl{-1, 0});
    while (!q.empty()) {
        tl p = q.front(); q.pop();
        ll y = get<0>(p);
        ll x = get<1>(p);
        ll d = get<2>(p);
        if (ds[y][x] != LINF) continue;
        if (ss[y][x] == '#') continue;
        ds[y][x] = d;
        for (auto to : dist) {
            ll ny = y + to[0];
            ll nx = x + to[1];
            if (ny >= 0 && ny < h && nx >= 0 && nx < w) {
                q.emplace(ny, nx, d + 1);
            }
        }
    }
    if (ds[h - 1][w - 1] == LINF) {
        cout<<-1<<endl;
        return 0;
    }
    ll cnt = 0;
    rep(i, h) rep(j, w) if (ss[i][j] == '.') cnt++;
    cout<<cnt - ds[h - 1][w - 1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
int main(void)
{
    int n,A=0,ober[10][10],side[10],lon=0;
    while(1){
        for(int i=0;i<12;i++)side[i]=0;
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cin>>ober[i][j];
                side[j]+=ober[i][j];
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cout<<setw(5)<<ober[i][j];
                A+=ober[i][j];
            }
            cout<<setw(5)<<A<<"\n";
            lon+=A;
            A=0;
        }
        for(int i=0;i<n;i++)cout<<setw(5)<<side[i];
        cout<<setw(5)<<lon<<"\n";
        lon=0;
    }
}

Measured memory_bytes: 1172
#include <stdio.h>
int main(){
  int i,j,N,flag,change;
  int A[100];
  scanf("%d",&N);
  for(i=0;i < N;i++){
    scanf("%d",&A[i]);
  }

 
  flag=0;
  for(i=0; i < N-1; i++){
    for( j=N-1; j > i ; j--){
      if(A[j] < A[j-1]){
	change = A[j];
	A[j]=A[j-1];
	A[j-1]=change;
	flag++;
      }
      
    }
  }

    for(j=0;j < N ;j++){
      if(j==N-1){
	printf("%d",A[j]);
      }
      else{
      printf("%d ",A[j]);
      }
    }
    printf("\n");
    printf("%d\n",flag);
      return 0;
  }
	  
  



Measured memory_bytes: 2120
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=305;
int f[N<<1][N][N],a[N<<1],st[N<<1],vis[N<<1],bk[N<<1],top,n,cnt,ct,res;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	fp(i,1,n<<1)scanf("%d",&a[i]);
	for(R int i=1;i<=(n<<1);i+=2){
		if(a[i]==a[i+1])++cnt;
		else if(a[i]>0&&a[i+1]>0)vis[a[i]]=vis[a[i+1]]=1;
		else bk[(~a[i])?a[i]:a[i+1]]=1,++ct;
	}
	fd(i,n<<1,1)if(!vis[i])st[++top]=i;
	f[0][0][0]=1;
	fp(i,1,top)fp(j,0,cnt+ct)fp(k,0,ct)
		if(f[i-1][j][k]){
			R int coef=f[i-1][j][k];
			if(!bk[st[i]]){
				upd(f[i][j+1][k],coef);
				if(j)upd(f[i][j-1][k],coef);
				if(k)upd(f[i][j][k-1],mul(coef,k));
			}else{
				upd(f[i][j][k+1],coef);
				if(j)upd(f[i][j-1][k],coef);
			}
		}
	res=f[top][0][0];fp(i,1,cnt)res=mul(res,i);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 217344
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vecctor<ll>>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define all(v) v.begin(),v.end()



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,q;
    cin >> n >> q;
    ll ans = (n-2)*(n-2);
    ll h = n-2,w = n-2;
    vl yoko(n-1,n-2),tate(n-1,n-2);
    while(q--){
        ll t,x;
        cin >> t >> x;
        --t;
        if(t){
            if(x-2 < h){
                for(int j = x-1;j <= h;++j){
                    tate[j] = w;
                }
                h = x-2;
            }
            ans -= tate[x-1];
        }else{
            if(x-2 < w){
                for(int j = x-1;j <= w; ++j){
                    yoko[j] = h;
                }
                w = x-2;
            }
            ans -= yoko[x-1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6332