akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    int n;
    cin >> n;
    vi a(n), b(n);
    rep (i, n) {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    ll mi, ma;
    if (n % 2 == 1) {
        mi = a[n / 2];
        ma = b[n / 2];
    }
    else {
        mi = a[n / 2 - 1] + a[n / 2];
        ma = b[n / 2 - 1] + b[n / 2];
    }
    cout << ma - mi + 1 << endl;
}

Measured memory_bytes: 6352
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] stdR = br.readLine().split(" ");
        int N = Integer.parseInt(stdR[0]);
        int K = Integer.parseInt(stdR[1]);
        int Q = Integer.parseInt(stdR[2]);
        
        int[] A = new int[N];
        
        for(int i = 0; i < Q; i++){
            int who = Integer.parseInt(br.readLine());
            A[who-1]++;
        }
        
        for(int i = 0; i < N; i++){
            int count = K - Q + A[i];
            System.out.println( (count > 0) ? "Yes" : "No" );
        }
    }
}


Measured memory_bytes: 40096
#include<stdio.h>
#include<string.h>

int main(void)
{
  char s[11];
  int i,len,flag=0,count=0;
  scanf("%s",s);
  len = strlen(s);
  for(i=0;i<len;i++)
    {
      if(i == 0)
	{
	  if(s[i] != 'A')
	    {
	      flag++;
	      break;
	    }
	}
      else if(i == 1 || i == len-1)
	{
	  if((int)s[i] >=65 && (int)s[i] <= 90)
	    {
	      flag++;
	      break;
	    }
	}
      else if(i >= 2 && i < len-1)
	{
	  if(s[i] == 'C')
	    {
	      count++;
	    }
	  else if((int)s[i] >= 65 && (int)s[i] <= 90)
	    {
	      flag++;
	      break;
	    }
	}
    }
  if(count != 1)
    {
      flag++;
    }
  if(flag == 0)
    {
      printf("AC\n");
    }
  else
    {
      printf("WA\n");
    }
  return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main (void) {
    int n;
    cin >> n;
    int v[n], c[n];
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int total = 0;
    rep(i, n) {
        total += (v[i]-c[i]) > 0 ? (v[i]-c[i]) : 0;
    }
    cout << total << endl;
    return 0;
}



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

#define llint long long int

using namespace std;

int main(){
    int X, N;

    cin >> X >> N;

    vector<int> p(N);

    for(int i = 0; i < N; i ++){
        cin >> p[i];
    }
    int X_minus, X_plus;

    for(X_minus = X; X_minus >= 0; X_minus --){
        bool exist = false;

        for(int i = 0; i < N; i ++){
            if(X_minus == p[i]){
                exist = true;

                break;
            }
        }
        if(!exist){
            break;
        }
    }
    for(X_plus = X; X_plus <= 101; X_plus ++){
        bool exist = false;

        for(int i = 0; i < N; i ++){
            if(X_plus == p[i]){
                exist = true;

                break;
            }
        }
        if(!exist){
            break;
        }
    }
    if(X - X_minus > X_plus - X){
        cout << X_plus << endl;
    }else{
        cout << X_minus << endl;
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
int main() {
	ll A, B,K;
	cin >> A >> B >> K;
	if (A < K) {
		if (A + B < K) {
			cout << 0 << " " << 0;
			return 0;
		}
		cout << 0 << " " << A + B - K;
		return 0;
	}
	else {

		cout << A - K << " " << B;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<map>
#define ll long long
#define MM(arr,x) memset(arr,x,sizeof(arr))
#define INF 10000000
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int n;
	cin>>n;
	int a[n+10];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1,cmp);
	ll ans=0;
	int t=n;
	for(int i=1;i<=n;i++)
	{
		if(t>1)
		{
			ans+=a[i];
			t--;
		}
		if(t>1&&i>1)
		{
			ans+=a[i];
			t--;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4380
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(H * W - h * W - w * H + h * w);
	}
}


Measured memory_bytes: 21716
using System;

namespace AGC003A{
    public class Program{
        public static void Main(string[] args){
            var S = Console.ReadLine();
            var res = !(S.Contains("N") ^ S.Contains("S")) && !(S.Contains("E") ^ S.Contains("W"));
            Console.WriteLine(res ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 2648
n = int(input())
A, B = [0] * n, [0] * n
for i in range(n):
    A[i],B[i] = map(int, input().split())

A.sort()
B.sort()
ans = 0
if n % 2 == 1:
    ans = B[n // 2] - A[n // 2] + 1
else:
    large = B[n // 2] + B[n // 2 - 1]
    small = A[n // 2] + A[n // 2 - 1]
    ans = large - small + 1

print(ans)


Measured memory_bytes: 25372
#include<stdio.h>
int main(void)
{
	int n,m,k,i,l,j,a[200],b[100],c[200],d=0,h,g,p;
	scanf("%d %d",&n,&m);
	for(j=0;j<2*n;j++){
		a[j]=j+1;
	}
	for(i=0;i<m;i++){
		scanf("%d",&k);
		g=2*n-k;
		h=2*n-g;
		if(k>=1 && k<=2*n-1){
			for(j=0;j<g;j++){
				c[j]=a[k+j];
			}
			for(d=0;d<h;d++){
				c[g]=a[d];
				g++;
			}
		}
		else if(k==0){
			l=1;
			for(j=0;j<n;j++){
				b[j]=a[n+j];
				c[l-1]=a[j];
				c[l]=b[j];
				l+=2;
				
			}
		}
		for(j=0;j<2*n;j++){
			a[j]=c[j];
		}
	}
	for(i=0;i<2*n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int k = fs.nextInt();
        long ans = 0;
        for(int i=1; i<=k; ++i){
            for(int j=1; j<=k; ++j){
                for(int h=1; h<=k; ++h){
                    ans += gcd(i,gcd(j,h));
                }
            }
        }
        System.out.println(ans);
    }
    public static int gcd(int a, int b){
        if(a == 0) return b;
        return gcd(b%a, a);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 32704
#include<iostream>
#define N 8  // N*N board
#define NF 1  // This place isn't attacked.
#define F 0  // This place is attacked.
void printBoard(void);
void putQueen(int);
int M[N][N],row[N],col[N],dneg[2*N-1],dpos[2*N-1];
int main(){
  for(int i=0; i<N; i++){                     // initiaize
    for(int j=0; j<N; j++){                   // *
      M[i][j] = 0;                            // *
    }                                         // *
    col[i] = row[i] = dneg[i] = dpos[i] = F;  // *
  }                                           // *
  for(int i=N; i<(N*2-1); i++){               // *
    dneg[i] = dpos[i] = F;                    // *
  }                                           // end
  int k;
  std::cin >> k;
  for(int i=0,r,c; i<k; i++){
    std::cin >> r >> c;
    M[r][c] = 1;
  }
  putQueen(0);
  return 0;
}
void printBoard(void){
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(M[i][j] && row[i] != j) return;
    }
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      std::cout << (row[i] == j ? "Q" : ".");
    }
    std::cout << "\n";
  }
}
void putQueen(int i){
  if(i == N){
    printBoard();
    return;
  }
  for(int j=0; j<N; j++){
    if(col[j] == NF || dpos[i+j] == NF || dneg[i-j+N-1] == NF) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NF;
    putQueen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = F;
  }
}

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


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; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a == 1){ return a; } else{ return a * fact(a - 1); } }

int main(){
    ll N;
    string temp;
    vector<char> S;
    cin >> N >> temp;
    for (char c : temp){
        S.push_back(c);
    }
    rep(i, 1, S.size()){
        if (S[i] == S[i - 1]){
            S.erase(begin(S) + i);
            i--;
        }
    }
    cout << S.size() << endl;
    return 0;
}


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

long long yaku(long long n){
    long long res=1;
    for(long long i=2;i<=sqrt(n);i++){
        if(n%i==0) res=i;
        //cout << "hey"
    }
    return res;
}

int main(){
    long long n;
    cin >> n;
    long long y=yaku(n);
    cout << n/y+y-2 << endl; 
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n,m,x;

int main(){
    
    cin >> n >> m >> x;
    set<int> s;
    rep(i,0,m){
        int a;
        cin >> a;
        s.it(a);
    }
    
    int ans = 0;
    int now = x;
    while(0 < now){
        now--;
        if(s.count(now) != 0)ans++;
    }

    int ans2 = 0;
    now = x;
    while(now < n){
        now++;
        if(s.count(now) != 0)ans2++;
    }
    
    P(min(ans,ans2));
    return  0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int R = scanner.nextInt();
		
		if((0 <= R)&&(R < 1200)) {
			System.out.println("ABC");
		}else if ((1200 <= R)&&(R < 2800)) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}

	}

}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1005;
int a[100005];
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n,ans=0,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i>0)
		{
			if(a[i]<=a[i-1]) cnt++;
			else
			{
				ans=max(ans,cnt);
				cnt=0;
			}
		}
		if(i==n-1) ans=max(cnt,ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
char to[299];
int main(){
	to['b']='d';
	to['d']='b';
	to['p']='q';
	to['q']='p';
    string a,b;
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.length();i++)a[i]=to[a[i]];
    if(a==b) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 512
class UnionFind
  def initialize(n)
    @size = Array.new(n + 1, 1)
    @rank = Array.new(n + 1, 0)
    @parent = []

    (1..n).each do |i|
      @parent[i] = i
    end
  end

  def find(x)
    if @parent[x] == x
      x
    else
      @parent[x] = find(@parent[x])
    end
  end

  def unite(x, y)
    x = find(x)
    y = find(y)
    return if x == y

    if @rank[x] < @rank[y]
      @parent[x] = y
    else
      @parent[y] = x

      @rank[x] += 1 if @rank[x] == @rank[y]
    end

    @size[x] += @size[y]
  end

  def same?(x, y)
    find(x) == find(y)
  end

  def size(x)
    @size[find(x)]
  end
end

N, M = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)

uf = UnionFind.new(N)

M.times do
  x, y = gets.split.map(&:to_i)

  uf.unite(x, y)
end

group = Hash.new { |h, k| h[k] = [] }

P.each.with_index(1) do |v, i|
  id = uf.find(i)
  group[id] << [i, v]
end

ans = N

group.values.each do |value|
  listA = value.map(&:first)
  listB = value.map(&:last)

  ans -= (listA - listB).size
end

puts ans


Measured memory_bytes: 35796
#include "bits/stdc++.h"
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
//#define int long long
//#define error freopen("error.txt","w",stderr);
#define repo(i, begin, end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define ll long long int
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<"  ";
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define eb emplace_back
#define mp make_pair
double jk=0.004;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
#define mod 1000000007
#define N 1000000000
int in(){
int n;cin>>n; 
return n;}
void _do_(){
ll n;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0)sum+=i;
	}
	cout<<sum<<endl;


}
signed main(){
fastr
//int tc=in();
int tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms ";
return 0;}

Measured memory_bytes: 3660
N, K = map(int, input().split())
A = list(map(int, input().split()))
K = min(50, K)

for k in range(K):
    for i in range(N):
        if A[i] != N:
            break
    else:
        break

    B = [0] * N
    for i in range(N):
        d = A[i]
        left = max(0, i - d)
        right = min(N-1, i + d)
        B[left] += 1
        if right + 1 < N:
            B[right+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = B
print(" ".join(map(str, A)))


Measured memory_bytes: 149524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

#define MAX 3'234'566'667
int K;
// set<ll> S;
set<string> S;

void dfs(string s, int d){
	if(s.size() >= 10){
		ll l = stoll(s);
		if(l <= MAX) S.insert(s);
		// if(l <= MAX) S.insert(l);
		return;
	}
	// s = to_string(d) + s;
	s += to_string(d);

	rp(i, -1, 2){//{-1,0,+1}
		int k = d + i;
		if(k < 0 || 9 < k) continue;
		// if(k < 0 || 9 < k) k=0;
		dfs(s, k);
	}
}

ll solve(){
	// rp(i, 0, 10){//[0,9]
	// 	string s = "";
	// 	dfs(s, i);
	// }

	vector<ll> candidate;
	queue<ll> q;
	rp(i, 1, 10) q.push(i);

	while(q.size()){
		ll n = q.front(); q.pop();
		// cout<<n<<"\n";//
		candidate.push_back(n);
		if(candidate.size() >= K) break;

		int n1 = n%10;//nの第一位

		rp(i, -1, 2){//{-1,0,+1}
			int m = n1 + i;//次の第一位
			if(m < 0 || 9 < m) continue;
			q.push(n*10+m);
		}

	}

	// for(auto x:candidate)cout<<">"<<x<<"<\n";puts("");//
	// while(q.size()){cout<<">"<<q.front()<<"<\n";q.pop();}///

	ll ans = 0;
	// sort(all(candidate));
	ans = candidate[K-1];
	return ans;
}

int main(){
	cin>>K;
	cout<< solve() <<endl;
}


Measured memory_bytes: 2548
h, w, k = map(int, input().split())
hoge = 0
def p():
	global hoge
	hoge += 1
	return hoge
field = [[0 if c == '.' else p() for c in input()]for i in range(h)]

for i in range(1,h):
	for j in range(w):
		if field[i][j] != 0:continue
		field[i][j] = field[i-1][j]

for i in range(h-2,-1,-1):
	for j in range(w):
		if field[i][j] != 0:continue
		field[i][j] = field[i+1][j]

for i in range(h):
	for j in range(1,w):
		if field[i][j] != 0:continue
		field[i][j] = field[i][j-1]

for i in range(h):
	for j in range(w-2,-1,-1):
		if field[i][j] != 0:continue
		field[i][j] = field[i][j+1]

for i in range(h):
	print(*field[i])
				

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

using namespace std;

const int N = 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;
const int K = 300;

int n, m;
string s[N];
int sum1[K][K + K][K], sum2[K][K + K][K];

bool read() {
    if (!(cin >> n >> m))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> s[i];

    return true;
}

template<typename T>
long long diag(int x1, int y1, int x2, int y2, int d, const T& f, const int sum[K][K + K][K]) {
    auto id = f(x1, y1);

    if (id < 0 || id >= K + K || d / 2 >= K)
        return 0ll;

    auto l = x1;
    auto r = x2;

    if (l > r)
        swap(l, r);

    ++l;
    r -= d / 2 + 1;

    if (l >= K || r < 0 || l > r)
        return 0ll;

    return sum[d / 2][id][min(K - 1, r)] - (l > 0 ? sum[d / 2][id][l - 1] : 0);
}

void solve() {
    for (int d = 1; d < K; ++d) {
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < m; ++j)
                if (s[i][j] == '#') {
                    sum1[d][i + m - 1 - j][i] = (i + d < n && j + d < m && s[i + d][j + d] == '#');
                    sum2[d][i + j][i] = (i + d < n && j - d >= 0 && s[i + d][j - d] == '#');
                }

        for (int id = 0; id < K + K; ++id)
            for (int i = 1; i < K; ++i) {
                sum1[d][id][i] += sum1[d][id][i - 1];
                sum2[d][id][i] += sum2[d][id][i - 1];
            }
    }

    auto ans = 0ll;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (s[i][j] == '#') {
                for (int d = 2; d < K + K; d += 2) {
                    if (i + d < n && s[i + d][j] == '#') {
                        ans += (j >= d / 2 && s[i + d / 2][j - d / 2] == '#');
                        ans += (j + d / 2 < m && s[i + d / 2][j + d / 2] == '#');
                    }

                    if (j + d < m && s[i][j + d] == '#') {
                        ans += (i >= d / 2 && s[i - d / 2][j + d / 2] == '#');
                        ans += (i + d / 2 < n && s[i + d / 2][j + d / 2] == '#');
                    }

                    ans += diag(i - d, j, i, j + d, d, [](int x, int y) { return x + m - 1 - y; }, sum1);
                    ans += diag(i + d, j, i, j - d, d, [](int x, int y) { return x + m - 1 - y; }, sum1);
                    ans += diag(i, j + d, i + d, j, d, [](int x, int y) { return x + y; }, sum2);
                    ans += diag(i, j - d, i - d, j, d, [](int x, int y) { return x + y; }, sum2);
                }
            }

    cout << ans << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 421504
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int h,w;
	string field[50];
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		cin >> field[i];
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(field[i][j] == '.'){
				int cnt = 0;
				for(int k = -1;k <= 1;k++){
					for(int l = -1;l <= 1;l++){
						int nx = i + k,ny = j + l;
						if(nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] == '#') cnt++;
					}
				}
				field[i][j] = cnt + '0';
			}
		}
	}
	for(int i = 0;i < h;i++){
		cout << field[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc145_a(args);
        }

        static void abc145_a(string[] args)
        {
            int r = int.Parse(Console.ReadLine());
            int ans = (int)Math.Pow(r, 2);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vector<vll> v(n, vll(2));
  for (ll i = 0; i < n; i++) {
    cin >> v[i][0] >> v[i][1];
  }
  sort(all(v));
  cout << v[n - 1][0] + v[n - 1][1] << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

typedef struct node_{
    char *str;
    node_ *l;
    node_ *r;
} *node;

typedef struct binarytree_{
    node root;
    int size;
} *binarytree;

node build_node();
binarytree build_binarytree();
void tree_insert(binarytree,node);


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

    binarytree T;
    T = build_binarytree();

    for(int i=0;i<N;i++){
        tree_insert(T,build_node());
    }
    cout << T->size << endl;

    return 0;
}




node build_node()
{
    node x;
    x = new node_[1];
    x->l = NULL;
    x->r = NULL;
    x->str = new char[10];
    cin >> x->str;
    return x;
}

binarytree build_binarytree()
{
    binarytree T;
    T = new binarytree_[1];
    T->root=NULL;
    T->size=0;
    return T;
}


void tree_insert(binarytree T, node z)
{
    node y = NULL;
    node x = T->root;
    while(x!=NULL){
        y = x;
        int flag = strcmp(z->str,x->str);
        if(flag<0){
            x = x->l;
        }else if(flag>0){
            x = x->r;
        }else{
            return;
        }
    }
    T->size++;
    if(y==NULL){
        T->root = z;
    }else{
        int flag2 = strcmp(z->str,y->str);
        if(flag2<0){
            y->l = z;
        }else{
            y->r = z;
        }
    }
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

const int maxn = 310000;

int dp[maxn];

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	int n;
	cin>>n;
	int a[n+1];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i+1];
	}
	a[0]=a[1];
	fre(i,2,n){
		dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]) , dp[i-1]+abs(a[i-1]-a[i]));
	}
	output(dp[n]);
	return 0;
}

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

