akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/range/numeric.hpp>

#ifdef _MSC_FULL_VER
#include"randomizer.hpp"
#include"debug_print.hpp"
#endif

#include<cstdlib>
#include<ctime>

namespace lib
{
	template<class T>using pair = std::pair<T, T>;
	template<class T>constexpr T pow(T base, std::uint64_t p)
	{
		T ret = T(1);
		for (std::uint64_t i = 0; i <= 63; ++i)
		{
			if (((1ull << i) & p) != 0)
			{
				ret *= base;
			}
			base *= base;
		}
		return ret;
	}
	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

	struct union_find
	{
		std::vector<int> upper;
		union_find(std::size_t size):upper(size, -1) {}

		int group(int index)
		{
			if (upper[index] == -1)
			{
				return index;
			}
			else
			{
				return upper[index] = group(upper[index]);
			}
		}

		bool merge(int x, int y)
		{
			auto gx = group(x);
			auto gy = group(y);
			if (gx != gy)
			{
				upper[gx] = gy;
				return true;
			}
			return false;
		}

		auto get()
		{
			std::map<int, std::set<int>> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret[group(i)].emplace(i);
			}
			return ret;
		}

		auto tops()
		{
			std::set<int> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret.emplace(group(i));
			}
			return ret;
		}

		bool is_same_group(int x, int y)
		{
			return group(x) == group(y);
		}
	};
}

namespace out
{
	namespace detail
	{
		template<class>struct void_out
		{
			typedef void type;
		};
		template<class T>auto write(std::ostream& ost, T const& val)
			->typename void_out<decltype(ost << val)>::type
		{
			ost << val;
		}
		template<class T, class... Ts>void write(std::ostream& ost, T const& val, Ts const&... nexts)
		{
			write(ost, val);
			ost << " ";
			write(ost, nexts...);
		}
	}
	void write_line()
	{
		std::cout << std::endl;
	}
	template<class...Ts>void write_line(Ts const&... args)
	{
		detail::write(std::cout, args...);
		write_line();
	}
	template<class Range>void write_range(Range const& rng)
	{
		for (auto const& v : rng)
		{
			write_line(v);
		}
	}
}

namespace adaptor = boost::adaptors;

