akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
#include <algorithm>
#include <bitset>
#include <set>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;
typedef long long int lint;

class Point {
public:
	int x;
	int y;

	Point() {
		x = y = 0;
	}
	Point(int x, int y) {
		this->x = x; this->y = y;
	}

	Point operator + (Point obj) {
		return Point(this->x + obj.x, this->y + obj.y);
	}
	Point operator - (Point obj) {
		return Point(this->x - obj.x, this->y - obj.y);
	}
	int operator * (Point obj) {
		return (this->x * obj.y - this->y * obj.x);
	}

	friend std::ostream& operator << (std::ostream& ostr, const Point& p) {
		std::cout << "{" << p.x << ", " << p.y << "}";
		return ostr;
	}
};

bool interior(Point p1, Point p2, Point p3, Point p) {
	Point v1, v2, v3, pp1, pp2, pp3;
	v1 = p2 - p1; v2 = p3 - p2; v3 = p1 - p3;
	pp1 = p - p1; pp2 = p - p2; pp3 = p - p3;
	int cp1, cp2, cp3;
	cp1 = v1 * pp1; cp2 = v2 * pp2; cp3 = v3 * pp3;
	if (cp1 < 0 && cp2 < 0 && cp3 < 0) return true;
	if (cp1 > 0 && cp2 > 0 && cp3 > 0) return true;
	return false;
}

void AOJ0143()
{
	Point p[3], k, s;
	REP(i, 3) {
		cin >> p[i].x >> p[i].y;
	}
	cin >> k.x >> k.y >> s.x >> s.y;

	if (interior(p[0], p[1], p[2], k) ^ interior(p[0], p[1], p[2], s)) {
		cout << "OK" << endl;
	}
	else cout << "NG" << endl;

	return;
}

int main()
{
	int n;
	cin >> n;
	REP(i, n) AOJ0143();

	return 0;
}

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

int main() {
  int n, m;
  ll k;

  cin >> n >> m >> k;

  vector<ll> a(n);
  vector<ll> b(m);
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, m) {
    cin >> b[i];
  }

  vector<ll> at(n);
  map<ll, int> at_index;
  {
    ll v = 0;
    rep(i, n) {
      v += a[i];
      at[i] = v;
      at_index[v] = i;
    }
  }
  vector<ll> bt(m);
  map<ll, int> bt_index;
  {
    ll v = 0;
    rep(i, m) {
      v += b[i];
      bt[i] = v;
      bt_index[v] = i;
    }
  }

  int ans = 0;
  int a_at = 0;
  // at から読むケース
  rep(i, n) {
    int a_ans = 0;
    int b_ans = 0;
    ll ret = 0;
    if(at[i] > k) {
      break;
    } else {
      a_ans = i + 1;
      ret = k - at[i];
    }
    if(bt[0] > ret) {
      // btからは読めない
    } else {
      auto it = lower_bound(bt.begin(), bt.end(), ret);
      if(*it > ret) {
        it--;
      }
      b_ans = bt_index[*it] + 1;
    }
    ans = max(ans, a_ans + b_ans);
  }

  // bt から読むケース
  rep(i, m) {
    int a_ans = 0;
    int b_ans = 0;
    ll ret = 0;
    if(bt[i] > k) {
      break;
    } else {
      b_ans = i + 1;
      ret = k - bt[i];
    }
    if(at[0] > ret) {
      // atからは読めない
    } else {
      auto it = lower_bound(at.begin(), at.end(), ret);
      if(*it > ret) {
        it--;
      }
      a_ans = at_index[*it] + 1;
    }
    ans = max(ans, a_ans + b_ans);
  }

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


