akhauriyash/Code-Regression huggingface dataset:
from collections import Counter

n = int(raw_input())
d = map(int, raw_input().split())
count_d = Counter(d)

if count_d[0] != 1 or d[0] != 0:
    print 0
else:
    pre_i = 0
    result = 1
    pre_nodes = 1
    for i, num in count_d.items()[1:]:
        if i != pre_i + 1:
            result = 0
            break
        result *= (pre_nodes ** num)
        pre_i = i
        pre_nodes = num
    print result % 998244353

Measured memory_bytes: 20836
#include<bits/stdc++.h>
#define     FAST            ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
#define ll long long
using namespace std;
int main()
{
    string s;
    cin>>s;
    int mx=0,c=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='R')
        {
            c++;
        }
        else
        {
            mx=max(c,mx);
            c=0;
        }
        
        if(i==s.size()-1)
        {
            mx=max(c,mx);
        }
    }


    cout<<mx<<endl;





    return 0;
}


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

int main() {

	int n, m;
	cin >> n >> m;

	vector<vector<int>> mat(n);
	for (auto& row : mat) {
		copy_n(istream_iterator<int>(cin), m, back_inserter(row));
	}
	
	vector<int> vec;
	copy_n(istream_iterator<int>(cin), m, back_inserter(vec));


	for (auto& row : mat) {
		cout << inner_product(row.begin(), row.end(), vec.begin(), 0) << endl;
	}

	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

signed main(){
  int D, G;
  cin >> D >> G;
  vector<int> P(D);
  vector<int> C(D);
  for( int i = 0; i < D; i++ ) cin >> P.at(i) >> C.at(i);

  int ans = 5000;
  for (int bit = 0; bit < (1<<D); ++bit) {
    int now = 0;
    int score = 0;
    for (int i = 0; i < D; ++i) {
      if (bit & (1<<i)) { // i番目のbitが立っていれば
      now += P.at(i);
      score += P.at(i)*100*(i+1) + C.at(i);
      }
    }
    if( score >= G ){
      ans = min(ans, now);
      continue;
    }

    for( int i = D-1; i >= 0; i-- ){
      if( score >= G ) break;
      if (bit & (1<<i)) continue;
      for( int j = 1; j < P.at(i); j++ ){
        if( (i+1)*100*j >= G-score ){
          now += j;
          score += (i+1)*100*j;
          break;
        }
      }
    }
    if( score >= G ){
      ans = min(ans, now);
    }
  }

  cout << ans << endl;


 }


Measured memory_bytes: 256
#listの要素をキー、その出現数を値として持つディクショナリを返す
def count(list):
    dict = {}
    for i in range(len(list)):
        dict[list[i]] = dict.get(list[i], 0) + 1
    return dict
#dictのキーと値を一行ずつ出力
def output_dict_with_value(dict, sentence = None):
    if sentence != None:
        print(str(sentence))
    lst =  ["AC", "WA", "TLE", "RE"]
    for i in lst:
      if i in dict:
        print(i + " x " + str(dict[i]))
      else:
        print(i + " x 0")
times = int(input())
lst = []
for i in range(times):
  lst.append(input())
dict = count(lst)
output_dict_with_value(dict)


Measured memory_bytes: 82840
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];
    let mut x_plus_y: Vec<i64> = vec![];
    let mut x_minus_y: Vec<i64> = vec![];
    for _ in 0..n {
        let line: Vec<i64> = read_as_vec();
        let (x, y) = (line[0], line[1]);
        x_plus_y.push(x + y);
        x_minus_y.push(x - y);
    }

    x_plus_y.sort();
    x_minus_y.sort();
    println!(
        "{}",
        cmp::max(
            x_plus_y.last().unwrap() - x_plus_y.first().unwrap(),
            x_minus_y.last().unwrap() - x_minus_y.first().unwrap()
        )
    );
}


Measured memory_bytes: 5884
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;
 
int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n,i,j,k;
	cin>>n;
	int h[n];
	for(i=0;i<n;i++)cin>>h[i];
	int place=0,ans=0;
	for(i=0;i<n-1;i++){
		if(h[i]<=0)continue;
		for(k=0;k<h[i];k++){
			ans++;
			j=i+1;
			while(1){
				h[j]--;
				if(h[j]<0)break;
				j++;
			}
		}
//		cout<<ans<<endl;
	}
	if(h[n-1]>0)ans+=h[n-1];
	cout<<ans<<endl;
	return 0;
}

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

