akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int N,M,P;
typedef vector<int> vec;
int cnt = 0;
char S[200];
map<string,vec> mp;
map<string,string> mmp;
map<vec,string> vp;
void init(){
  cnt = 0;
  mp.clear(); mmp.clear(); vp.clear();
}

bool asset(char c){
  if( S[cnt] == c ) {
    cnt++; return true;
  }
  return false;
}

vec variable();
vec factor();
vec term();
vec formula();
vec operator*( const vec& a, const vec& b ) {
  if( a.empty() || b.empty() ) return vec();
  vec x = vec( N );
  for(int i=0;i<N;i++) x[i] = a[i] + b[i];
  return x;
}
vec operator/(const vec& a, const vec& b) {
  if( a.empty() || b.empty() ) return vec();
  vec x = vec( N );
  for(int i=0;i<N;i++) x[i] = a[i] - b[i];
  return x;
}
bool check( const vec &a, const vec &b ){
  if( a.empty() || b.empty() ) return false;
  for(int i=0;i<N;i++)
    if( a[i] != b[i] ) return false;
  return true;
}
vec variable(){
  string s = "";
  while( ( 'a' <= S[cnt] && S[cnt] <= 'z' ) ||
         ( 'A' <= S[cnt] && S[cnt] <= 'Z' ) ){
    s += S[cnt];
    asset( S[cnt] );
  }
  return mp[ mmp[s] ];  
}
vec factor(){
  if( asset( '(' ) ){
    vec v = formula();
    asset(')');
    return v;
  } else
    return variable();
}
vec term(){
  vec v = factor();
  while( true ){
    if( asset( '*' ) ){
      vec nv = factor();
      v = v * nv;
    } else if( asset( '/' ) ){
      vec nv = factor();
      v = v / nv;
    } else
      break;
  }
  return v;
}
vec formula(){
  vec v = term();
  while( true ){
    if( asset( '+' ) ) {}
    else if( asset( '-' ) ){}
    else break;
    vec nv = term();
    if( !check( v, nv ) ) return vec();
  }
  return v;
}

int main(){
  while( cin >> N >> M >> P && (N|M|P) ){
    init();
    for(int i=0;i<M;i++){
      string a;
      cin >> a;
      vec v = vec( N );
      for(int j=0;j<N;j++){
        int d; cin >> d;
        v[j] = d;
      }
      mp[a] = v;
      vp[v] = a;
    }
    cin >> S;
    for(int i=0;i<P;i++){
      string a,b; cin >> a >> b;
      mmp[a] = b;
    }
    vec v = formula();


    if( v.empty() ){
      cout << "error" << endl;
    } else if( vp.count( v ) ){
      cout << vp[v] << endl;
    } else {
      cout << "undefined" << endl;
    }
  }  
}

Measured memory_bytes: 3180
#include <cstdio>
#include <algorithm>
#include <bitset>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr i32 N = 100000;
i32 dp[N];

