akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1e9+7;



ll power(ll a,ll n){ //aのn乗計算 O(log(n))
  if(n == 0)return 1;

  ll res = 1;
  while(n > 0){//nがゼロになるまで
    if(n%2 ==1)res = res * a % MOD; //奇数ならa倍してべきを偶数にしている
    a = a * a % MOD; //aを自乗
    n /= 2;//aを自乗した分べきを半分減らす
  }
  return res;
}



//フェルマーの小定理より、aで割るという処理はinv(a)をかけることと同じになる
//そのinv(a)はa^(MOD-2)で求められる
ll inv(ll a){
  return power(a,MOD-2);
}


ll comb(ll n, ll a){  //nCaの計算
  ll bunbo =1 ,bunshi = 1;

  for(ll i =1;i<=a;++i){
    bunbo = bunbo *i %MOD;//
    bunshi = bunshi * (n-i+1) %MOD;//
  }
  return bunshi*inv(bunbo) %MOD;

}


int main(){
  ll N,A,B;
  cin >>N>>A>>B;
//  cout<<comb(N,A)<<" : " <<comb(N,B)<<endl;
//  cout <<power(2,N)<<endl;

  ll ans = power(2,N) -comb(N,A) - comb(N,B) -1;
  //MODを使ってる引き算は負になった時足さないといけない
  while(ans <0)ans +=MOD;

  cout <<ans<<endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
# A[y][x]: y行目、x文字目
A = [list(map(int, input().split())) for _ in range(N)]

m = {}

for row in A:
    cnt = 0
    for num in row:
        cnt += 1
        if cnt == 1:
            continue
        m.setdefault(num, 0)
        m[num] += 1

cnt = 0
for num in m.values():
    if num == N:
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void speed_solve(){
    ll n;
    cin >> n;
    ll a[n], b[n];
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,n) {
        a[i] = (a[i] == b[i]);
    }
    ll ok = 0;
    rep(i,n - 2) {
        repe(j,i,i + 3) {
            if(a[j] == 1 and a[j + 1] == 1 and a[j + 2] == 1){
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int tmp,cnt=0,n,m,x;
    vector<int> vec(100);
    cin >> n >> m >> x;
    rep(i,m){
        cin >> tmp;
        if(tmp<x)cnt++;
        else break;
    }
    cout << min(m-cnt,cnt) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n;
    cin >> n;
    map<ll, ll> m;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        m[x]++;
    }
    vector<ll> v;
    for (auto&& p : m) {
        if (p.second >= 2) {
            v.push_back(p.first);
            if (p.second >= 4) {
                v.push_back(p.first);
            }
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    if (v.size() < 2)
        cout << 0 << "\n";
    else
        cout << v[0] * v[1] << "\n";
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);
    
    int n; cin >> n;
    std::vector<int> w(n);
    rep(i,n) cin >> w[i];
    int sum = 0; rep(i,n) sum+=w[i];

    std::vector<int> v(n+1,0);
    for(int i=1; i<n+1; i++) v[i] = w[i-1]+v[i-1];

    int m = 1000000;

    rep(i,n){
        int s1 = v[i+1];
        int s2 = sum-s1;

        //cout << s1 << endl;

        m = min(m, abs(s1-s2));
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c,ans=0,base,a;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int j=0;j<m;j++){cin>>b[j];}
  for(int i=0;i<n;i++){
    base=c;
    for(int j=0;j<m;j++){
      cin>>a;
      base+=a*b[j];}
    if(base>0){ans++;}
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool pairsort1(const P& element1, const P& element2)
{//first昇順
	return element1.F < element2.F;
}
bool pairsort2(const P& element1, const P& element2)
{//first降順
	return element1.F > element2.F;
}
bool pairsort3(const P& element1, const P& element2)
{//second昇順
	return element1.S < element2.S;
}
bool pairsort4(const P& element1, const P& element2)
{//second降順
	return element1.S > element2.S;
}

int main() {
	int N;
	scanf("%d",& N);
	vector<int>A(N);
	int Max = 0;
	int Now = 0;
	rep(i, N) {
		scanf("%d",&A[i]);
		Max += abs(A[i] - Now);
		Now = A[i];
		if (i == N - 1) {
			Max += abs(Now);
		}
	}

	rep(i, N) {
		int tmp = Max;
		if (i == 0) {
			tmp -= abs(A[0]-0)+ abs(A[1] - A[0]);
			tmp += abs(A[1]-0);
		}
		else if (i == N - 1) {
			tmp -=abs(A[N-1]-A[N-2])+ abs(0 - A[N - 1]);
			tmp += abs(0-A[N - 2]);
		}
		else {
			tmp -= abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]);
			tmp += abs(A[i + 1] - A[i - 1]);
		}
		printf("%d\n",tmp);
	}

}



Measured memory_bytes: 1664
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#define int long long int
void dfs(int src,vector<int> adj[],bool visited[],int arr[],int dp[],int val)
{
	if(visited[src])
	   return ;
	else
	{
		val+=dp[src];
		arr[src]=val;
		visited[src]=true;
		for(int x:adj[src])
		    dfs(x,adj,visited,arr,dp,val);
	}
}
int32_t main()
{
	string str1,str2;
	cin>>str1>>str2;
	set<char> s1,s2;
	int j;
	for(j=0;str1[j]!='\0';j++)
	{
		s1.insert(str1[j]);
		s2.insert(str2[j]);
	}
	bool result=true;
	for(char x:str2)
	{
		auto it=s1.find(x);
		if(it==s1.end())
		{
			result=false;
			break;
		}
	}
	if(!result)
	{
		cout<<-1<<endl;
	}
	else
	{
		int l=str1.size();
		vector<int> adj[26];
		for(j=0;str1[j]!='\0';j++)
	    {
			adj[str1[j]-97].push_back(j);
		}
		int answer=0;
		int ptr=0;
		int turn=1;
		for(j=0;str2[j]!='\0';j++)
		{
			char x=str2[j];
			auto it=lower_bound(adj[x-97].begin(),adj[x-97].end(),ptr);
			if(it==adj[x-97].end())
			{
				turn++;
				ptr=*(adj[x-97].begin());
				ptr++;
			}
			else
			{
				ptr=*it;
				ptr++;
				if(ptr==l)
				{
					ptr=0;
					turn++;
				}
			}
		}
		answer=(turn-1)*(l)+ptr;
		cout<<answer<<endl;
	}
}


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


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...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}
int disum(int n){
	int sum=0;

	while(n){

		sum+=n%10;
		n/=10;





	}
	return sum;




}
int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
  	string s,t;
  	cin>>s>>t;
  	int p=0;
  	for (int i = 0; i < s.size(); ++i)
  	{
  		/* code */
  		if(s==t){
  			p=1;
  			break;
  		}
  		rotate(s.begin(), s.begin() + 1, s.end());
  		// rotate(s);

  		// watch(s);
  	}
  	if(p==1)
  		cout<<"Yes"<<endl;
  	else
  		cout<<"No"<<endl;
    return 0;

}



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

/*iamsorry*/
 
#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(nullptr); //cout.tie(nullptr);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define E               "\n"
#define S               " "
#define INF             9e18
#define M7              1000000007
#define M9              998244353
#define PI              3.141592653589793238L
#define lcm(a,b)        ((a)/__gcd((a),(b)))*(b)
#define midl(l,r)       ((l)+((r)-(l))/2)
#define prec(n)         fixed<<setprecision(n)
#define in(arr,n)       for(int i=0; i<(n); ++i) cin>>arr[i]
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define vc              vector
#define fr              first
#define sc              second
#define pb              push_back
#define eb              emplace_back
#define ins             insert
#define emp             emplace

#ifdef DOPPELLEBEN
template<typename T1,typename T2> ostream& operator<<(ostream &out,const pair<T1,T2> &p) {return out<<'('<<p.first<<", "<<p.second<<')';}
template<typename T> auto operator<<(ostream &out,T &&x)->decltype(x.begin(),out) {out<<'{'; for(auto it=x.begin();it!=x.end();++it)out<<*it<<(it==prev(x.end())?"":", "); return out<<'}';}
void dump() {}
template<typename T,typename... Args> void dump(T &&x,Args... args) {cerr<<" "<<x; dump(args...);}
struct ND{~ND(){cerr<<"]\n";}};
#define dbg(x...) cerr<<" ["<<(strcmp(#x,"")?#x ":":""),dump(x),ND(),cerr<<""
#else
#define dbg(...) 0 && cerr
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rann(n) rng()%(n)
#define ran(l,r) (l)+rng()%((r)-(l)+1)

template<typename T,typename t> T maxm(T &x,t y) {if(y>x)x=y; return x;}
template<typename T,typename t> T minm(T &x,t y) {if(y<x)x=y; return x;}
template<typename T> int sz(T &&x) {return (int)((x).size());}

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int,int>;
using mii = map<int,int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int,int>>;
using seti = set<int>;
using setd = set<int,greater<int>>;
using pqmx = priority_queue<int>;
using pqmn = priority_queue<int,vector<int>,greater<int>>;

/*__*/

void Main() {
	string s; cin>>s;
	int ans=(s[0]==s[1]&&s[0]=='R')*2+(s[1]==s[2]&&s[1]=='R')*2;
	if(ans==4 || ans==6) ans=3;
	if(ans==0) ans=find(all(s),'R')!=s.end();
	cout<<ans;
}

signed main() {
    thegamebegins

    int T=1;
    // cin>>T;
    while(T--) Main();

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int h,w,k;
    cin>>h>>w>>k;
    auto vec=make_vec<char>(h,w);
    vector<int> yoko(h);
    vector<bool> skip(h,false);
    rep(i,h) {
        if(i>0) yoko[i]=yoko[i-1];
        int add=0;
        rep(j,w) {
            cin>>vec[i][j];
            if(vec[i][j]=='#') add++;
        }
        if(add==0) skip[i]=true;
        yoko[i]+=add;
    }
    
    auto ans=make_vec<int>(h,w);
    int now=1;
    rep(i,h) {
        if(skip[i]) continue;
        rep(j,w) {
            ans[i][j]=now;
            if(vec[i][j]=='#') now=min(yoko[i],now+1);
        }
        now++;
    }
    
    for(int i=1;i<h;i++) {
        if(!skip[i]) continue;
        rep(j,w) {
            if(ans[i-1][j]==0) break;
            ans[i][j]=ans[i-1][j];
            skip[i]=false;
        }
     }
    
    for(int i=h-2;i>=0;i--) {
        if(!skip[i]) continue;
        rep(j,w) {
            if(ans[i+1][j]==0) break;
            ans[i][j]=ans[i+1][j];
            skip[i]=false;
        }
    }
    
    rep(i,h) {
        rep(j,w) {
            cout<<ans[i][j]<<" \n"[j==w-1];
        }
    }
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

int main()
{
    IOS;
    int m,k;
    cin>>m>>k;
    if(k>=(1<<m )|| (k==1 && m==1))
    {
        cout<<-1<<endl;
        return 0;
    }
    if(k==0)
    {
        for(int i=0;i<1<<m;i++)
        {
            cout<<i<<" "<<i<<" ";
        }
        cout<<endl;
        return 0;
    }
    for(int i=1;i<1<<m;i++)
    {
        if(i!=k) cout<<i<<" ";
    }
    cout<<k<<" ";
    for(int i=(1<<m)-1;i>=1;i--)
    {
        if(i!=k) cout<<i<<" ";
    }
    cout<<0<<" "<<k<<" "<<0<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
	ll n, ct, ans;
	
	ans = 0;
	ct = 1;
	cin >> n;
	while(n){
		n /= 2;
		ans += ct;
		ct *= 2;
	} 
	cout << ans << '\n';
}

int main(){
	int t = 1;
	
	while(t--){
		solve();
	}
}




Measured memory_bytes: 256
#include<stdio.h>
int main(){

	int a,b,i;
	char op;

	for(i=1; ;i++){

	scanf("%d %c %d", &a, &op, &b);

	if(op=='?')break;

	if(op=='+'){
	printf("%d\n",a+b);
	}

	if(op=='-'){
	printf("%d\n",a-b);
	}
	if(op=='*'){
	printf("%d\n",a*b);
	}
	if(op=='/'){
	printf("%d\n",a/b);
	}

	}

	return 0;

}

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

int main() {
    int n, m;
    cin >> n >> m;
    auto a = vector<int>(n);

    int sum = 0;
    for (auto &a_i : a) {
        cin >> a_i;
        sum += a_i;
    }

    int cnt = 0;
    for (auto a_i : a) {
        if (a_i * 4 * m >= sum)
            ++cnt;
    }

    cout << (cnt >= m ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import math
n,d=list(map(int,input().split()))
x=[list(map(int,input().split())) for i in range(n)]
count=0
tmp=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            tmp+=pow(x[i][k]-x[j][k],2)
        distance=math.sqrt(tmp)
        if distance.is_integer()==True:
            count+=1
        tmp=0
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

int main() {
	int N, X, D = 0;
	int cnt = 1;
	int l;
	std::vector<int> L;

	std::cin >> N >> X;
	for (int i = 0; i < N; i++) {
		std::cin >> l;
		L.push_back(l);
	}

	for (int i = 0; i < N; i++) {
		D += L[i];
		if (D > X) break;
		cnt++;
	}
	std::cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>
#include <set>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

void warshall_floyd(int n, vector<vector<ll>> &d)
{
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

void warshall_floyd2(int n, vector<vector<ll>> &d)
{
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j] + 1);
            }
        }
    }
}

int main()
{
    // 整数の入力
    ll N, M, L;
    cin >> N >> M >> L;
    vector<vector<ll>> D(N, vector<ll>(N, BASE_NUM));
    vector<vector<ll>> D_HOKYU(N, vector<ll>(N, BASE_NUM));
    for (int i = 0; i < M; i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        D[a - 1][b - 1] = c;
        D[b - 1][a - 1] = c;
    }
    warshall_floyd(N, D);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (D[i][j] <= L)
            {
                D_HOKYU[i][j] = 0;
            }
        }
    }
    // for (int i = 0; i < N; i++)
    // {
    //     for (int j = 0; j < N; j++)
    //     {
    //         if (D_HOKYU[i][j] == BASE_NUM)
    //         {
    //             cout << 9;
    //         }
    //         else
    //         {
    //             cout << D_HOKYU[i][j];
    //         }
    //     }
    //     cout << endl;
    // }
    warshall_floyd2(N, D_HOKYU);