Measured memory_bytes: 34388
import heapq
n, m = map(int, input().split())
limit = [[] for i in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        # 間に合わないので使えない        
        continue
    # m-a日目までに取り掛かれば間に合うバイトを格納
    limit[m-a].append(b)

available = []
ans = 0
for i in range(m-1, -1, -1):
    # 最終日から辿ることで、新たに選択不可となるバイトが生じない
    for item in limit[i]:
        heapq.heappush(available, -item)
    if available:
        ans += -heapq.heappop(available)
print(ans)

Measured memory_bytes: 24288
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,in,ans=0;
    cin>>a;
    vector<int> c,d;
    for(int i=0;i<a;i++){
        cin>>in;
        c.push_back(in);
    }
    cin>>b;
    for(int i=0;i<b;i++){
        cin>>in;
        d.push_back(in);
    }
    for(int i:d){
        if(find(c.begin(),c.end(),i)!=c.end())ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;
const int N = 1e5 + 3;
int n, k, q, freq[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	int n, m;
	scanf("%d %d", &n, &m);
	priority_queue<int> q;
	for (int i = 0; i < n; ++i) {
		int a;
		scanf("%d", &a);
		q.push(a);
	}
	while (m--) {
		int val = q.top();
		q.pop();
		q.push(val / 2);
	}
	long long res = 0;
	while (q.size()) {
		res += q.top();
		q.pop();
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 892
import numpy as np

n, a, b = map(int, input().split())
h = np.array([int(input()) for _ in range(n)], dtype=np.int64)


def f(x):
    li = h - b * x
    li[li < 0] = 0
    cnt = np.ceil(li / (a - b))
    ret = cnt.sum() <= x
    return ret


l = 0
r = np.ceil(max(h) / b).astype(np.int64)
while r - l > 1:
    mid = (l + r) // 2
    if f(mid):
        r = mid
    else:
        l = mid

print(r)


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();

		Integer num[] = new Integer[N];
		for (int i = 0; i < N; i++) {
			num[i] = scanner.nextInt();
		}

		Arrays.sort(num, Collections.reverseOrder());

		int sum = 0;
		for (int i = 0; i < K; i++) {
			sum += num[i];
		}


		System.out.println(sum);
	}

}

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

int main (void){
  int a,b;
  cin >> a >> b;
  if ( (a + b)%2==1 ){
    cout << (a + b)/2+1 << endl;
  }
  else {
    cout << (a + b)/2 << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
lis = list(map(int, input().split()))
count = 0
minn = lis[0]
minl = min(lis)
flug = 0
for i in range(n):
    if flug == 0:
        if  minn >= lis[i]:
            count += 1
            minn = lis[i]
            if minn == minl:
                count += lis[i+1:].count(minl)
                flug = 1
print(count)

Measured memory_bytes: 24744
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
using namespace std;
typedef long long int lo;
#define pb push_back
#define pf push_front
#define ft front
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9;
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
bool is_p(string s){
    lo n = s.size();
    string s1 = "";
    for(lo i = n - 1 ; i >= 0 ; i--){
        s1 += s[i];
    }
    if(s == s1){
        return 1;
    }
    return 0;
}
lo a,b,c,d,e,n,m,k,t,h,x,y,a1[100005],a2[100005];
char c1[505][505],c2,c3,c4;
string s1,s2,s3,s4;
double d1,d2,d3;
vector <lo> v;
map <lo,lo> mp1;
map <string,lo> mp2;
set <lo> stt;
queue <lo> q;
priority_queue <lo> pq;
lo vis [10000];
deque <lo> dq;
int main() {
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    cin >> s1;
    n = s1.size();
    if(!is_p(s1)){
        cout << "No\n";
        return 0;
    }
    s2 = s1.substr(0, (n - 1) / 2);
    if(!is_p(s2)){
        cout << "No\n";
        return 0;
    }
    // cout << s1 << " " << s2 << " " << s3 << endl;
    s3 = s1.substr((n + 3) / 2 - 1, n - ((n + 3) / 2) + 1);
    if(!is_p(s3)){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    // cout << s1 << " " << s2 << " " << s3 << endl;
    return 0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int G[500][500];
int ACC[501][501];

int main() {
  int n, m, q; in(n),in(m),in(q);
  loop(i,0,m) {
    int l, r; in(l),in(r);
    l--;r--;
    G[l][r]++;
  }
  
  loop(y,0,n) {
    loop(x,0,n) {
      ACC[y+1][x+1] = ACC[y+1][x] + ACC[y][x+1] - ACC[y][x] + G[y][x];
    }
  }
  
  // loop(y,0,n+1) {
  //   loop(x,0,n+1) {
  //     print(ACC[y][x], " ");
  //   }
  //   print("");
  // }
  
  loop(i,0,q) {
    int l,r; in(l),in(r);
    int cnt = ACC[r][r];
    cnt += ACC[l-1][l-1];
    cnt -= ACC[l-1][r];
    cnt -= ACC[r][l-1];
    // print(ACC[r][r]);
    // print(ACC[l-1][l-1]);
    // print(ACC[l-1][r]);
    // print(ACC[r][l-1]);
    print(cnt);
  }
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> rate(8, 0);
	int a;
	int over = 0;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(a >= 3200)over++;
		else rate[a / 400]++;
	}
	
	int ans = 0;
	for(int i = 0; i < 8; i++){
		if(rate[i] > 0)ans++;
	}

	cout << max(1, ans) << " " << ans + over << endl;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc121a()
}

fun abc121a() {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val whites = H * W
    val blacks = H * w + W * h - h * w
    println(whites - blacks)
}


Measured memory_bytes: 37824
s = int(input())
def f(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3*n+1
ans = []
for i in range(1,1000001):
  if i == 1:
    a = s
    ans.append(a)
  else:
    a = f(ans[-1])
    ans.append(a)
  if ans.count(ans[-1]) > 1:
    print(i)
    break

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

#define ll           long long int

static const int maxn = 3000 + 5;

int N;
ll score[maxn];
ll dp[maxn][maxn][2];
bool memoize[maxn][maxn][2];

inline ll solve(int i, int j, int turn)
{
      if (i > j) return 0;
      ll &ret = dp[i][j][turn];
      bool &mem = memoize[i][j][turn];
      if (mem) return ret;
      mem = 1;
      if (turn == 0)
      {
            if (i == j)
            {
                  ret = (-score[i] + solve(i+1, j, 1));
            }
            else
            {
                  ll takeFront = -score[i] + solve(i+1, j, 1);
                  ll takeBack = -score[j] + solve(i, j-1, 1);
                  ret = min(takeFront, takeBack);
            }
      }
      else
      {
            if (i == j)
            {
                  ret = score[i] + solve(i+1, j, 0);
            }
            else
            {
                  ll takeFront = score[i] + solve(i+1, j, 0);
                  ll takeBack = score[j] + solve(i, j-1, 0);
                  ret = max(takeFront, takeBack);
            }
      }
      return ret;
}

int main()
{
      ll sum = 0;
      cin >> N;
      for (int i = 1; i <= N; i++)
      {
            cin >> score[i];
            sum += score[i];
      }
      cout << (solve(1, N, 1));
}



Measured memory_bytes: 158208
N = int(input())
A = list(map(int,input().split()))

dp = [0] * N
dp[0] = 1000

for i in range(1, N):
    dp[i] = dp[i - 1]
    for j in range(i):
        V = dp[j] // A[j]
        W = dp[j] + (A[i] - A[j]) * V
        dp[i] = max(dp[i], W)

print(dp[N - 1])

Measured memory_bytes: 9200
import sys
fin = sys.stdin.readline

N = int(fin())
T, A = [int(elem) for elem in fin().split()]
avg_temps = [1000 * T - 6 * int(elem) for elem in fin().split()]

min_diff = float('inf')
closest_place = -1

for place, avg_temp in enumerate(avg_temps, start=1):
    diff = abs(avg_temp - 1000 * A)
    if diff < min_diff:
        min_diff = diff
        closest_place = place

print(closest_place)


Measured memory_bytes: 3060
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

struct Seg{
    vec dat;
    //要素数
    int n;

    Seg(int n_){
        n=1;
        while(n<n_)n*=2;
        dat.resize(2*n);

        for(int i=0;i<2*n-1;i++)
            dat[i]=INF;
    }

    //k番目の値をaに変更
    void update(int k,ll a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }

    //[a,b)の最小値を求める
    //kは節点の番号、[l,r)はその区間
    ll query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l)return INF;
        if(a<=l && r<=b)return dat[k];
        else{
            ll vl=query(a,b,2*k+1,l,(l+r)/2);
            ll vr=query(a,b,2*k+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
};

int main(){
    int N,M; cin>>N>>M;
    string S; cin>>S;
    Seg seg(N+M);
    vec dp(N,INF);
    seg.update(N,0);
    for(int i=N-1;i>=0;i--){
        if(S[i]=='1') continue;
        ll res=seg.query(i+1,i+M+1,0,0,seg.n);
        if(res==INF){
            cout<<-1<<endl;
            return 0;
        }
        dp[i]=1+res;
        seg.update(i,dp[i]);
    }
    vec ans={0}; ll k=dp[0];
    rep(i,N){
        if(dp[i]==k-1){
            ans.pb(i);
            k--;
        }
    }
    ll m=dp[0];
    rep(i,m-1) cout<<ans[i+1]-ans[i]<<" ";
    cout<<N-ans[m-1]<<endl;
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

string S,T;
int N;
int main(){
    cin >> S >> T;
    
    cout << T << S << endl;
    return 0;
}


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

using namespace std;

map <string,int> m;

int main() 
{
    m["SUN"]=0;
    m["MON"]=1;
    m["TUE"]=2;
    m["WED"]=3;
    m["THU"]=4;
    m["FRI"]=5;
    m["SAT"]=6;
    string s;
    cin>>s;
    if (s=="SUN") return cout<<7,0;
    cout<<7-m[s];
}

Measured memory_bytes: 256
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;
fn dfs(
    now: usize,
    val: usize,
    ans: &mut Vec<usize>,
    graph: &mut Vec<Vec<usize>>,
    seen: &mut Vec<bool>,
) {
    if seen[now] {
        return;
    }

    seen[now] = true;
    ans[now] = val;

    for &next in graph[now].clone().iter() {
        println!("next {}", next);
        dfs(next, now, ans, graph, seen);
    }
}
fn bfs(st: usize, gr: &Vec<Vec<usize>>, ans: &mut Vec<usize>) -> usize {
    let mut que = VecDeque::new();
    let mut now;
    let mut seen = vec![false; gr.len()];

    que.push_back(st);
    seen[st] = true;

    while !que.is_empty() {
        now = que.pop_front().unwrap();

        for e in gr[now].iter() {
            if !seen[*e] {
                que.push_back(*e);
                ans[*e] = now;
                seen[*e] = true;
            }
        }
    }

    *ans.iter().max().unwrap()
}
fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize,usize);m],
    }

    let mut gr = vec![vec![]; n];

    for i in 0..m {
        gr[ab[i].0 - 1].push(ab[i].1 - 1);
        gr[ab[i].1 - 1].push(ab[i].0 - 1);
    }

    //println!("{:?}", gr);
    let mut ans = vec![(n + 10); n];
    ans[0] = 0;
    //let mut seen = vec![false; n];
    bfs(0, &mut gr, &mut ans);
    //println!("{:?}", ans);

    for i in 0..n {
        if ans[i] == n + 10 {
            println!("No");
            return;
        }
    }
    println!("Yes");
    for i in 1..n {
        println!("{}", ans[i] + 1);
    }
}


Measured memory_bytes: 17416
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    vector<int> ABC(3);
    rep(i, 3) cin >> ABC[i];

    sort(all(ABC));

    int A1 = ABC[2] - ABC[0], A2 = ABC[2] - ABC[1];
    int ans = A1 / 2;
    ans += A2 / 2;

    if (A1 % 2 && A2 % 2) {
        ans++;
    }
    else if (A1 % 2 || A2 % 2) {
        ans += 2;
    }

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

Measured memory_bytes: 3564
#include<iostream>
#include<cmath>
using namespace std;
int c,p,rp;
void rec(int m,int cp){
	if(m==1||cp<4){
		c++; return;
	}
	for(int i=0;i*m*m<=cp;i++)rec(m-1,cp-i*m*m);
}
int main(){
	while(cin>>p,p){
		c=0; rp=(int)sqrt(p); rec(rp,p);
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> vec_t(N+1);
    vector<int> vec_x(N+1);
    vector<int> vec_y(N+1);

    vec_t.at(0) = 0;
    vec_x.at(0) = 0;
    vec_y.at(0) = 0;

    for (int i = 1; i <= N; i++)
    {
        cin >> vec_t.at(i) >> vec_x.at(i) >> vec_y.at(i); 
    }
    
    int dis;
    bool check = true;

    for (int i = 1; i <= N; i++)
    {
        dis = abs(vec_x.at(i) - vec_x.at(i-1)) + abs(vec_y.at(i) - vec_y.at(i-1));
        if (dis > vec_t.at(i) - vec_t.at(i-1))
        {
            check = false;
        }
        else
        {
            if (vec_t.at(i) % 2 == 0)
            {
                if ((vec_x.at(i) + vec_y.at(i)) % 2 != 0)
                {
                    check = false;
                }
            }
            else
            {
                if ((vec_x.at(i) + vec_y.at(i)) % 2 != 1)
                {
                    check = false;
                }
            }
        }

        if (!check) break;
    }

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


Measured memory_bytes: 1408
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;
vector<string> lis(0);

int digit(long long int n){
    string s;
    s = std::to_string(n);
    return s.size();
}

void dfs(ll a, ll d, string p){
    if(a == d){
        lis.emplace_back(p);
        return;
    }
    string l = p + '3';
    dfs(a+1, d, l);
    string m = p + '5';
    dfs(a+1, d, m);
    string n = p + '7';
    dfs(a+1, d, n);
}

int main(){
    ll N; cin >> N;
    ll ans = 0;
    ll d = digit(N);
    rep(i, 3, d){
        ans += pow(3, i) - 3*pow(2,i) + 3;
    }
    string p = "";
    dfs(0, d, p);
    for(auto k: lis){
        ll q = stoi(k);
        if(q > N){continue;}
        bool w = false, x = false, y = false;
        rep(j, 0, d){
            if(k[j] == '3'){w = true;}
            else if(k[j] == '5'){x = true;}
            else{y = true;}
        }
        if(x&&y&&w){ans++;}
    }
    prt(ans);
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
	int a, b;
	cin >> a >> b;
	if (a - 2 * b <= 0)
		cout << "0" << endl;
	else
		cout << a - 2 * b << endl;
}





Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int ans=a;
	ans=max(ans,b);
	ans=max(ans,c);
	if ((ans*3-a-b-c)%2==0) printf("%d\n",(ans*3-a-b-c)/2);
	else printf("%d\n",((ans+1)*3-a-b-c)/2);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int x;
    cin >> x;

    cout << 48 - x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	VI p(n);
	REP(i,n-1){
		int a; cin >> a;
		p[a-1]++;
	}
	REP(i,n){
		cout << p[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4844
from collections import Counter 
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
x=len(set(a))
if x<=k:
    print(ans)
else:
    b=Counter(a).most_common(x)
    for i in range(x-1,k-1,-1):
        ans+=b[i][1]
    print(ans)

Measured memory_bytes: 48440
#include <bits/stdc++.h>
using namespace std;
int n,m,p,d[100001];

int cal(int a,int b){return (n+b-a)%n;}

int main(){
  cin>>n>>m>>p;
  d[m]=p;
  for(int i=0;i<m;i++)cin>>d[i];
  sort(d,++m+d);
  int st=0;
  while(d[st]!=p) st++;
  
  int ans=min(cal(p,d[(m+st-1)%m]),cal(d[(st+1)%m],p));

  for(int i=(st+1)%m;i!=st;i=(i+1)%m){
    ans=min(ans,2*cal(p,d[i])+cal(d[(i+1)%m],p));
    ans=min(ans,2*cal(d[(i+1)%m],p)+cal(p,d[i]));
  }
  cout <<ans*100<<endl;
  return 0;
}

Measured memory_bytes: 1220
n,m=map(int,input().split())
ans=[-1]*n
for _ in range(m):
    s,c=map(int,input().split())
    if ans[s-1]==-1:
        ans[s-1]=c
    elif ans[s-1]!=c:
        print(-1)
        exit()
if ans[0]==0:
    if n==1:
        print(0)
        exit()
    else:
        print(-1)
        exit()
elif ans[0]==-1:
    if n==1:
        ans[0]=0
    else:
        ans[0]=1
for i in range(1,n):
    if ans[i]==-1:
        ans[i]=0
ans_=""
for i in range(n):
    ans_+=str(ans[i])
print(ans_)

Measured memory_bytes: 3064
n,k = map(int,input().split())

s=input()
s = list(map(int,s))

memo = [0]

for i in range(1,n):
    if s[i-1] != s[i]:
        memo.append(i)

ans = 0
for i in range(len(memo)):
    start = memo[i]
    if (s[start] == 1):
        end = i + 2*k +1
    else:
        end = i + 2*k
    if end < len(memo):
        end = memo[end]
    else:
        end = len(s)
    ans = max(ans, end-start)
print(ans)

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

int main(){
    int N, M;
    int vote_sum = 0;
    int product = 0;
    cin >> N >> M;
    vector<int> vote(N);

    for(int i=0; i<N; i++){
        cin >> vote.at(i);
        vote_sum += vote.at(i);
    }
    double border = (double)vote_sum / (double)(4*M);

    for(int i=0; i<N; i++){
        if(vote.at(i) >= border)
            product++;
    }

    if(product >= M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        for (int i = 0; i < 3; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var t = Array.ConvertAll(line, int.Parse);
            var cardfrom = new DateTime(2000, 1, 1, t[0], t[1], t[2]);
            var cardto= new DateTime(2000, 1, 1, t[3], t[4], t[5]);
            var ans = cardto - cardfrom;
            Console.WriteLine("{0} {1} {2}", ans.Hours, ans.Minutes, ans.Seconds);
        }
    }
}

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

int main(void){
	int x;
	cin >> x;
	if (x==1) cout << 0 << endl;
	else cout << 1 << endl;
return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
#include <climits>
using namespace std;

int main(){
    int k;
    int a,b;
    cin >> k >> a >> b;
    int t1,t2;
    t1=a/k;
    t2=b/k;
    if(a%k==0|| b%k==0)
    {
        cout << "OK"<<endl;
    }
    else if(t1!=t2)
    cout << "OK "<< endl;
    else
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

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

		int a = sc.nextInt ();
		int b = sc.nextInt ();
		int c = sc.nextInt ();

		if ( a < b && b < c ) {
			System.out.println ( "Yes" );
		} else {
			System.out.println ( "No" );
		}
	}
}

Measured memory_bytes: 26144
//
//  main.cpp
//  ITP1_10-B
//
//  Created by Saicj on 2015/08/05.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

#define PI 3.1415926

int main(int argc, const char * argv[]) {

    
    double a,b,C;
    
    cin >> a >> b >> C;
    
    /**
     *  ??¢?§????(???/???)?????????sin??
     ??¨??? a^2 + b^2 -2ab*cosC = c^2
     a + b + c
     
     
     */

    double rad = C * PI / 180.0;
    
    double area = (a * b)/2 * sin(rad);
    
    double c = sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(rad)));
    
    double perimeter = a + b + c;
    
    double h = (area * 2) / a;
    
    printf("%.4lf %.4lf %.4lf \n", area, perimeter, h);
    
    
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define li                list<int>
#define pii               pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
#define all(x)            (x).begin(), (x).end()
#define PI                3.14159265358979
void c_p_c()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("ou.txt", "w", stdout);
#endif
}
// int FUN1 (int a[], int n, int x) {
// 	int i;
// 	for (i = 0; i < n && a[i] != x; i++);
// 	if (i == n) return -1;
// 	else return i;
// }

void solve()
{

	int n, k; cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	int counter = 0;
	for (int i = 0; i < k; i++)
		counter += a[i];
	cout << counter;
}
int32_t main()
{
	c_p_c();
	solve();
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define IN(n) int n; cin>>n;
#define ARR(arr,i,n) int arr[n]; REP(i,0,n){cin>>arr[i];}
#define MOD 1000000007

using namespace std;

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

    // code comes here
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n>0)
    {

        cnt++;
        n/=k;
    }
    cout<<cnt<<endl;

    return 0;
}






Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {



    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
            int n =sc.nextInt();
            int m =sc.nextInt();
            int arr[]=new int[n];

            for(int i=0;i<n;i++)
            {
                arr[i]=sc.nextInt();
            }
            int checkArr[] =new int[n];

            for(int i=-0;i<m;i++)
            {
                int a =sc.nextInt()-1;
                int b=sc.nextInt()-1;
                if(arr[b]>arr[a])
                {
                    checkArr[a]=-1;
                }
                else if(arr[a]>arr[b])
                {
                    checkArr[b]=-1;
                }
                else
                {
                    checkArr[a]=-1;
                    checkArr[b]=-1;
                }
            }
            int count =0;
            for(int i=0;i<n;i++)
            {
                if(checkArr[i]!=(-1))
                {
                    count=count+1;
                }
            }
            System.out.println(count);

    }


}

Measured memory_bytes: 59596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 998244353;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


template< typename T >
struct BIT {
  vector< T > data;

  BIT(int sz) {
    data.assign(++sz, 0);
  }

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

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



int main() {
    LL N,K;cin >> N >> K;
    vector<LL> L(K);
    vector<LL> R(K);
    rep(i,K)cin >> L[i] >> R[i];

    BIT<LL> q(2*N+2);
    q.add(1,1);
    q.add(2,-1);

    for(LL i = 1;i <= N;i++){
        rep(j,K){
            LL tmp = q.sum(i) % MOD;
            q.add(i+L[j],tmp);
            q.add(i+R[j]+1,-tmp);
        }
    }

    LL ans = q.sum(N) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 6420
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto nhw = aryread();
    auto n = nhw[0];
    auto h = nhw[1];
    auto w = nhw[2];
    long cnt;

    foreach(i;0..n)
    {
        auto ab = aryread();
        if (h <= ab[0] && w <= ab[1])
        {
            cnt++;
        }
    }
    cnt.writeln;
}


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

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

int H,W,R,C,a;

bool f[505][505][4];
bool used[505][505][2];
bool visited[505][505];
struct state{
  int y,x;
};

int main(){
  while(1){
    cin>>H>>W>>R>>C;
    memset( f , false , sizeof(f) );
    memset( used , false , sizeof(used) );
    memset( visited , false , sizeof(visited) );

    if(H==0&&W==0&&R==0&&C==0)break;

    for(int i=1;i<=W;i++){
      cin>>a;
      f[1][i][0]=a;
      f[0][i][2]=a;
    }

    for(int i=1;i<=H;i++){
      for(int j=0;j<=W;j++){
        cin>>a;
        f[i][j][1]=a;
        f[i][j+1][3]=a;
      }
      for(int j=1;j<=W;j++){
        cin>>a;
        f[i][j][2]=a;
        f[i+1][j][0]=a;
      }
    }
    queue< state > Q; 
    for(int y=1;y<=H;y++){
      Q.push((state){y,0});
      Q.push((state){y,W+1});
    }
    for(int x=1;x<=W;x++){
      Q.push((state){0,x});
      Q.push((state){H+1,x});
    }


    while(!Q.empty()){
      state s=Q.front();Q.pop();

      visited[s.y][s.x]=true;

      for(int i=0;i<4;i++){
        int ny=s.y+dy[i];
        int nx=s.x+dx[i];
        if(ny<0||nx<0)continue;
        if(ny>H||nx>W)continue;
        assert( f[s.y][s.x][i] == f[ny][nx][ (i+2)%4 ] );
        used[ny][nx][ f[s.y][s.x][i] ]=1;
        if(used[ny][nx][0]&&used[ny][nx][1]&&!visited[ny][nx]){
          visited[ny][nx]=true;
          Q.push((state){ny,nx});
        }
      }
    }
    bool ans=false;
    if(visited[R][C])ans=true;
    for(int i=0;i<4;i++){
      int y=R+dy[i];
      int x=C+dx[i];
      if( f[R][C][i] == 0 ){
        ans |= visited[y][x];
      }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 2980
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main() {
//    double x;
//    static constexpr double TEI = log(1.01);
//    cin  >> x;
//    cout << (int)ceil(log(x / 100) / TEI) << endl;

    long long x;
    cin >> x;
    long long i = 0, target = 100;
    while(target < x) {
        i++;
        target *= 1.01;
    }
    cout << i << endl;

    return 0;
}


Measured memory_bytes: 3636
S = input()
for bit in range(1 << len(S)-1):
    ans = [0,0,0]
    f = int(S[0])
    for i in range(0,len(S)-1):
        if bit & (1 << i):
            f -= int(S[i+1])
            ans[i] = "-"
        else:
            f += int(S[i+1])
            ans[i] = "+"
    if f == 7: break
for i in range(len(S)):
    if i == len(ans):
        print(S[i] + "=",end="")
    else:
        print(S[i] + ans[i],end="")
print(7)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
    using namespace std;
     
    int main(){
      int n, a, b;
      cin >> n >> a >> b;
      
      int town[n];
      rep(i,n) cin >> town[i];
      
      int dist[n-1];
      rep(i,n-1) dist[i] = town[i+1] - town[i];
      
      int can_walk = b / a; //歩ける最大値
      int cont_dist = 0; //連続で歩く距離
      long long ans = 0;
      rep(i,n-1){
        if(dist[i] <= can_walk) 
          ans = ans + dist[i] * a;
        else
          ans = ans + b;
      }
      
      cout << ans << endl;
      return 0;
    }

Measured memory_bytes: 1024
import sys
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix

input = sys.stdin.readline

n, m, l = list(map(int, input().split()))
g_dense = np.zeros((n, n))

for _ in range(m):
    a, b, c = map(int, input().split())
    g_dense[a-1][b-1] = c

q = int(input())
st = [list(map(int, input().split())) for _ in range(q)]

path = shortest_path(g_dense, directed=False)

g_dense = np.zeros((n, n))

for i in range(n):
    for j in range(n):
        if path[i][j] <= l:
            g_dense[i][j] = 1

path = shortest_path(g_dense, directed=False)

INF = float('inf')

for s,t in st:
    ans = path[s-1][t-1]
    if ans == INF:
        print(-1)
    else:
        print(int(ans) - 1)

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

long long gcd(long long a,long long b){
	if(a%b==0)return b;
	else return gcd(b,a%b);
}

int main(){
	long long n,k,m=0;
	bool alt=false;
	cin>>n>>k;
	long long a[n];
	rep(i,n){
		cin>>a[i];
		if(a[i]==k)alt=true;
		m=max(m,a[i]);
	}
	long long tmp;
	rep(i,n){
		if(i==0)tmp=gcd(a[0],a[1]);
		else tmp=gcd(tmp,a[i]);
	}
	if(alt)cout<<"POSSIBLE"<<endl;
	else if(m<k)cout<<"IMPOSSIBLE"<<endl;
	else cout<<((k%tmp==0)?"POSSIBLE":"IMPOSSIBLE")<<endl;
	return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int N, D;
  cin >> N >> D;
  vector<vi> X(N, vi(D, 0));
  for (int i = 0; i < N; i++) {
    vi x(D, 0);
    for (int j = 0; j < D; j++) {
      cin >> x[j];
    }
    X[i] = x;
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int sum = 0;
      for (int k = 0; k < D; k++) {
        sum += sqr(X[i][k] - X[j][k]);
      }
      if (sqr((int)sqrt(sum)) == sum) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;

//点を表す構造体
class Point{
public:
  double x, y;

  Point(double x=0, double y=0){
    this->x = x;
    this->y = y;
  }

  Point operator+(Point &seg2){
    return Point(x+seg2.x, y+seg2.y);
  }

  Point operator-(Point &seg2){
    return Point(x-seg2.x, y-seg2.y);
  }

  Point operator*(double k){
    return Point(x*k, y*k);
  }

  bool operator < (const Point &p) const{
    return x != p.x? x<p.x : y<p.y;
  }

  bool operator == (const Point &p) const{
    return equals(x, p.x) && equals(y, p.y);
  }

};

//ベクトルを点の別表記でも表せるようにしておく
class Vector : public Point{
public:
  Vector() : Point() {}

  Vector(double x, double y) : Point(x, y) {}

  Vector(Point p) : Point(){
    x = p.x;
    y = p.y;
  }

  double norm(){
    return x*x + y*y;
  }

  double abs(){
    return sqrt(norm());
  }

  static double dot(Vector a, Vector b){
    return a.x*b.x + a.y*b.y;
  }

  static double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
  }

  static bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a, b), 0.0);
  }

  static bool isParallel(Vector a, Vector b){
    return equals(cross(a, b), 0.0);
  }
};

//線分(ベクトルを用いて)を表す構造体。両端の点が定義されている点に注意
class Segment{
public:
  Point p1, p2;

  Segment(Point p1, Point p2){
    this->p1 = p1;
    this->p2 = p2;
    x = p2.x-p1.x;
    y = p2.y-p1.y;
  }

  static bool isOrthogonal(Segment a, Segment b){
    return equals(dot(a, b), 0.0);
  }

  static bool isParallel(Segment a, Segment b){
    return equals(cross(a, b), 0.0);
  }

private:
  int x, y;
  static double dot(Segment a, Segment b){
    return a.x*b.x + a.y*b.y;
  }

  static double cross(Segment a, Segment b){
    return a.x*b.y - a.y*b.x;
  }
};

typedef Segment Line;

class Circle{
public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0.0): c(c), r(r){}
};

string ccw(Point p0, Point p1, Point p2){
  enum res {COUNTER_CLOCKWISE=0, CLOCKWISE, ONLINE_BACK, ONLINE_FRONT, ON_SEGMENT};
  Vector a = p1-p0;
  Vector b = p2-p0;
  if(Vector::cross(a, b) > EPS) return "COUNTER_CLOCKWISE";
  if(Vector::cross(a, b) < -EPS) return "CLOCKWISE";
  if(Vector::dot(a, b) < -EPS) return "ONLINE_BACK";
  if(a.norm() < b.norm()) return "ONLINE_FRONT";
  return "ON_SEGMENT";
}

int main(){
  double p0_x, p0_y, p1_x, p1_y;
  cin >> p0_x >> p0_y >> p1_x >> p1_y;
  Point p0(p0_x, p0_y), p1(p1_x, p1_y);

  int q; cin >> q;
  double x, y;
  Point p2;
  for(int i=0; i<q; i++){
    cin >> x >> y;
    p2.x = x; p2.y = y;
    cout << ccw(p0, p1, p2) << endl;
  }

  return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int ka[214514],inv[214514],sum[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int p2[55],res=1;
	p2[0]=1;p2[1]=x%inf;
	for(int i=2;i<=50;i++){
		p2[i]=p2[i-1]*p2[i-1];
		p2[i] %= inf;
	}
	for(int i=1;i<=50;i++){
		if(k%2==1){
			res *= p2[i];
			res %= inf;
		}
		k /= 2;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}

signed main(){
	int b,w;
	cin>>b>>w;
	setkaijo(214514);
	setinv(214514);
	int x = 0, y = 0;
	for(int i=1;i<=b+w;i++){
		if( i-1 == b ) y = 1;
		if( i-1 == w ) x = 1;
		if( i-1 > b ){
			y *= 2;
			y %= inf;
			y += comb( i-2, b-1 );
			y %= inf;
		}
		if( i-1 > w ){
			x *= 2;
			x %= inf;
			x += comb( i-2, w-1 );
			x %= inf;
		}
		int cp = modpow(2, i-1);
		int tmp = cp;
		tmp += x;
		tmp %= inf;
		tmp += inf - y;
		tmp %= inf;
		tmp *= modpow( (cp*2)%inf , (ll)inf-2 );
		tmp %= inf;
		cout<<tmp<<endl;
	}
}

Measured memory_bytes: 5504
#include<iostream>
// #include<vector>
// #include<algorithm>
// #include<math.h>

using namespace std;

int main(){
	int K, N;
	cin >> N >> K;
	bool result = true;
	int count = 1;

	for(int i=1; i+2<=N; i+=2){
		count++;
	}

	if(count < K){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}

	return 0;
} // g++ -std=c++11 test.cpp -o test && ./test

Measured memory_bytes: 256
#include <iostream>

int main(void) {
	using namespace std;
	int a, b;
	cin >> a >> b;
	if (a < b)cout << "a < b" << endl;
	else if (a > b)cout << "a > b" << endl;
	else cout << "a == b" << endl;
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>

using namespace std;

int main()
{
    string str1, str2;

    cin>>str1;
    cin>>str2;

    int c=0;
    for(int i=0; i<str1.length(); i++)
    {
        if(str1[i]==str2[i])
            c++;
    }

    cout<<c<<endl;

    return 0;
}


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

int main(){
    string s;
    int q;
    cin >> s >> q;
    deque<char> deq;
    for(int i = 0; i < s.size();i++) deq.push_back(s.at(i));
    bool reverse = false;
    for(int i = 0; i < q;i++){
        int t;
        cin >> t;
        if(t == 1){
            reverse = !reverse;
            continue;
        }else{
            int f; char c;
            cin >> f >> c;
            if(!reverse && f == 1) deq.push_front(c);
            else if(!reverse && f == 2) deq.push_back(c);
            else if(reverse && f == 1) deq.push_back(c);
            else if(reverse && f == 2) deq.push_front(c);
        }
    }
    while(!deq.empty()){
        if(!reverse){
            cout << deq.front();
            deq.pop_front(); 
        }else{
            cout << deq.back();
            deq.pop_back();
        }
    }
    cout << endl;
    return 0;
}     

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;
int main() {
	string s; bool t=false;
	cin >> s; int l = s.size();
	int w = 15 - l;
	if (l < 8) { t = true; }
	else
	{
		for (int a = 0; a < l; a++)
		{
			if (s[a] == 'o') { w++; }
			if (w > 7) { t = true; break; }
		}
	}
	if (t) { cout << "YES"; }
	else { cout << "NO"; }
	return 0;
}

Measured memory_bytes: 888
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])
SUM_=0
for i in range(N):
    SUM_+=AB[i][0]
    if SUM_>AB[i][1]:
        print('No')
        exit()
print('Yes')

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  if (a[0] != 0) {
    cout<<-1<<endl;
    return 0;
  }
  for (int i=0; i<n-1; i++) {
    if (a[i+1] > a[i]) {
      if (a[i+1] - a[i] != 1) {
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  long long ans = a[n-1];
  for (int i=n-2; i>=0; i--) {
    if (a[i+1] <= a[i]) {
      ans += a[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	long double a,b;
	cin>>a>>b;
	a*=b;
	ll ans=(ll)a;
	cout<<ans;
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3748
A=[]
for i in range(n:=int(input())):
  for _ in range(int(input())): x,y=map(int,input().split()); A+=[(i,x-1,y)]
print(max(sum(map(int,bin(i)[2:]))*all(i>>j&1<1 or i>>x&1==y for j,x,y in A) for i in range(2**n)))

Measured memory_bytes: 9068