auto main() -> i32 {
	i32 n, m;
	scanf("%d%d", &n, &m);
	std::vector<i32> rev[n];
	std::vector<i32> edge[n];

	for (i32 i = 0; i < m; i += 1) {
		i32 x, y;
		scanf("%d%d", &x, &y);
		--x, --y;
		rev[y].push_back(x);
		edge[x].push_back(y);
	}

	std::vector<i32> sorted;
	std::bitset<N> visit;

	for (i32 i = 0; i < n; i += 1) {
		if (visit[i]) {
			continue;
		}
		std::vector<i32> q;
		q.push_back(i);
		while (q.size() > 0) {
			i32 v = q.back();
			q.pop_back();
			if (v < 0) {
				sorted.push_back(~v);
				continue;
			}
			if (visit[v]) {
				continue;
			}
			visit[v] = true;
			q.push_back(~v);
			for (auto to : edge[v]) {
				if (!visit[to]) {
					q.push_back(to);
				}
			}
		}
	}

	i32 ans = 0;

	for (auto v : sorted) {
		for (auto from : rev[v]) {
			dp[from] = std::max(dp[from], dp[v] + 1);
			if (ans < dp[from]) {
				ans = dp[from];
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 14640
#include "bits/stdc++.h"

using namespace std;

struct unionfind
{
	//rankのオーバーフローに注意
	vector<int> par, rank;
	unionfind(int n)
	{
		par.resize(n);
		rank.resize(n);
		for (int i = 0; i < n; i++)
		{
			par[i] = i;
			rank[i] = 1;
		}
	}

	bool same(int u, int v)
	{
		return root(u) == root(v);
	}

	void unite(int u, int v)
	{
		if (same(u, v)) return;
		u = root(u), v = root(v);
		if (rank[u] > rank[v]) swap(u, v);
		par[u] = v;
		rank[v] += rank[u];
	}

	int root(int v)
	{
		if (par[v] == v) return v;
		return par[v] = root(par[v]);
	}
};

void solve()
{
	int s, t;
	cin >> s >> t;
	vector<pair<int, int>> es(t);
	for (int i = 0; i < t; i++)
	{
		cin >> es[i].first >> es[i].second;
	}
	reverse(es.begin(), es.end());

	unionfind uf(s);

	long a = 1L*s*(s-1)/2;
	vector<long> ans;

	for (auto e : es)
	{
		ans.push_back(a);
		int v = e.first-1, u = e.second-1;
		if (!uf.same(u, v)) a -= 1L*uf.rank[uf.root(u)]*uf.rank[uf.root(v)];
		uf.unite(u, v);
	}

	reverse(ans.begin(), ans.end());

	for (long a : ans)
	{
		cout << a << endl;
	}
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;

int dgSum(int x){
    int tot = 0;
    while(x){
        tot += (x % 10);
        x /= 10;
    }

    return tot;
}

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

    int n;  cin >> n;

    int fRes = BIG;
    for(int x = 1; x < n; x++){
        int y = n - x;
        fRes = min(fRes, dgSum(x) + dgSum(y));
    }

    cout << fRes << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int sum = a + b;
			int count = 0;
			while(sum != 0)
			{
				sum /= 10;
				++count;
			}
			System.out.println(count);
		}
	}
}

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

int main(){
    char b, ans; cin >> b;
    switch(b){
        case 'A': ans = 'T'; break;
        case 'C': ans = 'G'; break;
        case 'G': ans = 'C'; break;
        case 'T': ans = 'A'; break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<string>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5+5
#define nax (int)1e6+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define MAX_N (int)1e6+2
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// look for  all edge cases
//search for a pattern




	
signed main(){
	fast;
	
	string s,t;
	cin >> s >> t;
	int n = s.size();
	int ans =0 ;
	for(int i = 0 ; i< n;i++){
		if(s[i] != t[i]){
			ans++;
		}
	}
	
	cout<<ans;

	return 0;
}

	



Measured memory_bytes: 3800
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int n;
int a[200000];
int main(){
  cin >> n;
  REP(i,n) cin >> a[i+1];
  a[0] = 0;
  a[n+1]=0;
  int wa=0;
  REP(i,n+1) wa +=abs(a[i+1]-a[i]);
  REP(i,n){
    cout << wa-(abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1]))+abs(a[i+2]-a[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define MAX 1000
#define VMAX 10000
using namespace std;
int A[MAX],B[MAX],n,s;
int T[VMAX+1];
int solve(){
    bool V[MAX];
    int ans=0;
    for(int i=0;i<n;i++){
        B[i]=A[i];
        V[i]=false;
    }
    sort(B,B+n);
    for(int i=0;i<n;i++){
        T[B[i]]=i;
    }
    for(int i=0;i<n;i++){
        if(V[i])    
            continue;
        int cur=i;
        int S=0;
        int an=0;
        int m=VMAX;
        while(1){
            V[cur]=true;
            int v=A[cur];
            S+=v;
            an++;
            m=min(m,v);
            cur=T[v];
            if(V[cur])  
                break;
        }
        ans+=min(S+(an-2)*m,S+m+(an+1)*s);
    }
    return ans;
}
int main(){
    cin>>n;
    s=VMAX;
    for(int i=0;i<n;i++){
          cin>>A[i];
          s=min(s,A[i]);
    }
    int ans=solve();
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<char> storn(N);
  for(int i=0;i<N;i++){
    cin >> storn.at(i);
  }
  int count =0;
  for(int i=0;i<N;i++){
    if(storn.at(i)=='R'){
      count++;
    }
  }
  int count2 =0;
  for(int i=0;i<count;i++){
    if(storn.at(i)=='R'){
      count2++;
    }
  }
  cout << count-count2 <<endl;
}

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

int main()
{
	int n, m;
	cin >> n;

	vector<int> a(n);

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

	cin >> m;

	vector<int> b(m);

	for (int i = 0; i < m; i++)
		cin >> b[i];

	int f = 0;

	if (lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()))
		f = 1;

	cout << f << endl;

	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;

int main(int argc, char const *argv[])
{
	int n, x[100], y[100];
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> x[i];
	for (int i = 0; i < n; ++i) cin >> y[i];
	long double sum = 0;

	for (int i = 0; i < n; ++i) sum += abs(x[i] - y[i]);
	cout << sum << endl;
	sum = 0;

	for (int i = 0; i < n; ++i) sum += (x[i] - y[i]) * (x[i] - y[i]);
	cout << setprecision(10) << sqrt(sum) << endl;
	sum = 0;

	for (int i = 0; i < n; ++i) sum += abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
	cout << setprecision(10) << cbrt(sum) << endl;
	sum = 0;

	for (int i = 0; i < n; ++i) sum = max(sum, (long double)abs(x[i] - y[i]));
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3364
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a, b, c,d;
	if (n < 1000)a = 0;
	else {
		a = n / 1000;
		n -= a * 1000;
	}
	if (n < 100)b = 0;
	else {
		b = n / 100;
		n -= b * 100;
	}
	if (n < 10)c = 0;
	else {
		c = n / 10;
		n -= c * 10;
	}
	if (n == 0)d = 0;
	else d = n;
	
	if (a + b + c + d == 7)cout << a << '+' << b << '+' << c << '+' << d << "=7";
	else if (a + b + c - d == 7)cout << a << '+' << b << '+' << c << '-' << d << "=7";
	else if (a + b - c + d == 7)cout << a << '+' << b << '-' << c << '+' << d << "=7";
	else if (a + b - c - d == 7)cout << a << '+' << b << '-' << c << '-' << d << "=7";
	else if (a - b + c + d == 7)cout << a << '-' << b << '+' << c << '+' << d << "=7";
	else if (a - b - c + d == 7)cout << a << '-' << b << '-' << c << '+' << d << "=7";
	else if (a - b - c - d == 7)cout << a << '-' << b << '-' << c << '-' << d << "=7";
	else if (a - b + c - d == 7)cout << a << '-' << b << '+' << c << '-' << d << "=7";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderAGC033
{
    class Program
    {
        public struct point
        {
            public int h, w;
            public point(int h, int w)
            {
                this.h = h;
                this.w = w;
            }
        }
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split().Select(int.Parse).ToList();
            var Masu = new char[HW[0] + 2, HW[1] + 2];
            var qu = new Queue<point>();
            for (int i = 1; i <= HW[0]; ++i)
            {
                var line = Console.ReadLine();
                for (int j = 1; j <= HW[1]; ++j)
                {
                    Masu[i, j] = line[j - 1];
                    if ('#' == line[j - 1])
                    {
                        qu.Enqueue(new point(i, j));
                    }
                }
            }

            Func<int, int, bool> act = (int h, int w) =>
            {
                if ('.' == Masu[h, w])
                {
                    qu.Enqueue(new point(h, w)); Masu[h, w] = '#';
                    return true;
                }
                return false;
            };

            long count = 0;
            while (qu.Any())
            {
                var cnt = qu.Count();
                var b = false;
                for (int i = 0; i < cnt; ++i)
                {
                    var pt = qu.Dequeue();
                    b |= act(pt.h, pt.w + 1);
                    b |= act(pt.h, pt.w - 1);
                    b |= act(pt.h + 1, pt.w);
                    b |= act(pt.h - 1, pt.w);
                }
                if (b)
                { ++count; }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 32224
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

ll n,m,v,p;
vl a;
vl s;

bool check(int X){
  if(X <= p-1) return true;
  if(a[p-1] - a[X] > m) return false;

  // 票の受け皿の数
  ll num = n*m + (X-p+1)*a[X] - (s[X] - s[p-1]);
  return num >= m*v;
}


int main(){
  cin >> n >> m >> v >> p;
  a.resize(n);

  rep(i,n) cin >> a[i];

  sort(all(a), greater<ll>());

  s.resize(n+1);
  rep(i,n) s[i+1] = s[i] + a[i];

  int ok = 0, ng = n;
  while (abs(ng-ok)>1){
    int mid = (ok+ng)/2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok+1 << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <functional>
using namespace std;

typedef long long ll;
const ll InF = 1e9;

ll dfs(int N, int A, int B, int C, vector<int> l, int cur, int a, int b, int c) {
  if (cur == N) {
    if (min(a,min(b,c))>0) return abs(a-A)+abs(b-B)+abs(c-C) - 30;
    else return InF;
  }
  ll ret0,ret1,ret2,ret3;
  ret0 = dfs(N,A,B,C,l,cur+1,a+l[cur],b,c) + 10;
  ret1 = dfs(N,A,B,C,l,cur+1,a,b+l[cur],c) + 10;
  ret2 = dfs(N,A,B,C,l,cur+1,a,b,c+l[cur]) + 10;
  ret3 = dfs(N,A,B,C,l,cur+1,a,b,c);
  return min(ret0,min(ret1,min(ret2,ret3)));
}

int main() {
  int N,A,B,C;
  cin>>N>>A>>B>>C;
  vector<int> l(N);
  for (int i = 0; i < N; i++) cin>>l[i];
  ll ans;
  ans = dfs(N,A,B,C,l,0,0,0,0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 998244353;
const int NMAX = 100020;

using namespace std;

struct UnionFind{
    ll parent[NMAX];
    ll separate[NMAX];
    ll count[NMAX];

    void Create(int n){
        for(int i = 0; i <= n; i++){
            parent[i] = i;
            count[i] = 1;
            separate[i] = 0;
        }
    }

    int Root(int i){
        if(parent[i] == i){
            return i;
        } else {
            parent[i] = Root(parent[i]);
            return parent[i];
        }
    }

    void Unite(int x, int y){
        int px = Root(x);
        int py = Root(y);
        if(px != py){
            if (count[px] > count[y]) swap(px, py);
            parent[px] = py;
            count[py] += count[px];
        }
    }

    bool Same(int x, int y){
        if(Root(x) == Root(y)){
            return true;
        } else {
            return false;
        }
    }

    void Devide(int x, int y){
        if(Same(x,y)){
            separate[x]++;
            separate[y]++;
        }
    }

    ll Count(int x){
        ll c = count[Root(x)] - 1;
        c -= separate[x];
        return c;
    }
};

int main(){
    std::ios::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    UnionFind uf;
    uf.Create(n);


    vector<int> f(n+1, 0);
    ll ans[NMAX];

    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        f[a]++;
        f[b]++;
        uf.Unite(a,b);
    }

    for(int i = 0; i < k; i++){
        int c,d;
        cin >> c >> d;
        uf.Devide(c,d);
    }

    for(int i = 1; i <= n; i++){
        ans[i] = uf.Count(i) - f[i];
        cout << ans[i];
        if(i != n){
            cout << " ";
        } else {
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n==1)
        cout<<"Hello World"<<endl;
    else
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[500010], bit[500010], n, m[500010], ans[500010];

pair< pair<ll,ll>, ll>p[500010];

void update(ll idx, ll val)
{
    while(idx<=n)
    {
        bit[idx]+=val;
        idx+= idx & (- idx);
    }
}

ll sum(ll idx)
{
    ll tot=0;
    while(idx>0)
    {
        tot+=bit[idx];
        idx-= idx & (- idx);
    }
    return tot;
}
int main()
{
    ll t,i,j,k,l,r,mn=0, mx=0;
    sl2(n,k);
    for( i=1; i<=n; i++)
    {
        sl(a[i]);
    }

    for(i=0; i<k; i++)
    {
        sl2(l,r);
        p[i].ff.ff=r;
        p[i].ff.ss=l;
        p[i].ss=i;
    }

    sort(p, p+k);
    /*for(i=0; i<k; i++)
    {
        cout<<p[i].ff.ss<<" "<<p[i].ff.ff<<" "<<p[i].ss<<endl;
    }*/
    memset(m, -1, sizeof(m));
    ll cnt=0;
    for( i=1; i<=n; i++)
    {
        if(m[a[i]]!=-1)
        {
            //cout<<i<<endl;
            update(m[a[i]], -1LL);
        }
        m[a[i]]=i;
        update(i, 1);

       // cout<<cnt<<" "<<p[i].ff.ff<<endl;
        while(cnt<k &&   p[cnt].ff.ff==i)
        {
            //cout<<p[i].ss<<" "<<sum(p[i].ff.ff)<<" "<<sum(p[i].ff.ss-1)<<endl;
            ans[p[cnt].ss] = sum(p[cnt].ff.ff) - sum(p[cnt].ff.ss-1);
            cnt++;
        }
    }

    for(i=0; i<k; i++)
    {
        printf("%lld\n", ans[i]);
    }

}




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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	LL two = 0;
	LL four = 0;
	FOR(i, 0, N) {
		LL cnt = 0;
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			cnt++;
		}
		if (cnt > 1)four++;
		else if (cnt)two++;
	}
	LL ans = (four*2+1>=N)||(2*four+two>=N);

	cout << (ans?"Yes":"No") << endl;

	return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll K, N;
  IN(K,N);
  vll A(N);
  REP(i,N) IN(A[i]);
  vll B(N, 0);
  REP(i,N-1) B[i] = A[i+1] - A[i];
  B[N-1] = A[0] + K-A[N-1];
  //vec_print(B);
  sort(ALL(B));
  reverse(ALL(B));
  OUT(K-B[0]);

  return 0;
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main(){
  int days,sj,sm,j,m;
  cin >> days >> sj >> sm >> j >> m;
  while(1){
    if(sj<=0 && sm<=0)break;
    sj-=j;
    sm-=m;
    days--;
  }
  cout << days << endl;
  return 0;
}

Measured memory_bytes: 1160
a = input()
b = input()
if len(a) > len(b):
    print('GREATER')
    exit()
if len(a) < len(b):
    print('LESS')
    exit()
for i in range(len(a)):
    if a[i] > b[i]:
        print('GREATER')
        exit()
    if a[i] < b[i]:
        print('LESS')
        exit()
print('EQUAL')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,x,a,b;
int main(void){
    cin>>n>>m>>x;
    for(int i=0;i<m;i++){
        int s;
        cin>>s;
        if(s<=x)a++;
        else b++;
    }
    cout<<min(a,b)<<endl;
}


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


def solve(N: int):
    digits = [[0 for i in range(10)] for j in range(10)]
    d = 1
    for i in range(1, N+1):
        last = i % 10
        first = i//d
        if first >= 10:
            d *= 10
            first = i//d
        digits[last-1][first-1] += 1
    sum = 0
    for i in range(10):
        for j in range(10):
            sum += digits[i][j]*digits[j][i]
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int dp[10000];
int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  std::vector<int > a(M), b(M);
  std::vector<int > c[1004];
  int cc;
  for (int i=0 ;i<M; i++){
    scanf("%d", &a[i]);
    scanf("%d", &b[i]);
    for (int j=0 ;j<b[i]; j++){
      scanf("%d", &cc);
      cc--;
      c[i].push_back(cc);
    }
  }

  for (int i=0; i<10000; i++){
    dp[i]=1000000005;
  }
  
  dp[0]=0;
  
  for (int i=0; i<5000; i++){
  //for (int i=0; i<30; i++){
    //printf("====i=%d====\n", i);
    for (int j=0; j<M; j++){
      int s=i;
      for (int k=0; k<b[j]; k++){
	s = s|(1<<c[j][k]);
      }
      dp[s]=std::min(dp[i]+a[j], dp[s]);
      //printf("dp[%d]=%d\n", s, dp[s]);
    }
  }
  printf("%d\n", (dp[(1<<N)-1]==1000000005)?-1:dp[(1<<N)-1]);
  return 0;
}

Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	ll n; int k;
	while(~scanf("%lld%d", &n, &k)) {
		ll ans = 0;

		if(3 <= n && (n + 4 * k) % 11 == 0) ans += (n * 5 + k * 240 + 187) / 11;
		if(3 <= n && 4 * k % 11 == 0) ans -= (k * 240 + 187) / 11;
		if(3 <= n && (n + 4 * k + 1) % 11 == 0) ans += (n * 5 + k * 240 + 181) / 11;
		if(3 <= n && (4 * k + 1) % 11 == 0) ans -= (k * 240 + 192) / 11;
		if(3 <= n && (n + 4 * k + 2) % 11 == 0) ans += (n * 5 + k * 240 + 186) / 11;
		if(3 <= n && (4 * k + 2) % 11 == 0) ans -= (k * 240 + 197) / 11;
		if(3 <= n && (n + 4 * k + 3) % 11 == 0) ans += (n * 5 + k * 240 + 180) / 11;
		if(3 <= n && (4 * k + 3) % 11 == 0) ans -= (k * 240 + 191) / 11;
		if(3 <= n && (n + 4 * k + 4) % 11 == 0) ans += (n * 5 + k * 240 + 174) / 11;
		if(3 <= n && (4 * k + 4) % 11 == 0) ans -= (k * 240 + 196) / 11;
		if(3 <= n && (n + 4 * k + 5) % 11 == 0) ans += (n * 5 + k * 240 + 179) / 11;
		if(3 <= n && (4 * k + 5) % 11 == 0) ans -= (k * 240 + 190) / 11;
		if(3 <= n && (n + 4 * k + 6) % 11 == 0) ans += (n * 5 + k * 240 + 173) / 11;
		if(3 <= n && (4 * k + 6) % 11 == 0) ans -= (k * 240 + 184) / 11;
		if(3 <= n && (n + 4 * k + 7) % 11 == 0) ans += (n * 5 + k * 240 + 178) / 11;
		if(3 <= n && (4 * k + 7) % 11 == 0) ans -= (k * 240 + 189) / 11;
		if(3 <= n && (n + 4 * k + 8) % 11 == 0) ans += (n * 5 + k * 240 + 183) / 11;
		if(3 <= n && (4 * k + 8) % 11 == 0) ans -= (k * 240 + 183) / 11;
		if(3 <= n && (n + 4 * k + 9) % 11 == 0) ans += (n * 5 + k * 240 + 177) / 11;
		if(3 <= n && (4 * k + 9) % 11 == 0) ans -= (k * 240 + 188) / 11;
		if(3 <= n && (n + 4 * k + 10) % 11 == 0) ans += (n * 5 + k * 240 + 182) / 11;
		if(3 <= n && (4 * k + 10) % 11 == 0) ans -= (k * 240 + 193) / 11;

		printf("%lld\n", ans);
	}
	return 0;
}


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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    string x, y;
    cin >> x >> y;

    LL L = x.size();
    y.Pb('.');

    for(LL i = 0; i < L; i++){
        cout << x[i];
        if(y[i] != '.')
            cout << y[i];
    }

    cout << '\n';

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n; cin >> n;
    int arr[n];
    unordered_map<int, int> m, vis;
    for(int i=0; i<n; i++){
        cin >> arr[i];
        m[arr[i]] += 1;
    }
    ll ans = 1;
    for(auto j:m){
        if(vis[j.first]) continue;
        if(j.second > 2) ans *= 0;
        if(j.first == 0 && j.second > 1) ans*=0;
        if(j.first != 0){ans *= 2; ans %= 1000000007;}
        vis[j.first] = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7076
N=int(input())
S=[input() for i in range(N)]
AC_count=0
WA_count=0
TLE_count=0
RE_count=0
for i in range(N):
    if S[i]=="AC":AC_count+=1
    if S[i]=="WA":WA_count+=1
    if S[i]=="TLE":TLE_count+=1
    if S[i]=="RE":RE_count+=1
print("AC x "+str(AC_count))
print("WA x "+str(WA_count))
print("TLE x "+str(TLE_count))
print("RE x "+str(RE_count))

Measured memory_bytes: 16196
#include <bits/stdc++.h>
using namespace std;
int n, i;
char a[11], b[11];
int main(){
	scanf("%s\n", &a);
	scanf("%s", &b);
	n = strlen(a);
	for(i=0; i<=n; i++){
		if(a[i] != b[i]) break;
	}
	if(i == n) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const long long mod=1000000007;
long long f[2005][2005];
long long fac[5000005],inv[5000005];
int n,k;
long long qpow(long long a,long long b){
	b%=(mod-1);
	a=a%mod;
	long long ans=1;
	while(b){
		if(b&1)	ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(){
	fac[0]=inv[0]=1;
	for(int i=1;i<=5000000;i++)	fac[i]=fac[i-1]*i%mod;
	inv[5000000]=qpow(fac[5000000],mod-2);
	for(int i=4999999;i>=1;i--)	inv[i]=inv[i+1]*(i+1)%mod;
}
long long C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	init();
	scanf("%d%d",&n,&k);
	if(k==1){
		puts("1");
		return 0;
	}	
	f[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=i;j<=n;j++){
			if(i==0&&j==0)	continue;
			if(i)	f[i][j]=(f[i][j]+f[i-1][j])%mod;
			f[i][j]=(f[i][j]+f[i][j-1]*C(i+(j-1)*(k-1)+1+k-2-1,i+(j-1)*(k-1)+1-1)%mod)%mod;
		}
	}
	cout<<f[n][n]*fac[n]%mod<<endl;
}

Measured memory_bytes: 109056
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    int M = T.size();

    int dp[N+1][M+1];
    fill(dp[0], dp[N+1], 0);

    pair<int, int> before[N+1][M+1];
    bool appended[N+1][M+1];
    fill(appended[0], appended[N+1], false);

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (S[i] == T[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
                before[i+1][j+1] = make_pair(i, j);
                appended[i+1][j+1] = true;
            } else {
                if (dp[i][j+1] > dp[i+1][j]) {
                    dp[i+1][j+1] = dp[i][j+1];
                    before[i+1][j+1] = make_pair(i, j+1);
                } else {
                    dp[i+1][j+1] = dp[i+1][j];
                    before[i+1][j+1] = make_pair(i+1, j);
                }
            }
        }
    }

    string ret = "";
    int nowi = N;
    int nowj = M;
    while (dp[nowi][nowj] > 0) {
        pair<int, int> bf = before[nowi][nowj];
        if (appended[nowi][nowj] && S[bf.first] == T[bf.second]) ret += S[bf.first];
        nowi = bf.first;
        nowj = bf.second;
    }

    reverse(ret.begin(), ret.end());
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 220160
n, h, w = map(int, input().split())
a = list()
b = list()
for i in range (n):
    tempa, tempb = map(int, input().split())
    a.append(tempa)
    b.append(tempb)


ans = 0
for i in range(n):
    if (int(a[i]) >= h) and (int(b[i]) >= w):
        ans += 1

print(int(ans))

Measured memory_bytes: 3064
k,n=map(int,input().split())
a=sorted(map(int,input().split()))
distance=[0]*n

for i in range(n-1):
    distance[i]=a[i+1]-a[i]
    
distance[n-1]=a[0]-a[n-1]+k

ans=k-max(distance)
print(ans)

Measured memory_bytes: 77388
# -*- coding: utf-8 -*-
import sys

H, W = map(int, raw_input().split())

S = []
for i in range(0, H):
	S.append(raw_input())

ans = [["" for i in range(W)] for j in range(H)]

dx = (1, 0, -1,  0, 1, -1, -1,  1)
dy = (0, 1,  0, -1, 1,  1, -1, -1)

for i in range(0, H):
	for j in range(0, W):
		if S[i][j] == "#":
			ans[i][j] = "#"
			continue

		count = 0
		for d in range(0, 8):
			ni = i + dy[d]
			nj = j + dx[d]

			if ni < 0 or H <= ni: continue
			if nj < 0 or W <= nj: continue
			if S[ni][nj] == "#": count+=1

		ans[i][j] = str(count)


for i in range(0, H):
	for j in range(0, W):
		sys.stdout.write(ans[i][j])
	print


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

int parse(){
	vector<int> nums;
	int val=0;

	char c = getchar(); //read '['
	if(c!='['){
		cout<<"error: "<<c<<endl;
	}

	c = getchar();
	ungetc(c, stdin);
	if(c != '['){
		scanf("%d",&val);
		getchar(); //read ']'
		return val/2+1;
	}else{
		while(true){
			nums.push_back(parse());
			c = getchar();
			if(c==']'){
				break;
			}
			ungetc(c, stdin);
		}
	}

	sort(nums.begin(),nums.end());
	for(int i=0;i<nums.size()/2+1;i++){
		val+=nums[i];
	}
	return val;
}

int main(){
	int n;
	cin>>n;
	for(int I=0;I<n;I++){
		getchar();
		int ans= parse();
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1296
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//変数
int H, W, ans;
vector<vector<int>> c;
vector<int> A(10, 0);

//サブ関数
//入力
void input() {
	cin >> H >> W;
	int tmp;
	REP(i, 10) {
		vector<int> tmpv;
		REP(j, 10) {
			cin >> tmp;
			tmpv.push_back(tmp);
		}
		c.push_back(tmpv);
	}

	
	REP(i, H) REP(j, W) {
		cin >> tmp;
		if (tmp != -1)A[tmp]++;
	}
}


//計算
void calc() {
	REP(k, 10)REP(i, 10)REP(j, 10) {
		c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	}
	REP(i, 10) {
		ans += A[i] * c[i][1];
	}
}


//出力
void output() {
	DEBUGING(ans);
}

//デバッグ
void debug() {
	WAITING(aaa);
}


//メイン関数
int main() {

	input();
	calc();
	output();
	//debug();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
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;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  ll L[N]; rep(i,N) cin >> L[i];

  sort(L,L+N);
  int cnt = 0;
  for (int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      for (int k=j+1;k<N;k++){
        if (L[i]==L[j] || L[j]==L[k]) continue;
        if (L[i]+L[j]>L[k]) cnt++;
      }
    }
  }

  cout << cnt << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}

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

const int INF = 1001001001;

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> key;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j,b) {
            int c;
            cin >> c;
            c--;
            s |= 1<<c;
        }
        key.emplace_back(s,a);
    }

    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    rep(s,1<<n) {
        rep(i,m) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count = 0;
    for(int i = 0; i < N - 2; i++)
    {
        if(S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C')
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    a = list(map(int, input().split()))

    tmp = N - K
    tmp = tmp / (K-1)
    if tmp - int(tmp) != 0:
        ans = 2 + int(tmp)
    else:
        ans = 1 + int(tmp)
    print(ans)

if __name__ == "__main__":
    main()

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

int main() {
    string n;
    while(cin >> n) {
        int k = n.size();
        vector<int> dp(2019,0);
        
        int res = 0;
        for(int i=0; i<k; ++i){
            vector<int> dp1(2019,0);
            int m = n[i]-'0';
            if(m != 0) {
                dp1[m] += 1;
            }
            for(int j=0; j<2019; ++j) {
                dp1[(j*10+m)%2019] += dp[j];
            }
            res += dp1[0];
            dp = dp1;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
  {
    int n,i,count=0,min;
    cin>>n;
    int arr[n];
    for(i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    min=arr[1];
    for(i=1;i<=n;i++)
    {
        if(min>=arr[i])
        {
            count++;
            min = arr[i];
        }
    }
    cout<<count;
  }

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int a,b;
    char c[1];
    int d;
    scanf("%d %c %d",&a,&c[0],&b);
    if(c[0]=='+'){
        d=a+b;
    }
    else if(c[0]=='-'){
        d=a-b;
    }
    else{}
    printf("%d",d);
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
 
def main():
    N, Q = map(int, input().split())
    S = input().rstrip()
 
    cnt_ac = 0
    arr_ac = [0] * (N)
    for x in range(0, N-1):
        if S[x:x+2] == 'AC':
            cnt_ac += 1
        arr_ac[x+1] = cnt_ac
 
    for i in range(Q):
        L, R = map(int, input().split())
        print(arr_ac[R-1] - arr_ac[L-1])
 
 
main()

Measured memory_bytes: 6356
#include<iostream>
#include <iomanip>
using namespace std;
int main() {
    int a, b, d, f;
    double a_d, b_d, r;
    cin >> a >> b;
    a_d = a; b_d = b;
    d = a/b; f = a%b; r = a_d/b_d;
    cout << d << " " << f << " " << fixed << setprecision(15) << r << endl;
    return 0;
}


Measured memory_bytes: 3216
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 505;
int n,m,h,w;
int ans[MAXN][MAXN];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> m >> h >> w;
  if(n%h==0 && m%w==0){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      if(i%h==0 && j%w==0){
        ans[i][j] = -(h*w-1)*4e3-1;
      }
      else ans[i][j] = 4e3;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }



return 0;
}
///....


Measured memory_bytes: 3584
#include<stdio.h>
 #include<stdlib.h>
 int main()
 {
 	int n;
 	scanf("%d",&n);
 	int *a;
 	a=(int *)malloc(sizeof(int)*n);
	int i,j,t;
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++)
	{
		for(j=0;j<=i-1;j++)
		{
			if(a[i]<a[j])
				{t=a[j];
				a[j]=a[i];
				a[i]=t; }
			} 
		for(j=0;j<n-1;j++)printf("%d ",a[j]);
		printf("%d\n",a[n-1]); 
		}
	return 0;	 
 }


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int dp[100001][3];
int n,t;
int r,s,p;

string ss;
// r = 0 ,s = 1 , p = 2;
int solve(int i, int state){
	if(i>=n) return 0;
	int &res = dp[i][state];
	if(res!=-1) return res;
	int k = 0;
	int sum=0;
	int j = i;
	
			if(ss[j]=='r'){
				if(state!=0)
				k=max(k,solve(j+t,0));
			if(state!=1)
				k = max(k,solve(j+t,1));
			if(state!=2)
				k = max(k,p+solve(j+t,2));
			}else if(ss[j]=='p'){
				if(state!=0)
				k=max(k,solve(j+t,0));
			if(state!=1)
				k = max(k,s+solve(j+t,1));
			if(state!=2)
				k = max(k,solve(j+t,2));
			
			}else{
				if(state!=0)
				k=max(k,r+solve(j+t,0));
			if(state!=1)
				k = max(k,solve(j+t,1));
			if(state!=2)
				k = max(k,solve(j+t,2));
			
		
	}
	
	return res=k;
}


int main(){
	fastio();
	cin>>n>>t;
	cin>>r>>s>>p;
	cin>>ss;
	for(int i=0;i<=n;i++)
		for(int j=0;j<3;j++)
			dp[i][j]=-1;

vector<int> ans;
		for(int i=0;i<n;i++){
			int k = 0;
			if(ss[i]=='r'){
				k=max(k,solve(i+t,0));
				k = max(k,solve(i+t,1));
				k = max(k,p+solve(i+t,2));
			}else if(ss[i]=='p'){
				k=max(k,solve(i+t,0));
				k = max(k,s+solve(i+t,1));
				k = max(k,solve(i+t,2));
			}else{
				k=max(k,r+solve(i+t,0));
				k = max(k,solve(i+t,1));
				k = max(k,solve(i+t,2));
			}
			//if(i==0) cout<<"k"<<k<<" ";
			ans.push_back(k);
		}
		ll z = 0 ;
		for(int i=0;i<t;i++) z+=ans[i];
		cout<<z;
}

Measured memory_bytes: 6860
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll; 
typedef long double ld; 
const ll mod = 1e9+7;
vector <vector <ld> > dp(3001,vector <ld>(3001,-1));
ld solve( vector <ld> &probs, int i, int x)
{	
	if(x == 0)
		return 1;
	if(i == 0)
		return 0;
	if(dp[i][x]  > -0.9)
		return dp[i][x];
	dp[i][x] = probs[i]*solve(probs,i-1, x-1) + (1- probs[i])*solve(probs, i-1, x);
	
	return dp[i][x];
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); 
    int n; cin >> n;
    vector <ld> probs(n+1);
    for(int i = 1; i <= n ; i++)
		cin >>probs[i];
	cout<< fixed << setprecision(10)<< solve(probs , n, ((n+1)/2)); 
	return 0;
}
 


Measured memory_bytes: 143488