akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

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

  ll P = 1;
  
  ll ans = A[0]-1;
 
  for(int i = 1; i < N; i++){ 
    
    if( A[i] <= P+1){ 
      
      if( A[i] == P+1 ){ P++;}
      
    }
    else{
      
      ll x = P+1;
      
      if( A[i] % x == 0 ){ ans += (A[i]-x)/x;}
      
      else{ ans += (A[i]- (A[i]%(x)))/x;}
      
      
     
      
    }
    
  }
  
  cout << ans << endl;
  
  return 0;
} 

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n; cin>>n;

	string ans ="";

	while( n!=0){

		if(n%2 !=0){
			n--;
			ans = "1"+ans;
		}else {
			ans = "0"+ans;
		}

		n /=-2;
	}
	if(ans =="")ans ="0";

	writeln(ans);




}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdlib.h>

using namespace std;

int main(void){
    string s;//　4 <= s <= 10
    int x;
    int min_x = 1000;
    cin >> s;

    for(int i = 0; i < s.length()-2; i++){
        x = atoi(s.substr(i,3).c_str());
        min_x = min(abs(x-753), min_x);
    }
    cout << min_x;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN =1e5+10;
      
char s[MAXN][10+10];
long long int march[5+5];
int main()
{
	int n=0;
	scanf("%d",&n);//cin>>n;
	long long int ans=0;
	//long long m=0, a=0, r=0, c=0, h=0;
	//long long march[10];
	//char x[100005][10];
	for (int i=0; i<n; i++)
	{
		scanf("%s",&s[i]);//cin >> x[i];
	}
	for (int i=0; i<n; i++)
	{
		if(s[i][0]=='M')    march[0]++;
		if(s[i][0]=='A')    march[1]++;
		if(s[i][0]=='R')    march[2]++;
		if(s[i][0]=='C')    march[3]++;
		if(s[i][0]=='H')    march[4]++;
/*		switch(x[i][0])
		{
			case'M': m++;
					 break;
			case'A': a++;
					 break;
			case'R': r++;
					 break;
			case'C': c++;
					 break;
			case'h': h++;
					 break;
			default: break;
		}
*/
	}
	ans=march[0]*march[1]*march[2]+march[0]*march[1]*march[3]+march[0]*march[1]*march[4]+march[0]*march[2]*march[3]+march[0]*march[2]*march[4]+march[0]*march[3]*march[4]+march[1]*march[2]*march[3]+march[1]*march[2]*march[4]+march[1]*march[3]*march[4]+march[2]*march[3]*march[4];
	//s = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
printf("%lld", ans);//cout << s;//
	return 0; 
} 

Measured memory_bytes: 2176
program main
  implicit none
  character(10) :: s, q
  integer(8) :: n, i, ans, k, j, x
  integer, allocatable :: l(:)
  character(10), allocatable :: r(:)

  read(*,*) s
  n = len_trim(s)
  allocate(l(n-1))
  allocate(r(0:2**(n-1)-1))

  ans = 0
  do i = 0, 2**(n-1) -1
     q = ''
     do j = 1, n-1
        l(j) = mod(i,2**(n-j)) / 2**(n-j-1)
        write(q(j:j),'(i1)') l(j)
     end do
     r(i) = q
  end do
  
  do i = 0, 2**(n-1) -1
     q = r(i)
     k = 1
     do j = 1, n-1
        if(q(j:j) == '1')then
           read(s(k:j),'(i10)') x
           ans = ans + x
           k = j + 1
        end if
     end do
     read(s(k:n),'(i10)') x
      ans = ans + x
  end do
  write(*,*) ans
end program main



Measured memory_bytes: 2908
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    string s; cin >> s;
    ll n = s.size();
    vvl table(n+2,vl(26,n+1));
    for(ll i=n; i>=0; i--){
        rep(j,26){
            table[i][j] = table[i+1][j];
            if(i<n && s[i]-'a'==j) table[i][j] = i+1;
        }
    }
    vl dp(n+2,inf);
    dp[n+1] = 0;
    for(ll i=n; i>=0; i--){
        rep(j,26){
            chmin(dp[i], dp[table[i][j]] + 1);
        }
    }
    ll now = dp[0];
    ll id = 0;
    string ans;
    while(now > 0){
        rep(j,26){
            if(dp[table[id][j]] == now-1){
                now--;
                id = table[id][j];
                ans.push_back((char)(j+'a'));
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 50436
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define SZ 100001

int N;
int arr[SZ], X;

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	return (b ? gcd(b, a%b) : a);
}

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

	cin >> N >> X;
	int res = 1;
	for (int i = 0; i < N; ++i) {
		cin >> arr[i];
		int x = abs(X - arr[i]);
		if (i == 0) res = x;
		else res = gcd(res, x);
	}
	cout << res;

}

Measured memory_bytes: 640
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}
int h,w;
vector<string> mas;
vector<vector<int> > dist;

int gy[] = {1,0,-1,0};
int gx[] = {0,1,0,-1};

bool inside(int y,int x){
	return (y >= 0 && x >= 0 && y < h && x < w);
}

int bfs(){
	queue<pii> que;
	que.emplace(0,0);
	dist[0][0] = 1;
	while(!que.empty()){
		int y = que.front().first;
		int x = que.front().second;
		que.pop();
		rep(i,4){
			int ny = y + gy[i];
			int nx = x + gx[i];
			if(inside(ny,nx) && mas[ny][nx] == '.' && dist[ny][nx] > dist[y][x] + 1){
				que.emplace(ny,nx);
				dist[ny][nx] = dist[y][x] + 1;
			}
		}
	}
	return dist[h-1][w-1];
}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> h >> w;
	int white = 0;
	mas.resize(h);
	dist.resize(h,vector<int>(w,INF));
	rep(i,h){
		cin >> mas[i];
		rep(j,w){
			if(mas[i][j] == '.'){
				++white;
			}
		}
	}
	int ans = bfs();
	cout << ( ans == INF ? -1 : white - ans) << '\n';
	return 0;	
}