def func(n):
    """
    nの約数が８個だったらTrueを返す関数
    """
    yaku = []
    for i in range(1, n+1):
        if n % i == 0:
            yaku.append(i)
    
    return True if len(yaku) == 8 else False

count = 0
for n in range(1, N+1):
    if n % 2 == 0:
        continue
    else:
        if func(n):
            count += 1

print(count) 

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author Nikunj
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SandGlass solver = new SandGlass();
        solver.solve(1, in, out);
        out.close();
    }

    static class SandGlass {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int X = in.scanInt();
            int t = in.scanInt();
            out.println(Math.max(0, X - t));
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    }
    int dp[n][3];
    for(int i=0;i<3;i++)
        dp[0][i]=a[0][i];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            if(j==0) dp[i][j]=a[i][j]+max(dp[i-1][j+1],dp[i-1][j+2]);
            else if(j==1) dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j+1]);
            else if(j==2) dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j-2]);
        }
    }
    int max=INT_MIN;
    for(int i=0;i<3;i++){
        if(max<dp[n-1][i])
            max=dp[n-1][i];
    }
    cout<<max;
    return 0;
}


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

int main(){
    string str;
    
    while(1){
        getline(cin,str);
        if(str == "END OF INPUT") break;
        
        int cnt = 0;
        for(int i = 0 ; i < str.size() ; i++){
            cnt++;
            if(str[i] == ' '){
                cout << cnt-1;
                cnt = 0;
            }
            if(str[i] == str[str.size()-1] && i == str.size()-1) cout << cnt << endl;
        }
    }
    
    return 0;
}

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

