akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

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

    if(N == 1) {
        cout << abs(a[0] - W) << endl;
    } else {
        cout << max(abs(a[N-1]-W), abs(a[N-2]-a[N-1])) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main
import (
	"fmt"
	"os"
	"strings"
	"bufio"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string{
	sc.Scan()
	return sc.Text()
}

func main(){
	line := nextLine()
	col := strings.Split(line," ")
	for _,c := range col{
		fmt.Print(string([]rune(c)[:1]))
	}
	fmt.Println()
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int f(const void *a,const void *b){
  return *(double*)b-*(double*)a;
}
int main(){
  int N;
  double v[55];
  double S=0.0,P=2.0;
  scanf("%d",&N);
  for(int i=0;i<N;i++)
    scanf("%lf",v+i);
  qsort(v,N,sizeof(double),f);
  for(int i=0;i<N;i++){
    S+=v[i]/P;
    if(i<N-2) P*=2.0;
  }
  printf("%lf\n",S);
  return 0;
}

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


int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<long long int>r(N), g(N), b(N);
	if (S.at(0) == 'R') 
		r[0] = 1;
	else r[0] = 0;
	if (S.at(0) == 'G')
		g[0] = 1;
	else g[0] = 0;
	if(S.at(0) == 'B')
		b[0] = 1;
	else b[0] = 0;
	rep1(i, N) {
		if (S.at(i) == 'R') {
			r[i] = r[i - 1] + 1;
		}
		else r[i] = r[i - 1];
		if (S.at(i) == 'G') {
			g[i] = g[i - 1] + 1;
		}
		else g[i] = g[i - 1];
		if (S.at(i) == 'B') {
			b[i] = b[i - 1] + 1;
		}
		else b[i] = b[i - 1];
	}
	long long int answer = 0;
	for (int i = 0;i < N;i++) {
		for (int j = i + 1;j < N - 1;j++) {
			if (S.at(i) == 'R' && S.at(j) == 'G') {
				answer += b.at(N - 1) - b[j];
				if (2 * j - i < N && S.at(j - i + j) == 'B') answer--;
			}
			if (S.at(i) == 'R' && S.at(j) == 'B') {
				answer += g.at(N - 1) - g[j];
				if (2 * j - i < N && S.at(j - i + j) == 'G') answer--;
			}
			if (S.at(i) == 'B' && S.at(j) == 'R') {
				answer += g.at(N - 1) - g[j];
				if (2 * j - i < N && S.at(j - i + j) == 'G') answer--;
			}
			if (S.at(i) == 'B' && S.at(j) == 'G') {
				answer += r.at(N - 1) - r[j];
				if (2 * j - i < N && S.at(j - i + j) == 'R') answer--;
			}
			if (S.at(i) == 'G' && S.at(j) == 'B') {
				answer += r.at(N - 1) - r[j];
				if (2 * j - i < N && S.at(j - i + j) == 'R') answer--;
			}
			if (S.at(i) == 'G' && S.at(j) == 'R') {
				answer += b.at(N - 1) - b[j];
				if (2 * j - i < N && S.at(j - i + j) == 'B') answer--;
			}
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 3716
#include <stdio.h>

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

int main() {
    int m,n;
    int sum = 0;
    scanf("%d", &m);

    for (int i = 0; i < m; i++) {
        scanf("%d", &n);
        if(isPrime(n)) sum++;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

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

int64_t N, M; cin>> N >> M;

// Mの約数
VI div;
for (int64_t i = 1; i * i <= M; ++i){
    if (M % i == 0) {
        div.push_back(i);
        div.push_back(M/i);
    }
}
sort(ALL(div));
cout << *(upper_bound(ALL(div), M/N) - 1) << "\n";
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC090B solver = new ABC090B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC090B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int ans = 0;
            for (int i = A; i <= B; i++) {
                String s = "" + i;
                if (s.charAt(0) == s.charAt(4)
                        && s.charAt(1) == s.charAt(3)) {
                    ans++;
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 34848
<?php
$array_num = intval(trim(fgets(STDIN)));
for ($i = 0; $i < $array_num; $i++){
    $cards[] = preg_split("/[\s,]+/",trim(fgets(STDIN)));
}

$clovers = array();
$spades = array();
$diamonds = array();
$hearts = array();
foreach ($cards as $card){
    switch ($card[0]){
        case 'C':
            $clovers[] = intval($card[1]);
            break;
        case 'S':
            $spades[] = intval($card[1]);
            break;
        case 'D':
            $diamonds[] = intval($card[1]);
            break;
        case 'H':
            $hearts[] = intval($card[1]);
            break;
        default:
            echo "error!!";
    }
}

sort($clovers, SORT_NUMERIC);
sort($spades, SORT_NUMERIC);
sort($diamonds, SORT_NUMERIC);
sort($hearts, SORT_NUMERIC);

function findCard($type){
    $result_type_card = range(1,13);
    $result_type_card = array_diff($result_type_card,$type);
    return $result_type_card;
}

$result_clovers = findCard($clovers);
$result_spades = findCard($spades);
$result_diamonds = findCard($diamonds);
$result_hearts = findCard($hearts);

function outputs_card($values,$type){
    foreach ($values as $value){
        echo $type. " " . $value,PHP_EOL;
    }
}

outputs_card($result_spades,'S');
outputs_card($result_hearts,'H');
outputs_card($result_clovers,'C');
outputs_card($result_diamonds,'D');

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define LL long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,(int)(v.size()-1)) os << v[i] << " ";
    os << v[v.size()-1];
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 1e6+5;
const int maxh = 1e3+3;
const int mod = 1e9+7;
int cnt = 0;

int A[maxh];
int B[maxh];
int N,M;

int mult(LL a,LL b){
    return (a*b)%mod;
}

int main()
{
    cin >> N >> M;
    _rep(i,1,N) cin >> A[i];
    A[N+1] = -1;
    _rep(i,1,M) cin >> B[i];
    B[M+1] = -1;

    LL ans = 1;
    int pa = 1,pb = 1;
    sort(A+1,A+N+1,greater<int>());
    sort(B+1,B+M+1,greater<int>());

    for(int i = M*N;i >= 1;i--){
        if(A[pa] == i && B[pb] == i){
            pa++;pb++;
        }
        else if(A[pa] == i){
            ans = mult(ans,pb-1);
            pa++;
        }
        else if(B[pb] == i){
            ans = mult(ans,pa-1);
            pb++;
        }
        else{
            LL used = M*N - i;
            LL rest = (pa-1)*(pb-1);
            //cout << pa <<" "<< pb << endl;
            if(rest - used <= 0){ans = 0;break;}
            ans = mult(ans,rest-used);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    p = 10**9+7

    def combMod(n, r, p):
        numer = 1
        denom = 1
        for i in range(1, r+1):
            numer = numer * (n-r+i) % p
            denom = denom * i % p
        return numer * pow(denom, p-2, p) % p

    N, K = map(int, input().split())

    ans = 0
    for i in range(K, N+2):
        #0からN+iまでの和から、N+1-iからN+1までの和
        ans += ((N-i+1)+(N))*i//2 - (i-1)*i//2 + 1
        ans %= p

    print(ans)

if __name__ == '__main__':
    resolve()


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

w = "MARCH"
count = {key: 0 for key in w}

for i in range(N):
    S = input()
    c = S[0]
    if c in w:
        count[c] += 1

ans = 0
M = len(w)

for i in range(M):
    for j in range(i + 1, M):
        for k in range(j + 1, M):
            ans += count[w[i]] * count[w[j]] * count[w[k]]

print(ans)


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

int main(){
    int n, m; cin >> n >> m;
    vvi graph;
    rep(i, n){
        vector<int> z(n, 0); graph.push_back(z);
    }
    rep(i, m){
        int a, b; cin >> a >> b; a--; b--;
        graph[a][b] = 1; graph[b][a] = 1;
    }
    vector<int> v; rep(i, n) v.push_back(i);
    iota(v.begin(), v.end(), 1);
    vector<vector<int>> paths;
    do {
        vector<int> i;
        for(auto x : v){
            i.push_back(x-1);
        }
        paths.push_back(i);
    } while( next_permutation(v.begin(), v.end()));  

    int success = 0;
    for (auto path: paths){
        int curr = path[0];
        if (curr != 0) continue;
        bool pass = true;
        rep(i, path.size()-1){
            if (graph[curr][path[i+1]] != 1) pass = false;
            curr = path[i+1];
        }
        if (pass) success++;
    }

    cout << success << endl;
}   


Measured memory_bytes: 3384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int N, d[101]={};
  cin >> N;
  rep(i,N) cin >> d[i];
  int ans = 0;
  rep(i,N){
    for(int j=i+1; j<N; j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>fall(n, 0);
  for (int tsumugi = 0; tsumugi < n; tsumugi++)
    cin >> a[tsumugi];
  
  for (int matsuri = 0; matsuri < n; matsuri++){
    if (matsuri % 2 == 0)
      fall[0] += a[matsuri];
    else
      fall[0] -= a[matsuri];
  }
  cout << fall[0] << " ";
  
  for (int kaori = 1; kaori < n; kaori++){
    fall[kaori] = 2 * a[kaori - 1] - fall[kaori - 1];
    cout << fall[kaori] << " ";
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int ans, n, m, a[200003], minn = 200003;
char s[100003];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi();
	for (int i = 1; i <= n; i+=1)
	{
		minn = min(minn, a[i]);
		if (minn == a[i]) ++ans;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.length();
	int ans = 0;
	for (int i = 0;i < n;++i) {
		if (s[i] != s[n - 1 - i]) {
			++ans;
		}
	}
	int even = ans / 2;
	int odd = (ans + 1) / 2 ;
	if (n % 2 == 0)cout << even << endl;
	else cout << odd << endl;
	return 0;
}


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

int main() {
  int S;
  cin >> S ;
  int Hyaku , Ju , Ichi ;
  Hyaku = S / 100 ;
  S = S % 100 ;
  Ju = S / 10 ;
  S = S % 10 ;
  Ichi = S ;
  cout << Hyaku + Ju + Ichi << endl;
}


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main(void){
  int h, w;
  int cnt=0;
  char a[55][55];
  int ans[55][55]={};
  for(int i=1; i<55; i++){
    for(int j=1; j<55; j++){
      ans[i][j]=100;
    }
  }
  cin >> h >> w;
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cin >> a[i][j];
    }
  }
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cnt=0;
      if(a[i][j]=='.'){
          ans[i][j]=0;
          if(a[i-1][j-1]=='#'){cnt++;}
          if(a[i-1][j]=='#'){cnt++;}
          if(a[i-1][j+1]=='#'){cnt++;}
          if(a[i][j-1]=='#'){cnt++;}
          if(a[i][j+1]=='#'){cnt++;}
          if(a[i+1][j-1]=='#'){cnt++;}
          if(a[i+1][j]=='#'){cnt++;}
          if(a[i+1][j+1]=='#'){cnt++;}
          ans[i][j]=cnt;
      }
    }
  }
  for(int i=1;i<=h; i++){
    for(int j=1; j<=w; j++){
      if(ans[i][j]!=100)cout << ans[i][j];
      else cout << '#';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
nb=0
a=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
    s=input()
    for j in range(w):
        if s[j]=="#":
            a[i][j]=1
            nb+=1

res=0
for ii in range(2**h):
    for jj in range(2**w):
        cnt=nb
        for i in range(h):
            for j in range(w):
                if a[i][j]==1 and (ii&(1<<i) or jj&(1<<j)):
                    cnt-=1
        if cnt==k:
            res+=1
print(res)


Measured memory_bytes: 68520
#include <bits/stdc++.h>
#define MAXN 200007
#define MOD 998244353
using namespace std;
struct robot{int x,d;} rb[MAXN];
bool cmp(robot a,robot b) {return a.x<b.x;}
int dp[MAXN],seg[4*MAXN];
void upd(int l,int r,int val,int pos,int ind)
{
	if(l==r) {seg[ind]=val; return;}
	int s=(l+r)/2;
	if(pos<=s) upd(l,s,val,pos,2*ind);
	else upd(s+1,r,val,pos,2*ind+1);
	seg[ind]=max(seg[2*ind],seg[2*ind+1]);
}
int nmax(int l,int r,int lt,int rt,int ind)
{
	if(lt<=l && rt>=r) return seg[ind];
	if(r<lt || l>rt) return -1000000001;
	int s=(l+r)/2;
	return max(nmax(l,s,lt,rt,2*ind),nmax(s+1,r,lt,rt,2*ind+1));
}
int binarna(int l,int r,int val) 
{
	if(l==r) return l;
	int s=(l+r)/2;
	if(rb[s].x>=val) return binarna(l,s,val);
	return binarna(s+1,r,val);
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>rb[i].x>>rb[i].d;
	rb[n].x=rb[n].d=2000000000;
	sort(rb,rb+n,cmp);
	dp[n]=1;
	fill(seg,seg+4*MAXN,-1000000001);
	for(int i=n-1;i>=0;i--)
	{
		int t=binarna(0,n,rb[i].x+rb[i].d);
		int dist=max(t,nmax(0,n,i,t-1,1));
		upd(0,n,dist,i,1);
		dp[i]=(dp[i+1]+dp[dist])%MOD;
	}
	printf("%d",dp[0]);
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define N 400000+5


int main () 
{
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////    

    lli l,r,c,d;
    cin>>l>>r>>c>>d;

    lli e = __gcd(c,d);
    e = c/e;
    e = e*d ;

    lli o1 = (lli)(r/c) - (lli)(l/c);
    if(l%c == 0) o1++;

    lli o2 = (lli)(r/d) - (lli)(l/d);
    if(l%d == 0) o2++;

    lli o3 = (lli)(r/e) - (lli)(l/e);
    if(l%e == 0) o3++;

    lli ans1 = o1+o2-o3;

    cout<<r-l+1-ans1;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
constexpr long long int MOD = 1000000007LL;
long long int search(const int s, const int t, const std::vector<int>& s_list, const std::vector<int>& t_list, std::vector< std::vector<long long int>>& memo) {
	if (s >= s_list.size() || t >= t_list.size()) return 1;
	else if (memo[s][t] >= 0) return memo[s][t];
	else if (s_list[s] == t_list[t]) return memo[s][t] = (search(s + 1, t, s_list, t_list, memo) + search(s, t + 1, s_list, t_list, memo)) % MOD;
	else return memo[s][t] = (search(s + 1, t, s_list, t_list, memo) + search(s, t + 1, s_list, t_list, memo) - search(s + 1, t + 1, s_list, t_list, memo) + MOD) % MOD;
}
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> s_list(n), t_list(m);
	for (auto& s : s_list) std::cin >> s;
	for (auto& t : t_list) std::cin >> t;
	std::vector<std::vector<long long int>> memo(n, std::vector<long long int>(m, -1));
	std::cout << search(0, 0, s_list, t_list, memo) << std::endl;
}


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

using namespace std;

int main(){
  int n; cin >> n;
  int univ[4][3][10]={};
  for(int i=0;i<n;++i) {
    int b,f,r,v;
    cin >> b >> f >> r >> v;
    univ[b-1][f-1][r-1]+=v;
  }
  for(int i=0;i<4;++i){
    for(int j=0;j<3;++j){
      for(int k=0;k<10;++k){
	cout << " " << univ[i][j][k];
      }
      cout << endl;
    }
    if(i==3) break;
    for(int j=0;j<20;++j) cout << '#';
    cout << endl;
  }

      
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n;
  cin>>n;
  int a[n],b[n],count;
  count=0;
  rep(i,n){
    cin>>a[i]>>b[i];
    count+=b[i]-a[i]+1;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	int a, b, c; cin >> a >> b >> c;

	cout << a + b + c - max(a, max(b, c)) << endl;
}

Measured memory_bytes: 256
import functools

n = int(input())
xs = list(map(int, input().split()))

def foldMulti(acc, x):
    return acc*x

if 0 in xs:
    print(0)
elif len([x for x in xs if x > 1]) >= 60:
    print(-1)
else:
    res = functools.reduce(foldMulti, xs, 1)

    if res > 1e18:
        print(-1)
    else:
        print(res)



Measured memory_bytes: 22664
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	string N;
	cin >> N;
	if (N[0] == '7' || N[1] == '7' || N[2] == '7') 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



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

bool kaibun(string s){
    char size= s.size();
    bool judge =true;
    rep(i,(size)/2){
        if(s[i] != s[size-1-i]){
            judge = false;
        }
    }
    return judge;
}


int main(){
    string s;
    cin >> s;
    vector<bool> ans(3,true);
    char size= s.size();
    ans[0] = kaibun(s);
    string s1 =s.substr(0,(size-1)/2);
    ans[1] = kaibun(s1);
    string s2 = s.substr((size+1)/2, size-(size+1)/2);
    ans[2] = kaibun(s2);
    
    bool answer =true;
    rep(i,3){
        if(ans[i]==false)
            answer = false;
    }
    if(answer)
        cout << "Yes" <<endl;
    else
         cout << "No" <<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int k = (n / x);
	if (n % x != 0) {
		k++;
	}
	cout << k * t;


	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

        int k = Integer.parseInt(scan.next());
        int n = Integer.parseInt(scan.next());

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
        }

        scan.close();

        // 最後と最初の距離を初期値とする
        int max = a[0] + (k - a[n - 1]);
        for (int i = 0; i < n-1; i++) {
            int distance = a[i + 1] - a[i];
            if (max < distance) {
                max = distance;
            }
        }

        System.out.println(k - max);
    }

}


Measured memory_bytes: 51316
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
)

func main() {
    var fp *os.File = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)

    line := readLine(reader)
    arr := strings.Split(line, " ")
    N, _ := strconv.Atoi(arr[0])
    D, _ := strconv.Atoi(arr[1])
    var unit int = D * 2 + 1
    var surplus int

    if N % unit == 0 {
        surplus = 0
    } else {
        surplus = 1
    }

    fmt.Println(N / unit + surplus)
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    char fg[8][8];

    while (cin >> fg[0][0]) {
        for (int i = 0; i < 8; i++)
            for (int j = 0; j < 8; j++) {
                if (!i && !j)
                    continue;
                cin >> fg[i][j];
            }

        int x, y;
        bool flag = false;
        for (y = 0; y < 8; y++) {
            for (x = 0; x < 8; x++)
                if (fg[y][x] == '1') {
                    flag = true;
                    break;
                }
            if (flag)
                break;
        }

        if (fg[y][x + 1] == '1') {
            if (fg[y][x + 2] == '1') 
                cout << "C\n";
            else if (fg[y + 1][x + 2] == '1') 
                cout << "E\n";
            else if (fg[y + 1][x - 1] == '1') 
                cout << "G\n";
            else 
                cout << "A\n";
        }
        else if (fg[y + 2][x] == '1')
            cout << "B\n";
        else if (fg[y + 1][x - 1] == '1')
            cout << "D\n";
        else 
            cout << "F\n";
    }

    return 0;
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
int n;
//int a[1000],b[1000],c[1000],x[1000];
int b[1000];
int main(){
    cin>>n;ll sum=0;
    for(int i=1;i<n;i++)
        cin>>b[i];
    b[0]=b[1];
    b[n]=b[n-1];
    for(int i=0;i<n;i++)
    {
        sum+=min(b[i],b[i+1]);
    }
    cout<<sum;
   return 0;
}


Measured memory_bytes: 256
import bisect

def divisor(n):
    lower, upper = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)
        i += 1
    return lower + upper[::-1]

n, m = map(int, input().split())
M = divisor(m)
if n not in M:
    x = bisect.bisect_left(M, n)
    ans = (m // M[x])
else:
    ans = m // n
print(ans)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		String strN = bufferedReader.readLine();
		int n = Integer.parseInt(strN);
		int a = n;
		while(a>0) {
			if((int) Math.sqrt(a) == Math.sqrt(a)) {
				break;
			}
			a--;
		}

		System.out.println(a);

	}

}


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

int main() {
  int A;
  int count = 0;
  string slime;
  cin >> A;
  cin >> slime;
  for(int i = 0; i < (A-1); i++){
    if(slime.at(i)==slime.at(i+1)){
      count++;
    }
  }
  cout << A - count <<endl;
}

Measured memory_bytes: 512
n, m = map(int, input().split())
s=[]
c=[]
for i in range(m):
	_s, _c = map(int, input().split())
	s.append(_s-1)
	c.append(_c)

for i in range(1000):
	*t, = map(int, list(str(i)))

	if len(t) != n:
		continue

	ok = True
	for j in range(m):
		if t[s[j]]!=c[j]:
			ok = False
			break
 
	if ok:
		print(i)
		quit()

print(-1)

Measured memory_bytes: 3064
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("YES") if fl else print("NO")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
s = list(input())
co = collections.Counter(s)
ls = []
for w in ["a","b","c"]:
    ls.append(co[w])
mx = max(ls)
f=True
for c in ls:
    if mx > c+1:
        f=False
yn(f)


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

int main(){
	int H, W;
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if ( i== 0||j==0||j==W-1||i==H-1){
					cout << '#';
				}
				else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    vi a(n + 1), b(n + 1, 0);
    rep(i, 0, n + 1) { cin >> a[i]; }
    rep(i, 1, n + 1) { cin >> b[i]; }

    ll cnt = 0;
    rep(i, 0, n + 1) {
        int d = min(a[i], b[i]);
        cnt += d;
        a[i] -= d;

        if (i == n) { break; }
        d = min(a[i], b[i + 1]);
        cnt += d;
        b[i + 1] -= d;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
ss = input()
n = len(ss)
result = 0
for i in range(1<<(n-1)):
    f = ss[0]
    for j in range(n-1):
        if (i>>j)&1:
            f += '+'
        f += ss[j+1]
    a = sum(map(int, f.split('+')))
    result += a
print(result)


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  ll ans = 0;

  rep(i, 1, N+1) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    ans += (ll) i;
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 3652
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 1<<19;
const int MM = 998244353;

struct UF{
	int t[MX];
	int find(int x){ return t[x]? t[x] = find(t[x]) : x; }
	int merge(int a, int b){
		a = find(a), b = find(b);
		if(a == b) return false;
		t[a] = b;
		return true;
	}
} uf;
vector<int> H[MX];

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= N; i++){
		int a, b;
		scanf("%d", &a);
		for(int t = 1; t <= a; t++){
			scanf("%d", &b);
			H[b].push_back(i);
		}
	}
	int ans = 0;
	for(int i = 1; i <= M; i++){
		for(int j = 1; j < H[i].size(); j++){
			ans += uf.merge(H[i][0], H[i][j]);
		}
	}
	if(ans == N-1) printf("YES\n");
	else printf("NO\n");
}



Measured memory_bytes: 16512
use std::cmp;

fn solve(a: &Vec<usize>, b: &Vec<usize>) -> usize {
    let n = a.len();
    let mut v = vec![];
    for i in 0..n {
        v.push((a[i], i));
        v.push((b[i], i));
    }
    v.sort();

    let mut ans = 0;
    let mut used_count = vec![0; n];
    for i in 0..n {
        let (t, i) = v[i];
        used_count[i] += 1;
        ans += t;
    }

    let used_two = used_count.iter().any(|&c| c == 2);
    if used_two {
        return ans;
    }

    let mut min = 1e15 as usize;
    for i in 0..n {
        let (t, i) = v[i];
        let ans = ans - t;
        let (t, j) = v[n];
        if i == j {
            let (t, _) = v[n + 1];
            min = cmp::min(ans + t, min);
        } else {
            min = cmp::min(ans + t, min);
        }
    }
    min
}

fn main() {
    let sc = std::io::stdin();
    let mut sc = Scanner { reader: sc.lock() };
    let n: usize = sc.read();
    let mut a: Vec<usize> = vec![0; n];
    let mut b: Vec<usize> = vec![0; n];
    for i in 0..n {
        a[i] = sc.read();
        b[i] = sc.read();
    }

    let all_a: usize = a.iter().sum();
    let all_b: usize = b.iter().sum();
    println!("{}", cmp::min(solve(&a, &b), cmp::min(all_a, all_b)));
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 14064
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	txt := scanner.Text()

	if txt == "Sunny" {
		fmt.Println("Cloudy")
	} else if txt == "Cloudy" {
		fmt.Println("Rainy")
	} else {
		fmt.Println("Sunny")
	}
}


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

split = 1
skip = True

for a in A:
    if skip == True:
        skip = not skip
        tmp = a
        zouka = 0
        continue
    if tmp == a:
        continue
    if zouka == 0:
        if a > tmp:
            zouka = 1
        else:
            zouka = -1
    elif zouka > 0:
        if a < tmp:
            split += 1
            zouka = 0
    else:
        if a > tmp:
            split += 1
            zouka = 0
    tmp = a
print(split)

Measured memory_bytes: 14228
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll count = 0;
    ll tmp = 0;
    string result = S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '('){
            tmp++;
        }else{
            if(tmp > 0){
                tmp--;
            }
        }
    }
    for(int i = 0; i < tmp; i ++){
        result = result + ")";
    }
    count += tmp; tmp = 0;
    for(int i = S.size() - 1; i >= 0; i--){
        if(S[i] == ')'){
            tmp++;
        }else{
            if(tmp > 0){
                tmp--;
            }
        }
    }
    for(int i = 0; i < tmp; i ++){
        result = "(" + result;
    }
    count += tmp;
    cout << result << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
DestList = list(map(int,input().split()))
Count = [0 for i in range(N)]
CurrTown = 1
Count[0] = 1
Flag = 0
Loop1 = 0
Loop2 = 0
LoopNum = 0
for i in range(K):
  CurrTown = DestList[CurrTown-1]
  if(Count[CurrTown-1]==1 and Flag==0):
    Loop1 = sum(Count)
    Flag=1
  elif(Count[CurrTown-1]==2 and Flag==1):
    Loop2 = sum(Count)
    LoopNum = (K-(Loop1*2-Loop2))%(Loop2-Loop1)+(Loop1*2-Loop2)
    CurrTown = 1
    for j in range(LoopNum):
      CurrTown = DestList[CurrTown-1]
    break;
  else:
    Count[CurrTown-1]+=1
print(CurrTown)

Measured memory_bytes: 32388
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> A(n), vs(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
		vs[i] = A[i];
	}
	sort(vs.begin(), vs.end());
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (i % 2) {
			int p = lower_bound(vs.begin(), vs.end(), A[i]) - vs.begin();
			if (p % 2 == 0) ++ans;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1024
#include<cstdio>

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

int main(){
    int n,a,min=1234567899,d=0,cnt=0;
    scanf("%d%*d",&n);
    REP(i,n){
        scanf("%d",&a);
        if(min>a){
            min = a;
        }else if(d==a-min){
            ++cnt;
        }else if(d<a-min){
            d = a - min;
            cnt=1;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 128
// AtCoder-Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define FORREV(i,N,_cnt) for(auto i=N-1,cnt=_cnt; cnt > 0; --i, --cnt)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
	ifstream ifs("in.txt");
	cin.rdbuf(ifs.rdbuf());
#endif
	ll N; cin >> N;
	vector<ll> X(N), Y(N);
	vector<pair<ll, ll> > Z(N);
	FOR(i, N) {
		cin >> X[i] >> Y[i];
		Z[i] = make_pair(X[i], Y[i]);
	}
	sort(ALL(Z));
	if (N == 1) {
		cout << 1 << endl;
		exit(0);
	}


	ll ans = numeric_limits<ll>::max();
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			// i -> j のときのA,Bを求める。
			auto a = Z[j].first  - Z[i].first;
			auto b = Z[j].second - Z[i].second;
			ll ans_tmp = 0; // aが必ず
			set< pair<ll, ll> > S;
			for (int z = 0; z < N; ++z) {
				if (!S.count(make_pair(
					Z[z].first - a, Z[z].second - b))) {
					ans_tmp += 1;				
				}
				S.insert(Z[z]);

			}
			chmin(ans, ans_tmp);			
		}
	}


	//// swap// // // // // // // 
	//for (auto& z : Z)
	//	swap(z.first, z.second);
	//sort(ALL(Z));
	//for (int i = 0; i < N; ++i) {
	//	for (int j = i + 1; j < N; ++j) {
	//		// i -> j のときのA,Bを求める。
	//		auto a = Z[j].first - Z[i].first;
	//		auto b = Z[j].second - Z[i].second;
	//		ll ans_tmp = 0; // aが必ず
	//		set< pair<ll, ll> > S;
	//		for (int z = 0; z < N; ++z) {
	//			if (!S.count(make_pair(
	//				Z[z].first - a, Z[z].second - b))) {
	//				ans_tmp += 1;
	//			}
	//			S.insert(Z[z]);

	//		}
	//		chmin(ans, ans_tmp);
	//	}
	//}
	//// // // // // // // // // // // // // // // // // // // 


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/** Nguyen Anh Tu **/
#include <bits/stdc++.h>
#define maxn 600000
#define maxc 1000000007
#define MOD 1000000007
#define reset(x) memset(x,0,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)
#define mid ((l+r) >> 1)
using namespace std;

int n,k,a[maxn],dp[maxn],t[4 * maxn],ans;

void update(int node, int l, int r, int u, int w){
    if(l == r){
        t[node] = max(t[node], w);
        return;
    }
    if(u <= mid) update(node*2,l,mid,u,w);
    else update(node*2+1,mid+1,r,u,w);
    t[node] = max(t[node*2], t[node*2+1]);
}

int get(int node, int l, int r, int u, int v){
    if(l >= u && r <= v) return t[node];
    if(l > v || r < u) return 0;
    return max(get(node*2,l,mid,u,v),get(node*2+1,mid+1,r,u,v));
}

int main()
{
    ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    cin >> n >> k;
    int MAX = 0;
    for(int i=1; i<=n; ++i){
        cin >> a[i];
        a[i] += 300001;
        MAX = max(MAX, a[i]);
    }
    for(int i=1; i<=n; ++i){
        dp[i] = get(1,1,MAX,a[i]-k, a[i]+k) + 1;
        update(1,1,MAX,a[i],dp[i]);
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}


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

int main() {
	int i,p;
p=0;
  char str;
  cin >> str;
 string test = "abcdefghijklmnopqrstuvwxyz";
 for (i = 0; i < 26; i++) {
	if(test.at(i)==str){
		p=1;
	}
}
 if(p==1){
	cout << 'a' << endl;
	}
else{
cout << 'A' << endl;
}

}


Measured memory_bytes: 3584
var so,gg: array [1..4] of longint ;
    i,j,k,a,b,c,d,e,f : longint ;
    cc : ansistring ;
procedure re(x : longint);
begin
if x>4 then
 begin
  if gg[1]+so[2]*gg[2]+so[3]*gg[3]+so[4]*gg[4]=7 then
   begin
    write(gg[1]);
    for i:=2 to 4 do
     begin
      if so[i]=1 then
       write('+')
      else
       write('-');
      write(gg[i]);
     end;
    writeln('=7');
    halt;
   end;
 end
else
 begin
  so[x]:=1;
  re(x+1);
  so[x]:=-1;
  re(x+1);
  so[x]:=0;
 end;
end;
begin
 readln(cc);
 for i:=1 to 4 do
  val(cc[i],gg[i]);

 re(2);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

const int INF=1e9;
int h,w,stat;
string str;
int main(){
  cin >>h>>w;
  vector<vector<bool>> s(h,vector<bool>(w));
  rep(r,h){
    cin>>str;
    rep(c,w){
      if(str[c]=='#') s[r][c]=false;//black
      else s[r][c]=true;//white
      
     // cout<<s[r][c]<<" ";
    }
    //cout<<endl;
  }
  vector<vector<int>> dp(h,vector<int>(w));// dp[i].. i回移動時に最小となる反転回数．
  rep(i,h)rep(j,w) dp[i][j]=INF;
  
  if(s[0][0]) dp[0][0]=0;
  else dp[0][0]=1;
  
  
  for(int i=1; i<=h+w-1;i++){//i回移動する． [i][0],[i-1][1],...[0][i]
    int j_st=max(i-w+1,0);
    int j_end=min(h-1,i);
    for(int j=j_st; j<=j_end;j++){// j回は下に移動する場合． dp[j]
      int k=i-j;
      if(j>=1){
      	if(s[j][k]^s[j-1][k]){ 
          dp[j][k]=min(dp[j][k],dp[j-1][k]+1);
        }else{
          dp[j][k]=min(dp[j][k],dp[j-1][k]);
        }
      }
       
      if(k>=1){
      	if(s[j][k]^s[j][k-1]){
          dp[j][k]=min(dp[j][k],dp[j][k-1]+1);
      	}else{
          dp[j][k]=min(dp[j][k],dp[j][k-1]);
      	}      
      }
      
      
    }
    
  }
  /*
  rep(i,h){
    rep(j,w){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  
  int ans=(dp[h-1][w-1]+1)/2;
  //if(s[0][0]==false) ans+=1;
  
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
ls = []
for x in range(K*2):
    ls.append(input().split())
ls2 = []
i = 1
while i < K*2:
    for j in ls[i]:
        ls2.append(j)
    i += 2
ls2 = set(ls2)
print(N - len(ls2))

Measured memory_bytes: 9356
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int M, K;
	cin >> M >> K;

	if (M == 1) {
		if (K == 0) cout << "0 0 1 1" << "\n";
		else cout << -1 << "\n";
	}
	else {
		if (K < (1 << M)) {

			cout << K << " ";
			for (int i = 0; i < (1 << M); i++) if (i != K) cout << i << " ";
			cout << K << " ";
			for (int i = (1 << M) - 1; i >= 0; i--) if (i != K) cout << i << " ";

		}
		else cout << -1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 1792
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, Q, S, LRi):
    cumulative_sum = [0, 0]
    for i in range(1, N):
        tmp = cumulative_sum[-1]
        if S[i - 1:i + 1] == 'AC':
            tmp += 1
        cumulative_sum.append(tmp)

    for l, r in LRi:
        print(cumulative_sum[r] - cumulative_sum[l])


if __name__ == '__main__':
    N, Q = map(int, input().split())
    S = input()
    LRi = [[int(i) for i in input().split()] for _ in range(Q)]
    solve(N, Q, S, LRi)

    # # test
    # from random import randint
    # from func import random_str
    # N, Q = 10 ** 5, 10 ** 5
    # S = random_str(N, 'ACGT')
    # LRi = [sorted([randint(1, N) for _ in range(2)]) for _ in range(Q)]
    # solve(N, Q, S, LRi)


Measured memory_bytes: 27924