Measured memory_bytes: 256
//
//  floor_function.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define PI 3.14159265

int main(int argc, const char* argv[]) {

  ll a, b, n;
  std::cin >> a >> b >> n;

  ll x = b - 1;
  if (x > n) {
    x = n;
  }
  ll first = (a*x)/b;
  ll second = x/b;
  ll result = first - a * second;


  std::cout << result << std::endl;
  return 0;
}


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

struct Edge{int from,cost;};

int n,m,p,a,b,c,d[2509];
vector<Edge> e[2509];
bool ok[2509];

void dfs(int x){
    ok[x]=1;
    rep(i,e[x].size())if(!ok[e[x][i].from])dfs(e[x][i].from);
}

bool BellmanFord(int s){
    rep(i,n)d[i]=inf;
    d[s]=0;
    bool update;
    rep(i,n){
        update=false;
        rep(j,n){
            if(!ok[j+1])continue;
            rep(k,e[j+1].size()){
                if(d[e[j+1][k].from]==inf)continue;
                if(d[j+1]>d[e[j+1][k].from]+e[j+1][k].cost){
                    d[j+1]=d[e[j+1][k].from]+e[j+1][k].cost;
                    update=true;
                }
            }
        }
        if(!update)break;
    }
    return update;
}

int main(){
    cin>>n>>m>>p;
    rep(i,m){
        cin>>a>>b>>c;
        e[b].push_back({a,p-c});
    }

    dfs(n);

    if(BellmanFord(1))cout<<"-1\n";
    else cout<<-d[n]<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

vector<vector<long long> > a(3, vector<long long> (3));
vector<vector<bool> > atari(3, vector<bool> (3, false));

void mani(long long b){
    for(long long i = 0; i < 3; i++){
        for(long long j = 0; j < 3; j++){
            if(b == a[i][j]) atari[i][j] = true;
        }
    }
    return;
}

bool bingo(){
    if(atari[0][0] == true and atari[0][1] == true and atari[0][2] == true) return true;
    else if(atari[1][0] == true and atari[1][1] == true and atari[1][2] == true) return true;
    else if(atari[2][0] == true and atari[2][1] == true and atari[2][2] == true) return true;
    else if(atari[0][0] == true and atari[1][0] == true and atari[2][0] == true) return true;
    else if(atari[0][1] == true and atari[1][1] == true and atari[2][1] == true) return true;
    else if(atari[0][2] == true and atari[1][2] == true and atari[2][2] == true) return true;
    else if(atari[0][0] == true and atari[1][1] == true and atari[2][2] == true) return true;
    else if(atari[0][2] == true and atari[1][1] == true and atari[2][0] == true) return true;
    else return false;
}
int main(){
    for(long long i = 0; i < 3; i++){
        for(long long j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }

    long long n;
    cin >> n;

    for(long long i = 0; i < n; i++){
        long long b;
        cin >> b;
        mani(b);
    }

    if(bingo() == true) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;cin>>s;
  for(int i=0;i<5;i++)cout<<s[i];cout<<" ";
  for(int i=6;i<13;i++)cout<<s[i];cout<<" ";
  for(int i=14;i<19;i++)cout<<s[i];cout<<endl;
  
}


Measured memory_bytes: 256
def solve(str_in_arr):
    """
    Calculate common favorite foods number of people

    Paramaters
    ----------
    str_in_arr : list of str
        list of string from standard input
        A first element of the list is number of favorite foods.

    Returns
    -------
    num_common_favorite_food : int
        common favorite foods number
    """
    _num_person, _num_food = str_in_arr[0].split()
    num_person, num_food = int(_num_person), int(_num_food)
    fav_foods_list = str_in_arr[1::]

    favorite_foods = [0] * int(num_food)

    for fav_foods in fav_foods_list:
        foods = fav_foods.split()[1::]
        for food in foods:
            idx_food = int(food) - 1
            favorite_foods[idx_food] += 1

    num_common_favorite_food = 0
    for num_person_per_food in favorite_foods:
        if num_person_per_food == num_person:
            num_common_favorite_food += 1

    return num_common_favorite_food


def main():
    num_person_and_food = input()
    _num_person, _ = num_person_and_food.split()
    num_person = int(_num_person)

    std_in = [num_person_and_food if idx == 0 else input() for idx in range(num_person+1)]
    print(solve(std_in))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



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

  ll n, a, b;
  cin >> n >> a >> b;
  
  if ((b - a) % 2 == 0) cout << (b - a) / 2 << '\n';
  else {
    cout << min(a, n - b + 1) + (b - a - 1) / 2 << '\n';
  }




  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;

    vector<int> row(h), col(w);
    REP(i, h){
        cin >> row[i];
    }
    REP(i, w){
        cin >> col[i];
    }

    sort(row.rbegin(), row.rend());
    sort(col.rbegin(), col.rend());
    row.push_back(0);
    col.push_back(0);

    ll ans = 1, n = h*w;
    int r = 0, c = 0;
    while(n > 0){
        if(row[r] > n || col[c] > n){
            ans = 0;
            break;
        }else if(row[r] == n && col[c] == n){
            r = min(h, r+1);
            c = min(w, c+1);
        }else if(row[r] == n){
            r = min(h, r+1);
            ans *= c;
            ans %= MOD;
        }else if(col[c] == n){
            c = min(w, c+1);
            ans *= r;
            ans %=MOD;
        }else{
            ans *= ((r*c) - (h*w - n) + MOD)%MOD;
            ans %= MOD;
        }
        n--;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// 2012/05/26 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, p;
		cin >> n >> p;

		if(n==0&&p==0)
			break;

		int B = p;
		int C[50] = {0};

		int i = 0;

		while(true){
			if(B>0){
				B--;
				C[i]++;
			}
			else{
				B = C[i];
				C[i] = 0;
			}

			if(C[i]==p)
				break;

			i = (i+1)%n;
		}

		cout << i << endl;
	}

	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 200010;
const int ML = 62;
const ll INF = TEN(18) * 2;

ll ps[ML][maxn];

int main() {
	int N; ll K; cin >> N >> K;
	vi A(N); rep(i, N) cin >> A[i];

	rep(i, N) {
		A.pb(A[i]);
	}

	map<int, int> lf;

	for (int i = N * 2 - 1; i >= 0; --i) {
		if (i < N) {
			ps[0][i] = lf[A[i]] - i + 1;
		}
		lf[A[i]] = i;
	}

	rep(i, ML-1) {
		rep(j, maxn) {
			if (ps[i][j] == INF) {
				ps[i + 1][j] = INF;
			} else {
				ps[i + 1][j] = ps[i][j] + ps[i][(j + ps[i][j]) % N];
				if (ps[i + 1][j] > INF) ps[i + 1][j] = INF;
			}
		}
	}

	ll len = N * K;
	ll p = 0;

	for (int i = ML-1; i >= 0; --i) {
		if (p + ps[i][p % N] <= len) {
			p += ps[i][p % N];
		}
	}

	vi vec;
	set<int> st;

	for (; p < len; ++p) {
		int x = A[p % N];
		if (st.count(x)) {
			while (st.count(x)) {
				st.erase(vec.back());
				vec.pop_back();
			}
		} else {
			vec.pb(x);
			st.insert(x);
		}
	}

	rep(i, vec.size()) printf("%d%c", vec[i], i + 1 == vec.size() ? '\n' : ' ');

	return 0;
}

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

int main()
{
	int n;
	cin >> n;
	double odd = n/2;
	if(n%2) odd++;
	cout << fixed << setprecision(10) << odd/n << endl;
	return 0;
}


Measured memory_bytes: 256
<?php

while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	foreach ($input as $value) {
		$args[] = $value;
		if (count($args) >= 2) {
			break;
		}
	}
	if (count($args) >= 2) {
		break;
	}
}

$str1 = $args[0];
$str2 = $args[1];

$length = strlen($str1);
$result = "No";

if ($str1 == $str2) {
	$result = "Yes";
}else{
	for ($i=0; $i < $length; $i++) {
		for ($j=0; $j < $length; $j++) { 
			$char = $str1[$i];
			$pos = strpos($str2, $char, $j);
			$substr1 = substr($str2, $pos);
			$substr2 = substr($str2, 0, $pos);
			if ($str1 == $substr1 . $substr2) {
				$result = "Yes";
				break;
			}
		}
	}
}


out($result);

function out($var){
	echo $var , PHP_EOL;
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//オーバーフローに注意 long long　にする
//'1'+=16;      で大文字Aに
//'大文字'+=32;  で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


 
int main() {
 
  int n,m;
  cin >> n >> m;
  
  vector<bitset<30>> p(n);
  
  rep(i,n) {
    int k;
    cin >> k;
    rep(j,k) {
    int x;
    cin >> x;
    p.at(i).set(x-1);
    }
  }
  
  bitset<30> ans = p[0];
  
  repo(i,n) {
  ans = (p.at(i) & ans);
  }
  
  int answer = ans.count();
  
  cout << answer << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>	

using namespace std;

int main() {
	int n,k,h[100000],min=999999999;
	cin >> n>>k;
	for (int i = 0; i < n; i++ ) {
		cin >> h[i];
	}
	sort(h,h+n);
	for (int i = 0; i <= n - k; i++) {
		if (min > h[i + k - 1] - h[i])min = h[i + k - 1] - h[i];
	}
	cout <<min;
}

Measured memory_bytes: 640
import Data.List

main = getLine >> getLine >>= print.f.map length.group.sort.([0..10^5-1]++).map(read::String->Int).words
f (x:y:z:rest) = max (x+y+z-3) $ f (y:z:rest)
f [x,y] = x+y-2
f [x] = x-1

Measured memory_bytes: 47484
N = int(input())
S = []
for i in range(N):
    S.append(input())
anaglams = {}
count = 0
for s in S:
    chrs = [0]*26
    for c in s:
        index = ord(c) - ord('a')
        chrs[index] += 1
    if str(chrs) not in anaglams:
        anaglams[str(chrs)] = 0
    else:
        anaglams[str(chrs)] += 1
    count += anaglams[str(chrs)]
print(count)

Measured memory_bytes: 30772
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    int t;
    cin >> t;
    t++;
    a[i] = t;
  }
  vector<int> res(100005);
  rep(i, n){
    int t = a[i];
    res[t - 1]++;
    res[t]++;
    res[t + 1]++;
  }
  sort(res.begin(), res.end());
  reverse(res.begin(), res.end());
  cout << res[0] << endl;
}


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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> data(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=data.at(i).at(1)-data.at(i).at(0)+1;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<17;

int main(){
    string s;
    cin >> s;
    int a[3]={};
    for(int i=0;i<s.length();i++){
        a[s[i]-'a']++;
    }
    if(max({a[0],a[1],a[2]})-min({a[0],a[1],a[2]})<=1) puts("YES");
    else puts("NO");
    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

vector<ll> b(51), p(51);

ll dfs(int level, ll x) {
  if(level == 0) return 1;

  if(x == b[level]) return p[level];
  else if(b[level-1]+2 < x) return p[level-1]+1+dfs(level-1, x-b[level-1]-2);
  else if(x == b[level-1]+2) return p[level-1]+1;
  else if(x > 1) return dfs(level-1, x-1);
  else return 0;
}

int main()
{
  int n;
  ll x;
  cin >> n >> x;
  b[0] = p[0] = 1;
  for(int i = 1; i <= 50; ++i) {
    b[i] = 2*b[i-1]+3;
    p[i] = 2*p[i-1]+1;
  }
  cout << dfs(n, x) << endl;
}


Measured memory_bytes: 3520
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    vi a(8);
    while(cin >> a[0]){
        rep(i,7)cin >> a[i+1];
        string s = "14141212";
        string ans;
        int sum = INF;
        rep(t,8){
            string str;
            int cnt = 0;
            rep(i,8){
                str += s[(i+t)%8];
                cnt += max(0LL, a[i] - (str.back() - '0'));
            }

            if(sum > cnt || ans == ""){
                sum = cnt;
                ans = str;
            }
            if(sum == cnt){
                if(ans > str)ans = str;
            }
        }
        rep(i,8){
            if(i)cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
}



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

int main(){
  
	int N;
  	cin >> N ;
  
	if(N<2)cout<<1<<endl;
	else if(2<=N&&N<4)cout<<2<<endl;
  	else if(4<=N&&N<8)cout<<4<<endl;
  	else if(8<=N&&N<16)cout<<8<<endl;
  	else if(16<=N&&N<32)cout<<16<<endl;
  	else if(32<=N&&N<64)cout<<32<<endl;
  	else if(64<=N&&N<128)cout<<64<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  map<ll, int> MAP;
  FOR(i,0,N) {
    ll in; cin >> in;
    if(MAP[in] == 2) MAP[in] = 1;
    else MAP[in] = 2;
  }
  int ans = 0;
  for(auto m : MAP) if(m.second == 2) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll n;
  cin>>n;
  ll ret = n - 1;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0)ret=min(ret,i-1+n/i-1);
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    int ans = INF;
    for (int i = -100; i <= 100; i++) {
        int tmp = 0;
        for (int ai : a) tmp += (ai - i) * (ai - i);
        ans = min(ans, tmp);
    }
    cout << ans << '\n';
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, M; cin >> N >> M;
	vint s(M), t(M);
	vvint dat(N, vint(N, -1));

	for (int i = 0; i < M; i++) {
		cin >> s[i] >> t[i]; --s[i], --t[i];
		dat[s[i]][t[i]] = i;
	}
	
	function<vdouble(int)> DP = [&](int ng) -> vdouble {
		vdouble dp(N, -1);
		dp[N-1] = 0;
		for (int u = N-2; u >= 0; u--) {
			int f = 0;
			for (int v = u+1; v < N; v++) {
				if (dat[u][v] == -1 || dat[u][v] == ng || dp[v] < 0) continue;
				if (dp[u] < 0) dp[u] = 0;
				dp[u] += dp[v];
				f++;
			}
			if (f > 0) dp[u] /= f, dp[u] += 1.0;
			else dp[u] = -1;
			if (dp[u] == -1) return (vdouble());
		}
		return (dp);
	};

	vdouble E = DP(-1);
	double minv = E[0];	
	vint cridx(N, -1);
	for (int i = 0; i < M; i++) {
		if (cridx[s[i]] == -1 || E[t[cridx[s[i]]]] < E[t[i]]) {
			cridx[s[i]] = i;
		}
	}
	//cout << minv << endl;
	for (int i = 0; i < N; i++) {
		if (cridx[i] != -1) {
			//cout << cridx[i] << endl;
			vdouble EE = DP(cridx[i]);
			if (EE == vdouble()) continue;
			chmin(minv, EE[0]);
			//cout << minv << endl;
		}
	}
	cout << minv << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3072
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    while(1){
        int n,m;
        int now = 1;
        int field[1010]={0},sai[1010] = {0};
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        for(int i = 1; i <= n; i++){
            cin >> field[i];
        }
        int cnt = 0;
        for(int i = 1; i <= m; i++){
            cin >> sai[i];
        }
        for(int i = 1; i <= m; i++){
            now += sai[i];
            now += field[now];
            cnt++;
            if(now >= n) break;
        }
        cout << cnt << endl;
    }

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int a=N%10;
  N=N/10;
  int b=N%10;
  N=N/10;
  int c=N%10;
  N=N/10;
  int d=N%10;
  
  

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


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, ans;
  cin >> n;
  ans = n * n;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String a = sc.next();
		String b = a.substring(a.length()-1);
		if ("3".equals(b)){
		System.out.println("bon");

		} else if ("0".equals(b)||"1".equals(b)||"6".equals(b)||"8".equals(b)) {
		System.out.println("pon");

		}else{
		System.out.println("hon");

		}
	}
}


Measured memory_bytes: 35628
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
A, B = map(int, input().split())
print(A * B)




Measured memory_bytes: 9160
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
	int N;
	int A[100];

	cin >> N;
	int min = 1000000000;
	int max = 1;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		if (min > A[i])min = A[i];
		if (max < A[i])max = A[i];
	}
	cout << max - min << endl;

	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
li = [input().split() for i in range(b)]
for i in range(b):
    li[i] = [int(x) for x in li[i]]
li2 = []
for i in range(b):
    li2.append(li[i][0])
    li2.append(li[i][1])

for i in range(1,a+1):
    print(li2.count(i))

Measured memory_bytes: 3060
// abc160_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, X, Y;
    cin >> N >> X >> Y;

    X--; Y--;
    vector<int> ans(N);

    REP(i, N) REPN(j, i+1, N){
        int a = j - i;
        int b = abs(X - i) + 1 + abs(Y - j);
        ans[min(a, b)]++;
    }

    REPN(k, 1, N){
        print(ans[k]);
    }



    return 0;
}


