akhauriyash/Code-Regression huggingface dataset:
//karna padega 
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s,t;
		cin>>s>>t;
		int n =3;
		int ans =0;
		fn{
			ans+=s[i]==t[i];
		}
		cout<<ans;
	
	}
	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,m;
  cin >> n >> m;
  int ans = m -(n-1),p =2*n-1;
  for (int i = 0; i < p; ++i)
  {
    cout << ans+i << " ";
  }
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
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;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int a[N];
int main()
{
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= k; i ++)
	{
		int m;
		cin >> m;
		while(m --)
		{
			int x;
			cin >> x;
			a[x] = 1;
		}
	}
	int c= 0;
	for(int i = 1; i <= n; i ++)
		if(!a[i])
			c ++;
		cout << c;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3624
N = int(input())
N -= 1

d = 26
for i in range(1,15):
    if N >= d:
        N -= d
        d *= 26
    else:
        d //= 26
        ans = ""
        # for j in range(i):
        #     ans += chr(N // d + ord("a"))
        #     N %= d
        #     d //= 26

        for j in range(i):
            ans += chr(N % 26 + ord("a"))
            N //= 26
        break

print(ans[::-1])

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
const int m = 2019;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  vector<int> cnt(m);
  int x = 1; // exp modint
  int a = 0; // sum(10^0-10^i) modint
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cnt[a]++;
    a = (a + (s[i] - '0') * x) % m;
    ans += cnt[a];
    x = x * 10 % m;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	// your code goes here