void Main()
{
	std::vector<int> vec(4);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
	boost::sort(vec);
	if (vec[0] == 1 &&
		vec[1] == 4 &&
		vec[2] == 7 &&
		vec[3] == 9)
	{
		out::write_line("YES");
	}
	else
	{
		out::write_line("NO");
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::cin.sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;

char str[1005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int len=strlen(str);
    int i;
    int cnt[4]={0};
    for(i=0; i<len; i++) {
        if(str[i]=='N') {
            cnt[0]++;
        }
        else if(str[i]=='S') {
            cnt[1]++;
        }
        else if(str[i]=='E') {
            cnt[2]++;
        }
        else {
            cnt[3]++;
        }
    }
    if(cnt[0] && !cnt[1]) {
        printf("No\n"); return 0;
    }
    if(!cnt[0] && cnt[1]) {
        printf("No\n"); return 0;
    }
    if(cnt[2] && !cnt[3]) {
        printf("No\n"); return 0;
    }
    if(!cnt[2] && cnt[3]) {
        printf("No\n"); return 0;
    }
    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 128
n = int(input())
l = [[0,0]] * n
for i in range(n):
    A,B = map(int,input().split())
    l[i] = [A,B]
l = sorted(l,key=lambda x:x[1])

t = 0
for i in range(n):
    t += l[i][0]
    if(t > l[i][1]):
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 39600
import Control.Applicative
  
main = do
    [_,n] <- map read.words <$> getLine
    str <- getLine
    putStrLn $ answer n str

answer :: Int -> String -> String
answer n str = take (n-1) str ++[upc (str !! (n-1))] ++ drop n str

upc 'A' = 'a'
upc 'B' = 'b'
upc 'C' = 'c'

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

typedef long long LL;
const int M=1005;
const int MO=1e9+7;
int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}

char g[M][M];
int dp[M][M];

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",g[i]+1);
	dp[0][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(g[i][j]=='#') continue;
			dp[i][j]=add(dp[i-1][j],dp[i][j-1]);
		}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 10007
#define INF 9223372036854775807

signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=1;
  std::cin >> x;
  rep(i,x){
    std::cin >> y;
    while(y%2==0){
      y/=2;
      z++;
    }
  }
  std::cout << z << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>b) cout<<b*c+(a-b)*d;
  else cout<<a*c;
  cout<<endl;
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

using namespace std;

long long int dp[1005][1005];
vector<int>crr;

char arr[1002][1002];
int n,m;
long long int M=1000000007;

void pathCalc(int i,int j)
{
	if(dp[i][j]!=-1)
	{
		int a=1;
	}
	
	else if(i==0 && j==0)
	{
		dp[i][j]=1;
	}
	else if(i==0)
	{
		dp[i][j]=0;
		if(arr[i][j-1]=='.')
		{
			pathCalc(i,j-1);
			dp[i][j]=dp[i][j-1]%M;
		}
	}
	else if(j==0)
	{
		dp[i][j]=0;
		if(arr[i-1][j]=='.')
		{
			pathCalc(i-1,j);
			dp[i][j]=dp[i-1][j]%M;
		}
		else
			dp[i][j]=0;
	}
	else
	{
		dp[i][j]=0;
		if(arr[i-1][j]=='.')
		{
			pathCalc(i-1,j);
			dp[i][j]+=(dp[i-1][j])%M;
		}
		if(arr[i][j-1]=='.')
		{
			pathCalc(i,j-1);
			dp[i][j]+=(dp[i][j-1])%M;
		}
		dp[i][j]%=M;
	}
}


int  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,a,b,c,d,w;
    cin>>n>>m;

    for (int i = 0; i < n; ++i)
    {
    	for (int j = 0; j < m; ++j)
    	{
    		cin>>arr[i][j];
    		dp[i][j]=-1;
    		if(arr[i][j]=='#')
    			dp[i][j]=0;
    	}
    }
    pathCalc(n-1,m-1);
    // for (int i = 0; i < n; ++i)
    // {
    // 	for (int j = 0; j < m; ++j)
    // 	{
    // 		cout<<dp[i][j]<<" ";
    // 	}
    // 	cout<<endl;
    // }
    cout<<dp[n-1][m-1]%M;
    return 0;
}

Measured memory_bytes: 9216
x, n = map(int, input().split())

if n == 0:
    print(x)
    exit()

else:
    p = list(map(int, input().split()))
    li = [i for i in range(-101, 102) if i not in p]
    li.sort(reverse = True)

    tmp1 = float('inf')
    ans = float('inf')

    for i in li:
        if abs(i - x) <= tmp1:
            if i < ans:
                ans = i
                tmp1 = abs(i - x)

    print(ans)


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int N=2002;
int f[N][N],n,m,k,ans;

int main(){
	int i,j,t;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<k;++i) f[i][k-i]=1;//start from 1,not 0
	for(i=1;i<=n;++i)
	 for(j=1;j<=m;++j) if(f[i][j]){
	 	for(t=0;t<k;++t)
	 	 if(i+t<=n && j+k-1-t<=m)
	 	  f[i+t][j+k-1-t]=(f[i+t][j+k-1-t]+f[i][j])%mod;
	    if(i%(k-1)==n%(k-1) && j%(k-1)==m%(k-1))
	    	ans=(ans+f[i][j])%mod;
	 }
	printf("%d\n",ans);
}

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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 1e6 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

int main()
{
    int n, m;
    ll sum1 = 0;
    ll sum2 = 0;
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        sum1 += i;
    }
    for(int i = 1; i < m; i++)
    {
        sum2 += i;
    }
    cout << sum1 + sum2 << endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct card
{
 char suit;
 int value;
};

void buble(struct card a[],int n)
{
 for(int i = 0;i < n;i++){
  for(int j = n-1; j >= i+1;j--){
	 if(a[j].value < a[j-1].value){
	  card t = a[j];a[j] = a[j-1];a[j-1]  = t;
	 }
	}
 }
}