Measured memory_bytes: 256
//  Be name khoda
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>
using namespace std;

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

#define F first
#define S second
#define MP make_pair

const int MAX = 4000+9;
const ll MOD = 924844033;

ll fac[MAX];
ll dp1[MAX][MAX], dp2[MAX][MAX];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fac[0] = 1;
	for (int i = 1; i < MAX; i++)
		fac[i] = fac[i-1] * i % MOD;
	int n, k;
	cin >> n >> k;
	// dp1
	dp1[0][0] = 1;
	for (int i = 1; i < MAX; i++) {
		dp1[i][0] = 1;
		dp1[i][1] = i;
		for (int t = 2; t <= i; t++)
			dp1[i][t] = (dp1[i-1][t] + dp1[i-2][t-1]) % MOD;
	}
	// dp2
	dp2[0][0] = 1;
	for (int i = 1; i <= 2*k; i++) {
		int x = ((i <= k) ? i : i-k);
		x = (n-x)/k;
		for (int t = 0; t <= x; t++)
			for (int j = t; j <= n; j++)
				dp2[i][j] = (dp2[i][j] + dp2[i-1][j-t] * dp1[x][t] % MOD) % MOD;
	}
	for (int i = 0; i <= n; i++)
		dp2[2*k][i] = dp2[2*k][i] * fac[n-i] % MOD;
	ll sum = 0, f;
	for (int i = 0; i <= n; i++) {
		f = ((i%2)?-1:1) * dp2[2*k][i] % MOD;
		sum = (sum + f + MOD) % MOD;
	}
	cout << sum << "\n";
}



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

