akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int main(){

  int n = in();
  int a = in();
  int b = in();

  int M = min(a, b);
  int m = max(0, (a + b) - n);

  cout << M << " " << m << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#define pi 3.14159265358979323846
using namespace std;

int main()
{
	int H,W,i,j;
	while(true)
	{
		cin>>H>>W;
		if(H!=0||W!=0){
			
			for(i=1;i<=H;i++)
			{
				if(i%2==1)
				{
					for(j=1;j<=W;j++)
						{
							if(j%2==1)
								cout<<'#';
							else
								cout<<'.';
						}
					cout<<endl;
				} 
				else
				{
					for(j=1;j<=W;j++)
					{
						if(j%2==1)
							cout<<'.';
						else
							cout<<'#';
					}
					cout<<endl;
				}
				
			}
		
		}
		else
			return 0; 
		cout<<endl;
	}
}
 


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ii a[111111];
vi L[511];
bool used[511];
int cnt[511];
int C[411][111111];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int u,v; cin>>u>>v; u--; v--;
		a[i]=mp(u,v);
	}
	reverse(a,a+m);
	for(int i=0;i<m;i++)
	{
		int u=a[i].fi; int v=a[i].se;
		C[u][i]++; C[v][i]++;
		L[u].pb(i); L[v].pb(i);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=100100;j++) C[i][j]+=C[i][j-1];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=0;k<n;k++) used[k]=false,cnt[k]=0;
			priority_queue<ii,vector<ii>,greater<ii> > pq;
			if(!L[i].empty())
			{
				pq.push(mp(L[i][0],i));
				cnt[i]++;
			}
			if(!L[j].empty())
			{
				pq.push(mp(L[j][0],j));
				cnt[j]++;
			}
			used[i]=used[j]=1; 
			bool pp=1;
			//cerr<<"TRY "<<i<<' '<<j<<'\n';
			while(!pq.empty())
			{
				int pos = pq.top().fi; int id = pq.top().se; pq.pop();
				int u = a[pos].fi; int v = a[pos].se;
				//cerr<<"POS : "<<u<<' '<<v<<'\n';
				if(u==id) swap(u,v);
				if(used[u]){pp=0; break;}
				used[u]=1; cnt[u]=C[u][pos];
				if(L[u].size()>cnt[u])
				{
					pq.push(mp(L[u][cnt[u]],u));
					cnt[u]++;
				}
				if(cnt[id]<L[id].size())
				{
					pq.push(mp(L[id][cnt[id]],id));
					cnt[id]++;
				}
			}
			if(pp) ans++;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 176256
import math

n,D = map(int,input().split())

point = []
for _ in range(n):
  x = list(map(int, input().split()))
  point.append(x)

cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for d in range(D):
      dist += (point[i][d] - point[j][d])**2
    dist = math.sqrt(dist)
    if int(dist) == dist:
      cnt += 1
print(cnt)

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

int main() {
  int n, q;
  cin >> n >> q;
  queue<int> time;
  queue<string> name;
  for (int i = 0; i < n; i ++) {
    string tmpName;
    int tmpTime;
    cin >> tmpName >> tmpTime;
    time.push(tmpTime);
    name.push(tmpName);
  }
  int endProcess = 0;
  int count = 0;
  while (endProcess < n) {
    // 先頭の要素の取り出し
    string tmpName = name.front();
    int tmpTime = time.front();
    // 先頭の要素の削除
    name.pop();
    time.pop();
    if (tmpTime > q) {
      count += q;
      name.push(tmpName);
      time.push(tmpTime - q);
    } else {
      count += tmpTime;
      endProcess ++;
      cout << tmpName << " " << count << endl;
    }
  }
}



