akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll n, ll m) {
  cout << (n - 1) * (m - 1) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll m;
	ll n;
	scanf("%lld", &n);
	scanf("%lld", &m);
	solve(n, m);
	return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

// Binary Indexed Tree
// 0-indexed
template <typename T>
class BIT {
private:
  // データ
  vector<T> bit;
  // 単位元, 要素数
  int neutral = 0;
  // 更新クエリ, 区間クエリ
  function<T(T,T)> f = [](const T l, const T r) -> T { return l+r; },
                   g = [](const T l, const T r) -> T { return l+r; };
public:
  // 初期化
  BIT(int n_ = 1e5) { init(n_); }
  void init(int n_ = 1e5) { bit.assign(n_+1, neutral); }
  // iに対する点更新クエリ
  void update(int i, T w) {
    for(int x = i+1; x < bit.size(); x += x&-x) bit[x] = f(bit[x], w);
  }
  // [0,i]に対する区間クエリ
  T query(int i) {
    T ret = neutral;
    for(int x = i+1; x > 0; x -= x & -x) ret = g(ret, bit[x]);
    return ret;
  }
};


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

  int n;
  cin >> n;
  V<int> a(n);
  REP(i, n) cin >> a[i];

  auto check = [&](int mid) -> bool {
    int now = 1e5;
    int ret = 0;
    BIT<int> bit(2e5+10);
    bit.update(now, 1);
    REP(i, n) {
      if(a[i] < mid) now++;
      else now--;
      bit.update(now, 1);
      ret += bit.query(now-1);
      // cout << now << "," << ret << "," << bit.query(now) << endl;
    }
    // cout << "ret=" << ret << endl;
    int m = n*(n+1)/4 + 1;
    return ret < m;
  };

  int lb = 0, ub = 1e9+10;
  while(ub-lb > 1) {
    int mid = (lb+ub)/2;
    // cout << lb << " " << mid << " " << ub << endl;
    if(check(mid)) lb = mid;
    else ub = mid;
  }

  cout << lb << endl;

  return 0;
}


Measured memory_bytes: 2660
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
template<class T>
class BIT {
    vector<T> bit;
    int n, m;
public:
    BIT(int n): n(n), bit(n){
        m = 1;
        while(m < n) m <<= 1;
    }

    T sum(int k){
        T ret = 0;
        for (; k > 0; k -= (k & -k)) ret += bit[k-1];
        return ret;
    }

    void add(int k, T x){
        for (k++; k <= bit.size(); k  += (k & -k)) bit[k-1] += x;
    }