int main(){
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    vector<ll> p;
    for(int i=0;i<41;i++){
        p.push_back(pow(2,i));
    }
    auto it = lower_bound(p.begin(), p.end(), a);
    int j = distance(p.begin(), it);
    it = lower_bound(p.begin(), p.end(), b);
    int k = distance(p.begin(), it);

    int r=(ll)(pow(2,j)-a)%4;
    for(int i=0;i<r;i++){
        ans=ans^(a+i);
    }
    int t=(ll)(b+1-pow(2,k-1))%4;
    for(int i=0;i<t;i++){
        ans=ans^(b-i);
    }
    cout<<ans<<endl;
   
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

#引用
#https://juppy.hatenablog.com/entry/2019/11/13/%E6%9C%80%E5%A4%A7%E3%83%BB%E6%9C%80%E5%B0%8F%E3%82%BB%E3%82%B0%E6%9C%A8_%E3%82%B3%E3%83%94%E3%83%9A%E7%94%A8_Python

n, k = LI()
a = [I() for _ in range(n)]

def init_max(init_max_val):
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2]) 
    
def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])
    
def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = 0
ma = max(a)
#num_max:n以上の最小の2のべき乗
num_max =2**(ma-1).bit_length()
seg_max=[ide_ele_max]*2*num_max
init_max(a)
for ai in a:
    res = query_max(max(0, ai-k), min(ai+k+1, num_max))
    update_max(ai, res+1)