Measured memory_bytes: 5620
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	VI a(n);
	REP(i, n) { cin >> a[i]; }
	sort(ALL(a), std::greater<int>());
	ll result = 0;
	queue<int> q;
	REP(i, n) {
		if(i == 0) {
			q.push(a[0]);
			continue;
		}

		result += q.front();
		q.pop();
		q.push(a[i]);
		q.push(a[i]);
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
/*Sawal nahi hone wala phir bhi kar lo ek try*/
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
const long long mod = 1000000007;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;


ll powMod(ll x,ll y)            {ll p=1; while(y){if(y%2){p=(p*x)%mod;} y/=2; x=(x*x)%mod;} return p;}
ll invMod(ll x)                 {return powMod(x,mod-2);}
ll gcd(ll a, ll b)              {return b == 0 ? a : gcd(b, a % b);}
ll nCr(ll n, ll r)              { if(n<r)return 0;ll nfac = 1;ll dfac = 1;for(ll i=n-r+1;i<=n;i++){nfac = (nfac*i)%mod;}for(ll i=1;i<=r;i++){dfac = (dfac*invMod(i))%mod;}return (nfac*dfac)%mod;}

int solve()
{
    int n;cin>>n;
    map<string,int>x;
    rep(i,n)
    {
        string s;cin>>s;
        x[s] = 1;
    }
    cout<<x.size();
    
   return 0;    
}

int main()
{
    //fast;
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	#endif */
	return 0;
}

Measured memory_bytes: 19208
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> r;
    vector<ll> g;
    map<ll,ll> b;
    ll cnt=0;
    rep(i,n){
        if(s[i]=='R'){
            r.push_back(i);
        }
        else if(s[i]=='G'){
            g.push_back(i);
        }
        else{
            b[i]++;
            cnt++;
        }
    }
    ll p=r.size();
    ll q=g.size();
    ll ans=0;
    rep(i,p){
        rep(j,q){
            ll ct=0;
            ll x=max(r[i],g[j]);
            ll y=min(r[i],g[j]);
            ll z=(x+y)/2;
            if((x+y)%2==0){
                if(b[z]) ct++;
            }
            if(2*y-x>=0){
                if(b[2*y-x]){
                    ct++;
                }
            }
            if(2*x-y>=0){
                if(b[2*x-y]){
                    ct++;
                }
            }
            ans+=cnt-ct;
        }
    }
    cout << ans << endl;
    return 0;
} 


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

int main() {
  string S;
  int a=700;
  cin >>S;
  for(int i=0;i<3;i++){
    if(S.at(i)=='o'){
      a=a+100;
    }
  }
  cout <<a <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	long long int n;
	long long int total = 0;

	cin >> n;

	vector<long long int>a(n + 1);
	vector<long long int>b(n + 1);
	vector<long long int>c(n + 1);

	FOR(i, 1, n) {
		cin >> a[i];
	}
	FOR(i, 1, n) {
		cin >> b[i];
	}
	FOR(i, 1, n) {
		cin >> c[i];
		c[i]--;
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());

	FOR(i, 1, n) {
		long long int p = lower_bound(a.begin(), a.end(), b[i]) - a.begin() ;
		long long int q = lower_bound(c.begin(), c.end(), b[i]) - c.begin() ;
		total += (p - 1)*(n - q + 1);
	}

	cout << total << endl;
	return 0;
}

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(2000)
n,q=map(int,input().split())
e=[[] for _ in range(n)]
cnt=[0]*n
for _ in range(n-1):
  a,b=map(int,input().split())
  e[a-1].append(b-1)
  e[b-1].append(a-1)
for _ in range(q):
  x,y=map(int,input().split())
  cnt[x-1]+=y
vis=[1]*n
queue=[0]
vis[0]=0
while queue:
  now=queue.pop()
  for i in e[now]:
    if vis[i]:
      queue.append(i)
      cnt[i]+=cnt[now]
      vis[i]=0
print(' '.join(map(str,cnt)))

