akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	string s;cin >> s;
	int q;cin >> q;
	string res[2];
	int f = 0;
	while(q--){
		int t;cin >> t;
		if(t == 1){
			f ^= 1;
		}
		else {
			int p;cin >> p;
			p--;
			char c;cin >> c;
			res[p^f] += c;
		}
	}
	reverse(res[0].begin(),res[0].end());
	string ret = res[0] + s + res[1];
	if(f)reverse(ret.begin(),ret.end());
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4244
// C - Go to School
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n, x;
	cin >> n;
	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		cin >> x;
		ans[x - 1] = i;
	}
	for (int i = 0; i < n; i++) cout << (i > 0 ? " " : "") << (ans[i] + 1);
	cout << endl;

	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main(void){
	int N;
	char s[100000][5] = {};
	scanf("%d", &N);
	for(int i=0;i<N;i++){
		scanf("%s", s[i]);
	}
	int AC=0;
	int WA=0;
	int TLE=0;
	int RE=0;
	for(int i=0;i<N;i++){
		switch(s[i][0]){
			case 'A':
				AC++;
				break;
			case 'W':
				WA++;
				break;
			case 'T':
				TLE++;
				break;
			case 'R':
				RE++;
				break;
		}
	}
	printf("AC x %d\n",AC);
	printf("WA x %d\n",WA);
	printf("TLE x %d\n",TLE);
	printf("RE x %d\n",RE);

	return 0;
}


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

#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define endl '\n'
#define exists(s, e) (s.find(e)!=s.end())
#define WHILE(n)
#define pb push_back
#define f first
#define s second
#define UNI(vec) vec.erase(std::unique(vec.begin(), vec.end()),vec.end());
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<int, pii> piii;

const int INF = 0x3f3f3f3f;
#define MAXN 3001
using namespace std;
int n,m,ans;
double dp[MAXN][MAXN];
vector<double> a;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    double x;
    for (int i =0; i < n; i++){
        cin>>x;
        a.pb(x);
    }
    dp[1][1] = a[0];
    dp[1][0] = 1-a[0];
    for(int i = 1; i < n; i++){
        for(int j = 0; j <= i; j++){
            dp[i+1][j] += dp[i][j] * (1-a[i]);
            dp[i+1][j+1] += dp[i][j] * a[i];
            //dp[i+1][j] += dp[i][j] * (1-a[0]);
        }
    }
    double ans = 0;
    for(int i = n/2 + 1; i <= n; i++){
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(10);
    cout<<ans;



}