int N, Y;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Y;
  vector<int> ans(3, -1);

  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N - i; ++j) {
      if (i * 10000 + j * 5000 + (N - i - j) * 1000 == Y) {
        ans[0] = i;
        ans[1] = j;
        ans[2] = N - i - j;
      }
    }
  }

  cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << '\n';
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)

int work1, work2;


int main(){
  int N;
  cin >> N;
  int ans=0;

  while( N%100 == 0) N=N/10;

  if( N == 10) ans = 10;
  else if( N%10 == 0) ans = N/10;
  else{
    while(N>10){
      ans += N%10;
      N = N/10;
    }
    ans += N;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    long long N,W; cin>>N>>W;
    long long low,x; cin>>low>>x;
    vector<long long> a,b,c,d;
    a.push_back(x);
    rep(i,N-1){
        long long w,v; cin>>w>>v;
        if(w-low==0) a.push_back(v);
        if(w-low==1) b.push_back(v);
        if(w-low==2) c.push_back(v);
        if(w-low==3) d.push_back(v);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    sort(d.begin(),d.end());
    a.push_back(0);
    b.push_back(0);
    c.push_back(0);
    d.push_back(0);
    long long A=a.size(),B=b.size(),C=c.size(),D=d.size();
    for(long long i=A-1;i>0;i--) a[i-1]+=a[i];
    for(long long i=B-1;i>0;i--) b[i-1]+=b[i];
    for(long long i=C-1;i>0;i--) c[i-1]+=c[i];
    for(long long i=D-1;i>0;i--) d[i-1]+=d[i];
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    reverse(c.begin(),c.end());
    reverse(d.begin(),d.end());

    long long ans=0;
    for(long long i=0;i<A;i++){
        for(long long j=0;j<B;j++){
            for(long long k=0;k<C;k++){
                for(long long l=0;l<D;l++){
                    if(i*low+j*(low+1)+k*(low+2)+l*(low+3)<=W){
                        ans=max(ans,a[i]+b[j]+c[k]+d[l]);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int a, b, c, d, e, f, g, h;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;
	int suma = a+b+c+d, sumb = e+f+g+h;

	if(suma >= sumb){
		cout << suma << endl;
	}else{
		cout << sumb << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    prime = [1] * (10**5+1)
    prime[1] = 0
    for i in range(2, 10**5+1):
        if i:
            for j in range(2, 10**5+1):
                if i*j <= 10**5:
                    prime[i*j] = 0
                else:
                    break

    cs = [0] * (10**5+1)
    for i in range(1, 10**5+1):
        cs[i] = cs[i-1] + (i&1 and prime[i] and prime[(i+1)//2])
    for _ in range(int(input())):
        l, r = map(int, input().split())
        print(cs[r] - cs[l-1])


if __name__ == '__main__':
    main()


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

class Graph
{
    private :
        int V;
        list<int> *adj;
    public :
        Graph(int V);
        void add_edge(int m,int n);
        int DFS(int s, int a[]);
};
Graph::Graph(int v)
{
    V = v;
    adj = new list<int>[V+1];
}
void Graph::add_edge(int m,int n)
{
    adj[m].push_back(n);
    adj[n].push_back(m);
}
int Graph::DFS(int s, int a[])
{
    // Mark the current node as visited and print it
    int val=a[s];
    if(adj[s].size()==0)return 1;
    // Recur for all the vertices adjacent to this vertex
    list<int>::iterator i;
    for(i = adj[s].begin(); i != adj[s].end(); ++i)
    {
      if(val>a[*i])
      continue;
      else
      {
        return 0;
      }
    }
  return 1;
}

int main()
{
    int n,m,a[100000],f[100000];
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    Graph g(n);
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        g.add_edge(a,b);
    }
  long long int r = 0;
    for(int i=1;i<=n;i++)
    {
      r += g.DFS(i,a);
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 12624
import java.util.*;

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

		for(int i=0;i<9;i++){
			String name=sc.next();
			int am=sc.nextInt(), pm=sc.nextInt();
			System.out.printf("%s %d %d\n",name,am+pm,am*200+pm*300);
		}
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  int n,k;
  cin>>n>>k;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  sort(h,h+n);
  ll ans=0;
  for(int i=0;i<n-k;i++)
    ans+=h[i];
  cout<<ans<<endl;
  return 0;
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int const MX = 200005;
int a[MX];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, k; cin >> n >> k;
    rep(i,n) cin >> a[i+1];

    map<int, int> mp;
    int now = 1, cnt = 1;
    while(1) {
//        cout << now << endl;
        mp[now] = cnt;
        if (mp[a[now]] != 0) break;
        if (cnt > k) {
            cout << now << endl;
            return 0;
        }
        now = a[now];
        cnt++;
    }

    now = a[now];
    int cycle = cnt - mp[now] + 1;
//    cout << "now: " << now << endl;
//    cout << "cnt: " << cnt << endl;
//    cout << "cycle: " << cycle << endl;
//    cout << "offset :" << mp[now] << endl;

    k -= mp[now] - 1;
    if (k) k = k % cycle;
    int p = now;
    rep(i,k) {
//        cout << p << ' ';
        p = a[p];
    }
//    cout << endl;
    cout << p << endl;

    return 0;
}


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

int main(void)
{
    int a[9] = {};
    bool check[9] = {};
    int n = 0;
    for (int i = 0; i < 9; ++i)
    {
        cin >> a[i];
    }
    cin >> n;

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

    /*
    cout << "inputed\n";
    for (int i = 0; i < 9; ++i)
    {
        cout << "a[" << i << "] == " << a[i] << endl;
    }
    cout << "n == " << n << endl;
    for (int i = 0; i < n; ++i)
    {
        cout << "b[" << i << "] == " << b[i] << endl;
    }
    */

    for (int i = 0; i < 9; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (a[i] == b[j])
            {
                check[i] = true;
            }
        }
    }

    /*
    cout << "checked\n";
    for (int i = 0; i < 9; ++i)
    {
        if (check[i] == true)
        {
            cout << "check[" << i << "] == "
                 << "true" << endl;
        }
        else
        {
            cout << "check[" << i << "] == "
                 << "false" << endl;
        }
    }
    */

    if (check[0] == true && check[1] == true && check[2] == true)
    {
        cout << "Yes";
    }
    else if (check[3] == true && check[4] == true && check[5] == true)
    {
        cout << "Yes";
    }
    else if (check[6] == true && check[7] == true && check[8] == true)
    {
        cout << "Yes";
    }

    else if (check[0] == true && check[3] == true && check[6] == true)
    {
        cout << "Yes";
    }
    else if (check[1] == true && check[4] == true && check[7] == true)
    {
        cout << "Yes";
    }
    else if (check[2] == true && check[5] == true && check[8] == true)
    {
        cout << "Yes";
    }

    else if (check[0] == true && check[4] == true && check[8] == true)
    {
        cout << "Yes";
    }
    else if (check[2] == true && check[4] == true && check[6] == true)
    {
        cout << "Yes";
    }

    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3640
N,K,S = map(int,input().split())

if S!=10**9:
    for i in range(K):
        print(S)
    for i in range(N-K):
        print(S+1)
else:
    for i in range(K):
        print(S)
    for i in range(N-K):
        print(3)


Measured memory_bytes: 48860
//#define _GLIBCXX_DEBUG
#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)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int a,b,c,x,y;
signed main(){
  cin>>a>>b>>c>>x>>y;
  int ans = INF;
  rep(i,200001){
    if(i % 2 == 1)continue;
    int sum = c*i;
    sum += a*max(0LL, x-(i/2));
    sum += b*max(0LL, y-(i/2));
    chmin(ans, sum);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>

using namespace std;
long long n,m;
char ch1[100005],ch2[100005];

long long gcd(long long a,long long b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

map<long long,char> plat;

int main(){
    cin >> n >> m;
    for(register int i = 1; i <= n; ++i)
        cin >> ch1[i];
    for(register int i = 1; i <= m; ++i)
        cin >> ch2[i];
    long long lcm = n * m / gcd(n, m);
    for(long long i = 1; i <= m; i++){
        plat[lcm / m * (i - 1) + 1] = ch2[i];
    }
    for(long long i = 1; i <= n; i++){
        if(plat[lcm / n * (i - 1) + 1] && plat[lcm / n * (i - 1) + 1] != ch1[i]){
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << lcm << endl;
    return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	ll K;
	cin>>K;

	ll ans=0;
	ll N=0;
	for(ll i= 0; i<=1e8;i++){
		N=(N*10+7)%K;
		//dout<<i<<':'<<N<<_n;
		if(N%K==0){cout<<i+1;return;}
	}
	cout<<-1<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    if (((n / 10) == 9) || ((n % 10) == 9)) {
    cout << "Yes" << endl;
    }
    else {
    cout << "No" << endl;}
    return 0;
}


Measured memory_bytes: 256
program kadai5
    implicit none
    integer :: a(1:32) = (/1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51/)
    integer :: k
    read(*,*) k
    write(*,*) a(k)

end program kadai5



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	if a % 2 == 0 && a == b && b == c && c == a {
		fmt.Println(-1)
	} else {
		cnt := 0
		for {
			if a % 2 == 0 && b % 2 == 0 && c % 2 == 0 {
				a2 := a / 2
				b2 := b / 2
				c2 := c / 2

				a = b2 + c2
				b = a2 + c2
				c = a2 + b2

				cnt += 1
			} else {
				break
			}
		}
		fmt.Println(cnt)
	}
}


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

typedef long long ll;
const int maxn = 300005;

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

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

inline bool check(int l, int r)
{
    int lbd = 0, rbd = 0;
    for (int i = l; i <= r; i++) {
        if (b[i] < i) {
            if (lbd > b[i] || (b[i] < l || b[i] > r))
                return false;
            lbd = b[i];
        }
        else if (b[i] > i) {
            if (rbd > b[i] || (b[i] < l || b[i] > r))
                return false;
            rbd = b[i];
        }
    }
    return true;
}

int main()
{
    n = gi();
    for (int i = 1; i <= n; i++) b[i] = gi(), a[i] = (b[i] == i);
    for (int i = 2; i < n; i++)
        if (!a[i - 1] && !a[i] && !a[i + 1]) return puts("No"), 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == 0) {
            int now = 1;
            int l = i, r = i;
            while ((a[r] ^ now) && r <= n) ++r, now ^= 1;
            --r;
            if (!check(l, r)) return puts("No"), 0;
            i = r;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll k; cin>>k;
    string s; cin>>s;

    if (sz(s) <= k) {
        cout<<s<<endl;
        return 0;
    }

    s = s.substr(0, k);
    cout<<s + "..."<<endl;
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;
int n,k;
int func(int i)
{	
	return (i*(n-i+1)+1);
}

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

	cin>>n>>k;

	int sum = 0;
	for(int i=k;i<=(n+1);i++)
	{
		sum = (sum+func(i))%mod;
	}

	cout<<sum<<'\n';
	return 0;
}	

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
/*
int dfs(int pos, int nowW) {
	if (pos == N) return 0;
	if (nowW+w[pos] > W) return dfs(pos+1, nowW);
	return max(dfs(pos+1, nowW+w[pos])+v[pos], dfs(pos+1, nowW));
}
*/

int main() {
	int N,W;
	cin>>N>>W;
	vector<int> v(N), w(N);
	for (auto i = 0; i < N; i++)
		cin>>v[i]>>w[i];
	vector<vector<int>> dp(N+1, vector<int>(W+1, 0));
	//dp[position][current weight]
	for (auto i = N-1; i >= 0; i--) {
		for (auto j = 0; j <= W; j++) {
			if (j+w[i] > W) dp[i][j] = dp[i+1][j];
			else dp[i][j] = max(dp[i+1][j+w[i]]+v[i], dp[i+1][j]);
		}
	}
	cout << dp[0][0] << endl;
	return 0;
}

Measured memory_bytes: 4956
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int A,B,m;
vector<int> a,b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A>>B>>m;
    for (int i = 0; i < A; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    for (int i = 0; i < B; i++)
    {
        int temp;
        cin >> temp;
        b.push_back(temp);
    }
    vector<ll> ans;
    rep(i,m){
        int temp,temp1,cost;
        cin>>temp>>temp1>>cost;
        temp--;
        temp1--;
        ans.push_back(a[temp]+b[temp1]-cost);
    }
    sort(ALL(a));
    sort(ALL(b));
    ans.push_back(a[0]+b[0]);
    sort(ALL(ans));
    cout << ans[0] << "\n";
}


Measured memory_bytes: 2424
n, a, b = map(int, input().split())
s = input()

accept = 0
accept_ab = 0
for i in s:
    if i == "a":
        if accept<a+b:
            accept+=1
            print("Yes")
        else:
            print("No")
    if i == "b":
        if accept<a+b and accept_ab <b:
            accept+=1
            accept_ab+=1
            print("Yes")
        else:
            print("No")
    if i =="c":
        print("No")


Measured memory_bytes: 4016
import java.util.Scanner;

public class Main
{
	private static int calcGCD(int a,int b)
	{
		if(b==0){
			return a;
		}else{
			return calcGCD(b,a%b);
		}
	}
	private static int calcLCM(int a,int b)
	{
		int gcd=calcGCD(a,b);
		if(a%gcd==0){
			return (a/gcd)*b;
		}else{
			return (b/gcd)*a;
		}
	}
	
	public static void main(String[] args)
	{
		int a,b;
		int gcd,lcm;
		Scanner scan=new Scanner(System.in);
		while(scan.hasNext()){
			a=scan.nextInt();
			b=scan.nextInt();
			gcd=calcGCD(Math.max(a,b),Math.min(a,b));
			lcm=calcLCM(a,b);
			System.out.println(gcd+" "+lcm);
		}
		scan.close();
	}
}

Measured memory_bytes: 26228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

const ll N=2e5+10;
vector<map<ll,ll>> si(N),dp(N);
vector<set<ll>> G(N);
ll n;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

vector<ll> tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

ll dfs1(ll f, ll ff) {
  if(si[f][ff]) return si[f][ff];
  ll res=0;
  for(auto p:G[f]) {
    if(p==ff) continue;
    res+=dfs1(p,f);
  }
  if(ff) si[ff][f]=n-res-1;
  return si[f][ff]=res+1;
}

ll dfs2(ll f,ll ff) {
  if(dp[f][ff]) return dp[f][ff];
  ll res=1;
  if(dp[f][0]) {
    res=dp[f][0];
    (res*=mpow(dfs2(ff,f),mod-2)*tfact[dfs1(ff,f)]%mod)%=mod;
    (res*=mpow(tfact[dfs1(f,0)-1],mod-2))%=mod;
  }
  else {
    for(auto p:G[f]) {
      if(p==ff) continue;
      (res*=dfs2(p,f)*mpow(tfact[dfs1(p,f)],mod-2)%mod)%=mod;
    }
  }
  (res*=tfact[dfs1(f,ff)-1])%=mod;
  return dp[f][ff]=res;
}

void bfs(ll f) {
  queue<ll> q;
  q.push(f);
  while(q.size()) {
    ll n=q.front();
    q.pop();
    dfs2(n,0);
    for(auto p:G[n]) {
      if(dp[p][0]) continue;
      q.push(p);
    }
  }
}

int main() {
  cin >> n;
  for(ll i=0;i<n-1;i++) {
    ll a,b;
    cin >> a >> b;
    G[a].insert(b);
    G[b].insert(a);
  }
  fact(N);
  bfs(1);
  for(ll i=1;i<=n;i++) {
    cout << dfs2(i,0) << endl;
  }
}

Measured memory_bytes: 202368
#include <stdio.h>
#include<math.h>
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main(void)
{
    long double theta;
    long double a,b,h,hh,x;
    long double V;
    long double tan;
    const long double PI=3.14159265358979323846;

    bool flag;
    scanf("%Lf",&a);
    scanf("%Lf",&b);
    scanf("%Lf",&x);
    if(x>a*a*b/2)
    {
        tan=2*b/a-2*x/(a*a*a);
        theta=atan(tan)*180/PI;
    }
    else
    {
        tan=b*b*a/(2*x);
        theta=atan(tan)*180/PI;
    }
    std::cout<<std::fixed<<std::setprecision(10)<<theta<<endl;
     return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 2000000001;
clock_t START, END;

int ans;

struct Point {
	int x, y, t, l;
	Point(int x = 0, int y = 0) :x(x), y(y) {}
	bool operator < (const Point& rhs) const {
		if (y == rhs.y)
			return t > rhs.t;
		return y < rhs.y;
	}
};
struct Node {
	Node* ch[2];
	int r, v;
	int cmp(int x) const {
		if (x == v) return -1;
		return x < v ? 0 : 1;
	}
};
struct Treap {
	void rotate(Node*& o, int d) {
		Node* k = o->ch[d ^ 1];
		o->ch[d ^ 1] = k->ch[d];
		k->ch[d] = o;
		o = k;
	}
	void insert(Node*& o, int x) {
		if (o == NULL) {
			o = new Node();
			o->ch[0] = o->ch[1] = NULL;
			o->v = x;
			o->r = rand();
		}
		else {
			int d = o->cmp(x);
			insert(o->ch[d], x);
			if (o->ch[d]->r > o->r)
				rotate(o, d ^ 1);
		}
	}
	void remove(Node*& o, int x) {
		int d = o->cmp(x);
		if (d == -1) {
			if (o->ch[0] == NULL)
				o = o->ch[1];
			else if (o->ch[1] == NULL)
				o = o->ch[0];
			else {
				int d2 = (o->ch[0]->r > o->ch[1]->r ? 1 : 0);
				rotate(o, d2);
				remove(o->ch[d2], x);
			}
		}
		else
			remove(o->ch[d], x);
	}
	void find(Node* o, int l, int r) {
		if (o) {
			int L = o->cmp(l);
			int R = o->cmp(r);
			if ((L == -1 || L == 0) && (R == -1 || R == 1)) {
				ans++;
				find(o->ch[0], l, r);
				find(o->ch[1], l, r);
			}
			else if (L == 1)
				find(o->ch[1], l, r);
			else
				find(o->ch[0], l, r);
		}
	}
};

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	};
	int n;
	Point a, b;
	vector<Point> points;
	Treap Set;
	Node* root = NULL;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &a.x, &a.y, &b.x, &b.y);
		if (a.y == b.y) {
			if (a.x > b.x)
				swap(a.x, b.x);
			a.t = 0;
			a.l = b.x;
			points.push_back(a);
		}
		else {
			if (a.y > b.y)
				swap(a.y, b.y);
			a.t = 1;
			b.t = -1;
			points.push_back(a);
			points.push_back(b);
		}
	}
	sort(points.begin(), points.end());
	for (vector<Point>::iterator it = points.begin(); it != points.end(); it++) {
		if (it->t == 0) {
			if (root)
				Set.find(root, it->x, it->l);
		}
		else if (it->t == 1) {
			Set.insert(root, it->x);
		}
		else
			Set.remove(root, it->x);
	}
	cout << ans << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 8788
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""
n = int(input())
v = list(map(int, input().split()))
v.sort()
sp = 0
d = (int(v[0]) + int(v[1])) / 2
for i in range(2, n):
    d = (d + int(v[i])) / 2
print(d)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int a,b,c;
  int ans = 0;
  cin >> a >> b >> c;
  if(a == b && b == c) ans = 1;
  if(a != b && b != c && c!= a) ans = 1;
  if(ans == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())

ans=[0,0]
concentration=0.0
for i in range(F//(100*B)+1):
    tmp_water=100*B*i
    for j in range((F-tmp_water)//(100*A)+1):
        tmp_water+=100*A*j
        max_suger=min((tmp_water//100)*E,F-tmp_water)
        for k in range((max_suger)//D+1):
            tmp_suger=D*k
            tmp_suger+=C*((max_suger-tmp_suger)//C)
            if tmp_water+tmp_suger==0:
                continue
            elif tmp_suger/(tmp_water+tmp_suger)>=concentration:
                concentration=tmp_suger/(tmp_water+tmp_suger)
                ans[0]=tmp_water+tmp_suger
                ans[1]=tmp_suger

print(*ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 1e5 + 5;
ll w[105],v[105];
ll cache[105][mxN];
ll n,W;
ll dp(int idx, ll wleft){
	if(idx>n)
		return 0;
	if(wleft<0)
		return 0;
	ll &ans = cache[idx][wleft];
	if(ans!=-1)
		return ans;
	ll best = 0;
	if(w[idx]<=wleft)
		best = max(best, v[idx]+dp(idx+1,wleft - w[idx]));
	best = max(best , dp(idx+1,wleft));

	return ans = best;
}
void solve(){
	cin>>n;cin>>W;
	memset(cache,-1,sizeof(cache));
	for(int i = 1 ; i <= n;i++){
		cin>>w[i]>>v[i];
	}
	cout<<dp(1,W)<<'\n';
	// for(int i = 1;i<=N;i++){
	// 	for(int i = 0;i<)
	// }
}
int main() {	
	// IOS
	ll T;
	// cin>>T;
	
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 85612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class DCaracalVsMonster {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            long h = s.nextLong();
            out.println(func(h));
//        out.println(Math.pow(2, h) - 1);
        }

        private long func(long h) {
            if (h == 1L) {
                return 1L;
            }

            return 2 * func(h / 2) + 1;
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int N,Q;
vector<int> graph[200020];
int counter[200020];
bool visited[200020];

void dfs(int n) {
    visited[n] = true;
    for(int i = 0;i < graph[n].size();i++) {
        if(visited[graph[n].at(i)] == false) {
            counter[graph[n].at(i)] += counter[n];
            dfs(graph[n].at(i));
        }
    }
    visited[n] = false;
    return;
}

int main() {
    cin >> N >> Q;
    for(int i = 0;i < N - 1;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }
    for(int i = 0;i < N;i++) {
        counter[i] = 0;
        visited[i] = false;
    }
    for(int i = 0;i < Q;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        counter[A] += B;
    }
    dfs(0);
    for(int i = 0;i < N;i++) {
        cout << counter[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 23680
# -*- coding: utf-8 -*-

def main():
     k, n = map(int, input().split())
     l = list(map(int, input().split()))

     l = sorted(l)
     diff_max = 0
     for i in range(len(l)-1):
          diff = l[i+1] - l[i]
          if diff_max < diff:
               diff_max = diff
     
     ans = k - diff_max
     last = l[-1] - l[0]
     if last < ans:
          ans = last
     print(ans)

if __name__ == "__main__":
    main()


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using VI = vector<int>;


int main()
{
  int N, K;
  cin >> N >> K;
  vector<bool> check(N);
  REP(i, K) {
    int d; cin >> d;
    int m;
    REP(j, d) {
      cin >> m;
      check[m-1] = true;
    }
  }
  int ans = 0;
  REP(i, N) {
    if(!check[i])
      ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define P push
#define x1 xx
#define y1 yy
#define x2 xxx
#define y2 yyy
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MOD = 1e8;
const int MAX = 1e5+5;
ll a[111];
ll res=100000000000;


int main()
{
    ll n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=-100;i<=100;i++){
            ll sum=0;
        for(int j=0;j<n;j++){
            if(a[j]==i)continue;
            sum+=abs(i-a[j])*abs(i-a[j]);
        }
        res=min(res,sum);
    }
    cout<<res;

        return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
c = 0
while True:
  for i in range(n):
    if a[i] / 2 == a[i] // 2:
      a[i] = a[i] // 2
    else:
      print(c)
      exit()
  c += 1

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

int main(){
    int n,m;
    cin >> n >> m;
    int city[n];
    int i,j;
    int a,b;
    for(i=0;i<n;i++)
        city[i] =0;
    
    for(i=0;i<m;i++){
        cin >> a >> b;
            for(j=0;j<n;j++){
                if(a==j+1 || b==j+1)
                    city[j]++;
            }
    }
    
    for(i=0;i<n;i++)
        cout << city[i] << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

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

    string s;
    set<string> backet;
    int res = 0;
    cin >> s;

    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    for(int i = 2; i < s.size()-1; ++i){
         if(backet.count("C") == 1 && res == 2){
            cout << "WA" << endl;
            return 0;
        }
        if(s[i] == 'C'){
            backet.insert("C");
            ++res ;            
        }
    }
    if(backet.count("C") == 1 && res == 2){
       cout << "WA" << endl;
        return 0; 
    }
    if(backet.count("C") == 0){
            cout << "WA" << endl;
            return 0;
        } 

    for(int i = 0; i < s.size(); ++i){
        if(s[i] != 'A'){
            if(s[i] != 'C'){
                if( 'a' <= s[i] && s[i] <= 'z'){
                    }else{
                     cout << "WA" << endl;
                    return 0; 
                }
            }
        }
    }

    cout << "AC" << endl;
    return 0;

}

Measured memory_bytes: 888
#include <bits/stdc++.h>
 
using namespace std;
 
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define All(a, b) for(auto &a : b)
#define Rep(a, b, c) for(int a = b; a < c; ++a)
 
#define int long long
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
 
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bitone(i) __builtin_popcount(i)
#define bitl(i) __builtin_clz(i)
#define bitr(i) __builtin_ctz(i)
 
const int N=2e5+5;
int n, a[N];
 
main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	For(i, 1, n) cin >> a[i];
	sort(a + 1, a + n + 1);
	For(i, 1, n){
		if(a[i] == a[i + 1]) return cout << "NO",0; 
	}
	cout << "YES";
}

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

typedef long long ll;
using namespace std;

int h, w, n, sr, sc;

const char DIRECTIONS[4] = { 'U', 'D', 'L', 'R' };

int main() {
    string s, t;
    cin >> h >> w >> n >> sr >> sc >> s >> t;
    sr--;
    sc--;
    for (auto target: DIRECTIONS) {
        if (target == 'U') {
            int r = sr;
            for (int i = 0; i < n; i++) {
                if (s[i] == 'U') {
                    r--;
                    if (r < 0) {
                        printf("NO");
                        return 0;
                    }
                }
                if (t[i] == 'D' && r < h - 1) {
                    r++;
                }
            }
        } else if (target == 'D') {
            int r = sr;
            for (int i = 0; i < n; i++) {
                if (s[i] == 'D') {
                    r++;
                    if (r > h - 1) {
                        printf("NO");
                        return 0;
                    }
                }
                if (t[i] == 'U' && r > 0) {
                    r--;
                }
            }
        } else if (target == 'L') {
            int c = sc;
            for (int i = 0; i < n; i++) {
                if (s[i] == 'L') {
                    c--;
                    if (c < 0) {
                        printf("NO");
                        return 0;
                    }
                }
                if (t[i] == 'R' && c < w - 1) {
                    c++;
                }
            }
        } else if (target == 'R') {
            int c = sc;
            for (int i = 0; i < n; i++) {
                if (s[i] == 'R') {
                    c++;
                    if (c > w - 1) {
                        printf("NO");
                        return 0;
                    }
                }
                if (t[i] == 'L' && c > 0) {
                    c--;
                }
            }
        }
    }
    printf("YES");
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORD(i, b, a) for (int i = b; i >= a; --i)

#define sz(v) ((int) v.size())
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())

using namespace std;

const int maxn = 5e5 + 10;

int n;
int a[maxn], in[maxn];
vector<int> adj[maxn];

void dfs(int u) {
  for (int v : adj[u]) if (a[v] <= a[u]) {
    a[v] = a[u] + 1;
    dfs(v);
  }
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  string s; cin >> s;
  n = sz(s);
  REP(i, n) if (s[i] == '<') {
    adj[i].push_back(i + 1);
    in[i + 1]++;
  } else {
    adj[i + 1].push_back(i);
    in[i]++;
  }
  REP(i, n + 1) if (!in[i]) {
    dfs(i);
  }
  long long res = 0;
  REP(i, n + 1) res += a[i];
  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 47644
#include <iostream>
#define rep(i) for(i=0;i<5;i++)
using namespace std;
int main(){
  int a[5],i;
  while(cin>>a[0],a[0]){
    int b[3]={0};
    b[a[0]-1]++;
    for(i=1;i<5;i++){
      cin>>a[i];
      b[a[i]-1]++;
    }
    if(b[0]&&b[1]&&!b[2])rep(i)cout<<((a[i]==1)?1:2)<<endl;
    else if(b[0]&&!b[1]&&b[2])rep(i)cout<<((a[i]==3)?1:2)<<endl;
    else if(!b[0]&&b[1]&&b[2])rep(i)cout<<((a[i]==2)?1:2)<<endl;
    else rep(i)cout<<'3'<<endl;
  }
}

Measured memory_bytes: 2992
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

S = readline().rstrip()
S = S.replace('BC', '#')

tmp = 0
ans = 0
for i in range(len(S)-1,-1,-1):
	if S[i] == "#":
		tmp += 1
	elif S[i] == "A":
		ans += tmp
	else:
		tmp = 0
print(ans)


Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define ll long long
#define test(a) cout << "*" << a << endl;
#define ss stringstream
int main (){
  int i,j;
  int N,M;
  int P[100001];
  int Y[100001];
  vector<ll>vec[100001];
  int X[100001][100001];
  
  cin >> N >> M;
  rep1(i,M){
    cin >> P[i] >> Y[i];
    vec[P[i]].push_back(Y[i]);
  }
  rep1(i,N){
    sort(vec[i].begin(),vec[i].end());
  }
  
  rep1(i,M){
    cout << setw(6) << setfill('0') << P[i] ;
    j = vec[P[i]].size()/2 ;
    if(Y[i] < vec[P[i]][ vec[P[i]].size()/2 ]){    
      while(1){
        if(vec[P[i]][j] == Y[i]){
          cout << setw(6) << setfill('0') << j+1 << endl;
          break;
        }
        j--; 
      }
    }   
    else{
      while(1){
        if(vec[P[i]][j] == Y[i]){
          cout << setw(6) << setfill('0') << j+1 << endl;
          break;
        }
        j++;
      }      
    } 
   
  }
 
}

Measured memory_bytes: 7808
import sys
N,K=map(int, input().split())
A=list(map(int, input().split())) 
A.sort(reverse=1)
m=A[0]
for i in range(N-1):
  if A[i]!=A[i+1]:
    m=min(m,A[i]-A[i+1])

n=K%m
if K>A[0]:
  print("IMPOSSIBLE")
  sys.exit()
for i in range(N):
  if A[i]%m==n:
    print("POSSIBLE")
    sys.exit()

print("IMPOSSIBLE")

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 998244353
#define pi 3.141592653589793
const int N = 2000001;
using namespace std;



int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    pair<int, char> p[a + b + c];
    for (int i = 0; i < a; i++) {
        cin >> p[i].first;
        p[i].second = 'a';
    }

    for (int i = a; i < a + b; i++) {
        cin >> p[i].first;
        p[i].second = 'b';
    }

    for (int i = a + b; i < a + b + c; i++) {
        cin >> p[i].first;
        p[i].second = 'c';
    }

    sort(p, p + a + b + c, greater<>());
    int n = x + y;
    vector<pair<int, char>> final;
    for (auto e : p) {
        if (e.second == 'a') {
            if (x) {
                --x;
                final.pb(e);
            }
        }

        if (e.second == 'b') {
            if (y) {
                --y;
                final.pb(e);
            }
        }

        if (e.second == 'c') {
            final.pb(e);
        }

        if (final.size() == n) {
            break;
        }
    }

    ll ans = 0;
    for (auto e : final) {
        ans += e.first;
        if (e.second == 'c') {
            x ? --x : --y;
        }
    }

    cout << ans;

}


Measured memory_bytes: 4852