// for (int i = 0; i < N; i++)
//     {
//         for (int j = 0; j < N; j++)
//         {
//             if (D_HOKYU[i][j] == BASE_NUM)
//             {
//                 cout << 9;
//             }
//             else
//             {
//                 cout << D_HOKYU[i][j];
//             }
//         }
//         cout << endl;
//     }
        ll Q;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        ll s, t;
        cin >> s >> t;
        s--;
        t--;
        if (D_HOKYU[s][t] == BASE_NUM)
        {
            cout << -1 << endl;
        }
        else
        {
            cout << D_HOKYU[s][t] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a,b,c,d;
int ans[10000000];
int flg[10000000];
int main(){
  for(int i=0;i<=10000000;i++)flg[i]=-1;
  while(cin>>n>>m){
    for(int i=0;i<=d;i++)flg[i]=-1;
    
    n=n%m;
    d=c=-1;
    for(int i=0;i<=10000000;i++){
      n*=10;
      if(flg[n]!=-1){
	c=i;break;
      }
      flg[n]=i;d=max(d,n);
      ans[i]=n/m;
      cout<<ans[i];
      n=n%m;
      if(n==0)break;
    }
    cout<<endl;
    if(c!=-1){
      for(int i=1;i<=c;i++){
	if(i<=flg[n]){
	  cout<<' ';
	}else{
	  cout<<'^';
	}
      }
    cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 42116
(defun main()
  (let ((d0 (read-char))
        (d1 (read-char))
        (d2 (read-char))
        (d3 (read-char)))
    (if (or (and (eq d0 d1) (eq d1 d2)) (and (eq d1 d2) (eq d2 d3)))
      (princ "Yes") (princ "No"))
    (princ #\newline)
    )
)

(main)

Measured memory_bytes: 8164
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
ans=0
x=t[0]
y=0
for i in range(n-1):
    y+=1
    if t[i]-x>k:
        ans+=1
        x=t[i]
        y=1
    elif y==c:
        ans+=1
        x=t[i+1]
        y=0
print(ans+2 if t[-1]-x>k else ans+1)

Measured memory_bytes: 50904
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a+b);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a-b);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	string s;
	cin>>s;
	int n=s.length(),i;
	cout<<s;
	if(s[n-1]=='s')
		cout<<'e';
	cout<<'s'<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

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

using namespace std;

int main() {
  string L;
  cin>>L;
  string answer;

  for(int i=0; i<L.size(); i++){
    if(L[i] == '0') answer=answer+'0';
    else if(L[i] == '1') answer=answer+'1';
    
    if(L[i] == 'B' && answer.empty()==false){ 
      answer.erase(answer.size()-1);
    }
  }

  cout << answer << endl;
}

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

int main(){
 	int A, B;
  	cin >> A >> B;
 	set<int> se{1,2,3};
  	se.erase(A);
  	se.erase(B);
  	int C = *se.begin();
  	cout << C << endl;
	return 0;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
     int k, a, b;
     cin >> k >> a >> b;
     int x1 = a / k, x2 = b / k;
     lop(i, a, b + 1)
     {
          if (i % k == 0)
          {
               cout << "OK";
               return;
          }
     }

     cout << "NG";

}

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

     int test = 1;
     // cin >> test;
     while (test--)solve();


}





Measured memory_bytes: 3652
# DFS
# N,A,B,C = 5,100,90,80
# L = [98,40,30,21,80]
N,A,B,C = map(int, input().split())
L = [int(input()) for _ in range(N)]
ans = float('inf')

def dfs(cur,a,b,c)->int:
    if cur==N:
        if min(a,b,c)>0: return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:            return float('inf')
        
    ret0 = dfs(cur+1, a,       b,       c)
    ret1 = dfs(cur+1, a+L[cur],b,       c) + 10
    ret2 = dfs(cur+1, a,       b+L[cur],c) + 10
    ret3 = dfs(cur+1, a,       b,       c+L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#A
"""n,k =map(int, input().split())

print(k * (k - 1)**(n - 1)) """

#B
"""
import math
r, n, m = map(int, input().split())
kankaku = 2 * r / n
tyusin = n / 2
sum = 0
for i in range(0, n + m):
    if i - m < 0:
        yoko1 = 2*math.sqrt(r ** 2 - ((tyusin-i)*kankaku)**2 )
        sum += yoko1
    elif i > n:
        yoko2 = 2*math.sqrt(r ** 2 - ((tyusin - i + m) * kankaku)** 2)
        sum += yoko2
    else:
        yoko1 = 2*math.sqrt(r ** 2 - ((tyusin-i)*kankaku)**2 )
        yoko2 = 2*math.sqrt(r ** 2 - ((tyusin - i + m) * kankaku)** 2)
        sum += max(yoko1, yoko2)
print(sum)
"""

#C
n = int(input())
an = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += an[i] - 1
print(ans)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	multiset<int> ms;
	REP(i, N) {
		int A;
		scanf("%d", &A);
		
		auto it = ms.lower_bound(A);
		if (it == ms.begin()) ms.insert(A);
		else {
			ms.erase(--it);
			ms.insert(A);
		}
	}
	
	cout << ms.size() << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll N, ll A) {
  cout << N * N - A << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll A;
	ll N;
	scanf("%lld", &N);
	scanf("%lld", &A);
	solve(N, A);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int A[n]={};
    int MaxA = 0;
    int MinA = 1e9;
    int ans;
    for(int i=0;i<n;i++){
        cin >>A[i];
        // if(i==0){
        //     MaxA=A[i];
        //     MinA=A[i];
        // }
        // MaxA=max(MaxA,A[i]);
        // MinA=min(MinA,A[i]);
    }
    sort(A, A+n);
    // cout << MaxA-MinA <<endl;
    cout << A[n-1] - A[0] <<endl;
    
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

vector<int> gen_primeList(const int size){
    vector<bool> v(size, true);
    v[0] = false;
    v[1] = false;
    
    for(int prime=2; prime<size;){
        for(int tmp=2*prime; tmp<size; tmp+=prime){ v[tmp]=false; }
        ++prime;
        while(prime<size && v[prime]==false){ ++prime; }
    }
    
    vector<int> vPrime;
    for(int i=0; i<size; ++i){
        if(v[i]){ vPrime.push_back(i); }
    }
    return vPrime;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    
    int Q; cin >> Q;
    
    int N=100000;
    vector<int> vPrime = gen_primeList(N+1);
    
    unordered_map<int,int> ht(vPrime.size());
    for(uint i=0; i<vPrime.size(); ++i){ ht[vPrime[i]]=1; }
    
    vector<int> vSimilar2017;
    for(uint i=0; i<vPrime.size(); ++i){
        if(ht.find((vPrime[i]+1)/2) != ht.end()){ vSimilar2017.push_back(vPrime[i]); }
    }
    
    vector<int> cSum(N+1, 0);
    for(uint i=0; i<vSimilar2017.size(); ++i){
        ++cSum[ vSimilar2017[i] ];
    }
    for(int i=1; i<=N; ++i){ cSum[i] += cSum[i-1]; }
    
    for(int i=0; i<Q; ++i){
        int l, r; cin >> l >> r;
        cout << (cSum[r] - cSum[l-1]) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1536
#include "stdio.h"

int hakai(int* a,int len){

	int find_num = 0;
	int search_num = 1;

	for (int i = 0; i < len; ++i){
		if (search_num == a[i]) {
			search_num++;
			find_num++;
		}
	}

	if (find_num == 0) return -1;

	if (len == find_num) return 0;

	return len - find_num;
}

int main(void){

	int N;
	scanf("%d",&N);

	int a[N + 1];
	scanf("%d",&a[0]);

	for (int i = 1; i < N; ++i){
		scanf(" %d",&a[i]);
	}

	int result = hakai(a,N);

	printf("%d",result);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
int N, M, K, H, W, L, R, X, Y;
//string S, T;

signed main(){
  int A, B;
  cin >> N >> A >> B;
  COUT(min(N*A,B));
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVVld = vector<VVld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


template<typename T>
struct BIT {
  int n; vector<T> d;
  BIT(int n=0) : n(n), d(n+1) {}
  void add(int i, T a=1) {
    for (i++; i <= n; i += i & -i) chmax(d[i], a);
  }
  // sum [0, i)
  T sum(int i) {
    if (i == 0) return 0;
    T x = 0;
    for (; i > 0; i -= i & -i) chmax(x, d[i]);
    return x;
  }
};


int main() {
  int n; cin >> n;
  V h(n);
  Vll a(n);
  rep(i, n) {
    cin >> h[i];
    --h[i];
  }
  rep(i, n) cin >> a[i];

  BIT<ll> dp(n);

  rep(i, n) {
    int x = (i == 0) ? 0 : h[i];
    dp.add(h[i], dp.sum(x) + a[i]);
  }
  
  ll ans = dp.sum(n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4096
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
-- end of templete





main = do
    [n, m] <- getInts
    arr <- newArray (1,n) 0 :: IO (IOUArray Int Int)
    getInts >>= sequence . binMap (\x y -> modifyArray arr (min x y) (+1) >> modifyArray arr (max x y) (subtract 1))
    forM_ [2..n] $ \i -> readArray arr (i-1) >>= modifyArray arr i . (+)
    res <- newIORef 0
    forM [1..n-1] $ \i -> do
        [a,b,c] <- getInts
        t <- readArray arr i
        modifyIORef res (+(min (t*a) (t*b+c)))
    readIORef res >>= print
    return ()


Measured memory_bytes: 117048
a = list(input())
b = list(input())
c = list(input())

f=-1
now=1

while f<0:
    if now==1:
        if len(a)==0:
            f=1
            break
        if a[0]=="a":
            now=1
        elif a[0]=="b":
            now=2
        else:
            now=3
        del a[0]
    elif now==2:
        if len(b)==0:
            f=2
            break
        if b[0]=="a":
            now=1
        elif b[0]=="b":
            now=2
        else:
            now=3
        del b[0]
    else:
        if len(c)==0:
            f=3
            break
        if c[0]=="a":
            now=1
        elif c[0]=="b":
            now=2
        else:
            now=3
        del c[0]
            
    #print(a,b,c)

if f==1:
    print("A")
elif f==2:
    print("B")
else:
    print("C")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{

    char a;
    cin >> a;

    char ans;

    if (a >= 'A' && a <= 'Z')
    {
        ans = 'A';
    }
    else
    {
        ans = 'a';
    }
    cout << ans << endl;
    return (0);
}

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

using namespace std;


int main()
{
  int H, W;
  string S[300];
  int dp1[301][301] = {{}}, dp2[301][301] = {{}};

  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
  }

  int ret = 0;

  for(int i = 1; i < W; i++) {
    for(int j = 0; j < H; j++) {
      for(int k = 0; k < H; k++) {
        dp1[j + 1][k + 1] = dp1[j][k] + (S[j][i - 1] == S[k][i]);
      }
    }
    for(int j = 0; j < H; j++) {
      for(int k = 0; k < H; k++) {
        dp2[j + 1][k + 1] = min(dp2[j + 1][k], dp2[j][k + 1]) + dp1[j + 1][k + 1];
      }
    }
    ret += dp2[H][H];
  }

  cout << ret << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int len,bj1=0;
	cin>>a;
	len=a.length();
	for(int i=0;i<len;i++)
	{
		if(a[i]=='C')bj1=1;
		if(a[i]=='F'&&bj1==1){cout<<"Yes"<<endl;return 0;}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,h,t,re=0;
    scanf("%d",&t);
    int wq[t+3];
    for(g=0;g<t;g++)
        scanf("%d",&wq[g]);
    for(g=0;g<t;g++)
        for(h=g+1;h<t;h++)
            re+=wq[h]*wq[g];
    printf("%d\n",re);
    return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b = M()
if a >= 13:
    print(b)
elif a <= 5:
    print(0)
else:
    print(b//2)

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

int main() {
    ll x; cin >> x;
    ll ans = (x / 11) * 2;
    if (x % 11 == 0) {
        cout << ans << endl;
    } else if (x % 11 <= 6) {
        cout << ans + 1 << endl;
    } else {
        cout << ans + 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def solve(A):
    N = len(A)
    A = [0] + A + [0]

    Stot = 0
    for i in range(0, N+1):
        Stot += abs(A[i]-A[i+1])

    for i in range(1, N+1):
        S = Stot - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1])
        print(S)


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    solve(A)


if __name__ == '__main__':
    main()

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int N;
  cin >> N;
  mii table;
  string ans = "YES";
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (table[a] > 0) {
      ans = "NO";
      break;
    }
    table[a]++;
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

void solve(){
    int n; cin >> n;
    double tmp = 0;
    for(int i = 0; i < n; i++){
        double a;
        cin >> a;
        tmp += 1 / a;
    }
    printf("%lf",1/tmp);
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    poss = []

    time = 0
    x = 0
    y = 0 
    for i in range(n):
        t,a,b = f()
        dis = abs(a-x) + abs(y-b)
        if dis<= t - time and dis%2 == (t- time)%2:
            time = t
            x = a
            y = b
        else:
            print('No')
            return
    
    print('Yes')



solve()


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;

#define forn(i, a, n) for (int i = (a); i < (int)n; i++)
#define trav(x, arr) for (auto &x : arr)
#define sz(x) (int)x.size()
#define Matrix(m, h, w) std::vector<vector<int>> m(h, vector<int> (w)); 
using ll = long long;

#define vi vector<int>
#define vl vector<long>
#define vll vector<ll>

// benq
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;


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


    int n , k; cin >> n >> k;

    vi p(n+1);

    forn(i, 0, n) cin >> p[i];

    sort(begin(p), end(p));

    int res = 0;

    forn(i, 0, k+1) 
        res += p[i];


    cout << res;


    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main(){
	int n,k,i;
	char s[12]="";
	if(scanf("%d %s %d",&n,s,&k)!=3)return 1;
	k--;
	for(i=0;i<n;i++){
		if(s[i]!=s[k]){
			s[i]='*';
		}
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
arr=list(map(int,input().strip().split()))
arr.sort()
maxi=arr[-1]
booll=[True]*(maxi+1)
r=0
for i in range(n-1):
    a=arr[i]
    if(booll[a]==True):
        for j in range(a,maxi+1,a):
            booll[j]=False
        if(a<arr[i+1]):
            r=r+1
if(booll[arr[n-1]]==True):
    r=r+1
print(r)    


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

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

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

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

/* output */
#define IN(x) cin >> x
#define DE(x) cerr << (x) << " "
#define BR cerr << "\n"
#define OUT(x) cout << (x) << endl
#define FIX cout << fixed << setprecision(10)

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

ll N = 0;
ll L, R, d;
ll ret = 0;

int main(void){
  
  IN(L);
  IN(R);
  IN(d);
  ret = (R/d) - ((L-1)/d);

  OUT(ret);

}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n,k,q;
  cin>>n>>k>>q;
  vector<ll> ar;
  vector<ll> vec;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    ar.push_back(a);
    vec.push_back(a);
  }
  ar.push_back(0);
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  ll border=0,ans=174417441744;
  for(int b=0;b<vec.size();b++){
    vector<ll> kans;
    priority_queue<ll,vector<ll>,greater<ll>> pque;
    for(int i=0;i<=n;i++){
      if(ar[i]>border) pque.push(ar[i]);
      else{
        ll sz=max((ll)pque.size()-k+1,(ll)0);
        for(int j=0;j<sz;j++){
          kans.push_back(pque.top());
          pque.pop();
        }
        while(!pque.empty()) pque.pop();
      }
    }
    sort(kans.begin(),kans.end());
    if(kans.size()<q) break;
    else ans=min(ans,kans[q-1]-kans[0]);
    border=vec[b];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++) 
using namespace std;

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

const int MAXN = 100100;

string s;
int n;

void load() {
	cin >> s;
	n = s.size();
}

void solve() {
	int mini = n;
	for (int i = 0; i < n - 1; ++i) {
		if (s[i] != s[i+1]) mini = min(mini, max(i+1, n-i-1));
	}
	printf("%d\n", mini);
}

int main() {
	load();
	solve();
	return 0;
}


Measured memory_bytes: 512
using System;

namespace PrimeNumber
{
    class Program
    {
        private static bool?[] arr = new bool?[1000000];

        private static bool Save(int n, bool b)
        {
            arr[n] = b;
            return b;
        }

        private static bool IsPrime(int n)
        {
            if (arr[n] != null) return (bool)arr[n];
            if (n == 2) return Save(n, true);
            if (n % 2 == 0) return Save(n, false);

            var l = Math.Sqrt(n);

            for (var i = 3; i <= l; i += 2)
                if (n % i == 0) return Save(n, false);
       
            return Save(n, true);
        }

        static void Main(string[] args)
        {
            int num;
            
            while (int.TryParse(Console.ReadLine(), out num))
            {
                var count = num >= 2 ? 1 : 0;
                for (var i = 3; i <= num; i+=2)
                    if (IsPrime(i)) count++;
                Console.WriteLine(count);
            }
        }
    }
}


Measured memory_bytes: 11088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int cnt[35];
int main() {
  int n,m;
  cin>>n>>m;

  for (int i=0; i<n; i++) {
    int k;
    cin>>k;
    for (int j=0; j<k; j++) {
      int a;
      cin>>a;
      cnt[a-1]++;
    }
  }
  int ans=0;
  for (int i=0; i<m; i++) {
    if (cnt[i]==n) ans++;
  }

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

Measured memory_bytes: 256