Measured memory_bytes: 68992
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
#define INF 99999999
typedef std::pair<int,int> pii;
int main(){
    std::vector<std::vector<int>> c(3,std::vector<int>(3,0));
    std::vector<int> a(3),b(3);
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            std::cin >> c[i][j];
        }
        b[i]=c[0][i];
    }
    a[0]=0;
    a[1]=(c[1][0]+c[1][1]-b[1]-b[0])/2;
    a[2]=(c[2][0]+c[2][1]-b[1]-b[0])/2;
    for(int i=0;i<3;i++){
        
        for(int j=0;j<3;j++){
            if(c[i][j]!=a[i]+b[j]){
                std::cout << "No" <<std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" <<std::endl;
    return 0;
}

Measured memory_bytes: 256
import copy
def bubbleSort(A, N):
    cnt = 0
    flag = 1
    while flag:
        flag = 0
        for j in range(N - 1, 0, -1):
            if A[j][1] < A[j - 1][1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 1
                cnt = cnt + 1
    return cnt


def selectionSort(A, N):
    cnt = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j][1] < A[minj][1]:
                minj = j
        cnt = cnt + int(i != minj)
        A[i], A[minj] = A[minj], A[i]
    return cnt

def prArr(A, N):
    for i in range(N):
        if i != 0:
            print(" ", end = "")
        print(A[i], end = "")
    print()

    
N = int(input())
A = [i for i in input().split()]
B = copy.deepcopy(A)

bubbleSort(A, N)
selectionSort(B, N)

prArr(A, N)
print("Stable")

prArr(B, N)
print("Stable" if A == B else "Not stable")



Measured memory_bytes: 6348
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    print(N * (N+1) // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10096
import sys
import math as m
A,B,H,M = list(map(int, sys.stdin.readline().rstrip().split())) 

aH = ((H%12)*60 + M)/720
aM = M/60
angle = max(aH,aM) - min(aH,aM)
angle*2*m.pi


ans = A**2 + B**2 - 2*A*B*m.cos(angle*2*m.pi)
ans = ans**0.5
print(ans)

Measured memory_bytes: 9516
#include <iostream>

using ll = long long;

int main() {
	int N, x;
	std::cin >> N >> x;

	ll result = 0;
	
	int left = 0;
	int right = 0;

	for(int i = 0; i < N; i++) {
		left = right;
		std::cin >> right;

		if(left + right > x) {
			result += left + right - x;
			right = x - left;
		}
	}

	std::cout << result << std::endl;

	return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    string tmp;
    int maze[H+1][W+1];
    int dp[H+1][W+1];
    for(int i = 0; i<=H; i++){
        for(int j = 0; j<=W; j++){
            dp[i][j] = 0;
        }
    }
    dp[1][1] = 1;
    for(int i = 1; i<=H; i++){
        cin >> tmp;
        for(int j = 1; j<=W; j++){
            if(tmp[j-1]=='#'){
                maze[i][j] = 0;
            }else{
                maze[i][j] = 1;
            }
        }
    }
    for(int i = 1; i<=H; i++){
        for(int j = 1; j<=W; j++){
            if(i == 1 && j == 1){
                continue;
            }
            dp[i][j] = (dp[i][j-1]*maze[i][j-1] + dp[i-1][j]*maze[i-1][j]) % 1000000007;
        }
    }
    cout << dp[H][W] << endl;
    return 0;
}

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

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

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

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n,m;cin>>n>>m;
  vector<ll>a(m);
  rep(i, m)cin>>a[i];
  ll sum=0;
  rep(i, m)sum+=a[i];
  if(n-sum<0)cout<<-1;
  else cout<<n-sum;
  return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	vector<vector<int> >v(n+1);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	/*for(int i=1;i<v.size();i++){
		for(int j=0;j<v[i].size();j++){
			cout<<v[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	int arr[n+1];
	for(int i=1;i<n+1;i++){arr[i]=0;}
	queue<int> st;
	int i=n,tm;
	st.push(1);
	while(i && (!st.empty())){
		tm=st.front();
	//	cout<<tm<<endl;
		st.pop();
		i-=1;
		for(int j=0;j<v[tm].size();j++){
			//cout<<arr[v[tm][j]]<<"j"<<endl;
			if(arr[v[tm][j]]==0){
				//cout<<"ho"<<endl;
				arr[v[tm][j]]=tm;
				st.push(v[tm][j]);
			}
		}
	}
	//cout<<i<<endl;
	if(i==0){
		cout<<"Yes\n";
		for(int i=2;i<n+1;i++){
			cout<<arr[i]<<"\n";
		}
	}
	else{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 10064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n; cin >> n;
    string c; cin >> c;

    int lwcount = 0,rrcount = 0;

    int wcount = 0, rcount = 0;

    for(int i = 0;i < n;i ++){
        if(c.at(i) == 'W') wcount ++;
        else rcount ++;
    }

    for(int i = 0;i < rcount;i ++){
        if(c.at(i) == 'W') lwcount ++;
    }
    for(int i = 0;i < wcount;i ++){
        if(c.at(n-1-i) == 'R') rrcount ++;
    }

    cout << max(lwcount,rrcount) << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;

int H,W;
string S[505];
int did[505*505];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) cin>>S[y];
	FOR(x,W) S[0][x]='$', S[H-1][x]='&';
	
	FOR(y,H) FOR(x,W) if(S[y][x]=='.') {
		if(x%2==0) S[y][x]='$';
		else S[y][x]='&';
	}
	
	FOR(y,H) {
		FOR(x,W) {
			if(S[y][x]=='#' || S[y][x]=='$') cout<<'#';
			else cout<<'.';
		}
		cout<<endl;
	}
	cout<<endl;
	FOR(y,H) {
		FOR(x,W) {
			if(S[y][x]=='#' || S[y][x]=='&') cout<<'#';
			else cout<<'.';
		}
		cout<<endl;
	}
	
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 4976
import itertools

n = int(input())

p = [[int(i) for i in input().split()] for i in range(n)]

def how_far(a,b):
    return ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5

p_list = list(itertools.permutations(p))

s = 0

for x in p_list:
    for y in range(n-1):
        s += how_far(x[y],x[y+1])

print(s/len(p_list))


Measured memory_bytes: 13888
from collections import Counter
def min_fac_array(n):
    nums = [i for i in range(n+1)]
    for i in range(2,n+1):
        if nums[i] == i:
            for j in range(2*i,n+1,i):
                if nums[j] == j:
                    nums[j] = i
    return nums

def fac_fast(mfa,a):
    n = a
    fac = []
    while n != 1:
        fac.append(mfa[n])
        n //=mfa[n]
    return fac

def main(): 
    n = int(input())
    mfa = min_fac_array(n)
    ans = 1
    for i in range(2,n):
        fac = fac_fast(mfa,i)
        dic = Counter(fac)
        temp = 1
        for p in dic.values():
            temp*=p+1
        ans+=temp
    
    print(ans)
main()

Measured memory_bytes: 142592
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> C(N,0);
    for(int i=0; i<N; i++){
        cin >> C[i];
    }

    vector<long long> pattern(N,0);
    pattern[0]=1;
    vector<int> prev(200000+1,-1);
    for(int i=0; i<N; i++){
        int c=C[i];
        if(prev[c]!=-1 && prev[c]!=i-1){
            pattern[i]=(pattern[prev[c]]+pattern[i-1])%MOD;
        }else if(i>0){
            pattern[i]=pattern[i-1];
        }
        prev[c]=i;
    }
    cout << pattern[N-1] << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const ll N = 123456;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a , b;
    cin >> a >> b;

    cout << max(a + b , max(a - b , a * b)) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
		ArrayList<Integer> al = new ArrayList<>();
		int a = sc.nextInt();
		for (int i=0;i<N-1;i++){
			int b = sc.nextInt();
			if(b == a+1){al.add(a-1);}
			a = b;
		}
		int Ans = 0;
		for (int i=0;i<N;i++){Ans += sc.nextInt();}
		for (int i=0;i<N-1;i++){Ans += sc.nextInt()*((al.contains(i))?1:0);}
		System.out.println(Ans);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;

    vector<int> l;
    l.resize(n);

    int m=0, s=0;
    for (int i=0; i<n; i++) {
        int l;
        cin >> l;
        s += l;
        m = max(m, l);
    }

    cout << ( (m < s-m) ? "Yes" : "No" ) << endl;


    return 0;
}

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

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

const int INF = 1000000007;

int main(){
	int n;
	cin>>n;
	int cnt=0;
	int a[110000]={0};
	for(int i=0;i<n;i++)cin>>a[i];
	int arr[110000]={0};

	for(int i=0;i<n;i++){
		if(a[i]<=n){
			arr[a[i]-1]++;
		}
		else cnt++;
	}
	for(int i=0;i<n;i++){
		if(arr[i] - (i+1) < 0) cnt += arr[i];
		else cnt += arr[i] - (i+1);
	}

	cout<< cnt <<endl;

	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        int e;
        cin >> e;
        if(e==0) break;
        int m = 10000001;
        for(int z=0;z<=100;z++){
            int xy2 = e - pow(z,3);
            if(xy2 < 0) break;
            for(int y=0;y*y <= xy2;y++){
                int x = xy2 - y*y;
                m = min(x+y+z,m);
            }
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

const int N = 1e5+9;
struct vertex { vector<int> edge; };
ll n, m;
vertex g[N];
map<int, ll> dp[N]; // node=黒 to以降の塗り方

// ALL to. dp[node][to]
// return 1 + PROD(dp[node][to])
ll out(int node, int from) {
    ll res = 1;
    for(auto to : g[node].edge) {
        if(to == from)  continue;
        if(!dp[node].count(to))  dp[node][to] = out(to, node);
        res = res * dp[node][to] % m;
    }
    return (1 + res) % m;
}

// ALL from. dp[from][node]
void in(int node, int exc) {
    vector<ll> vals;
    for(auto to : g[node].edge)  vals.push_back(dp[node][to]);

    vector<ll> left{1}, right{1};
    int sz = vals.size();
    for(int i = 0; i < sz; i++) {
        left.push_back( left.back() * vals[i] % m );
        right.push_back( right.back() * vals[sz-1-i] % m );
    }
    right.pop_back();  reverse(begin(right), end(right));

    int i = -1;
    for(auto from : g[node].edge) {
        i++;
        if(from == exc)  continue;
        dp[from][node] = (left[i] * right[i] + 1) % m;
        in(from, node);
    }
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < n-1; i++) {
        int x, y;  cin >> x >> y;
        x--;  y--;
        g[x].edge.push_back(y);
        g[y].edge.push_back(x);
    }

    out(0, -1);
    in(0, -1);

    for(int node = 0; node < n; node++) {
        ll ans = 1;
        for(auto to : g[node].edge)  ans = ans * dp[node][to] % m;
        cout << ans << endl;
    }
}

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

using namespace std;

#define int long long
#define PB push_back
#define BP while(1){}
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

int N, K, dp[11][2005];
vector<int> b[11];

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

  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    int tc, tg;
    cin >> tc >> tg;
    b[tg].PB(tc);
  }
  for (int i = 1; i <= 10; ++i) {
    sort(b[i].begin(), b[i].end(), greater<int>());

    for (int j = 1; j < b[i].size(); ++j) {
      b[i][j] += b[i][j - 1] + 2 * (j + 1) - 2;
    }
  }

  for (int i = 1; i <= 10; ++i) {
    for (int j = 0; j <= K; ++j) {
      int tmax = 0;
      for (int i2 = 1; i2 < i; ++i2) {
        tmax = max(tmax, dp[i2][j]);
      }

      for (int k = 1; k <= b[i].size(); ++k) {
        if (K < j + k) continue;

        dp[i][j + k] = max(dp[i][j + k], tmax + b[i][k - 1]);
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= 10; ++i) {
    ans = max(ans, dp[i][K]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1404
import glob
import numpy as np

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\165\\B'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]
        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class B(Common):

    def resolve(self):

        X = int(self.input_data())

        count = 0

        money = 100

        while True:
            kinri = int(money * 0.01)
            money += kinri
            count += 1
            if money >= X:
                print(str(count))
                break


solver = B(REL_PATH)
solver.exec_resolve()

Measured memory_bytes: 27080
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define mp(a, b) make_pair((a),(b))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;
constexpr double eps = 0.000000001;

ll n, a, r, x[50], dp[51][51][3000];

int main() {
    cin >> n >> a;
    rep(i, n)cin >> x[i];
    for (auto &e:dp)for (auto &f:e)for (auto &j:f)j = 0;
    dp[0][0][0] = 1;
    rep(i, n) {
        rep(j, n) {
            rep(k, 2501) {
                dp[i + 1][j][k] += dp[i][j][k];
                dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
            }
        }
    }
    rep(i, n)r += dp[n][(i + 1)][(i + 1) * a];
    cout << r << endl;
}

Measured memory_bytes: 61184
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  vector<string> mp(N);
  FOR(i, N) cin >> mp[i];
  ll ans = 0;
  FOR(dy, N) {
    bool f = 1;
    for (int y = 0; y < N - 1; ++y) {
      for (int x = y + 1; x < N; ++x) {
        if (mp[(y + dy) % N][x] != mp[(x + dy) % N][y])
          f = 0;
      }
    }
    if (f)
      ans += N;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 384
# ???????????????'S'???????????????'H'???????????????'C'???????????????'D'
cards = { 
  "S" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 
  "H" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 
  "C" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 
  "D" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
}

n = gets.chomp.to_i
n.times do
  mark, num = gets.chomp.split(" ")
  num = num.to_i
  cards[mark][num-1] = false
end

["S", "H", "C", "D"].each {|mark| cards[ mark ].each {|num| puts "#{ mark } #{ num }" if num } }

Measured memory_bytes: 8704
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=3e5+5;
char s[N];int f[N][8],n;
int mp[2][8]={{3,6,2,4,3,3,7,6},{1,2,2,5,3,1,1,6}};
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%s",s+1),n=strlen(s+1);
	f[n+1][1]=f[n+1][2]=1;
	fd(i,n,1)fp(j,0,1)if(s[i]!='0'+(j^1))
		fp(k,0,7)upd(f[i][k],f[i+1][mp[j][k]]);
	printf("%d\n",f[1][0]);
	return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int sz=1e6+10;

void solve()
{
   ll n,i,sum=0;
   cin>>n;
   ll ar[n];
   for(i=0;i<n;i++) cin>>ar[i];
   for(i=1;i<n;i++)
   {
       if(ar[i]<ar[i-1])
       {
           sum+=ar[i-1]-ar[i];
           ar[i]=ar[i-1];
       }
   }
   cout<<sum<<endl;
}

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

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

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  ull n; cin >> n;
  ull ans = 0;
  for(ull i = 2; i*i <= n; i++){
    if(n % i == 0){
      int c = 0;
      while(n % i == 0){
        c++;
        n /= i;
      }
      for(int j = 1; j <= c; j++){
        ans++;
        c -= j;
      }
    }
  }
  if(n != 1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	int N;
	cin >> N;

	map<pair<int, int>, int> mpiii;

	for (long long i = 1; i <= N; i++){
		char s[10];
		sprintf(s, "%d", i);
		int s_num = s[0] - '0';
		int e_num = i % 10;
		if (e_num != 0) mpiii[make_pair(s_num, e_num)]++;
	}

	int ans = 0;
	for (int s = 1; s <= 9; s++){
		for (int e = 1; e <= 9; e++){
			int a_case = mpiii[make_pair(s, e)];
			int b_case = mpiii[make_pair(e, s)];
			ans += a_case * b_case;
		}
	}

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


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val An = readLine()!!.split(" ").map(String::toInt)
    val duplicate_count_map: MutableMap<Int,Int> = mutableMapOf()
    An.forEach  {
        duplicate_count_map[it] = (duplicate_count_map[it]?: 0) + 1
    }

    val total_comb = duplicate_count_map.values.map {  
        it.toLong() * (it.toLong() - 1L )/ 2L
        }.fold(0L) {a, b -> a + b}

    for(i in 0 until N) {
        println(total_comb - (duplicate_count_map[An[i]]?.let{  (it - 1).toLong() }?: 0L))
    }
}

Measured memory_bytes: 106468
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
int n,x,Ans,Dis[100010];
inline int Read()
{   rg int a=0,c=1;   rg char b=getchar();
    while(b!='-'&&(b<'0'||b>'9'))b=getchar();
    if(b=='-')c=-1,b=getchar();
    while(b>='0'&&b<='9')a=a*10+b-48,b=getchar();
    return a*c;
}
inline int Gcd(rg int A,rg int B){   return B?Gcd(B,A%B):A;   }
inline int Abs(rg int A){   return A>0?A:-A;   }
int main()
{   n=Read();   x=Read();
    for(rg int i=1;i<=n;i++) Dis[i]=Read();
    Ans=Abs(x-Dis[1]);
    for(rg int i=2;i<=n;i++) Ans=Gcd(Ans,Abs(x-Dis[i]));
    printf("%d\n",Ans);
}


Measured memory_bytes: 640
N = int(input())
for i in range(N):
    L = []
    while 1:
        *s, = map(int, input().split())
        if s[-1] == 0:
            L.extend(s[:-1])
            break
        L.extend(s)
    G = []
    st = []
    cur = 0
    for s in L:
        if s > 0:
            G.append([])
            if st:
                u = [cur, s-1]
                v = st[-1]
                v[1] -= 1
                G[u[0]].append(v[0])
                G[v[0]].append(u[0])
                st.append(u)
                while st and st[-1][1] == 0:
                    st.pop()
            else:
                st.append([cur, s])
            cur += 1
            continue
        u = st[s-1]; u[1] -= 1
        v = st[-1]; v[1] -= 1
        G[u[0]].append(v[0])
        G[v[0]].append(u[0])
        while st and st[-1][1] == 0:
            st.pop()
    for i, vs in enumerate(G):
        vs.sort()
        print(i+1, *map(lambda x: x+1, vs))



Measured memory_bytes: 5968
#include<stdio.h>
int main()
{
    long long int k,n;
    scanf("%lli%lli",&n,&k);
    if(n<k){if(2*n>k){n=k-n;}}
    else if(n>=k){if(n%k<=k/2){n=n%k;}
    else if(n%k>k/2){n=k-(n%k);}}
    printf("%lli",n);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll mod = 1000000007;

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

  int n, k;
  cin >> n >> k;
  vector<int> h(n+1);
  rep(i, n) cin >> h[i];

  vector<int> dp(100005, INF);

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

  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int w,h,n;
  cin >> w >> h >> n;
  int udk=0,rin=0;
  int answer=0;
  REP(i,n){
    int tmp;
    cin >> tmp;
    if(tmp==0) ++udk;
    else ++rin;
    if(udk==w-1||udk==w+h-2) continue;
    if((udk<w-1 && udk==rin) ||
       (w-1<udk && udk<w+h-2 && udk-2 == rin) ||
       (w+h-2<udk && udk-4 == rin)) ++answer;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

template <class T>
struct LazySegmentTree {
    int n;
    T def;
    vector<T> node, lazy;
    vector<bool> flag;
    function<T(T, T)> func;

    LazySegmentTree(int _n, T _def, function<T(T, T)> _func)
        : def(_def), func(_func) {
        n = 1;
        while (n < _n) n *= 2;
        node.resize(2 * n - 1, def);
        lazy.resize(2 * n - 1, 0);
        flag.resize(2 * n - 1, false);
    }

    void eval(int k, int l, int r) {
        if (flag[k]) {
            node[k] += lazy[k];
            if (r - l > 1) {
                lazy[k * 2 + 1] += lazy[k];
                lazy[k * 2 + 2] += lazy[k];
                flag[k * 2 + 1] = flag[k * 2 + 2] = true;
            }
            lazy[k] = 0;
            flag[k] = false;
        }
    }

    void update(int a, int b, T v, int k, int l, int r) {
        eval(k, l, r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] += v;
            flag[k] = true;
            eval(k, l, r);
        } else {
            update(a, b, v, 2 * k + 1, l, (l + r) / 2);
            update(a, b, v, 2 * k + 2, (l + r) / 2, r);
            node[k] = func(node[2 * k + 1], node[2 * k + 2]);
        }
    }

    T get(int a, int b, int k, int l, int r) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (b <= l || r <= a) return def;
        if (a <= l && r <= b) return node[k];
        T vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
        return func(vl, vr);
    }

    void update(int a, int b, T v) {
        update(a, b, v, 0, 0, n);
    }

    T get(int a, int b) {
        return get(a, b, 0, 0, n);
    }
};

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    LazySegmentTree<ll> st(200005, 0, [](ll a, ll b) { return a + b; });
    rep(i, 0, n - 1) {
        ll dif = (a[i + 1] - a[i] + m) % m;
        st.update(a[i] + 2, a[i] + dif + 1, -1);
        st.update(a[i] + dif + 1, a[i] + dif + 2, dif - 1);
    }
    vector<ll> c(m + 1);
    rep(i, 1, m + 1) {
        c[i] += st.get(i, i + 1) + st.get(i + m, i + m + 1);
        c[i] += c[i - 1];
    }
    c[1] += c[m];
    //debug(c);
    ll mn = c[1], cnt = 1;
    rep(i, 2, m + 1) {
        if (mn > c[i]) {
            mn = c[i];
            cnt = i;
        }
    }
    //debug(cnt);
    ll ans = 0;
    rep(i, 0, n - 1) {
        ans += min((a[i + 1] - a[i] + m) % m, (a[i + 1] - cnt + m) % m + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10112
n = int(input())
a = list(map(int, input().split()))
max = 0
min = 0
visited = [0] * 8
for i in range(n):
    if 1 <= a[i] and a[i] <= 399 and visited[0] == 0:
        max += 1
        min += 1
        visited[0] = 1
    elif 400 <= a[i] and a[i] <= 799 and visited[1] == 0:
        max += 1
        min += 1
        visited[1] = 1
    elif 800 <= a[i] and a[i] <= 1199 and visited[2] == 0:
        max += 1
        min += 1
        visited[2] = 1
    elif 1200 <= a[i] and a[i] <= 1599 and visited[3] == 0:
        max += 1
        min += 1
        visited[3] = 1
    elif 1600 <= a[i] and a[i] <= 1999 and visited[4] == 0:
        max += 1
        min += 1
        visited[4] = 1
    elif 2000 <= a[i] and a[i] <= 2399 and visited[5] == 0:
        max += 1
        min += 1
        visited[5] = 1
    elif 2400 <= a[i] and a[i] <= 2799 and visited[6] == 0:
        max += 1
        min += 1
        visited[6] = 1
    elif 2800 <= a[i] and a[i] <= 3199 and visited[7] == 0:
        max += 1
        min += 1
        visited[7] = 1
    elif 3200 <= a[i]:
        max += 1
if min == 0:
    min += 1
print(min, max)


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


int c[3][3];
int main(){
    REP(i,3) REP(j,3) cin >> c[i][j];
    
    // a1の値を決めると全部来ます。
    // a1の可能な値(0 ~ 100)を全探索
    bool isok = false;
    REP(i,101){
        int a1 = i;
        int b1 = c[0][0] - a1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;

        int a2 = c[1][0] - b1;
        int a3 = c[2][0] - b1;

        // これらん値がかのうか
        if(b1 >= 0 && b1 <= 100 && b2 >= 0 && b2 <= 100 && b3 >= 0 && b3 <= 100 && a2 >= 0 && a2 <= 100 && a3 >= 0 && a3 <= 100 && 
            a2+b2 == c[1][1] && a2+b3 == c[1][2] && a3+b2 == c[2][1] && a3+b3 == c[2][2]){
            isok = true;
            break;
        }
    }
    cout << (isok ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
  string S, T;
  string ans = "No";
  cin >> S >> T;

  if (S == T) {
    ans = "Yes";
  } else {
    for (int i = 0; i < T.size(); i++) {
      char tmp = T.at(T.size()-1);
      for (int j = T.size()-1; j > 0; j--) {
        T.at(j) = T.at(j-1);
      }
      T.at(0) = tmp;
      if (S == T) {
        ans = "Yes";
        break;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
while True:
    T = []
    am, pm = [int(x) for x in input().split()]
    if am == 0 and pm ==0:
        break
    T.append(am+pm)
    for i in range(4):
        am, pm = [int(x) for x in input().split()]
        T.append(am+pm)
    num = sorted(list(enumerate(T)), key=lambda x: -x[1])[0][0]
    print("ABCDEF"[num], T[num])






Measured memory_bytes: 5600
a, b, c, d = map(int, input().split())
x, y = c, d
if x<y: x, y = y, x
while y: x, y = y, x%y
lcm = c*d//x

a -= 1
e = b - (b//c + b//d - b//lcm)
f = a - (a//c + a//d - a//lcm)
print(e-f)

Measured memory_bytes: 3064
import sys
import collections

readline = sys.stdin.readline

def main():
    N = int(readline())
    A = []
    for _ in range(N):
        A.append(int(readline()))
    Aitems = list(zip(*collections.Counter(A).items()))
    Acount = list(Aitems[1])
    tmp = [x%2 for x in Acount]
    ans = sum(tmp)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 22252
/**
       ������������    ������������
		Author : Avi J Patel
		University : DA-IICT
       ������������    ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define N 100000
#define ff first
#define ss second
#define si size()
#define mod 1000000007
#define large 10000000000000001
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

int main()
{
	FAST;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='o')
		{
			cnt++;
		}
	}
	cnt+=15-s.size();
	if(cnt>=8)
	{
		cout<<"YES";
	}
	else
	cout<<"NO";
    return 0;
}








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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    vector<int> score(n, 0);

    rep(i, q) {
        cin >> a[i];
        a[i]--;
    }

    rep(i, q) {
        score[a[i]]++;
    }

    rep(j, n) {
        if (k-q+score[j] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=3e5+5;
typedef unsigned long long ull;
typedef long long ll;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
struct node{ll x,y;}a[55];
int n;
int main(){
    cin>>n;
    map<pair<ll,ll>,ll>p;
    for(int i=1;i<=n;i++){
        cin>>a[i].x>>a[i].y;
        p[{a[i].x,a[i].y}]=1;
    }
    auto f=[](node x,node y){
        if(x.x==y.x)return x.y<y.y;
        return x.x<y.x;
    };
    sort(a+1,a+1+n,f);
    set<pair<ll,ll> >q;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            q.insert({a[i].x-a[j].x,a[i].y-a[j].y});
        }
    }
    ll ans=n;
    for(auto pi:q){
        map<pair<ll,ll>,ll>mp;
        ll res=0;
        for(int i=1;i<=n;i++){
            if(mp[{a[i].x,a[i].y}])continue;
            res++;
            int ai=a[i].x,bi=a[i].y;
            mp[{ai,bi}]=1;
            while(p[{ai-pi.first,bi-pi.second}])ai=ai-pi.first,bi=bi-pi.second,mp[{ai,bi}]=1;
        }
        ans=min(ans,res);
    }
    o(ans);
}


Measured memory_bytes: 2816
/*
    Author: zxy_hhhh
    date: 2020/03/13
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#define ll long long
inline ll rd() {
    ll _x=0;int _ch=getchar(),_f=1;
    for(;!isdigit(_ch)&&(_ch!='-')&&(_ch!=EOF);_ch=getchar());
    if (_ch=='-'){_f=0;_ch=getchar();}
    for(;isdigit(_ch);_ch=getchar()) _x=_x*10+_ch-'0';
    return _f?_x:-_x;
}
void write(ll _x){if (_x>=10) write(_x/10),putchar(_x%10+'0'); else putchar(_x+'0'); }
inline void wrt(ll _x,char _p){if (_x<0) putchar('-'),_x=-_x; write(_x); if (_p) putchar(_p);}
#define maxn 200005
int dis[maxn],Fa[maxn];
std::vector<int> G1[maxn],G2[maxn];
int n,A,B;
void dfs(int u,int fa) {
    Fa[u]=fa;
    for(auto i:G2[u]) if (i!=fa) {
        dis[i]=dis[u]+1;
        dfs(i,u);
    }
}
int ans;
void DFS(int u,int fa,int D) {
    if (dis[u]<=D) return ;
    ans=std::max(ans,dis[u]*2);
    for(auto i:G1[u]) if (i!=fa) {
        if (!(Fa[u]==i||Fa[i]==u||Fa[u]==Fa[i]||Fa[Fa[i]]==u||Fa[Fa[u]]==i)) 
            ans=1e9;
        DFS(i,u,D+1);
    }
}
int main() {
    n=rd();A=rd(),B=rd();
    for(int i=2;i<=n;i++) {
        int x=rd(),y=rd();
        G1[x].push_back(y);
        G1[y].push_back(x);
    }
    for(int i=2;i<=n;i++) {
        int x=rd(),y=rd();
        G2[x].push_back(y);
        G2[y].push_back(x);
    }
    dfs(B,0);
    DFS(A,0,0);
    if (ans>1e8) wrt(-1,'\n');
    else wrt(ans,'\n');
}

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

int main(){
    int a,b,c;
    int i;
    int x=0;
    cin>>a>>b>>c;
    
    for(i=a;i<=b;i++){
        if(c%i==0)x++;
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int>d(N);
  for(int i=0;i<N;i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  int ans=0;
  for(int i=0;i<N;i++){
    if(i==0){
      continue;
    }
    else if(d.at(i)==d.at(i-1)){
      ans+=1;
    }  
  }
  cout << N-ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxm=2e6+5;
char s[maxm];
int n;
struct SAM{
    int ch[maxm][26];
    int fa[maxm],l[maxm];//l[]是等价类的最长字符串长度len
    int last=1,tot=1;//tot是节点数量
    //
    int lc[maxm],rc[maxm];
    int cnt[maxm];
    int idx[maxm];
    int solve(){
        for(int i=0;i<=tot;i++)cnt[i]=0;
        for(int i=1;i<=tot;i++)cnt[l[i]]++;
        for(int i=1;i<=tot;i++)cnt[i]+=cnt[i-1];
        for(int i=1;i<=tot;i++)idx[cnt[l[i]]--]=i;
        //
        for(int i=tot;i>=1;i--){
            int x=idx[i];
            if(!lc[fa[x]]||lc[x]<lc[fa[x]]){
                lc[fa[x]]=lc[x];
            }
            if(!rc[fa[x]]||rc[x]>rc[fa[x]]){
                rc[fa[x]]=rc[x];
            }
        }
        int ans=0;
        for(int i=1;i<=tot;i++){
            ans=max(ans,min(rc[i]-lc[i],l[i]));
        }
        return ans;
    }
    //
    void add(int c,int pos){//传入s[i]-'a'而不是s[i]
        int p=last,np=++tot;last=np;l[np]=l[p]+1;
        for(;p&&!ch[p][c];p=fa[p])ch[p][c]=np;
        if(!p)fa[np]=1;
        else{
            int q=ch[p][c];
            if(l[p]+1==l[q])fa[np]=q;
            else{
                int nq=++tot;l[nq]=l[p]+1;
                memcpy(ch[nq],ch[q],sizeof ch[q]);
                fa[nq]=fa[q];fa[q]=fa[np]=nq;
                for(;ch[p][c]==q;p=fa[p])ch[p][c]=nq;
            }
        }
        //记录最左和最右位置
        lc[np]=rc[np]=pos;
    }
    void init(){
        for(int i=1;i<=tot;i++){
            memset(ch[i],0,sizeof ch[i]);
            fa[i]=l[i]=0;
        }
        last=tot=1;
    }
}S;
signed main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    S.init();
    for(int i=1;i<=n;i++){
        S.add(s[i]-'a',i);
    }
    int ans=S.solve();
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, M;
pint deg[110000];
vint G[110000];

signed main() {
    cin >> N >> M;
    if (N <= 3) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < N; i++)deg[i] = pint(0, i);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
        deg[a - 1].first++, deg[b - 1].first++;
    }
    for (int i = 0; i < N; i++) {
        if (deg[i].first & 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    sort(deg, deg + N), reverse(deg, deg + N);
    if (deg[0].first >= 6 || deg[0].first == 4 && deg[1].first == 4 && deg[2].first == 4) {
        cout << "Yes" << endl;
        return 0;
    }
    if (deg[0].first == 4 && deg[1].first == 4) {
        int cnt = 0;
        for (int i = 0; i < 4; i++) {
            int cur = G[deg[0].second][i];
            vector<bool> used(N);
            used[deg[0].second] = true;
            while (cur != deg[0].second && cur != deg[1].second) {
                used[cur] = true;
                for (int j = 0; j < G[cur].size(); j++) {
                    if (!used[G[cur][j]]) {
                        cur = G[cur][j];
                        break;
                    }
                }
                used[deg[0].second] = false;
            }
            if (cur == deg[0].second)cnt++;
        }
        if (cnt == 2)cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int n,ans=0;
	double d;
	cin>>n>>d;
	while(n--)
	{
		double x,y;
		cin>>x>>y;
		double s=pow(pow(x,2)+pow(y,2),.5);
		if (s<=d)
		ans++;
	}
	cout<<ans<<endl;
	
	
	
}

    
	
		

	
			

		


 







Measured memory_bytes: 4384
n = int(input())
if n == 0:
    print(0)
    exit()
i = 1
ans = []
while n != 0:
    if n % (i*2) != 0:
        n -= i
        ans.append(1)
    else:
        ans.append(0)
    i *= -2
print("".join(map(str,ans[::-1])))

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
int A[1000];
int i,j,N,v;

scanf("%d",&N);
for(i=0;i<N;i++)
  scanf("%d",&A[i]);

for(i=1;i<N;i++){
for(j=0;j<N-1;j++)
  printf("%d ",A[j]);
printf("%d\n",A[N-1]);
v=A[i];
j=i-1;
while(j>=0&&A[j]>v){
A[j+1]=A[j];
j--;
}
A[j+1]=v;
}

for(j=0;j<N-1;j++)
  printf("%d ",A[j]);
printf("%d\n",A[N-1]);


return 0;
}



Measured memory_bytes: 2072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


void ok(){
    cout << "Yes" << endl;
    exit(0);
}

void ng(){
    cout <<  "No" << endl;
    exit(0);
}


Int n, a, b, c, d;
string s;
bool go(int from, int to){
    while(from < to){
        if(s[from + 1] == '.')from++;
        else if(s[from+2] == '.')from+=2;
        else return false;
    }
    return true;
}


int main(){
    cin >> n >> a >> b >> c >> d;
    a--,b--,c--,d--;
    cin >> s;
    if(a > b){
        swap(a, b);
        swap(c, d);
    }

    if(c < d){
        if(go(a, c) && go(b, d))ok();
        else ng();
    }
    while(a != c || b != d){
        if(a > b){
            if(go(a, c) && go(b, d))ok();
            else ng();
        }
        if(s[a+1] == '.' && a+1 != b){a++;continue;}
        if(s[a+2] == '.' && a+2 != b && a+1 != c){a+=2;continue;}
        if(b == d)ng();
        if(s[b+1] == '.'){b++;continue;}
        if(s[b+2] == '.'){b+=2;continue;}
        ng();
    }
    ok();
    return 0;
}

Measured memory_bytes: 640