int A,B,C;
scanf("%d %d %d", & A, & B, & C);
	int* a= new int[3];
	a[0]=A;
	a[1]=B;
	a[2]=C;
	
	
	sort(a,a+3);
	printf("%d",a[2]*10+a[1]+a[0]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int iss(int i,int j,int n,int m)
{
	if(i>=0 && i<n && j>=0 && j<m)
	 return 1;
	return 0;
}
int main()
{
 int n,m;
 cin>>n>>m;
 int c1,c2,d1,d2;
 cin>>c1>>c2>>d1>>d2;
 string a[n];
 for(int i=0;i<n;i++)
  cin>>a[i];
 int r=0;
 int vis[n][m];
 int reg[n][m];
 for(int i=0;i<n;i++)
  {
  	for(int j=0;j<m;j++)
  	 {
  	 reg[i][j]=-1;
  	 vis[i][j]=0;
  	 }
  }
  queue<pair<int,int>> q;
  for(int i=0;i<n;i++)
  {
  	for(int j=0;j<m;j++)
  	 {
  	 	if(vis[i][j]==0 && a[i][j]=='.')
  	 	{
  	 		q.push(make_pair(i,j));
  	 		vis[i][j]=1;
  	 		while(!q.empty())
  	 		{
  	 			pair<int,int> p=q.front();
  	 			int x=p.first;
  	 			int y=p.second;q.pop();
  	 			reg[x][y]=r;
  	 			if(iss(x-1,y,n,m) && vis[x-1][y]==0 && a[x-1][y]=='.')
  	 			 {
  	 			 	q.push(make_pair(x-1,y));
  	 			 	vis[x-1][y]=1;
  	 			 }
  	 			if(iss(x+1,y,n,m) && vis[x+1][y]==0 && a[x+1][y]=='.')
  	 			 {
  	 			 	q.push(make_pair(x+1,y));
  	 			 	vis[x+1][y]=1;
  	 			 }
  	 			if(iss(x,y-1,n,m) && vis[x][y-1]==0 && a[x][y-1]=='.')
  	 			 {
  	 			 	q.push(make_pair(x,y-1));
  	 			 	vis[x][y-1]=1;
  	 			 }
  	 			if(iss(x,y+1,n,m) && vis[x][y+1]==0 && a[x][y+1]=='.')
  	 			 {
  	 			 	q.push(make_pair(x,y+1));
  	 			 	vis[x][y+1]=1;
  	 			 }  	 			 
  	 		}
  	    	r++;
  	 	}
  	 }
  }
  /*for(int i=0;i<n;i++)
  {
  	for(int j=0;j<m;j++)
  	 cout<<reg[i][j]<<" ";
  	 cout<<endl;
  }*/
  set<pair<int,int>> st;
  vector<int> ed[r];
  for(int i=0;i<n;i++)
  {
  	for(int j=0;j<m;j++)
  	{
  		for(int ii=i-2;ii<=i+2;ii++)
  		{
  			for(int jj=j-2;jj<=j+2;jj++)
  			 {
  			 	if(iss(ii,jj,n,m) && reg[i][j]!=reg[ii][jj] && reg[i][j]!=-1 && reg[ii][jj]>-1)
  			 	{
  			 		int x=min(reg[i][j],reg[ii][jj]);
  			 		int y=max(reg[i][j],reg[ii][jj]);
  			 		if(st.find(make_pair(x,y))==st.end())
  			 		 {
  			 		 	st.insert(make_pair(x,y));
  			 		 	ed[x].push_back(y);
  			 		 	ed[y].push_back(x);
  			 		 }
  			 	}
  			 }
  		}
  	}
  }
  c1--;c2--;d1--;d2--;
  queue<pair<int,int>> qq;
  qq.push(make_pair(reg[c1][c2],0));
  int yy=0;
  int visi[r]={0};
  while(!qq.empty())
  {
  	pair<int,int> s=qq.front();
  	qq.pop();
  	int x=s.first;
  	int y=s.second;
  	if(x==reg[d1][d2])
  	{cout<<y<<endl;
  		yy=1;break;
  	}
  	for(int j=0;j<ed[x].size();j++)
  	{
  		if(visi[ed[x][j]]==0)
  		{
  			qq.push(make_pair(ed[x][j],y+1));
  			visi[ed[x][j]]=1;
  		}
  	}
  }
  if(yy==0) cout<<-1<<endl;
 return 0;
}

Measured memory_bytes: 30896
KAB = [int(x) for x in input().split()]
K = KAB[0]
A = KAB[1]
B = KAB[2]
count = 1
if (B - A <= 2) or K <= A:
    print(K + 1)
else:
    count = A
    K = K - A + 1
    if K % 2 == 1:
        count = count + 1 + (B - A) * (K // 2)
    else:
        count += (B - A) * K // 2
    print(count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

// 素因数分解 O(√n)以下
// (素因数,個数)
template<typename T>
vector<pair<T, int>> prime_factorization(T n) {
    vector<pair<T, int>> res;
    for (T i = 2; i*i <= n; i++) {
        int cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) res.push_back({i,cnt});
    }
    if (n > 1) res.push_back({n,1});
    return res;
}

//gcd
template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    ll a, b; cin >> a >> b;
    a = gcd(a, b);
    cout << prime_factorization(a).size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    vector<int> P(N), Q(N), check(N);
    rep(i, N) cin >> P[i];
    rep(i, N) {
        cin >> Q[i];
        check[i] = i + 1;
    }

    int p, q;
    int cnt = 1;
    do {
        bool flagp = true, flagq = true;
        rep(i, N) {
            if (P[i] != check[i]) flagp = false;
            if (Q[i] != check[i]) flagq = false;
        }

        if (flagp) p = cnt;
        if (flagq) q = cnt;
        cnt++;
    } while (next_permutation(all(check)));

    cout << abs(p - q) << endl;
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const ll MAXN = 200001;

bool test(ll k2){
    rep(c1,1,n+1){
        if((c1^k2) > n)return 0;
    }
    return 1;
}

ll get(){
    rep(c1,1,n+1){
        if(test(c1))return c1;
    }
    return -1;
}

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);
    ll a,b,c,d;
    cin >> n;
    if(n > 1 && n%2 == 1){
        cout << "Yes\n";
        cout << "3 " << n+1 << "\n";
        for(int c1 = 2; c1 <= n; c1+=2){
            cout << 1 << " " << c1 << "\n";
            cout << c1 << " " << c1+1 << "\n";
        }
        for(int c1 = n+2; c1 <= 2*n; c1+=2){
            cout << 1 << " " << c1+1 << "\n";
            cout << c1 << " " << c1+1 << "\n";
        }
    }
    else{
        ll mate = -1;
        rep(c1,2,n){
            if((n^1^c1) > 1 && (n^1^c1) < n){
                mate = c1;
                break;
            }
        }
        if(mate == -1){
            cout << "No\n";
        }
        else{
            cout << "Yes\n";
            cout << "3 " << n+1 << "\n";
            for(int c1 = 2; c1 < n; c1+=2){
                cout << 1 << " " << c1 << "\n";
                cout << c1 << " " << c1+1 << "\n";
            }
            for(int c1 = n+2; c1 < 2*n; c1+=2){
                cout << 1 << " " << c1+1 << "\n";
                cout << c1 << " " << c1+1 << "\n";
            }
            cout << mate + n*(mate%2) << " " << n << "\n";
            cout << (n^1^mate) + n*((n^1^mate)%2)  << " " << 2*n << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 2304
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np


def main():
	n=II()

	for i in range(1,10**5):
		if (n*i)%360==0:
			print(i)
			exit()










if __name__ == "__main__":
	main()


Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    ll n,w=pow(10,15),wi,ans=4,one=1;
    cin >> n;
    vector<ll> v(5);
    for(ll i=0;i < 5;i++){
        cin >> v.at(i);
        if(w>v.at(i)){//ネック
            wi=i;
            w=v.at(i);
        }
    }
    if(v.at(wi)!=1){
        ans += max(one,(n-1+v.at(wi))/v.at(wi));
    }else{
        ans += max(one,(n)/v.at(wi));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};

use std::collections::HashMap;
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    let mut iter = buf.split_whitespace();
 
    let k: u64 = iter.next().unwrap().parse().unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    
    let a: Vec<u64> = (0..n).map(|_| { iter.next().unwrap().parse().unwrap() }).collect();
    
    let mut tmp = vec![0; n];
    
    for i in 0..n-1 {
        tmp[i] = a[i+1] - a[i];
    }
    tmp[n-1] = a[0] + k - a[n-1];
    
    tmp.sort();
    
    let mut sum = 0;
    for i in 0..n-1 {
        sum += tmp[i];
    }
    
    //println!("{:?}",tmp);
    println!("{}",sum);
}

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

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

    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << '0';
    } else if (x >= a) {
        cout << "10";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e6+5;
const long long INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve() {
    int n , m , x;
    cin >> n >> m >> x;
    vector< int > c(n);
    vector< vector< int > > v(n, vector< int >(m));
    for(int i=0 ; i<n ;i++){
        cin >> c[i];
        for(int j=0 ; j<m ;j++){
            cin >> v[i][j];
        }
    }
    int ans = INF;
    int all = 1LL<<n;
    for(int mask = 0 ; mask< all ; mask++){
        vector< int > cnt(m,0);
        int cost =  0;
        for(int i=0 ; i<n ; i++){
            if(1LL<<i & mask){
                cost += c[i];
                for(int j=0 ; j<m ;j++){
                    cnt[j]+=v[i][j];
                }
            }

        }
        bool all = true;
        for(auto i : cnt){
            if(i < x){
                all = false;
                break;
            }
        }
        if(all){
            ans = min(ans , cost);
        }
    }
    if(ans==INF){
        cout << "-1\n";
    }
    else{
        cout <<ans << endl;
    }

}

signed main(){
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/*Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        if ((scanner.nextInt() * scanner.nextInt()) % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


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

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

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
  if (S == "Y") {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
// other libs
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)
				continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};
template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	Union_Find(T max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y))
			return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[a];
	}
};
bool ifPrime(int n) {
	if (n == 1)
		return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)
			return false;
	}
	return true;
}
vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}
bool isOK(int index, string s) {
	unordered_map<string, pair<int,vector<int>>> mp;
	if(index<1)return false;
	rep(i, (int) s.size() - index + 1) {
		mp[s.substr(i, index)].first++;
		mp[s.substr(i,index)].second.push_back(i);
	}
	for (pair<string,pair<int,vector<int>>> it : mp)
		if (it.second.first > 1) {
		    int fi=it.second.second[0];
		    if(lower_bound(it.second.second.begin(),it.second.second.end(),fi+index)!=it.second.second.end())
			return true;
		}
	return false;
}
int my_binary_search(string s) {
	int ng = (int) s.size();
	int ok = 0;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (isOK(mid, s))
			ok = mid;
		else
			ng = mid;
	}
	return ok;
}
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	cout << my_binary_search(s) << endl;
}

Measured memory_bytes: 6800
#include<cstdio>
typedef long long ll;
int main()
{
	ll n,k;scanf("%lld%lld",&n,&k);
	if(k&1)
	{
		ll a=n/k;
		printf("%lld\n",a*a*a);
	}
	else
	{
		ll a=n/(k/2);
		ll b=a/2;a-=b;
		printf("%lld\n",a*a*a+b*b*b);
	}
	return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.ne(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[55];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];

    ll ans = 0;
    while (true) {
        ll res = 0;
        rep(i, n) res += a[i] / n;
        if (res == 0) break;
        rep(i, n) {
            ll b = a[i] / n;
            a[i] = a[i] - n * b + res - b;
            ans += b;
        }
    }

    cout << ans << endn;
}

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


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = 998244353;

int main2() {
  int N; cin >> N;
  string s; cin >> s;

  ll bag[3] = {0, 0, 0};

  ll ans = 1;
  REP(i, 3 * N) {
    ll mul = 1;
    int a = 0;
    if (s[i] == 'R') a = 0;
    if (s[i] == 'G') a = 1;
    if (s[i] == 'B') a = 2;
    int b = (a+1) % 3;
    int c = (a+2) % 3;
    if (bag[a] >= bag[b] && bag[a] >= bag[c]) {
      mul = 1;
    }
    else if (bag[a] < bag[b] && bag[a] < bag[c]) {
      mul = min(bag[b], bag[c]);
    }
    else {
      mul = max(bag[b], bag[c]) - bag[a];
    }
    bag[a]++;
    if (bag[0] >= 1 && bag[1] >= 1 && bag[2] >= 1) {
      bag[0]--;
      bag[1]--;
      bag[2]--;
    }
    ans *= mul;
    ans %= MOD;
  }
  REP(i, N) ans = (ans * (i+1)) % MOD;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

typedef long long ll;

ll n,m;

ll fact[100005];
ll mod = 1000000007;

void compute(){
   fact[0]=1;
   for(int i=1;i<100005;i++){
   	fact[i]=(fact[i-1]*i)%mod;
   }
}

int main(){
	cin >> n >> m;
	compute();
	if(abs(n-m)>1){
		cout<<"0"<<endl;
	}
	else if(abs(n-m)==1){
        cout<<(fact[n]*fact[m])%mod<<endl;
	}
	else{

		cout<<(((fact[n]*fact[n])%mod)*2)%mod<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
    
def Koch(n, x1,y1,x2,y2):
    if n == 0: 
        plot(x1,y1)        
        return
    sx = (2 * x1 + x2) / 3
    sy = (2 * y1 + y2) / 3
    tx = (x1 + 2 * x2) / 3
    ty = (y1 + 2 * y2) / 3
    ux = (tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy = (tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    Koch(n-1, x1, y1, sx, sy)
    Koch(n-1, sx, sy, ux, uy)
    Koch(n-1, ux, uy, tx, ty)
    Koch(n-1, tx, ty, x2, y2)

n = int(input())
Koch(n, 0, 0, 100, 0)
plot(100,0)



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	ll N; cin>>N;
	ll ans=0;
	rep1(i,N){
		if(i%2==1){
			vector<ll>tmp=divisor(i);
			if(tmp.sz==8) ans++;
		}
	}
	cout<<ans;
}

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

int main(){
    int N; cin >> N;
    vector<int> A(N+1);
    vector<int> balls(N+1);
    for(int i=1; i < N+1; i++){
        int a; cin >> a;
        A[i] = a;
    }
    int ans = 0;
    for(int i=N; i > 0; i--){
        int j = 1;
        while(i * (j + 1) <= N) j++;
        int k = 0;
        while(j > 1){
            k += balls[i * j];
            k %= 2;
            j--;
        }
        if(k == A[i]){
            balls[i] = 0;
        } else {
            balls[i] = 1;
            ans++;
        }
    }
    cout << ans << endl;
    if(ans != 0){
        for(int i=1; i < N+1; i++){
            if(balls[i] == 1){
                cout << i << ' ';
            }
        }
    }
}

Measured memory_bytes: 2432
using System;
using System.Linq;
using static System.Console;

class P
{
    static void Main()
    {
        var a = ReadLine().Split().Select(int.Parse).ToList();
        int n = a[0], m = a[1];
        var A = new int[n][];
        var b = new int[m];
        for (int ni = 0; ni < n; ni++)
        {
            A[ni] = ReadLine().Split().Select(int.Parse).ToArray();
        }
        for (int mi = 0; mi < m; mi++)
        {
            b[mi] = int.Parse(ReadLine());
        }
        for (int ni = 0; ni < n; ni++)
        {
            for (int mi = 0; mi < m; mi++)
            {
                A[ni][mi] *= b[mi];
            }
            WriteLine(A[ni].Sum());
        }
    }
}


Measured memory_bytes: 18488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = INF;

int main(void){
  ll L;
  I(N);
  I(L);
  ll sum = 0;
  ll m = INF;
  REP(i, N) {
    sum += L + i;
  }
  REP(i, N) {
    if (m >= abs(L+i)) {
      m = abs(L+i);
      ret = sum - (L + i);
    }
  }

  P(ret);

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int H = int.Parse(str[0]);
		int W = int.Parse(str[1]);
		int ans = 0;
		int[,]A = new int[H,W];
		for(var i=0;i<H;i++){
			string s = Console.ReadLine();
			for(var j=0;j<W;j++){
				if(s.Substring(j,1)=="#"){
					A[i,j] = 1;
				}
			}
		}
		for(var i=0;i<H;i++){
			for(var j=0;j<W;j++){
				if(A[i,j]==0){
					int[,]B = new int[H,W];
					for(var i1=0;i1<H;i1++){
						for(var j1=0;j1<W;j1++){
							B[i1,j1] = 999999999;
						}
					}
					B[i,j] = 0;
					var list = new List<int>();
					list.Add(i*W+j);
					while(list.Count>0){
						var list2 = new List<int>(list);
						list.Clear();
						foreach(var ij in list2){
							int i3 = ij/W;
							int j3 = ij%W;
							if(i3>0 && B[i3-1,j3] > B[i3,j3]+1 && A[i3-1,j3]==0){
								B[i3-1,j3] = B[i3,j3]+1;
								list.Add((i3-1)*W+j3);
							}
							if(i3<H-1 && B[i3+1,j3] > B[i3,j3]+1 && A[i3+1,j3]==0){
								B[i3+1,j3] = B[i3,j3]+1;
								list.Add((i3+1)*W+j3);
							}
							if(j3>0 && B[i3,j3-1] > B[i3,j3]+1  && A[i3,j3-1]==0){
								B[i3,j3-1] = B[i3,j3]+1;
								list.Add(i3*W+j3-1);
							}
							if(j3<W-1 && B[i3,j3+1] > B[i3,j3]+1 && A[i3,j3+1]==0){
								B[i3,j3+1] = B[i3,j3]+1;
								list.Add(i3*W+j3+1);
							}
						}
					}
					int max = 0;
					for(var i1=0;i1<H;i1++){
						for(var j1=0;j1<W;j1++){
							if(A[i1,j1]==0){
								max = Math.Max(B[i1,j1],max);
							}
						}
					}
					ans = Math.Max(ans,max);
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13268
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  uf.Unite(a,b)
ans = 0
for i in range(n):
  ans = max(uf.Count(i),ans)
print(ans)

Measured memory_bytes: 77816
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

ll MOD = 1000000007;

int main()
{
    ll n;
    cin >> n;

    string s;
    ll c[4] = {};

    for(ll i=0; i<n; i++){
        cin >> s;
        if(s == "AC")
            c[0]++;
        else if(s == "WA")
            c[1]++;
        else if(s == "TLE")
            c[2]++;
        else if(s == "RE")
            c[3]++;

    }
    

    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;

}


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

const int MOD = 1000000007;

ll binary_pow(ll n, ll p)
{
    return p ? binary_pow(n * n % MOD, p >> 1) * (p & 1 ? n : 1) % MOD : 1;
}

ll combination(ll n, ll r)
{
    ll x = 1, y = 1;
    r = min(r, n - r);
    rep (i, r)
    {
        x = x * (n - i) % MOD;
        y = y * (i + 1) % MOD;
    }
    return x * binary_pow(y, MOD - 2) % MOD;
}

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

    ll ans = binary_pow(2, n) - combination(n, a) - combination(n, b) - 1;
    while (ans < 0)
        ans += MOD;

    cout << ans % MOD << endl;
    return 0;
}

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

int main(void){
  int n;
  cin >> n;
  vector<int> a(n + 1);
  int ans = 0;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    if(a[i] < i && a[a[i]] == i){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll i,j,x,y,c;
	cin >> x >> y;
	for(i=0;i<=x;++i)
	{
		c = i*2+(x-i)*4;
		if(c == y)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int h, w;
char m[105][105];
int dx[] = {0,0,1,-1,1,1,-1,-1};
int dy[] = {1,-1,0,0,1,-1,1,-1};
int cnt( int x, int y ){
    int r = 0;
    for( int i = 0 ; i < 8 ; ++i ){
        int xx = x+dx[i];
        int yy = y+dy[i];
        if( xx >= 0 && xx < h && yy >= 0 && yy < w && m[xx][yy] == '#' ){
            r++;
        }
    } return r;
}
int main(){

    cin >> h >> w;
    for( int i = 0 ; i < h ; ++i ){
        for( int j = 0 ; j < w ; ++j ){
            cin >> m[i][j];
        }
    }
    for( int i = 0 ; i < h ; ++i ){
        for( int j = 0 ; j < w ; ++j ){
            if( m[i][j] == '.' ) cout << cnt(i,j);
            else cout << m[i][j];
        } cout << '\n';
    }

}


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



int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  auto take = [&](int i) -> int {
    int dir = 0;
    for (int j = i + 1; j < N; j++) {
      int diff = A.at(j) - A.at(j-1);
      int newDir = diff > 0 ? 1 : diff == 0 ? 0 : -1;
      if (newDir == 0) {
	// do nothing
      }else if (dir == 0) {
	dir = newDir;
      }else if (dir == newDir) {
	// do nothing
      }else {
	return j;
      }
    }
    return N;
  };

  int cnt = 0;
  for (int i = 0; i < N; i = take(i)) cnt++;
  cout << cnt << endl;
  return 0;
}



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

const int INF = 1e9;
const string abcx = "abcx";

struct I {
  int n, a, b, c;
};

int f(I& in, vector<int>& l, string s) {
  int a = 0, b = 0, c = 0;
  int cnt_a = 0, cnt_b = 0, cnt_c = 0;
  rep(i, in.n) {
    if (s[i] == abcx[0])
      a += l[i], cnt_a++;
    if (s[i] == abcx[1])
      b += l[i], cnt_b++;
    if (s[i] == abcx[2])
      c += l[i], cnt_c++;
  }
  if (a == 0 || b == 0 || c == 0)
    return INF;
  int res = 0;
  res += abs(in.a - a) + abs(in.b - b) + abs(in.c - c);
  res += max(--cnt_a * 10, 0);
  res += max(--cnt_b * 10, 0);
  res += max(--cnt_c * 10, 0);
  return res;
}

void dfs(I& in, int& x, vector<int>& l, string acc) {
  if (acc.size() == in.n)
    x = min(x, f(in, l, acc));
  else
    for (auto c : abcx)
      dfs(in, x, l, acc + c);
}

int main() {
  I in{};
  cin >> in.n >> in.a >> in.b >> in.c;

  vector<int> l(in.n);
  rep(i, in.n) cin >> l[i];

  int ans = INF;
  dfs(in, ans, l, "");
  cout << ans << endl;
}

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> a(N);
    for (int64_t& A : a) {
        cin >> A;
    }

    vector<vector<int64_t>> connect(N);
    for (int64_t i = 0; i < N - 1; i++) {
        int64_t u, v;
        cin >> u >> v;
        u--; v--;
        connect[u].push_back(v);
        connect[v].push_back(u);
    }

    constexpr int64_t INF = LLONG_MAX;

    vector<int64_t> ans(N);
    function<void(int64_t, int64_t, vector<int64_t>& dp)> solve = [&](int64_t curr_node, int64_t pre_node, vector<int64_t>& dp) {
        auto itr = lower_bound(dp.begin(), dp.end(), a[curr_node]);
        int64_t before = *itr;
        *itr = a[curr_node];
        ans[curr_node] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();

        for (int64_t next_node : connect[curr_node]) {
            if (next_node == pre_node) {
                continue;
            }

            solve(next_node, curr_node, dp);
        }
        *itr = before;
    };

    vector<int64_t> dp(N + 1, INF);
    solve(0, -1, dp);

    for (int64_t v : ans) {
        cout << v << endl;
    }
}

Measured memory_bytes: 41720
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

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 (b<a) { a=b; return 1; } return 0; }



int n, a[202020];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = n-1; i > 0; i--){
		if(a[i] < a[i-1]){
			a[i-1]--;
		}
		if(a[i] < a[i-1]){
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}

int main(){
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll n, c, dp[200010];
map<ll, ll> mp;
ll mod = 1000000007;
int main(void){
    // Your code here!
    cin >> n;
    dp[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        cin >> c;
        if (mp[c] == 0 || mp[c] == i - 1)
        {
            dp[i] = dp[i - 1];
        }
        else
        {
            (dp[i] = dp[i - 1] + dp[mp[c]]) %= mod;
        }
        mp[c] = i;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 14336
n=int(input())
k=n
d=0
ans=0

while k>0:
  d+=1
  k=k//10

for i in range(d): #10**i~9999←i+1個
  if (i+1)%2==1:
    ans+=10**(i+1)-10**i
    

if d%2==1:
  ans=ans-(10**d-1-n)

print(ans)

Measured memory_bytes: 9068
#include <cstdlib>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <utility>
using namespace std;

#define MAX 500001

int num;

/**
 * max?????????????§?????????????????????¢??°
 * 
 * ??? > ????????????????????????????????????????????´??????
 * ????????????????????????????????°????????\??????????????????
 * @param binaryHeap
 * @param topId
 */
void maxHeapify(int *binaryHeap, int topId) {
    int left = 2 * topId;
    int right = 2 * topId + 1;
    int largest = topId;
    
    //????????????????????§????????¨??????max??????????????????????????????
    if(left <= num) {
        if(binaryHeap[left] > binaryHeap[topId]) {
            largest = left;
        }
    }
    
    //????????????????????§????????¨??????max??????????????????????????????
    if(right <= num) {
        //?????¨???????????????????????§????????¨????????????????????¨???
        if(binaryHeap[right] > binaryHeap[largest]) {
            largest = right;
        }
    }
    
    //??????????????????????????????????????°????????\??????????????????
    if(largest != topId) {
        swap(binaryHeap[topId], binaryHeap[largest]);
        maxHeapify(binaryHeap, largest);
    }
}



int main(void) {
    //ifstream ifs;
    //ifs.open("input.txt", ifstream::in);
    
    int binaryHeap[MAX];
    
    
    cin >> num;
    for(int i = 1; i < num + 1; i++) {
        cin >> binaryHeap[i];
    }
    for(int i = num / 2; i > 0; i--) {
        maxHeapify(binaryHeap, i);
    }
    for(int i = 1; i < num + 1; i++) {
        printf(" %d", binaryHeap[i]);
    }
    cout << endl;
    return 0;
}

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

int main(void){
  int N;
  cin >> N;
  vector<int> number(N);
  
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    number.at(i)=A;
  }
  sort(number.begin(),number.end());
  
  int ans=N;
  int i=0;
  while(i<N-1){
    if(number.at(i)==number.at(i+1)){
      ans-=2;
      i+=2;
    }
    else i++;
  }
  cout << ans << endl;
  return 0;
}
  

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a+b == 3) cout << 3 << endl;
    if(a+b == 4) cout << 2 << endl;
    if(a+b == 5) cout << 1 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    rep(i,1<<3) {
        int sum = s[0]-'0';
        rep(j,3) {
            if (i>>j & 1) sum += s[j+1]-'0';
            else sum -= s[j+1]-'0';
        }
        if (sum == 7) {
            rep(j,3) {
                cout << s[j];
                if (i>>j & 1) cout << "+";
                else cout << "-";
            }
            cout << s[3] << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.io.PrintWriter

@JvmField val _writer = PrintWriter(System.out, false)
fun main(args: Array<String>) { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val data = mutableMapOf<Int, MutableList<Int>>()
    val inp = arrayOfNulls<Pair<Int,Int>>(m)
    repeat(m) {
        val (p, y) = readLine()!!.split(' ').map { it.toInt() }
        inp[it] = p to y
        if(data[p] == null) data[p] = mutableListOf()
        data[p]!!.add(y)
    }

    val sorted = mutableMapOf<Int, MutableMap<Int,Int>>()
    data.forEach { d ->
        val shiList = d.value
        if (shiList != null) {
            val shiSorted = mutableMapOf<Int, Int>()
            var cnt = 1
            shiList.sortedBy { it }.forEach {
                shiSorted[it] = cnt
                cnt++
            }
            sorted[d.key] = shiSorted
        }
    }

    inp.forEach {
        println("%06d".format(it!!.first) + "%06d".format(sorted[it.first]!![it.second]) )
    }
}




Measured memory_bytes: 162596
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  int a,c;
  cin>>a;
  if(a%2==1){
    cout<<"No";
    return 0;
  }
  else{ 
 c=a/2;
  }
  string b;
  cin>>b;
  for(int i=0;i<c;i++){
    if(b.at(i)!=b.at(i+c)){
	  cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            //入力
            string input = Console.ReadLine();
            int n = int.Parse(input);

            string s = Console.ReadLine();

            if(s.Length % 2 == 1)
            {
                Console.WriteLine("No");
                return;
            }


            for(int i = 0;i < n/2;i++)
            {
                if(s[i] != s[n/2 + i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
                
        }
    }

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <map>


int n;

int main(){
    std::cin >> n;

    std::map<std::string, int> m;
    std::string str;
    for(int i = 0; i < n; i++){
        std::cin >> str;

        if(m[str] > 0) m[str] = 0;
        else m[str] = 1;
    }

    int ans = 0;
    for(auto itr = m.begin(); itr != m.end(); itr++){
        ans += itr->second;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll INF = -1;
const ll LIM = 100 * 1000;

int solve(void);

int main(void)
{
	while (solve())
	{
	}

	return 0;
}

int solve(void)
{
	ll N, W;
	cin >> N >> W;

	vector<ll> w(N), v(N);

	for (int i = 0; i < N; i++)
		cin >> w[i] >> v[i];

	// dp[i] : 価値が i の時の重さ
	vector<ll> dp(LIM + 1, 0);

	for (int i = 0; i < N; i++)
	{
		vector<ll> tmp(dp);
		for (int j = 0; j <= LIM; j++)
		{
			const ll next_val    = j + v[i];
			const ll next_weight = dp[j] + w[i];
			if(next_val > LIM) { continue; }
			if(next_weight > W) { continue; }
			if(j > 0 && dp[j] == 0) { continue; }
			tmp[next_val] = dp[next_val] > 0 ? min(dp[next_val], next_weight) : next_weight;
		}
		dp = tmp;
	}

	ll ans = 0;
	for(int i = 0; i < dp.size(); i++)
		if(dp[i]) { ans = i; }

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1904
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())
d = defaultdict(int)
max_n= 0
for n in range(N):
    s = input().strip()
    d[s] += 1
    if d[s] > max_n:
        max_n = d[s]

for s in sorted(d.keys()):
    if d[s] == max_n:
        print(s)


Measured memory_bytes: 32480
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

public class Main {

	public static void main(String[] arg) {
		Scanner ob=new Scanner(System.in);
		char c=ob.next().charAt(0);
		for(char c1='a';c1<='z';c1++){
		if(c==c1){c1++;System.out.println(c1);}
		}
	}
}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
string s;
int f(int n) {
	set<pair<long long, long long>> S;
	int h1 = 0, t1 = 1;
	int h2 = 0, t2 = 1;
	for (int i = 0; i < n; ++ i) {
		h1 = h1*37+s[i];
		t1 = t1*37;
		h2 = h2*31+s[i];
		t2 = t2*31;
	}
	S.insert({h1,h2});
	for (int i = n; i < s.length(); ++ i) {
		h1 = h1 * 37 - t1 * s[i-n] + s[i];
		h2 = h2 * 31 - t2 * s[i-n] + s[i];
		S.insert({h1,h2});
	}
	return S.size();
}

int main() {
	cin >> s;
	int x0 = 1, x3 = s.length();
	while (x3 - x0 > 3) {
		int x1 = (x0*2 + x3) / 3;
		int x2 = (x0 + x3*2) / 3;
		if (f(x1) < f(x2)) x0 = x1; else x3 = x2;
	}
	int r = 0;
	for (int i = x0; i <= x3; ++ i) {
		r = max(r, f(i));
	}
	cout << r << endl;
}


Measured memory_bytes: 6656
MOD = 10**9 + 7


def main():
    N = int(input())
    if N == 1:
        print(0)
        return
    ans = pow(10, N, MOD) - (pow(9, N, MOD) + pow(9, N, MOD) - pow(8, N, MOD))
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


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

signed main(void)
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	rep(i, ty - sy)
		cout << 'U';
	rep(i, tx - sx)
		cout << 'R';
	rep(i, ty - sy)
		cout << 'D';
	rep(i, tx - sx + 1)
		cout << 'L';
	rep(i, ty - sy + 1)
		cout << 'U';
	rep(i, tx - sx + 1)
		cout << 'R';
	cout << 'D' << 'R';
	rep(i, ty - sy + 1)
		cout << 'D';
	rep(i, tx - sx + 1)
		cout << 'L';
	cout << 'U';
	return 0;
}


Measured memory_bytes: 256