int const maxn = 200000 + 10;

int n;
int a[maxn];
int b[maxn];


int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }

  sort(b+1, b+n+1);

  int LM = b[n/2];
  int RM = b[n/2 + 1];

  for (int i = 1; i <= n; i++) {
    if (a[i] <= LM) cout << RM << endl;
    else cout << LM << endl;
  }


  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 998244353;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int gauss_jordan(vector<bitset<300>> &a){
    int n = a.size(), m = 300;
    int cnt = 0;
    for (int i = 0; i < m && cnt != n; ++i) {
        int p = cnt;
        for (int j = cnt; j < n; ++j) {
            if(a[j][i]){
                p = j;
                break;
            }
        }
        if((a[p][i]) == 0) continue;
        swap(a[cnt], a[p]);
        for (int j = 0; j < n; ++j) {
            if(cnt == j) continue;
            if(a[j][i]) a[j] ^= a[cnt];
        }
        cnt++;
    }
    a.erase(a.begin()+cnt, a.begin()+n);
    return cnt;
}

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<bitset<300>> v(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int x;
            scanf("%d" ,&x);
            if(x) v[i].set(j);
        }
    }
    int rank = gauss_jordan(v);
    ll ans1 = pow_(2, m-1, MOD), ans2 = MOD+pow_(2, n, MOD)-pow_(2, n-rank, MOD);
    cout << (ans1*ans2)%MOD << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    ll ap[a + 1], gp[b + 1], cp[c + 1], dp[c + 1], pap[a + 1], pgp[b + 1], pcp[c + 1];
    pap[0] = pgp[0] = pcp[0] = 0;

    for (ll i = 1; i <= a; i++)
        cin >> ap[i];
    sort(ap + 1, ap + a + 1);
    reverse(ap + 1, ap + a + 1);
    for (ll i = 1; i <= a; i++)
        pap[i] = pap[i - 1] + ap[i];

    for (ll i = 1; i <= b; i++)
        cin >> gp[i];
    sort(gp + 1, gp + b + 1);
    reverse(gp + 1, gp + b + 1);
    for (ll i = 1; i <= b; i++)
        pgp[i] = pgp[i - 1] + gp[i];

    for (ll i = 1; i <= c; i++)
        cin >> cp[i];
    sort(cp + 1, cp + c + 1);
    reverse(cp + 1, cp + c + 1);
    for (ll i = 1; i <= c; i++)
        pcp[i] = pcp[i - 1] + cp[i];

    ll i = x, j = y, k, ans1, ans2;
    dp[0] = pap[x] + pgp[y];
    for (k = 1; k <= c; k++)
    {
        if (i == 0 && j == 0)
            break;
        ans1 = ans2 = -1;
        if (i > 0)
            ans1 = pcp[k] + pap[i - 1] + pgp[j];
        if (j > 0)
            ans2 = pcp[k] + pap[i] + pgp[j - 1];
        if (ans1 > ans2)
            i--;
        else
            j--;
        dp[k] = max(ans1, ans2);
    }
    ll maxi = INT_MIN;
    for (ll i = 0; i < c + 1; i++)
    {
        maxi = max(maxi, dp[i]);
    }
    cout << maxi << endl;
    return 0;
}

