akhauriyash/Code-Regression huggingface dataset:
/***************************************************
 * Problem Name : B - Count ABC.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-02-06
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    int n;
    string str;
    cin >> n >> str;
    int cnt = 0;
    for (int i = 2; i < n;) {
		if(str[i] == 'C' && str[i-1] == 'B' && str[i-2] == 'A')
		{
			cnt++;
			i+=3;
		}else i++;
    }
    cout << cnt << "\n";

    return 0;
}


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

int main(){
int n;
cin >> n;
vector<int> x(n);
rep(i,n) cin>> x[i];
int ans = 1001001001;
for(int p = 1;p <= 100;p++){
    int now = 0;
    rep(i,n) now += (x[i]-p) * (x[i]-p);
    ans = min(ans,now);
}
cout << ans << endl;
}


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

using namespace std;

vector<int> G[150000];
bool used1[150000];
bool used2[150000];
double dp[150000];

void dfs1(int v){
    used1[v] = true;
    int n = G[v].size();
    if(v != 0) n--;
    for(int i = 0; i < G[v].size(); i++){
        if(!used1[G[v][i]]){
            dfs1(G[v][i]);
            dp[v] += (dp[G[v][i]]+1)/(double)n;
        }
    }
}

void dfs2(int v){
    used2[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        if(!used2[G[v][i]]){
            int n = G[v].size();
            int m = G[G[v][i]].size();
            if(G[v].size() != 1){
                double e = (dp[v]-(dp[G[v][i]]+1)/n)*((double)n/(double)(n-1));
                dp[G[v][i]] *= ((double)(m-1)/(double)(m));
                dp[G[v][i]] += (e+1)/(double)m;
            }else{
                dp[G[v][i]] *= ((double)(m-1)/(double)(m));
                dp[G[v][i]] += 1/(double)m;
            }
            dfs2(G[v][i]);
        }
    }
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    cout << fixed << setprecision(10);
    dfs1(0);
    
    dfs2(0);
    for(int i = 0; i < N; i++){
        cout << dp[i] << endl;
    }
}

Measured memory_bytes: 15360
# 0:17-
h, w = gets.to_s.split.map{|t| t.to_i }

# p ".#".bytes #=> [46, 35]
blacks = []
a = Array.new(h) do |i| 
  s = gets.to_s.chomp.bytes
  s.each_with_index do |c, j|
    blacks << [i, j] if c == 35
  end
  s
end

dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]

ans = -1
while blacks.any?
  
  ns = []
  ans += 1
  
  blacks.each do |x, y|
    nx = x - 1
    if 0 <= nx && a[nx][y] == 46
      a[nx][y] = 35
      ns << [nx, y]
    end
    nx = x + 1
    if nx < h && a[nx][y] == 46
      a[nx][y] = 35
      ns << [nx, y]
    end
    ny = y - 1
    if 0 <= ny && a[x][ny] == 46
      a[x][ny] = 35
      ns << [x, ny]
    end
    ny = y + 1
    if ny < w && a[x][ny] == 46
      a[x][ny] = 35
      ns << [x, ny]
    end
  end
  blacks = ns.dup
end

puts ans

Measured memory_bytes: 62460
import java.util.*;

public class Main {

	private static final long M = 1_000_000_007;

	private static class Combination {
		private final int M;
		private long[] fact;
		private long[] ifact;
		private long[] inv;

		public Combination(int n, int M) {
			this.M = M;
			fact = new long[n + 1];
			ifact = new long[n + 1];
			inv = new long[n + 1];

			fact[0] = fact[1] = 1;
			ifact[0] = ifact[1] = 1;
			inv[1] = 1;

			for (int i = 2; i <= n; i++) {
				fact[i] = fact[i - 1] * i % M;
				// p = (p / a * a) + (p % a)
				// 0 ≡ (p / a * a) + (p % a)          (mod p)
				// a^(-1) ≡ - (p % a)^(-1) * (p / a)  (mod p)
				inv[i] = M - inv[M % i] * (M / i) % M;
				ifact[i] = ifact[i - 1] * inv[i] % M;
			}
		}

		public long choose(int n, int k) {
			if (n < k) return 0;
			if (n < 0 || k < 0) return 0;
			return fact[n] * (ifact[k] * ifact[n - k] % M) % M;
		}
	}

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

		int s = 0, t = 0;
		Map<Integer, Integer> shown = new HashMap<>();
		for (int i = 0; i < n + 1; i++) {
			int a = sc.nextInt();
			if (shown.containsKey(a)) {
				s = shown.get(a);
				t = i;
				break;
			}
			shown.put(a, i);
		}

		Combination c = new Combination(n + 1, (int) M);
		StringBuilder sb = new StringBuilder();
		for (int k = 1; k <= n + 1; k++) {
			long answer = c.choose(n + 1, k);
			answer -= c.choose((n - t) + s, k - 1);
			answer += M;
			sb.append(answer % M);
			sb.append("\n");
		}

		System.out.print(sb.toString());
	}
}


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

#define MAX_MAX 1000010

using namespace std;

bool isChecked[MAX_MAX];
vector <int> prime;

int CountPrimeNum(int max) {
	
	int count = 0;
	for (int i = 0; i < MAX_MAX; i++) {
		if (prime[i] > max) break;
		count++;
	}	
	return count;
}


int main() {
	for(int i = 0; i < MAX_MAX; i++) {
		isChecked[i] = false;
	}
	
	isChecked[0] = true;
	isChecked[1] = true;
	
	for (int i = 2; i < MAX_MAX; i++) {
		if(isChecked[i]) continue;
		
		prime.push_back(i);
		
		for (int j = 1;j * i < MAX_MAX;j++) {
			isChecked[i*j] = true;
		}
	}
	
	int n;
	while(cin >> n) {
		cout << CountPrimeNum(n) << endl;
	}
	
	return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class UnionFind:
    """ Union-Find木 """

    def __init__(self, n):
        self.n = n
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        # 1-indexedのままでOK、その場合は[0]は未使用
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n+1)
        # あるノードを根とする集合に属するノード数
        self.size = [1] * (n+1)
        # あるノードを根とする集合が木かどうか
        self.tree = [True] * (n+1)

    def find(self, x):
        """ 根の検索(グループ番号と言えなくもない) """
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """ 併合 """
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        # 木かどうかの判定用
        if x == y:
            self.tree[x] = False
            return
        if not self.tree[x] or not self.tree[y]:
            self.tree[x] = self.tree[y] = False

        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def is_same(self, x, y):
        """ 同じ集合に属するか判定 """
        return self.find(x) == self.find(y)

    def get_size(self, x=None):
        if x is not None:
            """ あるノードの属する集合のノード数 """
            return self.size[self.find(x)]
        else:
            """ 集合の数 """
            res = set()
            for i in range(self.n+1):
                res.add(self.find(i))
            # グループ0の分を引いて返却
            return len(res) - 1
    
    def is_tree(self, x):
        """ 木かどうかの判定 """
        return self.tree[self.find(x)]

N = INT()
X = []
Y = []
for i in range(N):
    x, y = MAP()
    X.append((x, i))
    Y.append((y, i))

# xとy個別にソートして、距離の隣り合う頂点間だけ辺を貼る
X.sort()
Y.sort()
edges = []
for i in range(N-1):
    x1, u = X[i]
    x2, v = X[i+1]
    edges.append((x2-x1, u, v))
    y1, u = Y[i]
    y2, v = Y[i+1]
    edges.append((y2-y1, u, v))

# 最小全域木の構築
edges.sort()
uf = UnionFind(N)
ans = 0
for c, a, b in edges:
    if not uf.is_same(a, b):
        uf.union(a, b)
        ans += c
print(ans)


Measured memory_bytes: 55328
N,Q=map(int,input().split())
memo=[0]*N
S=input()
num=0

for i in range(1,N):
    if S[i-1]=='A' and S[i]=='C':
        num+=1
    memo[i]=num

for i in range(Q):
    l,r=map(int,input().split())
    l,r=l-1,r-1
    print(memo[r]-memo[l])

Measured memory_bytes: 8132
#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 n;  cin >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());

    if(n % 2 == 1){
        ll mi = a[n/2];
        ll ma = b[n/2];
        cout << ma - mi + 1 << endl;
    }
    else{
        ll mi1 = a[(n-1) / 2], mi2 = a[n / 2];
        ll ma1 = b[(n-1) / 2], ma2 = b[n / 2];
        ll mi = (mi1 + mi2);
        ll ma = ma1 + ma2;
        cout << ma - mi + 1 << endl;
    }


    return 0;
}


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

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

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

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

int dp[100005][13]; // dp[i][j]:=上からi桁目までの数で余りがjとなるものの数

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int n=s.size();
  dp[0][0]=1;
  rep(i,n){
    if(s[i]=='?'){
      rep(j,10){
        rep(k,13){
          int l=(k*10+j)%13;
          (dp[i+1][l]+=dp[i][k])%=MOD;
        }
      }
    }else{
      rep(j,13){
        int k=(j*10+(s[i]-'0'))%13;
        (dp[i+1][k]+=dp[i][j])%=MOD;
      }
    }
  }
  cout<<dp[n][5]<<endl;
}


Measured memory_bytes: 5584
import math
A,B,H,M=map(int,input().split())

x=6*M#長針の角度
y=30*H+(M/60)*30
Q=max(x-y,-(x-y))
W=min(360-Q,Q)

X=(A**2)+(B**2)-2*A*B*(math.cos(math.radians(W)))
print(X**(0.5))


Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
int a,n,ans;
int main()
{
	cin>>a;
	if(a==1)
	{
		cout<<1<<endl;
		return 0;;
	}
	for(int i=1;i<=30;i++)
	{
		if(pow(2,i)<=a&&pow(2,i+1)>a)
		{
			cout<<pow(2,i)<<endl;
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

ans = len(T)
for s in range(0, len(S) - len(T) + 1):
    count = 0
    for a, b in zip(S[s:s+len(T)], T):
        if a != b:
            count += 1
    ans = min(ans, count)
print(ans)

Measured memory_bytes: 9124
// Problem : D - Derangement
// Contest : AtCoder - AtCoder Beginner Contest 072
// URL : https://atcoder.jp/contests/abc072/tasks/arc082_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int n;cin>>n;
	vi v(n);cin>>v;
	int cnt=0;int ans=0;
	for(int i=0;i<n;i++)
	{
		if(v[i]==i+1)
		cnt++;
		else
		{
			ans+=(cnt+1)/2;
			cnt=0;
		}
	}
	ans+=(cnt+1)/2;
	cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3960
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int N;
int prime[MAXN],pcnt;
int Min_Factor[MAXN];

void Init(){
    for(int i=2;i<=10000;i++){
        if(!Min_Factor[i]){
            prime[++pcnt]=i;
            Min_Factor[i]=i;
        }
        for(int k=1;k<=pcnt&&prime[k]*i<=10000;k++){
            int x=prime[k]*i;
            Min_Factor[x]=prime[k];
        }
    }
}

void work(){
    Init();
    while(~scanf("%d",&N)&&N){
        int l=1,r=1;
        int s=0,ans=0;
        while(l<=pcnt||r<=pcnt){
            while(r<=pcnt&&s<N) s+=prime[r++];
            if(s<N) break;
            if(s==N) ans++;
            s-=prime[l++];
        }
        printf("%d\n",ans);
    }
}

int main(){
#ifdef NNever
//    freopen("data.in","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}







Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll ans = 0;
    int n;
    cin >> n;
    fori (i, 1, n + 1) {
        if (i % 3 == 0 or i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3652
from collections import defaultdict
h,n=map(int,input().split())
INF=float('inf')
ab=defaultdict(lambda: -INF)
for _ in range(n):
  a,b=map(int,input().split())
  ab[b]=max(ab[b],a)
dp=[INF]*(h+max(ab.values())+1)
dp[0]=0
for i in range(1,ab[min(ab.keys())]+1):
  dp[i]=min(ab.keys())
for i in range(ab[min(ab.keys())]+1,h+max(ab.values())+1):
  for m,d in ab.items():
    if i>=d:
      dp[i]=min(dp[i],dp[i-d]+m)
print(min(dp[h:]))

Measured memory_bytes: 42476
#include <bits/stdc++.h>
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;
}
template <class T>
inline T gcd(T m, T n) {
  if (n == 0)
    return m;
  else
    return gcd(n, abs(m) % abs(n));
}

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

void rec(int d, ll val, vll& lun) {
  lun.push_back(val);

  if (d == 10) return;

  for (int i = -1; i <= 1; i++) {
    int add = val % 10 + i;
    if (0 <= add && add <= 9) rec(d + 1, val * 10 + add, lun);
  }
}

int main() {
  IOS;
  constexpr char endl = '\n';

  int K;
  cin >> K;

  vll lun;
  FOR(i, 1, 10) rec(1, i, lun);
  sort(all(lun));

  cout << lun[K - 1] << endl;
}

Measured memory_bytes: 2420
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        c: chars,
    }
    let i = c[0] as usize - 'a' as u8 as usize;
    let s = "abcdefghijklmnopqrstuvwxyz".chars().collect::<Vec<_>>();
    println!("{}", s[i + 1]);
}


Measured memory_bytes: 4352
s = input()
ans = []
for i in range(len(s)):
    if s[i] == '0':
        ans.append("0")
    elif s[i] == '1':
        ans.append("1")
    elif s[i] == 'B':
        if len(ans) > 0:
            ans.pop()
for a in ans:
    print(a,end="")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin >>a>>b;
if((a==1||a==2) && (b==2||b==1))
cout<<3<<endl;
else if((a==1||a==3) && (b==3||b==1))
cout<<2<<endl;
else
cout<<1<<endl;
}  

Measured memory_bytes: 3620
<?php
$n=(int)trim(fgets(STDIN));
$a=explode(' ',trim(fgets(STDIN)));

$mi=array_shift($a);
$mx=$mi;
$sm=$mi;

foreach($a as $ai){
  if($ai<$mi){$mi=$ai;}
  elseif($mx<$ai){$mx=$ai;}
  $sm+=$ai;
}

echo $mi,' ',$mx,' ',$sm;
?>

Measured memory_bytes: 16976
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N, K;
string s;
int main(void){
    cin >> N >> K;
    cin >> s;

    s[K-1] = tolower(s[K-1]);

    cout << s << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;

ll euclid(ll a, ll b)
{
    int nr = 0;
    while (b != 0)
    {
        int c = b;
        b = a % b;
        a = c;
        nr++;
    }
    return nr;
}


int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    int nr = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        if (v[i] != i + 1)
        {
            nr++;
        }
    }
    if (nr != 2 && nr != 0)
    {
        cout << "NO";
    }
    else
    {
        cout << "YES";
    }
    return 0;
}


Measured memory_bytes: 256
n,c = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(c)]
li = [list(map(int,input().split())) for i in range(n)]
ans = 10 ** 100
cnt = [0,0,0]
masu = [[0 for i in range(c)] for j in range(3)]
for i in range(n):
    for j in range(n):
        cnt[(i+j)%3] += 1
        masu[(i+j)%3][li[i][j]-1] += 1
for i in range(c):
    for j in range(c):
        if i != j:
            for k in range(c):
                if i != k and j != k:
                    tryans = 0
                    num = [i,j,k]
                    for l in range(3):
  #                         print(num[l], masu[l])
                        for h in range(c):
                            if h != num[l]:
                                tryans += lis[h][num[l]] * masu[l][h]
                    ans = min(ans,tryans)
  #                 print(i,j,k,ans)
print(ans)

Measured memory_bytes: 5620
#include<stdio.h>

int main(){
    int N;
    int i, j, k;
    int F[50];

    scanf("%d", &N);
    F[0] = 1;
    F[1] = 1;
    for(i=2; i<=N; i++){
        F[i] = F[i-1] + F[i-2];
    }

    printf("%d\n", F[i-1]);

    return 0;
}


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

using namespace std;
int n;
char a[1000005];
int main()
{
//	freopen(".in","r"mstdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int maxx=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]=='I') ans++;
		else ans--;
		if(ans>maxx) maxx=ans;
	}
	cout<<maxx<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    int k,x;
    cin >> k>>x;
    for(int i=x-k+1;i!=x+k;++i){
	    if(i<-1000000||1000000<i){continue;}
	    if(i==x+k-1){cout<<i<<endl;break;}
	    cout<<i<<' ';
    } 

    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    lol a,b,x;
    cin>>a>>b>>x;
    if(a%x!=0)
        cout<<(b/x)-(a/x)<<"\n";
    else cout<<(b/x)-(a/x)+1<<"\n";
    return(0);
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;
int main()
{
	int a;
	int b[5] = {0};
	for (int i = 0; i < 6; i++) {
	cin >> a;
	b[a]++;
	}
int ans=0;
	for (int i = 1; i < 5; i++) {
		if(b[i]%2==1)ans++;
	}
	if (ans > 2)cout<<"NO"<<endl;

	else cout << "YES" << endl;

}

Measured memory_bytes: 256
n=int(input())
TA=[list(map(int,input().split())) for _ in range(n)]

nowt,nowa=TA[0]
for t,a in TA[1:]:
  c=max(-(-nowt//t),-(-nowa//a))
  nowt,nowa=c*t,c*a
print(nowt+nowa)
  

Measured memory_bytes: 3188
import sys
from collections import deque
import time
input = sys.stdin.readline

n, m = map(int, input().split())

path = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    path[a].append(b)
    path[b].append(a)

ans = [0] * (n+1)
alr = [0] * (n+1)
que = deque([1])
while len(que) > 0:
    idx = que.popleft()
    for i in path[idx]:
        if alr[i] == 0:
            que.append(i)
            ans[i] = idx
            alr[i] = 1
        else:
            pass

print('Yes')
for i in range(2, n+1):
    print(ans[i])


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

int main(void) {
    int n, m;
    std::vector<int> a;
    int sum = 0;

    std::cin >> n >> m;
    a.resize(m);
    for(int i = 0; i < m; i++) {
        std::cin >> a[i];
        sum += a[i];
    }

    if((n-sum) < 0) {
        std::cout << -1 << std::endl;
    } else {
        std::cout << n-sum << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <iomanip> 
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;


void average_length()
{
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

  double sum = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n; ++j)
    {
      if (i == j) continue;
      sum += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    }
  }

  cout << setprecision(14) << sum / n << '\n';
}


int calc_digits(long long int n)
{
  int digits = 0;
  while (n >= 1)
  {
    n /= 10;
    ++digits;
  }

  return digits;
}


void buy_an_interger()
{
  long long int a, b;
  long long int x;
  cin >> a >> b >> x;

  long long int left = 0, right = 1000000001;
  long long int mid;
  while (right - left > 1)
  {
    mid = left + (right - left) / 2;
    if (a * mid + b * calc_digits(mid) <= x) left = mid;
    else right = mid;
  }

  cout << left << '\n';
}


void honest_or_unkind2()
{
  //後回し
}


long long int gcd(int a, int b)
{
  if (a < b) 
  {
    int tmp;
    tmp = a;
    a   = b;
    b   = tmp;
  }

  int r = a % b;
  while (r != 0)
  {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}


long long int lcm(long long int a, long long int b)
{
  return a * b / gcd(a, b);
}


void snack()
{
  long long int a, b;
  cin >> a >> b;

  cout << lcm(a, b) << "\n";
}


bool is_prime(int n)
{
  if (n <= 1) return false;
  if (n == 2) return true;

  if (n % 2 == 0)return false;

  for (int i = 3; i * i <= n; i += 2)
  {
    if (n % i == 0) return false;
  }

  return true;
}


void next_prime()
{
  int x;
  cin >> x;

  int prime = x;
  while (!is_prime(prime)) ++prime;

  cout << prime << "\n";
}


int factorial(int n)
{
  int fact = 1;
  for (int i = n; i > 0; --i) fact *= i;
  return fact;
}


int calc_order(int n, vector<int> x)
{
  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    cnt += (x[i] - 1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; ++j) {
      if (x[j] > x[i]) --x[j];
    }
  }
  return cnt;
}


void count_order()
{
  int n;
  cin >> n;

  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];

  int p_cnt = 0, q_cnt = 0;
  p_cnt = calc_order(n, p);
  q_cnt = calc_order(n, q);

  cout << abs(p_cnt - q_cnt);
}




int main()
{
  average_length();
  //buy_an_interger();
  //cout << calc_digits(1000000000) << '\n';
  //honest_or_unkind2();
  //snack();
  //next_prime();
  //count_order();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll unsigned long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve() {
    int x;
    cin >> x;
    int a = x/500;
    int b = (x%500)/5;
    cout << a*1000 + 5*b;
    
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3628
"use strict";
function Main(input) {
 const replaceMap = {
  A: 'a',
  B: 'b',
  C: 'c'
 };
 const args = input.split('\n');
 const argNK = args.shift().split(' ').map(m => parseInt(m));
 const N = argNK.shift();
 const K = argNK.shift() - 1;
 const S = args.shift();
 const ch = S.charAt(K);
 console.log(S.slice(0, K) + replaceMap[ch] + S.slice(K + 1));

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int count,n;
  cin >> s;
  n = s.size();
  count = 0;
  for(int i = 0;i < n;i++) {
    if (s.at(i) == 'p')
        count++;
  }
  cout << n/2-count << endl;
}

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

int main(int argc, char const *argv[])
{
	int n,m,l;
	std::cin >> n >> m >> l;
	std::vector<std::vector<int>> a(n,std::vector<int>(m,0));
	std::vector<std::vector<int>> b(m,std::vector<int>(l,0));
	std::vector<std::vector<long long int>> c(n,std::vector<long long int>(l,0));
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < m ; j ++){
			std::cin >>a[i][j] ;
		}
	} 
	for(int i = 0 ; i < m ; i ++){
		for(int j = 0 ; j < l ; j ++){
			std::cin >>b[i][j] ;
		}
	}
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < l ; j ++){
			c[i][j] = 0;
			for(int k = 0 ; k< m ; k ++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < l -1 ; j ++){
			std::cout << c[i][j] << " " ;
		}
		std::cout << c[i][l-1] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3280
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    use std::f64::consts::PI;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut txy: Vec<(f64, f64, f64)> = vec(n, |_| {
        let x: f64 = scan(tokens);
        let y: f64 = scan(tokens);
        let theta = y.atan2(x);
        (theta, x, y)
    });
    txy.sort_by(|a, b| a.partial_cmp(b).unwrap());
    for i in 0..n {
        let (theta, x, y) = txy[i];
        txy.push((theta + 2.0 * PI, x, y));
    }
    let mut cum_x = vec![0_f64; 2 * n + 1];
    let mut cum_y = vec![0_f64; 2 * n + 1];
    for i in 0..2 * n {
        cum_x[i + 1] = cum_x[i] + txy[i].1;
        cum_y[i + 1] = cum_y[i] + txy[i].2;
    }
    let mut ans = 0_f64;
    let mut i = 0;
    let mut j = 0;
    while j < 2 * n {
        if txy[j].0 < txy[i].0 + PI {
            j += 1;
            let x = cum_x[j] - cum_x[i];
            let y = cum_y[j] - cum_y[i];
            ans = ans.max((x * x + y * y).sqrt());
        } else {
            i += 1;
            let x = cum_x[j] - cum_x[i];
            let y = cum_y[j] - cum_y[i];
            ans = ans.max((x * x + y * y).sqrt());
        }
    }
    println!("{}", ans);
}


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

int main() {
  string a;
  cin >> a;
  int x = 0;
  for(int i = 0;i < 3;i++) {
    if(a.at(i) == '1') {
      x++;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
  
    int A,B;
    cin>>A>>B;
    if(A+B>=10){
        cout<<"error"<<endl;
    }
    else{
        cout<<A+B<<endl;
    }
}

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

    string s, t;
    cin >> s >> t;

    int a[26] = {};
    int b[26] = {};
    rep(i, s.length()){
        a[s[i]-'a']++;
        b[t[i]-'a']++;
    }
    sort(a, a+26);
    sort(b, b+26);

    rep(i, 26){
        if(a[i] != b[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> b(n-1);
    for (int i = 0; i < n-1; ++i) {
        cin>>b[i];
    }
    reverse(b.rbegin(),b.rend());
    int ans=b[0];
    int ta=b[0];
    for (int i = 0; i < n-2; ++i) {
        ta=min(b[i],b[i+1]);
        ans+=ta;
    }
    ans+=b[n-2];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int x=0,f=0;
	char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) f^=(ch=='-');
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return f ? -x : x;
}
const int P=998244353,maxn=1010;
inline int kasumi(int x,int y) {
	int qwq=1;
	while (y) {
		if (y&1) qwq=qwq*x%P;
		y>>=1;
		x=x*x%P;
	}
	return qwq;
}
int x[maxn],y[maxn],n,ans;
signed main(){
	n=read();
	for (int i=1;i<=n;++i) {
		x[i]=read();y[i]=read();
	} 
	ans=(kasumi(2,n)-n-1-n*(n-1)/2+P)%P;
	for (int i=1;i<=n;++i) {
		for (int j=i+1;j<=n;++j) {
			int qwq=0;
			for (int k=j+1;k<=n;++k) {
				if ((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j])) ++qwq;
			}
			ans=(ans-kasumi(2,qwq)+P+1)%P;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m,v[200005],c[200005];
	long long dp[200005] = {}, memo[200005] = {},res=0;
	string str, str2;
	cin >> n;

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

	for (int i = 0; i < n; i++) {
		cin >> c[i];
		res += max(0LL, v[i] - c[i]);
	}

	cout << res;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    string s,t="1974";
    rep(i,4){
        ll a; cin>>a;
        s+=to_string(a);
    }
    sort(all(s));
    sort(all(t));
    if(s==t) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n, k;
    cin >> n >> k;
    vector<ll> a(n), s(n); // sはその前までで最も高いビルの高さ
    rep(i, n) cin >> a[i];
    ll h1 = a[0];
    rep2(i, 1, n)
    {
        if (h1 >= a[i - 1])
        {
            s[i] = h1;
        }
        else
        {
            s[i] = a[i - 1];
            h1 = s[i];
        }
    }
    ll ans = 2e18;
    rep(l, 1 << n)
    {
        if (k != __builtin_popcount(l))
            continue;
        if (!(l & 1))
            continue;
        ll h = a[0];
        ll ans1 = 0;
        rep(j, n)
        {
            if (j == 0)
                continue;
            if (l >> j & 1)
            {
                h = max(s[j], h);
                ans1 += max((ll)0, h - a[j] + 1);
                h = max(a[j], h + 1);
            }
        }
        ans = min(ans, ans1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char w[101];
	int i,al[26],len,flg,x;
	scanf("%s",w);
	len=strlen(w);
	for(i=0;i<26;i++)	al[i]=0;
	for(i=0;i<len;i++)	{
		x=w[i]-'a';
		al[x]++;
	}
	flg=1;
	for(i=0;i<26;i++)	{
		if(al[i]%2!=0)	{
			flg=0;	break;
		}
	}
	if(flg==1)	printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int n,m,i[101];
	   scanf("%d",&n);
	for(m = 1;m<=n;m++){
	scanf("%d",&i[m]);
	}
	for(m = n; m >= 1;m--) {
		printf("%d",i[m]);
		if(m == 1)
		break;
		
		printf(" ");
	}
		printf("\n");
return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int main(){
	int sum=0,c[6],i;
	for(i=0;i<6;i++)scanf("%d",&c[i]);
	sum+=c[0]*1;
	sum+=c[1]*5;
	sum+=c[2]*10;
	sum+=c[3]*50;
	sum+=c[4]*100;
	sum+=c[5]*500;
	if(sum<1000)i=0;
	else i=1;
	printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i,n){
        ll in;
        cin >> in;
        ll res = 0;
        if(in%2 == 0){
            while(in%2 == 0){
                in/=2;
                res++;
            }
            ans += res;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class205
    {
        static void Main()
        {
            var KN = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int K = KN[0], N = KN[1];
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int d = Math.Abs(K - A[N - 1] + A[0]);
            for (int i= 0; i < N-1; i++)
            {
                d = Math.Max(d, A[i+1]-A[i]);
            }
            Console.WriteLine(K-d);

        }
    }
}


Measured memory_bytes: 34780
import math

while True:
    n = int(input())
    if n == 0:
        break

    buf = input().split()
    dataset = []
    sum = 0
    for i in range(n):
        dataset.append(int(buf[i]))
        sum += dataset[i]

    ave = sum / n

    v_sum = 0
    for i in range(n):
        v_sum += (dataset[i] - ave) ** 2

    v = v_sum / n

    print(math.sqrt(v))



Measured memory_bytes: 5780
using System;

class Program
{
	static void Main()
	{
		var numbers = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var d = numbers[0];
		var n = numbers[1];

		if (n != 100) {
			var firstNumber = d switch
			{
				0 => 1,
				1 => 100,
				_ => 10000,
			};

			Console.WriteLine(firstNumber * n);
		} else {
			Console.WriteLine(d switch
			{
				0 => 101,
				1 => 10100,
				_ => 1010000,
			});
		}
	}
}


Measured memory_bytes: 27520
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
oa=0
ob=0
flag=True
if(a<b):
    a=a+v*t
    b=b+w*t
    if(b<=a):
        flag=True
    else:
        flag=False
else:
    a=a-v*t
    b=b-w*t
    if(a<=b):
        flag=True
    else:
        flag=False
print("YES" if flag else "NO")

Measured memory_bytes: 61764
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	br := make([]int, n)
	br[0] = ar[0]
	for i := 1; i < n; i++ {
		br[i] = gcd(br[i-1], ar[i])
	}
	cr := make([]int, n)
	cr[n-1] = ar[n-1]
	for i := n - 2; i >= 0; i-- {
		cr[i] = gcd(cr[i+1], ar[i])
	}
	max := cr[1]
	if max < br[n-2] {
		max = br[n-2]
	}
	for i := 1; i < n-1; i++ {
		result := gcd(br[i-1], cr[i+1])
		if max < result {
			max = result
		}
	}
	fmt.Println(max)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 5504
A,B=map(int,input().split())
ans=0
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
c=gcd(max(A,B),min(A,B))
def divisor(n):
    i=1
    table=[]
    while i*i<=n:
        if n%i==0:
            table.append(i)
            table.append(n//i)
        i+=1
    table=list(set(table))
    return table
div=divisor(c)
for i in range(len(div)):
    n=div[i]
    flag=1
    for i in range(2,n+1):
        if i*i>n:
            break
        if n%i==0:
            flag=0
            break
    if flag==1:
        ans+=1
print(ans)

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

using ull = unsigned long long;
const ull divisor = (ull) 1e9 + 7;

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

    const int N = n;
    const int M = m;

    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    ull remFactorialN = (ull) N;
    while (--n) {
        remFactorialN *= n;
        remFactorialN %= divisor;
    }

    ull remFactorialM = (ull) M;
    while (--m) {
        remFactorialM *= m;
        remFactorialM %= divisor;
    }

    ull answer = (remFactorialN * remFactorialM) % divisor;
    if (N == M) answer = (answer * 2) % divisor;

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256