Measured memory_bytes: 136496
#include<bits/stdc++.h>
using namespace std;
template<class T>inline void Rd(T &x){
	x=0;char c=getchar();bool f=0;
	while(c<'0'||c>'9'){if(c=='-')f^=1;c=getchar();}
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+c-'0',c=getchar();
	if(f)x=-x;
}
int n,L;
int main(){
	Rd(n);Rd(L);
	int ans=0,mn=0x3f3f3f3f;
	for(int i=L;i<L+n;++i){
		if(abs(mn)>abs(i))mn=i;
		ans+=i;
	}
	ans-=mn;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define br cout << "\n";
#define pb push_back
#define ll long long 
#define ff first 
#define ss second
#define all(x) x.begin(),x.end()
#define in(a , idx , n ) for (int i = idx ; i < n ; ++i)cin >>a[i];
using namespace std;
const int MOD = 1000*1000*1000 + 7 ; 
const int MAXN = 1000*100 +10 ;
const ll INF = 1e18 ; 
void solve(){
	int N, W;
	cin >> N >> W  ;
	vector<ll>w(N+1),v(N + 1 );
	int V = 0; 
	for (int i = 0 ; i < N ; ++i )
		cin >> w[i] >> v[i] , V+=v[i] ; 
	vector<ll>dp(V+1 ,INF  );

	dp[0] = 0 ; 	
	for(int i = 0 ; i <= N  ; ++i)
	{
		vector<ll>new_dp(V+ 1 );
		for (int j = 0; j <= V ; ++j )
		{
			if (j-v[i] >=0 )
			{
				new_dp[j] = min(dp[j], dp[j-v[i]] + 1ll*w[i]);  
				
			}
			else
				new_dp[j] = dp[j]; 
				
		}
		dp = new_dp; 
	}
	int res = -1 ; 
	for (int i = 0 ; i <= V ; ++i )
		if (dp[i] <= W)res = max ( res , i ); 

	cout << res , br 
}
int main (){ 
	int t = 1  ;
	// cin >> t ;
	while (t--){
		solve() ; 
	}
    
return 0 ; 
}


Measured memory_bytes: 4844
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x,y;
    cin>>x>>y;
    
    if((x+y)<=1||abs(x-y)<=1){
        cout1("Brown")
    }else{
        cout1("Alice")
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 30;
const ll LINF = 1LL << 60;
const double eps = 1e-9;
const ll MOD = 998244353LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
vector<char> t, d;
string s;
int n, q;
bool check(int pos) {
    bool f = false;
    for(int i = 0; i < q; i++) {
        if(s[pos] == t[i]) {
            if(d[i] == 'L') {
                pos--;
            } else {
                pos++;
            }
            if(pos == -1 || pos == n) {
                return true;
            }
        }
    }
    return false;
}
int main() {
    cin >> n >> q;
    cin >> s;
    t.resize(q), d.resize(q);
    for(int i = 0; i < q; i++) {
        cin >> t[i] >> d[i];
    }
    int ok = 0, ng = n;
    while(ng - ok > 1) {
        int mid = (ok + ng) / 2;
        if(check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    int l = ok;
    if(!check(0)) {
        l = -1;
    }
    ok = n - 1, ng = -1;
    while(ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if(check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    int r = ok;
    if(!check(n - 1)) {
        r = n;
    }
    cout << (l < r ? r - l - 1 : 0) << endl;
}


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

#define ll long long
#define pb push_back
#define mp make_pair

int main() {
    ll n;
    cin>>n;
    unordered_map<string, ll>m;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin>>s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    ll ans=0;
    for(auto i:m){
        ll x = i.second;
        ans += (x)*(x-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    ll l = 2, r = 2;
    for (int i = n-1; i >= 0; i--){
        ll x = ((l-1)/a[i]+1)*a[i];
        ll y = (r/a[i])*a[i];
        //printf("%d %d\n",x,y);
        if (x > r || y < l){
            printf("-1\n");
            return 0;
        }
        l = x;
        r = y+a[i]-1;
    }
    printf("%lld %lld\n",l,r);
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;

int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a + 2), t(b + 2);
    for (int i = 1; i < a+1; i++)
    {
        cin >> s[i];
    }
    s[a + 1] = INF;
    s[0] = -INF;
    for (int i = 1; i < b + 1; i++)
    {
        cin >> t[i];
    }
    t[b + 1] = INF;
    t[0] = -INF;
    for (int k = 0; k < q; k++)
    {
        ll x;
        cin >> x;
        auto i = lower_bound(s.begin(), s.end(), x);
        auto j = lower_bound(t.begin(), t.end(), x);
        ll S[] = {*i, *(i - 1)};
        ll T[] = {*j, *(j - 1)};
        ll ans = INF;
        for (ll s : S)
        {
            for(ll t:T)
            {
                ll d1, d2;
                d1 = abs(x - s) + abs(s - t);
                d2 = abs(x - t) + abs(t - s);
                ans = min(ans, min(d1, d2));
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2944
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

type town struct {
	x, y float64
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()
	towns := make([]*town, n)
	for i := 0; i < n; i++ {
		t := &town{x: scanFloat64(), y: scanFloat64()}
		towns[i] = t
	}

	cal := func(i, j *town) float64 {
		l, r := (i.x - j.x), (i.y - j.y)
		return math.Sqrt((l * l) + (r * r))
	}

	ans := 0.
	for i := 0; i < n; i++ {
		ti := towns[i]
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			tj := towns[j]
			ans += cal(ti, tj)
		}
	}

	fmt.Println(ans / float64(n))
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func perm(n, r int) int {
	ret := 1
	for i := 0; i < r; i++ {
		ret *= n
		n--
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))

s = int(a[0])#max
t = int(a[0])#min

for i in a:
    if s < i:
        s = i

for i in a:
    if t > i:
        t = i

print(s - t)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
	deque<char> k1,k2;
	string s;
	int l=0;
	cin>>s;
	for(int i=0;i<=s.size()-1;i++){
		k1.push_back(s[i]);
	}
	for(int i=s.size()-1;i>=0;i--){
		k2.push_back(s[i]);
	}
	int q;
	cin>>q;
	for(int i=1;i<=q;i++){
		int t;
		cin>>t;
		if(t==1){
			swap(k1,k2);
		}		
		else{
			int f;
			char c;
			cin>>f>>c;
			if(f==1){
				k1.push_front(c);
				k2.push_back(c);
			}
			else{
				k1.push_back(c);
				k2.push_front(c);
			}
		}
	}
	for(int i=0;i<k1.size();i++){
		cout<<k1[i];
	}
	return 0;
}


Measured memory_bytes: 1280
import sys
input = lambda: sys.stdin.readline().rstrip()
n, m = map(int, input().split())
# 人: 0~n, 言語:n~n+m
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n+m)
for i in range(n):
    _, *l = list(map(int, input().split()))
    for lang in l:
        uf.union(i, n+lang-1)

f = True
for i in range(1, n):
    if not uf.same(0, i):
        f = False
if f:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 66264
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BPostdocs {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string T;
        in>>T;
        for(auto& t : T){
            if(t=='?') t = 'D';
        }
        out<<T<<'\n';
    }
};


int main() {
	BPostdocs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3780
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	string s;
	cin >> s;
	if(s == "ABC") cout << "ARC";
	else cout << "ABC";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
int A,B,K;std::set<int> S;
int main(){std::cin>>A>>B>>K;for(int i=0;i<K;i++)if(B-A>=i){S.insert(A+i);S.insert(B-i);}for(auto x:S)std::cout<<x<<'\n';}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
dp = [0] * (n + 100)
dp[0] = 1
for i in range(n):
    if i + 1 <= n and i + 1 not in a:
        dp[i + 1] += dp[i]
    if i + 2 <= n and i + 2 not in a:
        dp[i + 2] += dp[i]
print(dp[n] % (10 ** 9 + 7))

Measured memory_bytes: 462708
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
vl v;

void input(void){
   cin>>n;
   inputv(v,n-1);
}

void solve(void){
    ll a=0;
    rep(i,n-2){
        a+=min(v[i],v[i+1]);
    }
    cout<<a+v[0]+v[n-2]<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

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

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)2e5 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

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

int n, a[N], x;
int main (){
  scanf ("%d %d", &n, &x);
  ll ans = 0;
  forn (i, 1, n) scanf ("%d", a + i);
  forn (i, 1, n - 1){
    if (a[i] + a[i + 1] > x){
      int sum = a[i] + a[i + 1];
      int cur = sum - x;
      if (cur <= a[i + 1]){
        ans += a[i + 1] - (a[i + 1] - cur);
        a[i + 1] -= cur;
      } else {
        ans += a[i + 1];
        cur -= a[i + 1];
        a[i + 1] = 0;
        a[i] -= cur;
        ans += cur;
      }
    }
  }
  printf ("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 640
from collections import Counter
import sys
import math

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)


def main():
    a, b, h, m = map(int, input().split())
    x1 = a * math.cos(2 * math.pi * (h % 12 / 12 + m / 60 / 12))
    y1 = a * math.sin(2 * math.pi * (h % 12 / 12 + m / 60 / 12))
    x2 = b * math.cos(2 * math.pi * (m / 60))
    y2 = b * math.sin(2 * math.pi * (m / 60))

    print(((x1 - x2)**2 + (y1 - y2)**2)**(1/2))


main()


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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    rep(i,n-k){
        if(vec[i]>=vec[k+i]) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3960
#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 fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcountll(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
	fast;
	int d,t,s;cin>>d>>t>>s;
	if(s*t>=d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


Measured memory_bytes: 3652
program phobia
  implicit none
  character(len=100000) :: s
  integer :: ca, cb, cc
  integer :: i

  ca = 0
  cb = 0
  cc = 0
 
  read(*,*) s

  do i = 1, len_trim(s)
     if (s(i:i) == 'a') then
        ca = ca + 1
     else if (s(i:i) == 'b') then
        cb = cb + 1
     else if (s(i:i) == 'c') then
        cc = cc + 1
     end if
  end do

  if ( max(abs(ca-cb) ,abs(cb-cc) ,abs(cc-ca) ) <= 1 ) then
     write(*,'(a)') 'YES'
  else
     write(*,'(a)') 'NO'
  end if
  stop
end program phobia


Measured memory_bytes: 3216
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String r = sc.next();
        String g = sc.next();
        String b = sc.next();

        int number = Integer.parseInt(r + g + b);

        if (number % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

	}
}

Measured memory_bytes: 23380
#include <iostream>
using namespace std;
int main() {
  int H;
  int attack;
  int ans;
  cin >> H;
  cin >> attack;
//  cout << H << endl;
//#  cout << attack << endl;
  ans = H%attack;
  
  if(ans==0){
    ans = H/attack;
  }else{
    ans = H/attack+1;
  }
    
  cout << ans << endl;
  return 0;
}

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

int num[10];
//map<int,int> mp;

int main(void)
{
    int m,n,l,r,i;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>l>>r;
        if(i==0)
        {
            num[0]=l;
            num[1]=r;
            continue;
        }
        num[0]=max(num[0],l);
        num[1]=min(num[1],r);
        if(num[0]>num[1])
        {
            cout<<0;
            return 0;
        }
    }
    cout<<num[1]-num[0]+1;
    return 0;
}


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

int main(){
  int N , x;
  int a[110];
  cin >> N >> x;
  for(int i = 0 ; i <N ; i++ ){
    cin >> a[i];
  }

  sort(a , a+N );

  for(int i = 0 ; i<N ; i++){
    x = x-a[i];
    if(x <0) {
      cout << i;
      break;
    }else if(i== N-1 && x > 0){
      cout << N-1;
      break;
    }
    /*else{ cout << N;
    break;}*/
    else if(x==0){
      cout << i+1;
      break;
    }
  }
}


Measured memory_bytes: 256
// Problem : P - Independent Set
// Contest : AtCoder - Educational DP Contest
// URL : https://a...content-available-to-author-only...r.jp/contests/dp/tasks/dp_p?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://g...content-available-to-author-only...b.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
#define INF 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
int n;
vector<vector<int>>g;
int cnt = 0;
ll mem[N][2];
ll dfs(int node, int par, int lst) {
	ll& ret = mem[node][lst];
	if (~ret)return ret;
	ret = 1;
	for (int nxt : g[node]) {
		ll cur = 0;
		if (nxt != par) {
			cur += dfs(nxt, node, 0) % mod;
			if (lst != 1)
			{
				cur += dfs(nxt, node, 1) % mod;
			}
			ret *= cur % mod;
			ret %= mod;
		}
	}
	return ret;
}
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	clr(mem, -1);
	cin >> n;
	g = vector<vector<int>>(n + 1);
	for (int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ll ans = dfs(1, -1, 1);
	ans += dfs(1, -1, 0);

	cout << ans %mod<< endl;
}


Measured memory_bytes: 19964
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll a[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    vector<ll> b;
    sort(a, a + n, greater<ll>());
    for (int i = 0; i < n - 1; ++i)
        if (a[i] == a[i + 1])
            b.push_back(a[i++]);

    if (b.size() < 2)
        cout << 0;
    else
        cout << b[0] * b[1];
}


Measured memory_bytes: 1660
import * as readline from "readline";

const rl = readline.createInterface({
    input: process.stdin,
});

const lines = [];
rl.on("line", (line) => {
    lines.push(line);
});
rl.on("close", () => {
    main(lines);
});

function main(lines) {
    const [k, x] = lines[0].split(' ').map(n => parseInt(n));
    const nums = new Array(2 * k - 1).fill(0).map((_, i) => x - (k - 1) + i);
    console.log(nums.join(' '));
}


Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'e' || c =='o' || c=='u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  char s;
  cin >> s;
  if (s == 'A') {
    cout << 'T' << endl;
  } else if (s == 'T') {
    cout << 'A' << endl;
  } else if (s == 'C') {
    cout << 'G' << endl;
  } else {
    cout << 'C' << endl;
  }
}


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

using namespace std;

#define pi 3.1415926535
#define ll long long
#define mod 1000000007



int main() {
	ll n;
	int i;
	ll a[200010];
	ll data[200010];
	ll dp[200010];
	ll stk1, stk2;
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	data[1] = a[1];
	dp[0] = 0;
	dp[1] = 0;
	for (i = 3; i <= n; i+=2) {
		data[i] = data[i - 2] + a[i];
	}
	for (i = 2; i <= n; i++) {
		if (i & 1) {
			dp[i] = max(dp[i - 1], dp[i - 2] + a[i]);
		}
		else {
			dp[i] = max(dp[i - 2] + a[i], data[i - 1]);
		}
	}
	//if (n & 1) dp[n] = max(dp[n], data[n] - data[1]);;
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 8280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    a[i]=0;
  }
  for(int i=0;i<k;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int o;
      cin>>o;
      a[o-1]++;
    }
  }
  int s=0;
  for(int i=0;i<n;i++){
if(a[i]==0){
  s++;
  
}
  }
cout<<s<<endl;
}

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

bool dp[5001][1<<12],mat[5000][12];

int main()
{
	int N,M;
	while(cin >> N >> M, (N||M))
	{
		int cnt=0;
		string str[12], text;
		memset(dp,0,sizeof(dp));
		memset(mat, 0, sizeof(mat));
		
		for(int i=0; i<N; i++)
			cin >> str[i];
			
		while(M--)
		{
			string t;
			cin >> t;
			text+=t;
		}
		
		for(int i=0; i<N; i++)
		for(int j=0; j<=text.size()-str[i].size(); j++)
		{
			bool g=true;
			for(int k=0; k<str[i].size(); k++)
			{
				if(text[j+k]!=str[i][k])
				{
					g=false;
					break;
				}
			}
			mat[j][i]=g;
			dp[j+str[i].size()][(1<<i)]=g;
		}

		for(int i=0; i<text.size(); i++)
		for(int j=0; j<(1<<N); j++)
		{
			if(!dp[i][j]) continue;
			for(int k=0; k<N; k++)
			{
				if(!mat[i][k]) continue;
				if(j&(1<<k)) continue;
				dp[i+str[k].size()][j+(1<<k)]=1;
			}
		}
		
		for(int i=0; i<=text.size(); i++)
			if(dp[i][(1<<N)-1]) cnt++;
			
		
		cout << cnt << endl;
	}
}

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

int fx(std::string N) {
    int ret = 0;
    for (auto i=N.begin(); i!=N.end(); i++) {
        ret += (*i - '0');
    }
    return ret;
}

int main() {
    std::string N;
    std::cin >> N;
    
    std::cout << (std::stoi(N) % fx(N) == 0 ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
var
	N,i,p,ans:Longint;
	A,B,C:Array[1..20]of Longint;
begin
	read(N);
	for i:=1 to N do read(A[i]);
	for i:=1 to N do read(B[i]);
	for i:=1 to N-1 do read(C[i]);
	p:=-2;
	for i:=1 to N do begin
		inc(ans,B[A[i]]);
		if A[i]=p+1 then inc(ans,C[p]);
		p:=A[i];
	end;
	writeln(ans);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, M, C;
  cin >> N >> M >> C;
  int ans = 0;
  vector<int> b(M);
  vector<vector<int>> a(N, vector<int>(M));
  REP(i, M) {
    cin >> b[i];
  }
  REP(i, N) {
    REP(j, M) {
      cin >> a[i][j];
    }
  }
  REP(i, N) {
    int tmp = C;
    REP(j, M) {
      tmp += a[i][j]*b[j];
    }
    if (tmp > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
int N;
  cin >> N;
vector<int> data(N);
  for(int i=0;i<N;i++){
  cin >> data.at(i);
  }
int count = 0;
  for(int i=0;i<N;i++){
  while(data.at(i) > 0){
  if(data.at(i)%2 == 0){
  data.at(i) /= 2;
  count++;
  }
  else{
  break;
  }
  }
  }
  cout << count;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define M 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a==0)
    {
        if(b<=99)
        cout<<b<<endl;
        else
        cout<<"101"<<endl;
    }
    

    else
    if(a==1)
    {
        if(b<=99)
        cout<<b<<"00"<<endl;
        else {
            cout<<10100<<endl;
        }
    }
    
    else
    if(a==2)
    {
        if(b<=99)
        cout<<b<<"0000"<<endl;
        else
        cout<<1010000<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define MAX 700
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

struct edge{ 
  int to,cap;
  double cost;
  int rev;
};

int v;
vector<edge> e[MAX];
double h[MAX];
double dist[MAX];
int prevv[MAX],preve[MAX];

void add_edge(int from,int to,int cap,double cost){
  e[from].push_back((edge){to,cap,cost,(int)e[to].size()});
  e[to].push_back((edge){from,0,-cost,(int)e[from].size()-1});
}

typedef pair<int,double> P;

double min_cost_flow(int s,int t,int f){
  double res=0.0;
  fill(h,h+v,0);
  while(f>0){
    priority_queue<P,vector<P>,greater<P> > pq;
    fill(dist,dist+v,inf);
    dist[s]=0;
    pq.push(P(0,s));
    while(pq.size()){
      P p=pq.top();
      pq.pop();
      int u=p.second;
      if(dist[u]-p.first<-eps)continue;
      for(int i=0;i<e[u].size();i++){
        edge &E=e[u][i];
        if(E.cap>0 && (dist[u]+E.cost+h[u]-h[E.to])-dist[E.to]<-eps){
          dist[E.to]=dist[u]+E.cost+h[u]-h[E.to];
          prevv[E.to]=u;
          preve[E.to]=i;
          pq.push(P(dist[E.to],E.to));
        }
      }
    }
    if(dist[t]==inf)return -1;
    for(int i=0;i<v;i++)h[i]+=dist[i];

    int d=f;
    for(int u=t;u!=s;u=prevv[u]){
      d=min(d,e[prevv[u]][preve[u]].cap);
    }
    f-=d;
    res+=(double)d*h[t];
    for(int u=t;u!=s;u=prevv[u]){
      edge &E=e[prevv[u]][preve[u]];
      E.cap-=d;
      e[u][E.rev].cap+=d;
    }
  }
  return res;
}

int main()
{
	int n;
	vector<Segment> vs,vt;
  vector<Point> ps;
	Point st;
	double ans=0.0;

  cin>>n;
  cin>>st.x>>st.y;
  for(int i=0;i<n;i++){
    Point a,b;
    cin>>a.x>>a.y>>b.x>>b.y;
    Segment s(a,b);
    vt.push_back(Segment(a,b));
    ans+=abs(b-a);
  }
  int s=vt.size()*2;
  int t=s+1;
  v=t+1;
  for(int i=0;i<vt.size();i++){
    for(int j=0;j<vt.size();j++){ 
      add_edge(i,j+vt.size(),1,abs(vt[i].p2-vt[j].p1));
    }
  }
  for(int i=0;i<vt.size();i++){
    add_edge(s,i,1,0);
    add_edge(i+vt.size(),t,1,0);
  }
  printf("%.10f\n",ans+min_cost_flow(s,t,vt.size()));
  return 0;
}

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

using namespace std;

char text[1000010],p[10010];

#define next Next
int next[10010];
int len;

void getNext()
{
    int i,j;
    j=next[0]=-1;
    i=0;
    while(p[i])
    {
        while(j!=-1&&p[i]!=p[j]) j=next[j];
        if(p[++i]==p[++j]) next[i]=next[j];
        else next[i]=j;
    }
    len=i;
}

int KMP()
{
    int i,j;
    int ans=0;

    getNext();
    i=j=0;
    while(text[i])
    {
        while(-1!=j&&text[i]!=p[j]) j=next[j];
        i++,j++;
        if(j>=len)
        {
            ans++;
            j=next[j];
            printf("%d\n",i-len);
        }
    }
    return ans;
}

int main()
{
    cin>>text>>p;

    KMP();

    return 0;
}



Measured memory_bytes: 4188
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int H, W, M, a, b;
	cin >> H >> W >> M;
	vector<P> bomb(M);
	vector<int> hline(H, 0);
	vector<int> wline(W, 0);
	rep(i,M){
		cin >> a >> b;
		--a; --b;
		bomb[i] = make_pair(a,b);
		hline[a]++;
		wline[b]++;
	}
	int h_max = -1, w_max = -1;
	rep(i,H)h_max = max(h_max, hline[i]);
	rep(i,W)w_max = max(w_max, wline[i]);
	set<int> h_ok, w_ok;
	rep(i,H)if(hline[i] == h_max)h_ok.insert(i);
	rep(i,W)if(wline[i] == w_max)w_ok.insert(i);
	int cnt = 0;
	rep(i,M){
		if(h_ok.count(bomb[i].first) == 1 && w_ok.count(bomb[i].second) == 1) ++cnt; 
	}
	if(cnt == h_ok.size() * w_ok.size())cout << h_max + w_max -1 << endl;
	else cout << h_max + w_max << endl;
	return 0;
}


Measured memory_bytes: 35896
#include<bits/stdc++.h>
using namespace std;
int a[100005][4];
int dp[100005][4];
int n;

int func(int ind, int flag) {

    if (ind == n) return 0;

    if (dp[ind][flag] != -1) return dp[ind][flag];

    int maxi = 0;
    if (flag == 0) {
        maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
        maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
        maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
    }
    else if (flag == 1) {
        maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
        maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
    }
    else if (flag == 2) {
        maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
        maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
    }
    else {
        maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
        maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
    }

    return dp[ind][flag] = maxi;
}
int fdp()
{
    vector<vector<int>> dp(n, vector<int>(4, -1));
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    dp[0][3] = a[0][3];
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j <= 3; j++)
        {
            if (j == 1)
                dp[i][j] = a[i][j] + max( dp[i - 1][2], dp[i - 1][3]);
            else if (j == 2)
                dp[i][j] = a[i][j] + max(dp[i - 1][1], dp[i - 1][3]);
            else
                dp[i][j] = a[i][j] + max(dp[i - 1][1], dp[i - 1][2]);
        }
    }
    return max(dp[n - 1][1], max(dp[n - 1][2], dp[n - 1][3]));
}
int main() {

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= 3; j++) {
            cin >> a[i][j];
        }
    }

    memset(dp, -1, sizeof dp);

    // cout << func(0, 0) << endl;
    cout << fdp();

    return 0;
}

Measured memory_bytes: 11888