Measured memory_bytes: 5760
using System;
class Program
{
	static void Main(string[] args)
	{
       string[] input = Console.ReadLine().Split(' ');
       int R = int.Parse(input[0]);
       int G = int.Parse(input[1]);
       int B = int.Parse(input[2]);
       int N = int.Parse(input[3]);
      
       int result = 0;
       for(int i = 0; i <= 3000; i++)
       {
         for(int j = 0; j <= 3000; j++)
         {
             int rg = i*R + j*G;
             if(N >= rg && (N-rg) % B == 0) result++;
         }
       }
      
       Console.WriteLine("{0}", result);
	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<cassert>
#define N 8
#define FREE -1
#define NON 1
using namespace std;

vector<int> row(N);
vector<int> col(N);
vector<int> pos(2*N-1);
vector<int> neg(2*N-1);

bool board[N][N];

void initialize(){
  for(int i = 0; i < N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  
  for(int i=0; i < 2*N-1; i++){
    pos[i] = FREE;
    neg[i] = FREE;
  }
}
 
void printBoard(){
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(board[i][j]){
	if(row[i] != j) return;
      }
    }
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cout<<((row[i] == j) ? "Q":".");
    }
    
    cout<<endl;

  }
}
 
void recursive(int i){
  if(i == N){
    printBoard();
    return;
  }
 
  for(int j = 0; j < N; j++){
    if(NON == col[j] || NON == pos[i+j] || NON == neg[i-j+N-1]){
      continue;
    }
    
    row[i] = j;
    col[j] = NON;
    pos[i+j] = NON;
    neg[i-j+N-1] = NON;
    
    recursive(i+1);

    row[i] = FREE;
    col[j] = FREE;
    pos[i+j] = FREE;
    neg[i-j+N-1] = FREE;
  }
}
 