    T lower_bound(T x){
        int i = -1;
        for (int j = m; j; j >>= 1) {
            if(i+j < bit.size() && bit[i+j] < x) x -= bit[i += j];
        }
        return i;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    BIT<ll> S(n);
    for (int i = 0; i < n; ++i) S.add(i, v[i]);

    for (int i = 0; i < q; ++i) {
        int c, x, y;
        scanf("%d %d %d", &c, &x, &y);
        if(c == 0) S.add(x, y);
        else printf("%lld\n", S.sum(y) - S.sum(x));
    }
    return 0;
}

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

int main(){
    long long  a,v,b,w,t;
    cin >>a>>v>>b>>w>>t;
    if(abs(a-b) <= (v-w)*t){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" <<endl;
    }
}


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

int main(void) {
  int a, b, h, m;
  double h_angle, m_angle, angle, all_m, ans;

  cin >> a >> b >> h >> m;

  //かかった時間はh*60+m
  //短針の0時からの時計回りの角度は
  all_m = h * 60 + m;
  h_angle = all_m * 0.5 - ((int)(all_m * 0.5) / 360) * 360;
  m_angle = all_m * 6 - ((int)all_m * 6 / 360) * 360;
  angle = (h_angle > m_angle) ? h_angle - m_angle : m_angle - h_angle;
  /*cout << h_angle << endl;
  cout << angle << endl;
  cout << cos(angle/180*M_PI) << endl; */
  //余弦定理
  ans = sqrt(a*a + b*b - 2*a*b*cos((M_PI/180)*angle));
  printf("%.10lf\n", ans);
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

main()
{
	IOS
	
	string s;
	cin >> s;
	
	cout << 700 + 100 * (s[0] == 'o') + 100 * (s[1] == 'o') + 100 * (s[2] == 'o');
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int cnt = 0;
        int sum;
        for(int ia=0;ia<=a;ia++){
            for(int ib=0;ib<=b;ib++){
                for(int ic=0;ic<=c;ic++){
                    sum = ia*500 + ib*100 + ic*50;
                    if(sum==x){cnt++;}
                }
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main (){
  int n;
  cin >> n;

  vector<int> d(n);
  for (int i = 0; i < n; i++ ){
    cin >> d.at(i); 
  }

  int sum;
  sum = 0;
  for (int i= 0; i < n; i++){
    for (int j = i+1; j < n; j++){
      sum = sum + d.at(i)*d.at(j);
    }
  }

  cout << sum << endl;
  //  cout << n << endl;
  //  cout << d << endl;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

int visited[maxn];
vector<int> g[maxn];
int tin[maxn], low[maxn];
set<pair<int, int>> bridge;
int timer = 0;

void dfs(int u, int p = -1) {
    tin[u] = low[u] = timer++;
    visited[u] = true;
    for (auto x : g[u]) {
        if (x == p)continue;
        if (!visited[x]) {
            dfs(x, u);
            low[u] = min(low[x], low[u]);
            if (low[x] > tin[u]) {
                bridge.insert({min(u, x), max(u, x)});
            }
        } else low[u] = min(low[u], tin[x]);
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;

        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 1; i <= n; i++)
        if (!visited[i])
            dfs(1);
    cout << bridge.size() << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

int n;
bool A[105][105];
int D[105];

void bfs(int src){
    queue<int> Q;
    Q.push(src);
    D[src] = 0;
    while(!Q.empty()){
        int cur = Q.front();
        Q.pop();
        for(int dst=0; dst<105; dst++){
            if(A[cur][dst]==1 && D[dst]==-1){
                D[dst]=D[cur]+1;
                Q.push(dst);
            }
        }
        
    }
}

int main(int argc, const char * argv[]) {
    for(int i=0; i<105; i++){
        for(int j=0; j<105; j++){
            A[i][j] = 0;
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        int u;
        int k;
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            int v;
            cin >> v;
            v--;
            A[u][v] = 1;
        }
    }
    for(int i=0; i<105; i++){
        D[i] = -1;
    }
    bfs(0);
    for(int i=0; i<n; i++){
        cout << i+1 << " " << D[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
N = int(input())
L = list(map(int,input().split()))

L.sort()
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] < L[j] and L[j] < L[k] and L[i] + L[j] > L[k]:
                cnt += 1

print(cnt)


Measured memory_bytes: 9184
INF = 10 ** 9
n, m = gets.split.map(&:to_i)
keys = []
m.times do
  price = gets.to_i
  openable = gets.split.map(&:to_i).inject(0) { |res, num| res | (2 ** (num - 1)) }
  keys << [price, openable]
end
max_num = 2 ** n
dp = Array.new(m + 1) { Array.new(max_num, INF) }
dp[0][0] = 0
m.times do |current|
  dp_current = dp[current]
  dp_next = dp[current + 1]
  price, openable = keys[current]
  max_num.times do |current_opened|
    next unless current_price = dp_current[current_opened]
    dp_next[current_opened] = current_price if dp_next[current_opened] > current_price
    next_opened = current_opened | openable
    tmp_price = current_price + price
    dp_next[next_opened] = tmp_price if dp_next[next_opened] > tmp_price
  end
end
puts dp.last.last == INF ? -1 : dp.last.last


Measured memory_bytes: 46280
n=str(input())
a=len(n)
N=list(n)
m=str(input())
A=len(m)
x=0
for i in range(a-A+1):
    C=[]
    for j in range(A):
        C.append(N[j])
    B=''.join(C)
    c=N[0]
    if B==m:
        print(i)
    N.remove(c)
    N.append(c)
   


Measured memory_bytes: 5580
#include <cmath>
#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const double pi=acos(-1);
int n;
struct vector2{ int x,y; }a[101];
vector2 operator-(vector2 a,vector2 b){ return (vector2){a.x-b.x,a.y-b.y}; }
double s[101];
int main(){
	scanf("%d",&n);
	ref(i,1,n){ scanf("%d%d",&a[i].x,&a[i].y); }
	ref(i,1,n){
		int m=0;
		ref(j,1,n)if(j!=i){
			vector2 b=a[j]-a[i];
			s[++m]=atan2(b.y,b.x);
		}
		sort(s+1,s+m+1);
		s[0]=s[m]-2*pi;
		double R=0;
		ref(j,1,m)R=max(R,s[j]-s[j-1]);
		R-=pi;
		if(R>=0){
			printf("%.10lf\n",R/(2*pi));
		}else printf("0\n");
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n, m;
int p[105000];

int r[100050];

void init(int n)
{
	for (int i = 1; i <= n; i++) {
		r[i] = i;
	}
}

int find(int x)
{
	if (r[x] == x)return x;
	else {
		r[x] = find(r[x]);
		return r[x];
	}
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	r[x] = y;
}

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

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

	}
	int x, y;
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		if (find(x) == find(y)) {
			continue;
		}
		else {
			unite(x, y);
		}

	}
	set<int>group;
	vector<int>g[105000];
	for (int i = 1; i <= n; i++) {
		int par = find(r[i]);
		group.insert(par);
		g[par].push_back(i);
	}
	
	int ans = 0;

	for (auto itr = group.begin(); itr != group.end();itr++) {
		vector<int>gg;
		int k = *itr;
		for (int j = 0; j < g[k].size(); j++) {
			gg.push_back(p[g[k][j]]);
		}
		sort(gg.begin(), gg.end());
		
		/*
		for (int i = 0; i < g[k].size(); i++) {
			cout << g[k][i] << " ";
		}
		cout << endl;
		for (int i = 0; i < gg.size(); i++) {
			cout << gg[i] << " ";
		}
		cout << endl;
		*/
		int s = 0, t = 0;
		int cnt = 0;

		//cout << "loop" << endl;
		while (s < g[k].size() && t < gg.size()) {
			//cout << cnt << endl;
			//cout << g[k][s] << " " << gg[t] << endl;
			//cout << endl;
			if (g[k][s] == gg[t]) {
				cnt++; s++; t++;
			}
			else {
				if (g[k][s] < gg[t])s++;
				else t++;
			}
		}
		ans += cnt;
	}

	cout << ans << endl;

	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    ll K;
    cin >> S >> K;
    string T = S + S;
    ll odd = 0, even = 0;
    int t = 0;
    for (int i = S.length() - 1; i >= 0; --i)
    {
        t++;
        if (i > 0 && S[i] != S[i - 1])
            break;
    }
    int s = 0;
    for (int i = 0; i < S.length(); ++i)
    {
        s++;
        if (i < S.length() - 1 && S[i] != S[i + 1])
            break;
    }

    FOR(i, T.length(), 1)
    {
        if (T[i - 1] == T[i])
        {
            if (i < S.length())
            {
                odd++;
            }
            else
            {
                even++;
            }
            T[i] = '#';
        }
    }

    ll ans = (K / 2LL) * even + ((K / 2LL) + (K % 2LL)) * odd;
    if (S.length() != t && t % 2 == 1 && s % 2 == 1)
    {
        K--;
        ans = odd + K * even;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 1001
#define N 150
int lcs(char *,char *);

int main(){
  int q,k,c[N];
  char X[MAX],Y[MAX];
  
  scanf("%d",&q);
  for(k=0;k<q;k++){
    scanf("%s",X);
    scanf("%s",Y);
    c[k]=lcs(X,Y);
    //}
    //for(k=0;k<q;k++){
    printf("%d\n",c[k]);
  }
  return 0;
}
int lcs(char *x,char *y){
  int i,j,m,n,C[MAX][MAX];
  m=strlen(x);
  n=strlen(y);
  for(i=1;i<=m;i++){
    C[i][0]=0;
  }
  for(j=0;j<=n;j++){
    C[0][j]=0;
  }
  
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1])
	C[i][j]=C[i-1][j-1]+1;
      else if(C[i-1][j]>=C[i][j-1])
	C[i][j]=C[i-1][j];
      else
	C[i][j]=C[i][j-1];
    }
  }
  return C[m][n];
}

Measured memory_bytes: 4520
#!/usr/bin/env python3
import sys
import math

def solve(N: int, X: int, T: int):
    a = (math.ceil(N/X))*T
    print(a)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()


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

int main() {
  int N; string S; cin >> N >> S;
  int ans = 0;
  rep(i, N-2) {
    if (S.substr(i, 3) == "ABC") ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
char s[50],t[50];
bool dp[500005];

int main(){
    cin >> s >> t;
    for(i=0;i<3;i++){
        if(s[i] == t[i])ans++;
    }
    p(ans);
    return 0;
}






Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	int n, m; cin >> n >> m;
	vector<int> h(n); rep(i, n)cin >> h[i];
	Graph G;
	vector<bool> flag(n); rep(i, n)flag[i] = true;
	rep(i, m) {
		cin >> a >> b;
		if (h[a-1] >= h[b-1])flag[b-1] = false;
		if (h[a-1] <= h[b-1])flag[a-1] = false;
	}
	int cnt = 0;
	rep(i, n) { if (flag[i])cnt++; }
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <set>

int main()
{	
	std::set<int> S;
	
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		int op, x;
		std::cin >> op >> x;
		if (op==0) {
			S.insert(x);
			std::cout << S.size() << std::endl;
		}
		else if (op==1) {
			if (S.find(x) != S.end()) std::cout << 1 << std::endl;
			else std::cout << 0 << std::endl;
		}
		else {
			S.erase(x);
		}
	}
	
	return 0;
}



Measured memory_bytes: 12460
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;

int main(void) {
    vector<ll> vec;
    int n, y;
    int i, j;
    cin >> n >> y;
    
    for(i=0; i<=n; i++) {
        for(j=0; i+j<=n; j++) {
            if(i+j<=n && 10000*i+5000*j+1000*(n-i-j)==y) {
                printf("%d %d %d", i, j, n-i-j);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var max int

	numbers := map[int]int{}
	for {
		var a int
		_, err := fmt.Scan(&a)
		if err != nil {
			break
		}
		numbers[a]++
		if numbers[a] >= max {
			max = numbers[a]
		}
	}

	var modes []int
	for a, b := range numbers {
		if b == max {
			modes = append(modes, a)
		}
	}

	sort.Ints(modes)
	for _, mode := range modes {
		fmt.Println(mode)
	}
}


Measured memory_bytes: 1124
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <iterator>

using namespace std;

int main()
{
    int c = 0;
    int a[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> a[i];
    }
    const int N = sizeof(a) / sizeof(int);
    while (true)
    {

        if (a[0] == a[1] && a[0] == a[2])
            break;

        int argmin = distance(a, min_element(a, a + N));

        if (
            abs(a[0] - a[1]) > 1 || abs(a[0] - a[2]) > 1 || abs(a[2] - a[1]) > 1)
        {
            a[argmin] += 2;
            c++;        
            continue;
        }

        if (
            (a[0] == a[1] && a[2] - a[0] > 0) ||
            (a[0] == a[2] && a[1] - a[0] > 0) ||
            (a[2] == a[1] && a[0] - a[1] > 0))
        {
            c++;
            break;
        }
        else
        {
            c += 2;
            break;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 256
def dfs(now,depth):
    if vis[now]:
        return 0
    if depth==n:
        return 1
    vis[now]=1
    ans=0
    for i in range(n):
        if graph[now][i]:
            ans+=dfs(i,depth+1)
    vis[now]=0
    return ans
n,m=map(int,input().split())
edge=[[int(i)for i in input().split()]for i in range(m)]
graph=[[0 for i in range(n)] for i in range(n)]
vis=[0]*n
for i in range(m):
    graph[edge[i][0]-1][edge[i][1]-1]=1
    graph[edge[i][1]-1][edge[i][0]-1]=1
print(dfs(0,1))


Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    s = set()
    for i in a:
        k = 0
        while not i&1:
            i >>= 1
            k += 1
        if not k:
            print(0)
            return
        s.add(k)
    if len(s) != 1:
        print(0)
        return
    a = [i >> 1 for i in a]
    l = a[0]
    for i in a[1:]:
        g = gcd(l,i)
        l = l*i//g
    print((m//l)-(m//(2*l)))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 58224
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G ((c=A[a]+A[P[a]]+C[a])%k?c:0)+M(
typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
    d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}
main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];S(a=H[a],*Z=O[a]=++b))X[a]=n;
//       for(cin>>a;cin>>s>>a>>b;S(H[a],b=O[a]),S(a,b-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}
       for(cin>>a;cin>>s>>a>>b;S(a,O[a]-1),S(H[a],O[a]))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 37312
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if a[p]==0:
      if s=="AC":
        a[p]=1
      else:
        b[p]+=1
for i in range(n):
    if a[i]==0:
        b[i]=0
print(sum(a),sum(b))

Measured memory_bytes: 45528
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main (){
ll K, Ans = 1;cin >> K;
ll n = 0;
map<ll, ll> M;

while(1){

    n*=10;n+=7;n%=K;M[n]++;

    if(n == 0){cout << Ans;exit(0);}

    if(M[n] == 2)break;

    Ans++;
}
cout << -1;
}

Measured memory_bytes: 66044
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        //System.out.print(S);
        if(S.equals("hi")||S.equals("hihi")||S.equals("hihihi")||S.equals("hihihihi")||S.equals("hihihihihi")){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
    }    
}

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

struct S {
  int p, w, left, right, f;
  double h;
};


const int INF = 1<<28;
const double inf = 1e10;
const double eps = 1e-8;
const int MAXN = 11;
const int MAXL = 11;

int N;
int B[MAXN], H[MAXN];
int L;
int P[MAXL], T[MAXL], id[MAXL];

bool equals(double a, double b) {
  return abs(a - b) < eps;
}

double getT(double h, double w, double f) {
  return 30.0 * h * w / f;
}

double getH(double t, double w, double f) {
  return f*t / (30.0*w);
}

int main() {
  int D; cin >> D;
  while(D--) {
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> B[i] >> H[i];
    vector<S> s(N+1, (S){0, 0, INF, INF, 0, 0});
    for(int i = 0; i < N; ++i) {
      s[i].p = i == 0 ? 0 : B[i-1];
      s[i].w = i == 0 ? B[i] : B[i] - B[i-1];
      s[i].right = s[i+1].left = H[i];
    }
    s[N].p = B[N-1];
    s[N].w = 100 - B[N-1];
    ++N;
    int M; cin >> M;
    while(M--) {
      int F, A; cin >> F >> A;
      for(int i = 1; i <= N; ++i) {
        if(i == N || F < s[i].p) {
          s[i-1].f += A;
          break;
        }
      }
    }
    int L; cin >> L;
    {
      vector<pair<pair<int, int>, int> > v(L);
      for(int i = 0; i < L; ++i) {
        cin >> v[i].first.second >> v[i].first.first;
        v[i].second = i;
      }
      sort(v.begin(), v.end());
      for(int i = 0; i < L; ++i) {
        T[i] = v[i].first.first;
        P[i] = v[i].first.second;
        id[i] = v[i].second;
      }
    }
    double now = 0;
    vector<double> ans(L);
    for(int k = 0; k < L; ) {
      double t = T[k] - now;
      for(int i = 0; i < N; ++i) {
        t = min(t, getT(min(s[i].left, s[i].right) - s[i].h, s[i].w, s[i].f));
      }
      now += t;
      for(int i = 0; i < N; ++i) {
        s[i].h += getH(t, s[i].w, s[i].f);
        if(equals(s[i].h, s[i].left)) s[i].h = s[i].left;
        if(equals(s[i].h, s[i].right)) s[i].h = s[i].right;
      }
      for(int i = 0; i+1 < N; ++i) {
        if(equals(s[i].h, s[i].right) && equals(s[i].h, s[i+1].h)) {
          s[i].right = s[i+1].right;
          s[i].w += s[i+1].w;
          s[i].f += s[i+1].f;
          s.erase(s.begin() + i + 1);
          --N;
        }
      }
      for(int i = 0; i < N; ++i) {
        if(equals(s[i].h, s[i].left)) {
          s[i-1].f += s[i].f;
          s[i].f = 0;
        } else if(equals(s[i].h, s[i].right)) {
          s[i+1].f += s[i].f;
          s[i].f = 0;
        }
      }
      if(equals(now, T[k])) {
        for(int i = 1; i <= N; ++i) {
          if(i == N || P[k] < s[i].p) {
            ans[id[k]] = min(50.0, s[i-1].h);
            break;
          }
        }
        ++k;
      }
    }
    for(int i = 0; i < L; ++i) {
      printf("%.10f\n", ans[i]);
    }
  }
  return 0;
}

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

using namespace std;

#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 each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    ll r = v[2] / 2, b = v[2] - r;
    ll ans = abs(r - b) * v[0] * v[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++)
        ans = (ans + i * (n - i + 1));

    for(ll i = 1; i < n; i++){
        ll a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        ans = (ans - a * (n - b + 1));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

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


int main(){
    int h1, m1, h2, m2, k;
    cin >> h1  >> m1 >> h2 >> m2 >> k;

    int su = 0;
    su = (h2 - h1) * 60 + (m2 -m1);
    cout << su - k << endl;

    return 0;
}


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

int main(void){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  const int dx=tx-sx,dy=ty-sy;
  
  cout<<string(dy,'U')<<string(dx,'R');
  cout<<string(dy,'D')<<string(dx,'L');
  cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
  cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	
	int a = 0 ;
	int b = 0 ;
	int c = 0 ;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if ( a < b && b < c ){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	
	return 0;
}

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

int main() {
   int a,b,k;
   cin >> a >> b >> k;
   for(int i=a;i<=min(a+k-1,b);i++)
   cout << i << endl;
   for(int i=max(b-k+1,a+k);i<=b;i++)
   cout << i << endl;
}

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

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 long long INF = 1LL << 60;

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

    long long h[n];
    for (int i = 0; i < n; ++i) cin >> h[i];

    long long dp[n];
    for (int i = 0; i < n; ++i) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < k; ++j) {
            if (i > j) chmin(dp[i], dp[i - j - 1] + abs(h[i] - h[i - j - 1]));
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <sstream>
#include <set>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))


int main() {

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;


    long long cur = 1;
    int res = 1;
    while (N - cur > 0) {

        cur *= K;
        ++res;
    }

    if (N != cur) {
        --res;
    }

    cout << res << endl;

    return 0;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")

typedef long long ll;
typedef unsigned long long ull;
// typedef __int128_t lll;
#define fatnet ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

const ll MOD1 = 1e9 + 7;
const ll MOD2 = 2000003983; // 3571 1e9 + 97
const ll MOD3 = 1e9 + 9;
const ll p1 = 1e6 + 3;
const ll p2 = 2017; // 131 37
const ll p3 = 37;
const ll INF = 5e18;

int main() {
    fatnet;

    ll n, d;
    cin >> n >> d;
    vector < vector < ll > > a(n);
    for (int i = 0; i < n; ++i) {
        a[i].resize(d);
        for (int j = 0; j < d; ++j)
            cin >> a[i][j];
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            double subans = 0;
            for (int t = 0; t < d; ++t) {
                subans += (a[i][t] - a[j][t]) * (a[i][t] - a[j][t]);
            }
            subans = sqrt(subans);
            if (floor(subans) == subans)
                ++ans;
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

a, b = list(map(int, input().split()))

if a <= 0 <= b:
    r = "Zero"
elif a > 0:
    r = "Positive"
else:
    if (b - a + 1) % 2 == 0:
        r = "Positive"
    else:
        r = "Negative"

ans = r
print(ans)


Measured memory_bytes: 2940
x, n = [int(i) for i in input().split()]
arr = [int(j) for j in input().split()]
if x not in arr:
	print(x)
else:
	xl = x
	xr = x
	count = 0
	while True:
		if count % 2 == 0:
			xl -= 1
			if xl not in arr:
				print(xl)
				break
		else:
			xr += 1
			if xr not in arr:
				print(xr)
				break
		count += 1



Measured memory_bytes: 9196
cnt, n, a = 0, int(input()), list(map(int, input().split()))
for i in range(n):
    mini = i
    for j in range(i, n):
        if a[j] < a[mini]: mini = j
    if i!=mini:
        a[i], a[mini] = a[mini], a[i]
        cnt+=1
print(*a)
print(cnt)

Measured memory_bytes: 7688
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  double n, t, a;
  cin >> n >> t >> a;
  vector<double> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 0;
  double temp = 1e9;
  for (int i = 0; i < n; i++) {
    double x = t - h[i] * 0.006;
    if (abs(a - x) < temp) {
      temp = abs(a - x);
      ans = i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
    int m, f, r;
    int s;

    while (1) {
        scanf("%d%d%d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) break;

        if (m < 0 || f < 0) puts("F");
        else {
            s = m + f;
            if (s >= 80) puts("A");
            else if (s >= 65) puts("B");
            else if (s >= 50) puts("C");
            else if (s < 30) puts("F");
            else puts(r >= 50 ? "C" : "D");
        }
    }
    return 0;
}



Measured memory_bytes: 2052
# Problem  https://atcoder.jp/contests/abc082/tasks/abc082_b
# Ruby 3rd Try
s = STDIN.gets.chomp
t = STDIN.gets.chomp
sChars = s.chars
tChars = t.chars
(sChars.sort.join < tChars.sort.reverse.join) ? (puts "Yes"):(puts "No")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    if (c <= b+a){
        cout << c+b;
        return 0;
    }
    int ans = b+c;
    c -= b;
    c-=a;
    c--;
    if (c > 0) ans -= c;
    cout << ans;
    return 0;
}




Measured memory_bytes: 768
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	string s;
	cin>>s;
	if(s == "SAT") cout<<1;
	if(s == "FRI") cout<<2;
	if(s == "THU") cout<<3;
	if(s == "WED") cout<<4;
	if(s == "TUE") cout<<5;
	if(s == "MON") cout<<6;
	if(s == "SUN") cout<<7;
	
	return 0;
}


Measured memory_bytes: 3600
import Control.Monad
  ( replicateM )
import Data.List
  ( sort )

main :: IO ()
main = do
  [n,l] <- map read . words <$> getLine
  ss    <- replicateM n getLine
  putStrLn $ minimumCombination ss

minimumCombination
  :: [String] -> String
minimumCombination = concat . sort


Measured memory_bytes: 1404
#include<iostream>
using namespace std;
int main()
{
    int n,m,x;
    int cot,q1=0,q2=0;
    cin>>n>>m>>x;
    for(int i=1;i<=m;i++)
        {
            cin>>cot;
            if(cot<x) q1++;
            if(cot>x&&cot<n) q2++;
        }
    if(q1>q2) cout<<q2;
    else cout<<q1;
}


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

int main() {
  int n,m; cin >> n >> m;
  int a,b;
  vector<int> G(n,0);
  REP(i,m) {
    cin >> a >> b;
    G[a-1]++; G[b-1]++;
  }
  REP(i,n) { cout << G[i] << endl; }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	string s;
	int n;
 
	cin >> s;
	n = s.length();
 
	if(s[0]!='A')
	{
		cout << "WA" << '\n';
		return 0;
	}
 
	int cnt = 0;
	for(int i=0;i<n;i++)
	{
		if(s[i]>='A' && s[i]<='Z')
		{
			cnt++;
		}		
	}
 
	if(cnt>2)
	{
		cout << "WA" << '\n';
		return 0;
	}
 
	cnt = 0;
	for(int i=2;i<n-1;i++)
	{
		if(s[i]=='C')
		{
			cnt++;
		}
	}
 
	if(cnt!=1)
	{
		cout << "WA" << '\n';
	}
	else
	{
		cout << "AC" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
n,p=map(int,input().split())
if n==1:
    print(p)
    exit()
d=dict()
pp=p
i=2
while p!=1:
    if p%i==0:
        p//=i
        if i in d:
            d[i]+=1
        else:
            d[i]=1
    elif i>pp**0.5:
        break
    else:
        i+=1
p=1
if d:
    for i,j in d.items():
        p*=i**(j//n)
    print(p)
else:
    print(1)

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

using namespace std;
typedef long long ll;
const int N=1e5+10;
int n;
ll x[N], y[N], h[N];

int main() {
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>x[i]>>y[i]>>h[i];
	}
	for(int i=0; i<=100; i++) {
		for(int j=0; j<=100; j++) {
			int ok=1, ans=-1;
			ll up=0x3f3f3f3f;
			for(int k=1; k<=n; k++) {
				ll d=abs(i-x[k])+abs(j-y[k]);
				if (h[k]>0) {
					ll tmp=h[k]+d;
					if (ans==-1) ans=tmp;
					else if (tmp!=ans) {
						ok=0;
					}
				}
				else {
					up=min(up, d);
				}
			}
			if (ok&&ans!=-1&&ans<=up) {
				cout<<i<<' '<<j<<' '<<ans<<endl;
				return 0;
			}
		}
	}	


	return 0;
}


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

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    if (s == "Cloudy") cout << "Rainy" << endl;
    if (s == "Rainy") cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int x;
  cin >> x;

  if(x == 0){
    cout << "1" << endl;
  }
  else{
    cout << "0" << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import Control.Monad (forM_, foldM)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST

main = do
  n <- readLn
  xs <- U.map fromIntegral . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let ys :: U.Vector Int64
      ys = U.scanl (+) 0 xs
  let arr :: UArray (Int,Int) Int64
      arr = runSTUArray $ do
        arr <- newArray ((0,0),(n,n)) 0
        -- arr ! (i,j) : 半開区間 [i,j) にいるやつを全部合体させるために必要な最小のコスト
        -- 1個のスライムから1個のスライムを得るのに合体は必要ないので arr ! (i,i+1) == 0
        forM_ [2..n] $ \d -> do
          forM_ [0..n-d] $ \i -> do
            let !j = i + d -- 0 <= i < j <= d
            -- c1: これまでの合体で払うコストの最小値
            c1 <- foldM (\x a -> min x <$> a) maxBound [(+) <$> readArray arr (i,k) <*> readArray arr (k,j) | k <- [i+1..j-1]]
            let c2 = ys U.! j - ys U.! i -- 今回の合体の際に払うコスト
            writeArray arr (i,j) $! c1 + c2
        return arr
  print $ arr ! (0,n)


Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;



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

	vector<int> L(M);
	vector<int> R(M);

	for (int i = 0; i < M; i++)
	{
		cin >>L[i] >> R[i];
	}

	int max_card = R[0];
	int  min_card = L[0];

	for (int i = 1; i < M; i++)
	{
		min_card = max(min_card, L[i]);
		max_card = min(max_card, R[i]);
	}

	if (max_card >= min_card) {
		cout << max_card - min_card + 1 <<endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll mod=1000 * 1000 * 1000 + 7;
ll mul(ll a, ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll add(ll a, ll b)
{
	return ((a%mod)+(b%mod))%mod;
}
ll sub(ll a, ll b)
{
	return ((a%mod)-(b%mod)+mod)%mod;
}
ll n,m,v,p;
ll a[100005];
bool ch(ll x)
{
	if(x<p)
	{
		return 1;
	}
	if(a[x]+m<a[p-1])
	{
		return 0;
	}
	
	ll u=v-(p-1)-(n-x);
	u*=m;
	//cout<<x<<" "<<u<<"\n";
	for(ll i=p-1;i<x;i++)
	{
		u-=abs(a[x]+m-a[i]);
	}
	if(u<=0)
	{
		return 1;
	}
	else 
		return 0;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>v>>p;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	ll l=0,h=n-1;
	while(h-l>1)
	{
		ll m=(h+l)/2;
		if(ch(m))
		{
			l=m;
		}
		else
		{
			h=m;
		}
	}
	if(ch(h))
	{
		cout<<h+1;
	}
	else
	{
		cout<<l+1;
	}
}


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

using namespace std;

const int N = 1e5;

vector<int> g[N];
int color[N];
bool vis[N];

bool dfs(int u) {
  vis[u] = true;
  for (int v : g[u]) {
    if (vis[v]) {
      if (color[v] != color[u] ^ 1) return false;
    } else {
      color[v] = color[u] ^ 1;
      if (!dfs(v)) return false;
    }
  }
  return true;
}

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

  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  if (dfs(0)) {
    long long a = count(color, color + n, 0);
    long long b = count(color, color + n, 1);
    long long total = a * b;
    cout << total - m << endl;
  } else {
    long long total = 1LL * n * (n - 1) / 2 - m;
    cout << total << endl;
  }
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

int main() {
	ll n,k;
	ll ans=0;
	cin>>n>>k;
	rep(i,k+1,n+1){
		ll s=0;
		while(1){
			if(i*s+k<=n){
				if(s==0&&k==0)ans--;
				ans+=min(n-i*s-k+1,i-k);
			}else break;
			s++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,H;cin>>N>>H;
  vector<long>A(N),B(N);
  for(long i=0;i<N;i++)cin>>A[i]>>B[i];
  sort(A.begin(),A.end(),greater<int>());
  sort(B.begin(),B.end(),greater<int>());
  long i=0;long ans=0;
  while(B[i]>A[0]&&H>0){
    H-=B[i];i++;ans++;
  }
  if(H<=0)cout<<ans;
  else cout<<ans+H/A[0]+(H%A[0]!=0);
  
}

Measured memory_bytes: 1920
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    vector<ll> a(n), s(n+1);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    sort(a.begin(), a.end());
    for (i = 0; i < n; i++) {
        s[i + 1] = s[i] + a[i];
    }
    int cnt = 0;
    for (i = n - 1; i >= 0; i--) {
        if (i == n - 1) {
            cnt++;
        }
        else {
            if (a[i + 1] > s[i + 1] * 2) {
                break;
            }
            else {
                cnt++;
            }
        }
    }
    printf("%d\n", cnt);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i,n-1){
        string a,b;
        int cnt = 0;
        a = s.substr(0,i+1); b = s.substr(i+1);
        rep(i,26){
            bool p=false,q=false;
            for(auto c: a) if(c == 'a'+i) p = true;
            for(auto c: b) if(c == 'a'+i) q = true;
            if(p && q) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256