print(max(seg_max))

Measured memory_bytes: 94592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, start, end) for (int i = start; i < end; i++)
#define rloop(i, start, end) for (int i = start; i >= end; i--)

void solve(){
    //code goes here
    int n;
    cin>>n;
    int d1[n], d2[n];
    int cnt=0, ans=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        d1[i]=a;
        d2[i]=b;
    }
    for(int i=0;i<n;i++){

        if(d1[i]==d2[i]){
            cnt++;
            ans=max(ans,cnt);
        }
        else{
            cnt=0;
        }
    }
    // cout<<cnt<<" "<<ans<<endl;
    if(ans>=3) cout<<"Yes";
    else cout<<"No";
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
L = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

dic = {}
for i in range(N):
  if L[i] in dic:
    dic[L[i]] += 1
  else:
    dic[L[i]] = 1

ans = 'YES'
for i in range(M):
  if T[i] in dic:
    if dic[T[i]] > 0:
      dic[T[i]] -= 1
    else:
      ans = 'NO'
      break
  else:
    ans = 'NO'
    break

print(ans)



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

signed main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  set<int> kazu;
  kazu.insert(A);
  kazu.insert(B);
  kazu.insert(C);
  
  if( kazu.size() == 2 ) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    vector<int> arr = {399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 9999};
    int n, val;
    cin >> n;
    unordered_map<int, int> color;
    for(int i = 0; i < n; i++) {
        cin >> val;
        auto it = lower_bound(arr.begin(), arr.end(), val);
        color[distance(arr.begin(), it)] += 1;
    }
    if (color.count(8) == 0) {
        cout << color.size() << " " << color.size() << endl;
    } else {
        int mn = max(int(color.size()-1), 1);
        int mx = int(color.size())+color[8]-1;
        cout << mn << " " << mx << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    ll tmp1 = 0;
    ll cst1 = 0;
    rep(i, n){
        tmp1 += a[i];
        if (i % 2 == 0 && tmp1 <= 0) {
            cst1 += 1 - tmp1;
            tmp1 = 1;
        }
        else if (i % 2 != 0 && tmp1 >= 0) {
            cst1 += tmp1 + 1;
            tmp1 = -1;
        }
    }

    ll tmp2 = 0;
    ll cst2 = 0;
    rep(i, n){
        tmp2 += a[i];
        if (i % 2 != 0 && tmp2 <= 0) {
            cst2 += 1 - tmp2;
            tmp2 = 1;
        }
        else if (i % 2 == 0 && tmp2 >= 0) {
            cst2 += tmp2 + 1;
            tmp2 = -1;
        }
    }

    cout << min(cst1, cst2) << endl;
    return 0;
}