int main(){
  initialize();
 
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      board[i][j]=false;
    }
  }

  int k;
  cin >> k;
  
  for(int i = 0; i < k; i++){
    int r, c;
    cin >> r >> c;
    
    board[r][c]=true;
    
  }
  
  recursive(0);

  return 0;
  
}



Measured memory_bytes: 3120
D, G = map(int,input().split())
PC = [list(map(int,input().split())) for _ in range(D)]

ans = 1e9
for i in range(1 << D):
  point = 0
  cnt = 0
  for j in range(D):
    if (i >> j)& 1:
      point += PC[j][0]*(j+1)*100+PC[j][1]
      cnt += PC[j][0]
    else:
      tmp = j
  if point < G:
    R = G-point
    if (PC[tmp][0]-1)*(tmp+1)*100 < R:
      continue
    cnt += -(-R//(100*(tmp+1)))
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3064
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
b = [list(map(int,input().split())) for _ in range(m)]
for x in a:
  ans,dist = -1,1000000000
  for i in range(m):
    d = abs(x[0]-b[i][0])+abs(x[1]-b[i][1])
    if d < dist:
      ans, dist = i+1,d
  print(ans)

Measured memory_bytes: 9196
N = gets.to_i
s =[]
hash = {}
ans = 0
N.times do |i|
  # 入力を受け取って昇順ソート
  s = gets.chomp.split("").sort.join
  # 登場回数をハッシュに記録
  if hash.has_key?(s)
    hash[s] += 1
    ans += hash[s]
  else
    hash[s] = 0
  end 
end

puts ans


Measured memory_bytes: 18464
#include <bits/stdc++.h>   
using namespace std;
#define N 3005   
#define REP(i, n) for(int i=0; i<n; i++)
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(b%a==0){
    printf("%d",a+b);
    }else{
    printf("%d",b-a);
    }
}



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