void selsection(struct card a[],int n)
{
 for(int i = 0;i < n;i++){
  int minj = i;
	for(int j = i;j < n;j++){
	 if(a[j].value < a[minj].value) minj = j;
	}
	card t = a[i];a[i] = a[minj];a[minj] =t;
 }
}

void print(struct card a[],int n)
{
 for(int i = 0;i < n;i++){
  if(i > 0) cout<<' ';
	cout << a[i].suit << a[i].value;
 }
 cout << endl;
}

bool isStable(struct card c1[],struct card c2[],int n){
 for(int i = 0;i < n;i++){
  if(c1[i].suit != c2[i].suit) return false;
 }
 return true;
}
int main(){
 int N;
 cin >> N; 
 card C1[N],C2[N];;
 for(int i = 0;i < N;i++) cin >> C1[i].suit >> C1[i].value;
 
 for(int i = 0;i < N;i++) C2[i] = C1[i];

 buble(C1,N);
 selsection(C2,N);

 print(C1,N);
 puts("Stable");

 print(C2,N);
 if(isStable(C1,C2,N)) puts("Stable");
 else puts("Not stable");
 return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>

int main()
{
	int a, b,d,r;
	double f;

	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;
	f = 1.00000 * a / b;

	printf("%d %d %f", d, r, f);

	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

long long memo[200000];

int main()
{

    string s;
    cin >> s;

    vector<int> x;
    for (auto c : s) {
        x.push_back(c - '0');
    }

    long n = x.size();

    for (long i = n - 5; i >= 0; i--) {
        long long sum = 0;
        for (long j = i + 4; j < n; j++) {
            if (j == i + 4) {
                sum = x[i] * 10000 + x[i+1] * 1000 + x[i+2] * 100 + x[i+3] * 10 + x[i+4];
            } else {
                sum = sum * 10 + x[j];
            }

            sum %= 2019;
            if (sum == 0) {
                memo[i] = memo[j+1] + 1;
                break;
            }
        }
    }

    long long sum = 0;
    for (long i = 0; i < n - 4; i++) {
        sum += memo[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5804
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    vi v;
    while(true){
        n--;
        if(n<0)break;
        v.pb(n%26);
        n/=26;
    }
    for(int i=v.size()-1;i>=0;i--){
        cout<<(char)('a'+v[i]);
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720ll;

void solve()
 { 
  char c;
  cin>>c;
  cout<<(isupper(c) ? 'A' : 'a');
 }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
long long gcd( int a, int b)
{
    int i=a,j=b;
    if(j==0)return i;

    else
    {
         return gcd(j,i%j);
    }
}
int main()
{
    int n,i,j,k,l,t;

    long long s=0;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
            {
                for(k=1;k<=n;k++)
                    {
                        t=gcd(i,j);
                        s=s+gcd(t,k);
                    }
            }

    }
    cout<<s<<endl;
    return 0;
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n, w, mono[100][2];
map<int, int> memo[100];

int saiki(int i, int cost) {
  if(cost > w) return -10000000;
  if(i == n) return 0;
  if(memo[i].count(cost)) return memo[i][cost];
  return memo[i][cost] = max(saiki(i + 1, cost + mono[i][0]) + mono[i][1], saiki(i + 1, cost));
}

int main() {
  cin >> n >> w;
  rep(i, 0, n) {
    cin >> mono[i][0] >> mono[i][1];
  }

  cout << saiki(0, 0) << endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

struct R {
  double s, l, t, x, y;
  void p(double tt) {
    t = tt;
    x = l * cos(t);
    y = l * sin(t);
  }
  double ht(R m) { return (s * 60.0 + m.s) / 720.0 * 2.0 * PI; }
  double mt() { return s / 60.0 * 2.0 * PI; }
  double d(R r) { return hypot(x - r.x, y - r.y); }
};

void solve() {
  R h, m;
  cin >> h.l >> m.l >> h.s >> m.s;
  h.p(h.ht(m));
  m.p(m.mt());
  cout << h.d(m) << endl;
}

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

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(void){
  int n,i,j,fs,ans=0;
  string s;
  cin >> n >> s;
  vector<P> al(27,P(0,0));
  for (i=0;i<26;i++){
    j=0;
    while (j<n && s.at(j)!=(char)(i+'a')) j++;
    al.at(i).first=j;
    for (;j<n;j++) if (s.at(j)==(char)(i+'a')) al.at(i).second=j;
  }
  for (i=0;i<n;i++){
    fs=0;
    for (j=0;j<26;j++) if (i>=al.at(j).first && i<al.at(j).second) fs++;
    ans=max(ans,fs);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
  
using namespace std;
  
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        double x[4],y[4];
        for(int j=0;j<4;j++)
            cin>>x[j]>>y[j];
        if(abs((x[3]-x[2])*(y[1]-y[0])-(x[1]-x[0])*(y[3]-y[2]))<1e-10)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
      
    return 0;
}


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

int main(){
  int H,W;
  cin >> H >> W;
  string S[H];
  rep(i,H) cin >> S[i];
  int dx[4]={-1,0,1,0};
  int dy[4]={0,-1,0,1};
  bool f=true;
  rep(i,H) rep(j,W){
    if (S[i][j]=='#'){
      bool f2=true;
      rep(k,4){
        if(i+dx[k]>=0 and i+dx[k]<H and j+dy[k]>=0 and j+dy[k]<W){
          if(S[i+dx[k]][j+dy[k]]=='#') f2=false;
        }
      }
      if(f2) f=false;
    }
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
mod = 10**9+7
if abs(N-M) > 1:
    print(0)
else:
    c1 = 1
    for i in range(1,N+1):
        c1 *= i
        c1 %= mod
    c2 = 1
    for i in range(1,M+1):
        c2 *= i
        c2 %= mod
    if N == M:
        print(c1*c2*2%mod)
    else:
        print(c1*c2%mod)

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

found = False
res = ""
len_S = len(S)
len_T = len(T)
found = False

for i in range(len_S):
    cnt = 0
    if i == len_S - len_T + 1: break
    for j in range(len_T):
        if T[j] == S[i+j] or S[i+j] == "?":
            cnt+=1
        if cnt == len_T:
            tmps = S[:i]
            tmpt = S[i+len_T:]
            res = S[:i] + T + S[i+len_T:]
            found = True
            break

if found: print(res.replace("?", "a"))
else: print("UNRESTORABLE")

Measured memory_bytes: 9016
use std::io::*;
use std::str::FromStr;

fn main() {
    let b: Vec<char> = read::<String>().chars().collect();
    
    println!("{}", 
        match b[0] {
            'A' => 'T',
            'C' => 'G',
            'G' => 'C',
            _ => 'A',
        });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,W; cin >> N >> W;
    VI v(N), w(N); REP(i,N) cin >> v[i] >> w[i];
    int dp[N+1][W+1]; CLR(dp);
    REP(i,N)REP(j,W){
        if(j+1-w[i] >= 0) chmax(dp[i+1][j+1], dp[i+1][j+1-w[i]] + v[i]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
    }
    int ans = 0;
    REP(i,W) chmax(ans, dp[N][i+1]);
    cout << ans << en;
    return 0;
}


Measured memory_bytes: 7056
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                             //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

inline ll max(ll a, ll b)
{
  if(a>b) re a;
  else re b;
}

inline ll min(ll a, ll b)
{
  if(a>b) re b;
  else re a;
}

int gcd(int a, int b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    cin>>n>>k;
    n%=k;
    cout<<min(n,abs(n-k));


  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end(), greater<int>());
  
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0) ans += a.at(i);
    else ans -= a.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int a[101][101];
int main()
{
	int g,i,j,r,c,h[102][102]={0};
	cin>>r>>c;
	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
		{
			cin>>g;
			h[i][j]=g;
			h[r][j]+=g;
			h[i][c]+=g;
			h[r][c]+=g;
		}
	}
	for(i=0;i<r+1;i++)
	{
		for(j=0;j<c+1;j++)
		{
			if(j!=c)
				cout<<h[i][j]<<" ";
			else
				cout<<h[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <iostream>

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

using namespace std;
using ll = long long;

int main()
{
    ll N,K,A[200010],visited[200010];
    cin>>N>>K;
    rep(i,N){
        int a;cin>>a;
        A[i]=a-1;
        visited[i]=-1;
    }

    ll time=0,next=A[0];
    visited[0]=time;
    while(visited[next]==-1){
        time++;
        visited[next]=time;
        if(time==K){
            cout << next+1 << endl;
            return 0;
        }
        next = A[next];
    }
    time++;

    ll r = K-time;
    ll q = time-visited[next];
    ll ans = next;
    rep(i,r%q){
        ans=A[ans];
    }
    cout << ans+1 << endl;
    return 0;

}

Measured memory_bytes: 6744
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b, x;
	scanf("%d%d%d", &a, &b, &x);
	printYN(a <= x && a + b >= x);
	
	Please AC;
}


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

using namespace std;

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

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define sum(v) accumulate(ALL(v),0)

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll cnt=0;
    REP(i,1,n+1){
        //1始まり
        REP(j,1,m+1){
            int b = j%10;
            int a = (j-b)/10;
            if(i == a*b && a>1 && b>1){
                cnt ++;
            }
        }
    }
    cout<<cnt<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	char op;
	while(true){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '?') break;
		switch(op){
		case '+':
			printf("%d\n",a+b);
			break;
		case '-':
			printf("%d\n",a-b);
			break;
		case '/':
			printf("%d\n",a/b);
			break;
		case '*':
			printf("%d\n",a*b);
			break;
		}
	}
}



Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};
static const int MAX_SIZE = 1 << 20; 
LL segMax[2 * MAX_SIZE - 1], segAdd[2 * MAX_SIZE - 1];
void add(int a, int b, LL x, int k = 0, int l = 0, int r = MAX_SIZE){
    if (r<=a||b<=l) return;
    if (a<=l&&r <= b){
        segAdd[k] += x;
        return;
    }
    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2, (l + r) / 2, r);
    segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
}
LL getMax(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE){
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return (segMax[k] + segAdd[k]);
    LL left = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
    LL right = getMax(a, b, k * 2 + 2, (l + r) / 2, r);
    return (max(left, right) + segAdd[k]);
}
int main(){
    int n;
    LL d,a;
	cin >> n >> d >> a;
    vector<P> v(n);
    vector<LL> x(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].fs >> v[i].sc;
        x[i] = v[i].fs;
    }
    sort(ALL(v));
    sort(ALL(x));
    for (int i = 0; i < n; i++) {
        add(i,i+1,v[i].sc);
    }
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        LL t = getMax(i,i+1);
        if(t <= 0) continue;
        LL p = (t + a - 1) / a;
        LL r = upper_bound(ALL(x),v[i].fs + 2 * d) - x.begin();
        add(i,r,- p * a);
        ans += p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BMagic2 {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int A, B, C, K;
        in>>A>>B>>C>>K;
        REP(i, K+1){
            REP(j, K-i+1){
                int x = B, y = C;
                REP(k, i) x *= 2;
                REP(k, j) y *= 2;
                if(A<x and x<y){
                    out<<"Yes\n";
                    return;
                }
            }
        }
        out<<"No\n";
    }
};


int main() {
	BMagic2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using ll = long long;

using namespace std;

int main(){
  int N;
  cin >> N;
  int rem = N % 10;
  string ans;
  if(rem  == 3){
    ans = "bon";
  }else if(rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9){
    ans = "hon";
  }else{
    ans = "pon";
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int h, w;
string s[55];
int d[55][55];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> h >> w;
	int cnt = 0;
	FOR(i, h) {
		cin >> s[i];
		FOR(j, w) {
			d[i][j] = 1e9;
			if (s[i][j]=='#') cnt++;
		}
	}
	queue<P> que;
	que.push({0, 0});
	d[0][0] = 0;
	while (!que.empty()) {
		P p = que.front();
		que.pop();
		if (p.first == h-1 && p.second == w-1) break;
		FOR(i, 4) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx >= 0 && nx < h && ny >= 0 && ny < w && s[nx][ny] != '#' && d[nx][ny] == 1e9) {
				que.push({nx, ny});
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	cout << (d[h-1][w-1] == 1e9 ? -1 : h*w-d[h-1][w-1]-cnt-1) << endl;
	return 0;
}

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

int main() {
   ll n;
   cin >> n;
   ll ans = 0;
   for (ll i = 1; i <= n; i++) {
      if(i%3!=0&&i%5!=0)ans = ans + i;
   }
   cout << ans <<endl;
}

Measured memory_bytes: 3504
import math
a, b, c = map(float,input().split())

sin = math.sin(math.radians(c))
cos = math.cos(math.radians(c))
edge = math.sqrt(a*a + b*b - 2*a*b*cos) 

print((a*b*sin)/2)
print(a + b + edge)
print(b*sin)


Measured memory_bytes: 5688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            sS = Console.ReadLine().Trim().Split(' ');
            List<long> lstInp = new List<long>();
            for (int i = 0; i < sS.Length; i++) { lstInp.Add(long.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstInp.Sort(delegate (long mca1, long mca2) { return (int)(mca2 - mca1); });      // 降順
            decimal dOut = 0;
            long iW1 = 0;
            long iW2 = 0;
            long iH1 = 0;
            long iH2 = 0;
            Boolean bW = false;
            Boolean bH = false;
            for (int i = 0; i < lstInp.Count; i++)
            {
                if (!bW)            // 横が2本見つかるまで
                {
                    iW2 = lstInp[i];
                    if (iW1 == iW2) { bW = true; }
                    else { iW1 = lstInp[i]; }
                }
                else                // 横が2本見つかった
                {
                    if (!bH)        // 縦が2本見つかるまで
                    {
                        iH2 = lstInp[i];
                        if (iH1 == iH2) { bH = true; break; }
                        else { iH1 = lstInp[i]; }
                    }
                    else { break; } // 縦が2本見つかった
                }
            }
            if (bW && bH) { dOut = (decimal)iW1 * (decimal)iH1; }

            //出力
            Console.WriteLine("{0}", dOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;
  int ans = (a + b) / 2;
  if ((a + b) % 2 != 0) {
    ans++;
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<bool> seen;
ll N,M,K,size=0;
vector<vector<ll>> Friend;
vector<vector<ll>> Block;
vector<vector<ll>> reallyblock;
vector<ll> sizeofgraph;
queue<ll> que;
vector<ll> allque;
vector<ll> rock;
ll dfs(ll from,ll count){
  count=size+1;
  //cout<<from<<" "<<count<<endl;
  size=count;
  que.push(from);
  seen.at(from-1)=true;
  for(ll i=0;i<(ll)Friend.at(from-1).size();i++){
    if(seen.at(Friend.at(from-1).at(i)-1)==false){dfs(Friend.at(from-1).at(i),count);}
  }
  return size;
}
ll binary_search(ll key) {
  ll left=0,right=allque.size()-1;
  while (right >= left) {
    ll mid=left+(right-left)/2;
    if (allque.at(mid) == key) return mid;
        else if (allque.at(mid) > key) right = mid - 1;
        else if (allque.at(mid) < key) left = mid + 1;
    }
    return -1;
}
int main() {
  cin>>N>>M>>K;
  Friend.resize(N);
  rock.resize(N);
  Block.resize(N);
  seen.resize(N);
  sizeofgraph.resize(N);
  allque.resize(N);
  for(ll i=0;i<M;i++){
    ll a,b;
    cin>>a>>b;
    Friend.at(a-1).push_back(b);
    Friend.at(b-1).push_back(a);
  }
  for(ll i=0;i<N;i++){
    allque.at(i)=i+1;
  }
  ll number=0;
  while(!allque.empty()){
    number++;
    size=0;
    ll a=dfs(allque.at(0),0);
    while(!que.empty()){
      sizeofgraph.at(que.front()-1)=a;
      rock.at(que.front()-1)=number;
      //que.front()をallqueから取り除く
      allque.erase(allque.begin()+binary_search(que.front()));
      que.pop();
    }
  }
  for(ll i=0;i<K;i++){
    ll c,d;
    cin>>c>>d;
    if(rock.at(c-1)==rock.at(d-1)){
      Block.at(c-1).push_back(d);
      Block.at(d-1).push_back(c);
    }
  }
  //後は同じ連結成分内のblock関係数を求めれば良い
  for(ll i=0;i<N;i++){
    cout<<(ll)sizeofgraph.at(i)-(ll)1-(ll)Friend.at(i).size()-(ll)Block.at(i).size()<<" ";
  }
}

Measured memory_bytes: 15552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}


class UnionFind {
public:
    vector<int> par;
    int N;
    UnionFind(int n) {
        par.resize(n, -1);
        N = n;
    }
    int Find(int n) {
        return par[n] < 0 ? n : par[n] = Find(par[n]);
    }
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        if (x == y) return false;
        if (-par[x] < -par[y]) swap(x, y);
        par[y] += par[x];
        par[x] = y;
        N--;
        return true;
    }
    bool Same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -par[Find(x)];
    }
    int size() {
        return N;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    REP(i, 0, n) {
        cin >> x[i] >> y[i];
    }
    int ans = n;
    REP(i, 0, n) {
        REP(j, i + 1, n) {
            ll p = x[j] - x[i];
            ll q = y[j] - y[i];
            UnionFind uf(n);
            REP(k, 0, n) {
                REP (t, 0, n) {
                    if (x[k] - x[t] == p && y[k] - y[t] == q) {
                        uf.Union(k, t);
                    }
                }
            }
            ans = min(ans, uf.size());
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int estGcd = M / N;
	int residue = M % N;
	while((estGcd) && (residue % estGcd)){
		estGcd--;
		residue += N;
	}
	printf("%d\n", estGcd);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

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

// ---- コーディングはここから！ ('-')7

void solve(){
	int n,k; cin>>n>>k;
	vl h(n);
	fore(i,0,n)cin>>h[i];
	vl dp(n+1,-1);
	auto f=[&](auto f, int a)->lli{
		lli res = INF;
		if(a==n-1)return 0;
		if(dp[a]!=-1)return dp[a];
		fore(i,1,k+1)if(a+i<n)res=min(res,f(f,a+i)+abs(h[a]-h[a+i]));
		return dp[a]=res;
	};
	cout<<f(f,0)<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 14208
X = int(input())
u = X
v = 1
x = True
while x:
    for i in range(2,(u // 2+1)):
        if u % i == 0:
            v = 0
            break
        else:
            pass
    if v == 1:
        print(u)
        x = False
        break
    v = 1
    u += 1
    

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int d, n;
	cin >> d >> n;
	if (n == 100)n++;
	string T = to_string(n);
	while (d > 0) {
		T += "00";
		d--;
	}
	cout << T << endl;
	return 0;
}

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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

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

    int64_t a, b;
    int n;

    while (true) {
        cin >> a >> b;
        if (cin.eof()) { break; }
        int64_t sum = a + b;
        int count = 1;
        while (sum >= 10) {
            sum /= 10;
            count++;
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3000
N = int(input())

count = 0

for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, i+1):
    if i % j == 0:
      tmp += 1
  # print(tmp)
  if tmp == 8:
    count += 1
    
print(count)
  

Measured memory_bytes: 2940
#include <stdio.h>

int N,sum=0;

void dfs(long long int tmp, int flag) {
  if (tmp > N) return;
  if (tmp <= N && flag == 7) sum++;
  dfs(tmp*10+3,flag|1);
  dfs(tmp*10+5,flag|2);
  dfs(tmp*10+7,flag|4);
}

int main() {
  scanf("%d",&N);
  dfs(0,0);
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
 
using namespace std;
 
int main()
{
  int a,b,x;
  cin>>a>>b>>x;
  while(x>0)
  {
    if (x>a+b||x<a)
    {
      cout<<"NO";
      break;
    }
    else if (x!=a||x==a){
      a+=1;
      b-=1;
      cout<<"YES";
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<int> to[1100];
vector<int> col(1100,-1);
int cnt0 = 0, cnt1 = 0;
bool ok = 1;
int n,m;
void dfs(int now, int p = -1, int col_n = 0){
    if(cnt0 + cnt1 >= n) return ;
    if(col_n == 0) cnt0++;
    else cnt1++;
    col[now] = col_n;
    for(auto u : to[now]){
        if(u == p) continue;
        else if(col[u] == col_n){
            ok = 0;
            return;
        }else if(col[u] == -1){
            dfs(u, now, 1 - col_n);
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    while(1){
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        cnt0 = 0;
        cnt1 = 0;
        rep(i,1100){
            to[i].clear();
            col[i] = -1;
        }
        ok = 1;
        rep(i,m){
            int u,v;
            cin >> u >> v;
            u--;
            v--;
            to[u].push_back(v);
            to[v].push_back(u);
        }
        dfs(0, -1, 0);
        if(!ok) cout << 0 << endl;
        else{
            set<int> si;
            if(cnt0 %2 == 0) si.insert(cnt0/2);
            if(cnt1 %2 == 0) si.insert(cnt1/2);
            cout << si.size() << endl;
            for(auto u : si){
                cout << u << endl;
            } 
        }

    }
    return 0;
}


Measured memory_bytes: 3272
#include<stdio.h>
int main(void){
int a,b,c,e;

scanf("%d %d %d",&a,&b,&c);
if(a<b){
  e=a;
  a=b;
  b=e;
}
if(a<c){
  e=a;
  a=c;
  c=e;
}
printf("%d",a*10+b+c);
}

Measured memory_bytes: 128
N = int(input())
A = sorted(int(i) for i in input().split())+[0]
cnt, ans = 0, 0
a = A[0]
for i in range(len(A)):
  if a == A[i]:
    cnt += 1
  elif a != A[i]:
    if cnt < a:
      ans += cnt
    elif cnt > a:
      ans += cnt-a
    a = A[i]
    cnt = 1
print(ans)

Measured memory_bytes: 14268
#include <bits/stdc++.h>
using namespace std;
const int N = 101;
int v[N][N]={0};
int stt[N]={0};
int fit[N]={0};
int t=0;

void dfs(int n){
	if(stt[n]!=0) return;
	stt[n] = ++t;
	for(int i=0;i<v[n][1];i++){
		dfs(v[n][i+2]);
	}
	fit[n]=++t;
}

int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int u,k;
		cin >> u >> k;
		v[u][0]=i+1;
		v[u][1]=k;
		for(int j=0;j<k;j++){
			int a;
			cin >> a;
			v[u][j+2]=a;
		}
	}
	for(int i=1;i<=n;i++)dfs(i);
	for(int i=1;i<n+1;i++){
		cout << i << " " <<stt[i] << " " << fit[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 3116
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m+f >=80:
        print('A')
    elif m+f >=65:
        print('B')
    elif m+f >=50:
        print('C')
    elif m+f >=30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5592
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main(){
  string S;
  cin >> S;
  int c=0,co=0;
  for(int i=2; i<S.size()-1; i++){
    if(S[i]=='C') c+=1;
  }for(int i=0; i<S.size(); i++){
    for(char a='a'; a<'z'; a++){
      if(S[i]==a) co+=1;
    }
  }
  if(S[0]=='A' && c==1 && co==S.size()-2){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

int ans=0;

void solve(ll a, ll b, ll c){
	if(a%2 || b%2 || c%2){
		return;
	}else if(a==b && b==c && c==a){
		ans = -1;
		return;
	}else{
		++ans;
		solve((b+c)/2,(c+a)/2,(a+b)/2);
	}
}

int main(void){
	ll a,b,c;
	cin >> a >> b >> c;
	solve(a,b,c);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
mod = 1000000007
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
map = Hash.new(0)
arr.each do |i|
  map[i] += 1
end
ok = true
map.each do |k, v|
  if k != 0
    ok = ok && v == 2
  end
end
if n % 2 != 0
  ok = ok && map[0] == 1
else
  ok = ok && map[0] == 0
end
if ok
  loop_count = n % 2 != 0 ? (n - 1) / 2 : n / 2
  result = 1
  loop_count.times do
    result *= 2
    result %= mod
  end
  puts result
else
  puts 0
end

Measured memory_bytes: 12684