akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=2e5+10,M=5e5+10,T=1e6+5,mod=924844033,sqr=5,sqrinv=554906420;
#define int long long
int n,u,v,siz[N],limit,lg,E,ot[M],ne[M],g[N];
int fac[N],inv[N],infac[N];
int a[T],b[T],r[T];
inline int ksm(int x,int y){
    int res=1;
    while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod; y>>=1;}
    return res;
}
inline void add(int &u,int &v){ot[++E]=v,ne[E]=g[u],g[u]=E;}
inline void init(){
    cin>>n;
    for(int i=1;i<n;i++){
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
}
void dfs(int x,int fa){
    siz[x]=1;
    for(int i=g[x];i;i=ne[i]){
        int to=ot[i];
        if(to==fa)continue;
        dfs(to,x); siz[x]+=siz[to];
        a[siz[to]]++;
    }
    a[n-siz[x]]++;
}
inline int solve_complex(int x,int tp){
    if(~tp)return ksm(sqr,x);
    else return ksm(sqrinv,x);
}
inline void DFT(int *A,int tp){
    for(int i=0;i<limit;i++)if(i<r[i])swap(A[i],A[r[i]]);
    for(int len=1;len<limit;len<<=1){
        int wn=solve_complex((mod-1)/(2*len),tp);
        for(int j=0;j<limit;j+=len<<1){
            int w=1;
            for(int k=0;k<len;++k,w=1ll*w*wn%mod){
                int x=A[j+k],y=1ll*w*A[j+k+len]%mod;
                A[j+k]=x+y,A[j+k+len]=x-y;
                if(A[j+k]>=mod)A[j+k]-=mod;
                if(A[j+k+len]<0)A[j+k+len]+=mod;
            }
        }
    }
}
inline void pre(){
    register int i; dfs(1,0);
    fac[0]=1;for(i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    inv[1]=1;for(i=2;i<=n;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
    infac[0]=1;for(i=1;i<=n;++i) infac[i]=1ll*infac[i-1]*inv[i]%mod;
}
inline void work(){
    a[0]=0; register int i;
    for(i=0;i<=n;i++)a[i]=1ll*a[i]*fac[i]%mod;
    for(i=0;i<=n;i++)b[i]=infac[n-i];
    limit=1; while(limit<=2*n)limit<<=1,++lg;
    for(i=1;i<limit;i++)r[i]=((r[i>>1]>>1)|((i&1)<<(lg-1)));
    DFT(a,1),DFT(b,1);
    for(i=0;i<limit;i++)a[i]=1ll*a[i]*b[i]%mod;
    DFT(a,-1);
    int INV=ksm(limit,mod-2);
    for(i=1;i<=n;i++)a[i+n]=1ll*a[i+n]*INV%mod*infac[i]%mod;
    for(i=1;i<=n;i++)a[i]=1ll*fac[n]*infac[i]%mod*infac[n-i]%mod*n%mod;
    for(i=1;i<=n;i++){
        a[i]-=a[i+n];
        if(a[i]<0)a[i]+=mod;
    }
    for(i=1;i<=n;i++)printf("%d\n",a[i]);
}
signed main(){
    init();pre();work();return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	printf("%d\n", (n * (n - 1) + m * (m - 1)) / 2);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    int cnt=0;
    for (int i=1; i<n; i++) {
        if(a[i-1]==a[i]){
            if(a[i]+1==a[i+1]){
                a[i]+=2;
                cnt++;
            }else{
                a[i]++;
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a, b, c, d;
  d = n % 10;
  c = (n/10) % 10;
  b = (n/100) % 10;
  a = (n/1000);

  if ((a == b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  long long ans = 1;
  int k = 1000000007;
  for(int i = 1; i <= n; i++){
    ans = (ans * i) % k;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
# frozen_string_literal: true

# Generated by AtcoderGreedy on 2018-05-05
# ABC096 B
# Your code here
$a, $b, $c = gets.chomp.split(' ').map(&:to_i)
$K = gets.chomp.to_i

k = 2**$K

puts [$a, $b, $c].reduce(:+) + [$a, $b, $c].max * k - [$a, $b, $c].max


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

typedef long long ll;

int main(){
	int n,d;
	cin >> n >> d;
	vector<vector <int>> x(n,vector<int>(d));

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

	int count = 0;

	for (int i = 0; i < n-1; i++){
		for (int j = i+1; j < n; j++){
			double kyori = 0;
	
			for (int k = 0; k < d ; k++)
			{
				//cout << x[i][k] << x[j][k] << endl;
				kyori += (x[i][k]- x[j][k])*(x[i][k]- x[j][k]);
				//cout << "kyori" << kyori<< endl;
			}
			kyori = pow(kyori,0.5);
			//cout << "kyori" << kyori<< endl;
			if(ceil(kyori) == floor(kyori)){
				count += 1;
			}
		}
		
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,r,i,k,p,c,cards[50],cards2[50],j;
  while(1){
  scanf("%d %d",&n,&r);
  if(n==0&&r==0)break;
  for(i=n-1,j=1;i>=0;i--,j++)cards[i]=j;
  for(i=0;i<r;i++){
    scanf("%d %d",&p,&c);
    for(j=0;j<p-1;j++)cards2[j]=cards[j];
    for(j=p-1,k=0;j<c+p-1;j++,k++)cards[k]=cards[j];
    for(j=c,k=0;j<c+p-1;j++,k++)cards[j]=cards2[k];
  }
  printf("%d\n",cards[0]);
  }
  return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {

        int N = nextInt();
        int K = nextInt();
        int H[] = new int[N];

        for(int i=0; i<N; i++){
            H[i] = nextInt();
        }
        
        Arrays.sort(H);        

        long sum=0;
        
        if((N-K)<=0){
    	    out.println(sum);
    	    return;
        }else{
            
        }

        for(int i=0; i<N-K; i++) {
            sum += (long)H[i];
        }
        
	    out.println(sum);
	    return;
    }        

	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 58196
k,a,b = map(int,input().split())

if a>=b-2 or a >= k:
  print(k+1)


else: 
  tataku = (a-1)
  nokori = k-(a-1)
  koukan_times = nokori//2

  bisuket = a + (b-a)*koukan_times

  if nokori%2 == 1:
    print(bisuket+1)
  else:
    print(bisuket)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll H,W,h,w,i,j,a;
	cin>>H>>W>>h>>w;
	if(H%h==0 && W%w==0)
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes\n";
	for(i=1;i<=H;i++)
	{
		for(j=1;j<=W;j++)
		{
			if(j%w==0 && i%h==0)
			{
				a=-1000*(w*h-1)-1;
			}
			else
			{
				a=1000;
			}
			cout<<a<<" ";
		}
		cout<<endl;
	}
	return 0;
}

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

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    for (int i = l; i <= r; i++)
    {
        if(i%d == 0)cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int a[200001] = {};
int b[200001] = {};

int main(void)
{
	string s;
	cin >> s;

	int a = count(s.begin(), s.end(), 'a');
	int b = count(s.begin(), s.end(), 'b');
	int c = count(s.begin(), s.end(), 'c');

	if (abs(a - b) <= 1 && abs(c - b) <= 1 && abs(c - a) <= 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <bitset>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define rrep(i,a,b) for(ll i=a-1;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define popcount __builtin_popcount
#define LIST(a) memset(a, 0, sizeof(a))

int main(void){
    vector<int> memo;
    vector<int> h;
    ll n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    h = vector<int>(n);
    memo = vector<int>(n, -1);
    rep(i, 0, n){
        cin >> h[i];
    }
    memo[0] = 0;
    memo[1] = abs(h[1] - h[0]);
    rep(i, 2, n){
        memo[i] = min(memo[i - 1] + abs(h[i] - h[i - 1]), memo[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << memo[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef map<ll,ll> mll;
typedef set<ll> sll;

#define se second
#define fi first
#define pb push_back
const ll MOD = 1e9+7;
const ll NMAX = 5*1e9+1;
ll n,m;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char s;
	cin>>s;
	s++;
	cout<<s;
}


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

const int maxn = 1e6 + 10;
typedef long long int ll;
int a[maxn];
void solved(){
    int n,m;cin>>n>>m;
    for(int i = 1; i <= m; i++)cin>>a[i];
    ll ans = 0;
    for(int i = 1; i <= m; i++){
        ans += a[i];
    }
    if(n >= ans){
        cout<<n - ans<<endl;
    }else{
        cout<<"-1"<<endl;
    }
}
int main(){
    solved();
    return 0;
}

Measured memory_bytes: 3672
a = []
while True:
    x = list(map(int, input().split()))
    a.append(x)
    if x[0] == 0 and x[1] == 0:
        break
 
isize = len(a)
for i in range(isize):
    jsize = a[i][0]
    for j in range(jsize):
        ksize = a[i][1]
        for k in range(ksize):
            if j % 2 == 0:
                if k % 2 == 0:
                    print('#', end='')
                else:
                    print('.', end='')
            else:
                if k % 2 == 0:
                    print('.', end='')
                else:
                    print('#', end='')
        print(end='\n')
    
    if isize - 1 > i:
        print(end='\n')


Measured memory_bytes: 7012
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	cin >> input;

	vector<bool> alphabet(26, false);
	for (int i = 0; i < input.size(); i++)
	{
		alphabet[input[i] - 'a'] = true;
	}

	for (int i = 0; i < 26; i++)
	{
		if (!alphabet[i])
		{
			cout << char(i + 'a') << endl;
			return;
		}
	}

	cout << "None" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

bool isprime(ll n){
  if (n == 0 || n == 1)
    return false;

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

  return true;
}

int main(void){
  ll n;
  cin >> n;
  
  ll ans = 1;
  for (ll i = 0; i <= n; i++){
    if (isprime(i)){
      ll t = 1;
      ll j = i;
      while (j <= n){
        t += n / j;
        j *= i;
      }

      ans = ans * t % MOD;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main(){
	int dx[512]={0};
	int dy[512]={0};
	dy['N']=1;
	dy['S']=-1;
	dx['E']=1;
	dx['W']=-1;
	int n;
	while(cin>>n,n){
		int mp[21][21]={0};
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			mp[x][y]=1;
		}
		int m;
		cin>>m;
		
		int X=10,Y=10;
		for(int i=0;i<m;i++){
			int l;
			char c;
			cin>>c>>l;
			for(int j=0;j<l;j++){
				X+=dx[c];
				Y+=dy[c];
				if(mp[X][Y]){
					mp[X][Y]=0;
					n--;
				}
			}
		}
		if(n)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1156
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int c_cnt = 0,isLarge = 0;
	char s[13];
	bool f1 = false,f2 = false,f3 = false;

	scanf("%s",s);
	if(s[0] == 'A')	f1 = true;
	for (int i = 2; i <= strlen(s) - 2; ++i)
	{
		if(s[i] == 'C')	++c_cnt;
	}
	if(c_cnt == 1)	f2 = true;
	for (int i = 0; i < strlen(s); ++i)
	{
		if(s[i] < 'a')	++isLarge;
	}
	if(isLarge <= 2)	f3 = true;
	if(f1 & f2 & f3)	puts("AC");
	else puts("WA");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int B = 61;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	map<int, int> mp;
	for (int i = N - 1; i >= 0; i--) {
		mp[A[i]] = i;
	}
	vector <vector<int> > ne(N, vector<int>(B, 0));
	for (int i = N - 1; i >= 0; i--) {
		ne[i][0] = mp[A[i]] - i;
		if (ne[i][0] <= 0)ne[i][0] += N;
		mp[A[i]] = i;
	}
	int mx = N * K + 5;
	for (int i = 1; i < B; i++) {
		for (int j = 0; j < N; j++) {
			int t = (ne[j][i - 1] + j + 1) % N;
			ne[j][i] = ne[j][i - 1] + 1 + ne[t][i - 1];
			if (ne[j][i] >= mx)ne[j][i] = mx;
		}
	}
	int cur = 0;
	int rest = N * K;
	for (int i = B - 1; i >= 0; i--) {
		if (ne[cur][i] < rest) {
			rest -= ne[cur][i] + 1;
			cur = (cur + ne[cur][i] + 1) % N;
		}
	}
	cerr << rest << endl;
	vector<int> res;
	if (rest > 0) {
		while (cur < N) {
			res.push_back(A[cur]);
			cur++;
			while (cur < N && cur + ne[cur][0] < N) {
				cur += ne[cur][0] + 1;
			}
		}
	}
	for (int i = 0; i < res.size(); i++) {
		if (i > 0)cout << " ";
		cout << res[i];
	}
	cout << endl;

}

Measured memory_bytes: 118896
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int amari;
		while(0 < 1) {
			amari = num1 % num2;
			if(amari == 0) break;
			num1 = num2;
			num2 = amari;
		}
		System.out.println(num2);
		sc.close();
	}	
}


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

using namespace std;

using ll = long long;

int main() 
{
    int n; cin >> n;
    vector<int> a(n);
    for (auto &e : a)
        cin >> e;
    vector<int> current;
    for (auto i = a.rbegin(); i != a.rend(); i++)
    {
        auto v = upper_bound(current.begin(), current.end(), *i);
        if (v == current.end())
            current.push_back(*i);
        else
        {
            *v = *i;
        }
    }
    cout << current.size();
    return 0;
}

Measured memory_bytes: 1276
import re
a, b = map(int, input().split())
s = input()
if s[a] == '-' and len(s) == a + b + 1:
  s = re.sub(r'-', '', s)
  if re.fullmatch(r'[0-9]+', s) and len(s) == a + b:
    print('Yes')
  else:
    print('No')
else:
  print('No')

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

int main() {
  int N;
  cin >> N;
  int AC=0, WA=0, TLE=0, RE=0;


  for(int i=0; i<N;i++){
    string a;
    cin >> a;
    if(a=="AC"){
      AC++;
    }else if(a=="WA"){
      WA++;
    }else if(a=="TLE"){
      TLE++;
    }else if(a=="RE"){
      RE++;
    }
  }


  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;


}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define print0(a)           cout<<a<<"\n"
#define print1(a)           cout<<a<<' '
#define print2(a,b)         cout<<a<<" "<<b<<" ";
#define print3(a,b,c)       cout<<a<<" "<<b<<" "<<c<<" ";
#define print4(a,b,c,d)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 1e18;
vector<int> g[N];
int h,w;
/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    
    // string s1,s2;
    // cin>>s1>>s2;
    // freopen(s1,"r",stdin);
    // freopen(s2,"w",stdout);
    
    FastIO;
    int T=1;
   // cin>>T;
    while(T--)
    {
       int n;
       cin>>n;
       vi a(n);
       cin>>a;
       MAP mp;
       for(auto it:a)mp[it]++;
       int ans = INT_MIN;
       for(auto it:a)
       {
           int val=it;
           ans = max(ans,mp[it]+mp[it-1]+mp[it+1]);
       }
       cout<<ans<<"\n";
       

      
     


       
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||
*/



Measured memory_bytes: 11648
K = int(input())

def list2int(digits):
    return int("".join(map(str, digits)))

def int2list(n):
    return list(map(int, str(n)))

def search(digits):
    ret = []
    v = digits[-1]
    for d in [-1, 0, 1]:
        if 0 <= v+d <= 9:
            ret.append(list2int(digits + [v+d]))
    return(ret)

result = list(range(1, 9+1))

i = 0
while len(result) < K:
    digits = int2list(result[i])
    result.extend(search(digits))
    i += 1

print(result[K-1])


Measured memory_bytes: 12872
import copy
def calcmax(a,b,fst,scd,n):
    for i in xrange(n):
        if fst == a[i]:
            count = i

    for i in xrange(n):
        if count == i:
            print scd
        else:
            print fst

if __name__ == '__main__':
    n = int(raw_input())
    a = [int(raw_input()) for i in xrange(n)]
    print("")

    fst = max(a)

    b = copy.deepcopy(a)
    b.remove(fst)

    scd = max(b)

    calcmax(a,b,fst,scd,n)


Measured memory_bytes: 36272
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

struct C{
	double r,x,y;
	C(double r,double x,double y) : r(r) , x(x) , y(y) {}
};

bool cmp_x(const C &a,const C &b){ return a.x == b.x ? a.y < b.y : a.x < b.x ; }
bool cmp_y(const C &a,const C &b){ return a.y == b.y ? a.x < b.x : a.y < b.y ; }

double dist(const C &a,const C &b){
	double x = a.x - b.x;
	double y = a.y - b.y;
	return sqrt( x * x + y * y );
}
int main(){
	int n;
	while(cin >> n && n){
		vector<C> a,b;
		for(int i = 0 ; i < n ; i++){
			double r,x,y;
			cin >> r >> x >> y;
			a.push_back(C(r,x,y));
			b.push_back(C(r,x,y));
		}
		double ans = 1e15;
		sort(a.begin(),a.end(),cmp_x);
		sort(b.begin(),b.end(),cmp_y);
		for(int i = 0 ; i < n ; i++){
			for(int j = max(0,i-25) ; j < min(i+25,n) ; j++){
				if(i!=j) ans = min(ans,dist(a[i],a[j])-a[i].r-a[j].r);
			}
			for(int j = max(0,i-25) ; j < min(i+25,n) ; j++){
				if(i!=j) ans = min(ans,dist(b[i],b[j])-b[i].r-b[j].r);
			}
		}
		printf("%.7f%c",ans,10);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int n;

	cin >> n;

	repc(i, 1, n) {
		bool p = false;

		if (i % 3 == 0) p = true;
		else {
			int x = i;

			while (x > 0) {
				if (x % 10 == 3) {
					p = true;
					break;
				}
				x /= 10;
			}
		}

		if (p) cout << ' ' << i;
	}

	cout << endl;

	return 0;
}



Measured memory_bytes: 3088
#include <stdio.h>
int main(){
  int k;
  int aa=0;
  scanf("%d",&k);
  for(int i=1;i<k;i++){
    if(i+1<=k)aa+=1;
    for(int j=i+1;j<k;j+=2){
      if(j+2<=k)aa+=1;
    }
  }
  printf("%d\n",aa);
  return 0;
}


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

namespace abc119d
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = ReadIntList().OrderByDescending(n=>n).ToList();
            var ans = 0;
            if(AB[0] - AB[1] >= 2)
            {
                ans = AB[0] * 2 - 1;
            }
            else
            {
                ans = AB[0] + AB[1];
            }
            Console.WriteLine(ans);



#if DEBUG
            Console.ReadKey();
#endif
        }

        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
        private static double ReadDouble() => double.Parse(Console.ReadLine());
        private static List<double> ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
        private static long ReadLong() => long.Parse(Console.ReadLine());
        private static List<long> ReadLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
        private static int BinarySearch<Type>(IReadOnlyList<Type> s, Type target) // target 以下の最大要素のインデックスを返す
            where Type : IComparable
        {
            var lower = 0;
            var upper = s.Count - 1;
            while (upper - lower > 1)
            {
                var mid = lower + (upper - lower) / 2;
                if (s[mid].CompareTo(target) <= 0)
                {
                    lower = mid;
                }
                else
                {
                    upper = mid;
                }

            }
            return lower;
        }
    }
}


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

typedef long long ll;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

template <typename T> T gcd(T a, T b) {
	if (b == 0) return abs(a);
	T r; while ((r = a % b) != 0) a = b, b = r;
	return abs(b);
}
template <typename T> T lcm(T a, T b) {
	return a/gcd(a, b) * b;
}
template<class T> T lcm(const vector<T>& v) {
    T l = v[0]; for (ll i=1; i < v.size(); i++) l = lcm(l, v[i]);
    return l;
}


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

    int n; cin >> n;
    vector<ll> a(n); cin >> a;

    ll ans = lcm(a);
    cout << ans << endl;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
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; }

vector<long long> cnt(2020, 0);
string s;
int main() {
    cin >> s;
    int slen = s.length();
    long long ans = 0;

    cnt.at(0) = 1;
    long long p = 1;
    long long amari = 0;
    for(int i = slen-1; i >= 0; --i) {
        amari = (amari + (s.at(i)-'0')*p) % 2019;
        ans += cnt.at(amari);
        p = (p*10) % 2019;
        cnt.at(amari)++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3736
//
//  main.cpp
//  Exercise
//
//

#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <array>
#include <set>

using namespace std;

using ll_t = long long;

class UnionFind {
public:
    vector<size_t> parent;
    vector<size_t> rank;
protected:
    size_t findParent(size_t x) {
        if (parent[x] == x) {
            return x;
        } else {
            parent[x] = findParent(parent[x]);
            return parent[x];
        }
    }
public:
    explicit UnionFind(size_t size) {
        parent.resize(size);
        rank.resize(size);
        for (size_t i = 0; i < size; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }
    virtual ~UnionFind() {}
    void unite(size_t x, size_t y) {
        size_t px = findParent(x);
        size_t py = findParent(y);
        if (px == py) {
            return;
        }
        if (rank[px] < rank[py]) {
            parent[px] = py;
        } else if (rank[px] > rank[py]) {
            parent[py] = px;
        } else { // rank[px] == rank[py]
            parent[py] = px;
            rank[px]++;
        }
    }
    bool isSame(size_t x, size_t y) {
        return findParent(x) == findParent(y);
    }
};

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    
    vector<int> ps;
    ps.reserve(N);
    for (int i = 0; i < N; i++) {
        int p;
        scanf("%d", &p);
        ps.push_back(p);
    }
    
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int xi, yi;
        scanf("%d %d", &xi, &yi);
        uf.unite(xi-1, yi-1);
    }
    
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (uf.isSame(i, ps[i]-1)) {
            cnt++;
        }
    }
    
    printf("%d", cnt);
    
    printf("\n");
    return 0;
}




Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

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

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	double t, x;
	cin >> t >> x;
	printf("%.10lf", t / x);
	return 0;
}












Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W=map(int,input().split())
a=[input() for i in range(H)]
l=[0]*W
for i in a:
    for j in range(W):
        if i[j]=="#":
            l[j]+=1
for i in a:
    if "#" in i:
        for j in range(W):
            if l[j]:
                print(i[j],end="")
        print()

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

int main() {
  int n, a, b;
  cin>>n>>a>>b;
  string s;
  cin>>s;

  vector<bool> ans(n);
  for (int i=0; i<n; i++) ans[i] = false;
  int cnt = 0;
  int cnt2 = 0;
  for (int i=0; i<n; i++) {
    if (s[i] == 'a' && cnt < a + b) {
      ans[i] = true;
      ++cnt;
    } else if (s[i] == 'b' && cnt < a + b && cnt2 < b) {
      ans[i] = true;
      ++cnt;
      ++cnt2;
    }
  }
  for (bool i: ans) {
    if (i) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  }
}

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

const int N = 100005;

int L[N], R[N], C[N];

int n, m;

using ll = long long;
ll a[N];

vector <int> v[N];

const ll inf = 0x3f3f3f3f3f3f3f3f;

void give(int k, ll v) {
    k = n + 1 -  k;
    a[k] = v;
}
ll calc(int k) {
	k = n + 1 - k;
    ll res = inf;
    for ( ; k; k -= k & -k) res = min(res, a[k]);
    return res;
}
void update(int k, ll val) {
	k = n + 1 - k;
	for ( ; k <= n; k += k & -k) a[k] = min(a[k], val);
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; i ++) scanf("%d %d %d", &L[i], &R[i], &C[i]), v[L[i]].push_back(i);
    for (int i = 1; i <= n; i ++) give(i, inf);
    give(1, 0);
    for (int i = 1; i <= n; i ++) {
        ll val = calc(i);
        for (auto x : v[i]) {
            int r = R[x], c = C[x];
            update(r, val + c);
        }
    }
    ll ans = calc(n);
    if (ans == inf) ans = -1;
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10956
def read():
	return [int(i) for i in input().split(" ")]
N, x = read()
A = read()
ans = sum(A)
tempcost = ans
BC = A[:]
for i in range(1, N):
	BC = [BC[j - 1] if BC[j - 1] < BC[j] else BC[j] for j in range(N)] 
	tempcost = x * i + sum(BC)
	if(ans > tempcost):
		ans = tempcost

print(ans)


Measured memory_bytes: 3316
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  string S[] = {"delicious", "safe", "dangerous"};
  int x, a, b;
  cin >> x >> a >> b;
  if (a >= b) {
    cout << S[0] << endl;
    return;
  }
  
  b -= a;
  if (b <= x) cout << S[1] << endl;
  else cout << S[2] << endl;
}


Measured memory_bytes: 3520
#include <iostream>

using namespace std;

int euclid(int x, int y) {
    int z;
    while (true) {
        z = x % y;
        if (z == 0) {
            return y;
        }
        x = y;
        y = z;
    }
    return 0;
}

int main() {
    long x, y;
    cin >> x >> y;

    cout << euclid(x, y) << "\n";
}

Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int w, h, n;
	cin >> w >> h >> n;
	int x1 = 0, x2 = w, y1 = 0, y2 = h;
	rep(_, n) {
		int x, y, type;
		cin >> x >> y >> type;
		if (type == 1) chmax(x1, x);
		else if (type == 2) chmin(x2, x);
		else if (type == 3) chmax(y1, y);
		else chmin(y2, y);
	}
	cout << max(0LL, x2 - x1)*max(0LL, y2 - y1) << endl;
}

Measured memory_bytes: 256
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let mut k: u128 = read();
    let v: Vec<usize> = (0..n).map(|_| read::<usize>() - 1).collect();
    let mut que = VecDeque::new();
    let mut seen = vec![false; n];
    let mut cur = 0;

    loop {
        if seen[cur] {
            while que[0] != cur {
                k -= 1;
                que.pop_front();

                if k == 0 {
                    println!("{}", que[0] + 1);
                    return;
                }
            }
            break;
        }
        que.push_back(cur);
        seen[cur] = true;
        cur = v[cur];
    }
    println!("{}", que[(k % que.len() as u128) as usize] + 1);
}

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

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

#define ll long long
#define vl vector<ll>
#define vll vector<vl>
#define P pair<ll, ll>

const int INF = 1e9;
const long double pi=3.14159265358979323846;

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	x/=a;
	if(x>=a*b/2.0)
	{
		x=a*b-x;
		double c=2.0*x/a;
		cout << setprecision(10) << fixed << atan(c/a)*180.0/pi << endl;
	}
	else
	{
		double c=2*x/b;
		double t=atan(c/b)*180.0/pi;
		cout << setprecision(10) << fixed << 90-t << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int64_t ans = 0;
  for(int i=0; i<N; i++){
    ans += vec.at(i)/2;
    if(i < N-1){
      if(vec.at(i) %2 == 1 && vec.at(i+1) > 0){
        ans++;
        vec.at(i+1)--;
      }
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
n = int(input())
m = n // 2
Data = list(map(int,input().split()))
Ans = []
if n % 2 == 0:
    for i in range(m):
        Ans.append(Data[n-1-i*2])
    for i in range(m):
        Ans.append(Data[2*i])
else:
    for i in range(m+1):
        Ans.append(Data[n-1-i*2])
    for i in range(m):
        Ans.append(Data[2*i+1])

for a in Ans:
    print(a,end=' ')


Measured memory_bytes: 26176
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int par[MAXN];
int main(){
    //freopen("file.in", "r", stdin);
	int n,q;
	cin>>n>>q;
	for(int i=1;i<=q;i++){
		int l,r;
		cin>>l>>r;
		par[l]++;par[r+1]--;	
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		par[i]+=par[i-1];
		ans+=(par[i]==q);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,L,sum=0;
    cin>>n>>L;
    vector<ll> a(n),left(n+1,0),right(n+1,0);
    for(ll i=0;i<n;i++){cin>>a.at(i);sum+=a.at(i);}
    for(int i=0;i<n;i++)left.at(i+1)+=left.at(i)+a.at(i);//左からの累積和
    bool flag=false;
    int l=0,r=0;
    for(int i=2;i<=n;i++){
     if(left.at(i)-left.at(i-2)>=L){
         flag=true;
         l=i;break;
     }
    }
if(flag){
    cout<<"Possible"<<endl;
for(int i=0;i<l-2;i++)cout<<i+1<<endl;
for(int i=a.size()-1;i>l-2;i--)cout<<i<<endl;
}
else cout<<"Impossible"<<endl;

}

Measured memory_bytes: 3200
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let op = s.next().unwrap().split("T").map(|a| a.len()).collect::<Vec<_>>();
	let x: i32 = s.next().unwrap().parse().unwrap();
	let y: i32 = s.next().unwrap().parse().unwrap();
	let mut xs = std::collections::BTreeSet::new();
	let mut ys = std::collections::BTreeSet::new();
	xs.insert(op[0] as i32);
	ys.insert(0);
	if op.len() > 1 {
		for (i, f) in op[1..].iter().enumerate() {
			let f = *f as i32;
			if i & 1 == 0 {
				ys = ys.into_iter().flat_map(|a| vec![a + f, a - f]).collect::<std::collections::BTreeSet<_>>();
			} else {
				xs = xs.into_iter().flat_map(|a| vec![a + f, a - f]).collect::<std::collections::BTreeSet<_>>();
			}
		}
	}
	if xs.contains(&x) && ys.contains(&y) {
		println!("Yes");
	} else {
		println!("No");
	}
}

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

#define maxn 100005
#define INF 0x3f3f3f3f
#define MINF 0x7fffffffffffffff
#define mod 1000000007
typedef long long ll;
using namespace std;

void slove()
{
	ll n, m, sum = 0, tmp;
	cin >> n >> m;
	for (int i = 0; i < m; i++) cin >> tmp, sum += tmp;
	if (n - sum >= 0) cout << n - sum;
	else cout << -1;
}

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

	slove();

	return 0;
}

Measured memory_bytes: 3652
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let x: usize = read();
    let mut ans = 1;
    for i in 2..x+1 {
      let mut tmp = i;
      while tmp * i <= x {
        tmp *= i;
        ans = max(ans, tmp);
      }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

struct UnionFind {
  vector<int> data;
  UnionFind(int n) {
    init(n);
  }
  void init(int n=1) {
    data.assign(n, -1);
  }
  int root(int x) {
    if (data[x] < 0) return x;
    return (data[x] = root(data[x]));
  }
  bool issame(int x, int y) {
    return (root(x) == root(y));
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int size(int x) {
    return (-data[root(x)]);
  }
};

template<typename T>
T kruskal(Edges<T> es, int n) {
  sort(es.begin(), es.end(), [](const edge<T> &a, const edge<T> &b) {
    return (a.cost < b.cost);
  });
  UnionFind tree(n);
  T ret = 0;
  for (auto e : es) {
    if (tree.merge(e.src, e.to)) ret += e.cost;
  }
  return ret;
}

struct P {
  ll x, y;
  int i;
};

bool comp1(P a, P b)
{
  if (a.x != b.x) return a.x < b.x;
  if (a.y != b.y) return a.y < b.y;
  return a.i < b.i;
}

bool comp2(P a, P b)
{
  if (a.y != b.y) return a.y < b.y;
  if (a.x != b.x) return a.x < b.x;
  return a.i < b.i;
}

int main()
{
  ll n; cin>>n;
  vector<P> p;
  rep(i, n) {
    ll x,y; cin>>x>>y;
    p.push_back(P{x, y, i});
  }

  Edges<ll> es;

  sort(p.begin(),p.end(),comp1);
  rep(i, n-1) {
    ll x = abs(p[i].x - p[i+1].x);
    ll y = abs(p[i].y - p[i+1].y);
    ll d = min(x, y);
    es.push_back(edge<ll>{p[i].i, p[i+1].i, d});
  }

  sort(p.begin(),p.end(),comp2);
  rep(i, n-1) {
    ll x = abs(p[i].x - p[i+1].x);
    ll y = abs(p[i].y - p[i+1].y);
    ll d = min(x, y);
    es.push_back(edge<ll>{p[i].i, p[i+1].i, d});
  }

  ll ans = kruskal(es, 2*n);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include<functional>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 30005
#define maxn 100005
typedef pair<int,int> PII;
typedef long long LL;

int n,m,k,ans;
struct Node{int to,next;}node[5005];
int head[2010],hcnt;
inline void add(int x,int y){
    node[hcnt].to=y;node[hcnt].next=head[x];
    head[x]=hcnt++;
}
int ct(int u,int fa,int num){
    if(num==0)return 1;
    int temp=1;
    for(int i=head[u];~i;i=node[i].next){
        int e=node[i].to;
        if(e==fa)continue;
        temp+=ct(e,u,num-1);
    }
    return temp;
}
int main(){
    //freopen("in.txt","r",stdin);
    int i,j,x,y;
    mst(head,-1);
    scanf("%d%d",&n,&k);
    for(i=2;i<=n;++i){
        scanf("%d%d",&x,&y);
        add(x,y);add(y,x);
    }
    ans=0;
    if(k&1){
        for(i=1;i<=n;++i){
            for(int l=head[i];~l;l=node[l].next){
                int e=node[l].to;
                if(e<=i)continue;
                int temp=ct(i,e,k/2)+ct(e,i,k/2);
                ans=max(ans,temp);
            }
        }
    }
    else{
        for(i=1;i<=n;++i){
            ans=max(ans,ct(i,-1,k/2));
        }
    }
    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c; cin >> a ;
	//string s,t; cin >> s>>t;
	if (a < 1200)cout << "ABC";
	else cout << "ARC";


	cout << endl;
	return 0;
}

Measured memory_bytes: 256