#define ll long long int
#define hell 998244353
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

void solve()
{
    string s,t;
    cin>>s>>t;
    int l1,l2;
    l1=s.length();
    l2=t.length();
    int dp[l1+1][l2+1];
    for(int i=0;i<=l1;i++)
    {
        for(int j=0;j<=l2;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=l1,j=l2;
    string ans="";
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 35456
//http://arc071.contest.atcoder.jp/tasks/arc071_b
#include <iostream>
using namespace std;

typedef long long ll;

int n,m;
ll x[100000] = {};
ll y[100000] = {};
const int mod = 1000000007;

void read_input(){
    int i;
    cin >> n >> m;
    for(i=0; i<n; i++){
        cin >> x[i];
    }
    for(i=0; i<m; i++){
        cin >> y[i];
    }
}

int main(void){
    read_input();
    int i,j;
    ll sum_x = 0;
    ll sum_y = 0;
    for(i=0; i<n; i++){
        sum_x += ((2*i - n + 1) * x[i]);
    }
    for(i=0; i<m; i++){
        sum_y += ((2*i - m + 1) * y[i]);
    }
    sum_x %= mod;
    sum_y %= mod;
    cout << (sum_x * sum_y) % mod << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100
#define MAXW 100000
#define LL long long int

int N, W, t, w[MAXN + 3], v[MAXN + 3];
LL dp[2][MAXW + 3];

int main() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++)
        cin >> w[i] >> v[i];

    t = 0;
    memset(dp, 0, sizeof(dp));
    
    for (int i = 1; i <= N; i++) {
        t = 1 - t;
        for (int c = 1; c <= W; c++) {
            dp[t][c] = dp[1 - t][c];
            if (c >= w[i])
                dp[t][c] = max(dp[t][c], v[i] + dp[1 - t][c - w[i]]);
        }
    }

    cout << dp[t][W] << endl;
}


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

int main()
{
	long long int n,i,s=0;
	cin >> n;
	long long int a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
		int t=0;
		if(a[i]%2==0)
		{
			while(a[i]%2==0)
			{
				a[i]/=2;
				t++;
			}
		}
		s+= t ;
	}
	cout << s << endl;


}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

char let[62];
vector<string> res, res2;
int tot;

int main() {
    forn(i, 26) {
        let[i] = 'a' + i;
        let[26 + i] = 'A' + i;
    }
    forn(i, 10) {
        let[52 + i] = '0' + i;
    }
    tot = 0;
    forn(i, 62) {
//        if (!(let[i] >= 'a' && let[i] <= 'c')) {
//            continue;
//        }
        string s(128, let[i]);
        cout << "? " << s << endl;
        int cnt;
        cin >> cnt;
        cnt = 128 - cnt;
        if (cnt > 0) {
            res.pb(string(cnt, let[i]));
            tot += cnt;
        }
    }
    int n = res.size();
    while (n > 1) {
        res2.clear();
        forn(i, n / 2) {
            string a = res[2 * i];
            string b = res[2 * i + 1];
            int pos = 0;
            forn(j, (int)b.size()) {
                while (true) {
                    assert(pos <= (int)a.length());
                    string na = a.substr(0, pos) + b.substr(j, 1) + a.substr(pos);
                    cout << "? " << na << endl;
                    int cnt;
                    cin >> cnt;
                    cnt = tot - cnt;
                    ++pos;
                    if (cnt == (int)na.length()) {
                        a = na;
                        break;
                    }
                }
            }
            res2.pb(a);
        }
        if (n % 2 == 1) {
            res2.pb(res[(int)res.size() - 1]);
        }
        res = res2;
        n = res.size();
    }
    cout << "! " << res[0] << endl;
    return 0;
}


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


int main(int argc, char const *argv[])
{
	int n,d;
	cin>>n>>d;
	int arr[n][d];
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < d; ++j)
		{
			cin>>arr[i][j];
		}
	}
	int cnt=0;
	for (int i = 0; i < n-1; ++i)
	{
		for (int j = i+1; j < n; j++)
		{
			int ans=0;
			for (int k = 0; k < d; ++k)
			{
				ans += (arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]);
			}
			int srt = pow(ans,0.5);
			if(srt*srt==ans) cnt++;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(void)
{
	int n,a[10010];
	int ans=0;
	cin >> n;
	for(int i=1;i<=n;i++)cin >> a[i];
	
	for(int i=1;i<=n;i++)
	{
		for(;;)
		{
			if(a[i]%2==1)break;
			a[i]/=2;
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

res = 0
flag = 0
ans = 0
Sum = 0

for i in range(n-k+1):
    if i == 0:
        Sum = sum(p[i:i+k])
        res = Sum
        continue
    
    Sum -= p[i-1]
    Sum += p[i+k-1]
    
    if res < Sum:
        res = Sum
        flag = i
        
for i in range(k):
    if p[flag+i]%2 == 0:
        ans += (p[flag+i]/2) + 0.5
    else:
        ans += (p[flag+i] + 1)/2
        
print(ans)


Measured memory_bytes: 24804