Measured memory_bytes: 1024
n,p=map(int,input().split())
 
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

temp=factorization(p)
ans=1
i=0
while i<len(temp):
  if temp[i][1]>=n:
    ans=ans*temp[i][0]
    temp[i][1]=temp[i][1]-n
  else:
    i=i+1
print(ans)

Measured memory_bytes: 9496
use std::io::Read;

fn update(bit: &mut [u64], x: usize, v: u64) {
    let mut i = x;
    while i < bit.len() {
        bit[i] = std::cmp::max(bit[i], v);
        i += i & (!i + 1);
    }
}

fn max(bit: &[u64], x: usize) -> u64 {
    let mut ans = 0;
    let mut i = x;
    while i > 0 {
        ans = std::cmp::max(ans, bit[i]);
        i -= i & (!i + 1);
    }
    ans
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let h: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let a: Vec<u64> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut bit = vec![0; n + 1];
    for i in 0..n {
        let v = max(&bit, h[i]) + a[i];
        update(&mut bit, h[i], v);
    }
    let ans = max(&bit, n);
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 13560
// C - Minimization
// with operation
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define ote(x) cout<<(x)<<endl
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

void prn(vi & v){rp(i,1,v.size()){printf("%d ",v[i]);}puts("");}///

int main(){
	int N,K; cin>>N>>K;
	int p = 0;
	vi A(N+1);// 1 origin
	vi G(N+1);// 1 origin
	A[0] = INT_MAX;
	G[0] = -1;
	rp(i,1,N+1){
		cin>>A[i];
		if(A[p]>A[i]) p = i;
		G[i] = (i-1)/(K-1);
	}

	// prn(A);//
	// prn(G);//
	// puts("^^^");//

	int count = 0;
	irp(g,G[p],-1){
		int minA = INT_MAX;
		int front = g*(K-1)+1;
		int back = min(N, (g+1)*(K-1)+1);
		rp(j,front,back+1) minA = min(minA, A[j]);
		rp(j,front,back+1) A[j] = minA;
		count++;
		// prn(A);//
	}

	// puts("--");//

	rp(g,G[p]+1,G[N]){
		int minA = INT_MAX;
		int front = g*(K-1)+1;
		int back = min(N, (g+1)*(K-1)+1);
		rp(j,front,back+1) minA = min(minA, A[j]);
		rp(j,front,back+1) A[j] = minA;
		count++;
		// prn(A);//
	}

	if(A[N]==A[p]){
		ote(count);
		// ote(G[N]+((N-1)%(K-1)!=0));
		return 0;
	}

	int g=G[N];
	int minA = INT_MAX;
	int front = g*(K-1)+1;
	int back = min(N, (g+1)*(K-1)+1);
	rp(j,front,back+1) minA = min(minA, A[j]);
	rp(j,front,back+1) A[j] = minA;
	count++;
	// prn(A);//

	ote(count);
	// ote(G[N]+((N-1)%(K-1)!=0));
}


Measured memory_bytes: 1024
def divisor(N):
    div = []
    for i in range(1, int(N ** 0.5 + 1)):
        if N % i == 0:
            div.append(i)
            if i * i != N:
                div.append(N // i)
    return sorted(div)


N = int(input())
ans = set()
div = divisor(N)
for d in div:
    p = N // d
    while d % p == 0 and p != 1:
        d = d // p
    if (d - 1) % p == 0:
        ans.add(p)
for d in divisor(N - 1):
    ans.add(d)
print(len(ans) - 1 if 1 in ans else len(ans))


Measured memory_bytes: 38896
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> A(N, 0);

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	long long result = 0;
	int check_height = 0;

	for (int i = 0; i < N; i++)
	{
		if (check_height < A[i])
		{
			check_height = A[i];
		}

		result += check_height - A[i];
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N, D, X;
    int A[100];

    cin >> N >> D >> X;

    long long ans = X;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        ans += 1 + (D - 1) / A[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	double r;
	double circle, menseki;
	double p = 3.141592653589;
	cin >> r;
	menseki = r*r*p;
	circle = 2 * p * r;

	printf("%.6f %.6f",menseki,circle);
	return 0;
}

Measured memory_bytes: 3288