akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
  int m,f,r;
  while(1){
    cin >> m >> f >> r;
    if(m==-1 && f==-1 && r==-1) break;
    if(m==-1 || f==-1) cout << "F" << endl;
    else if(m+f>=80) cout << "A" << endl;
    else if(m+f>=65) cout << "B" << endl;
    else if(m+f>=50) cout << "C" << endl;
    else if(m+f>=30 && r>=50) cout << "C" << endl;
    else if(m+f>=30) cout << "D" << endl;
    else cout << "F" << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main()
{
	char S[10];
	int r;
	int c=0;
	int d=0;
	
	scanf("%s", S);
	
	for(r=0; r<10; r++)
	{
		if(S[r]=='A' || S[r]=='T' || S[r]=='G' || S[r]=='C') 
		{
			c++;
			if(d < c) d = c;
		}
		
		else
		{
			c = 0;
		}
	}
	
	printf("%d", d);
	
	return 0;
}

Measured memory_bytes: 128
H, W = map(int, input().split())
s = [input() for _ in range(H)]

row = []
clm = []
for i in range(H):
    if '#' not in set(s[i]):
        row.append(i)
for i in range(W):
    if '#' not in set([v[i] for v in s]):
        clm.append(i)

for i in range(H):
    if i in row:
        continue
    ans = ''
    for j in range(W):
        ans += '' if j in clm else s[i][j]
    print(ans)

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

int main()
{
  int min, max;
  int n;

  while (cin >> n && n != 0){
    max = 0;
    min = 500;
    for (int i = 0; i < n; i++){
      int sum = 0;
      for (int j = 0; j < 5; j++){
        int a;
        cin >> a;
        sum += a;
      }
      if (max < sum) max = sum;
      if (min > sum) min = sum;
    }
    cout << max << " " << min << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
//------ © daxkofficial™ ------//
 
#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 ll long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define srt(x) sort((x).begin(), (x).end());
#define clr(x) memset(x, 0, sizeof(x))
#define mem(a,val) memset(a,val,sizeof(a))
#define trace(x) for(auto it:x) cout<<it<<' '; cout<<"\n";
#define sumv(x, w) for(auto it:x) w+=it;
#define traca(A, n) for(ll i=0; i<n; i++) cout<<A[i]<<' '; cout<<"\n";
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define cy cout<<"YES"<<"\n";
#define cn cout<<"NO"<<"\n";
#define nl cout<<"\n";
#define chk cout<<"*\n";
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

/*-----------------------------Modular Arithmetic---------------------*/
inline ll add(ll x,ll y,ll mod){x+=y; if(x>=mod) return x-mod; return x;}
inline ll sub(ll x,ll y,ll mod){x-=y; if(x<0) return x+mod; return x;}
inline ll mul(ll x,ll y,ll mod){return (x*1ll*y)%mod;}
inline ll power(ll x,ll y,ll mod){ll ans=1; while(y){if(y&1) ans=mul(ans,x,mod); x=mul(x,x,mod); y>>=1;} return ans;}
inline ll inv(ll x,ll mod){return power(x,mod-2,mod);}
 
 
 
/*------------------------ Important Functions ----------------------------*/

ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}
 
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
 
 
 
 
/*------------------------ Trouble begins here ----------------------------*/
 
 
const ll mod=1e9+7, M2=998244353;
const ll N=1e5+100;



ll fastpower(ll n, ll p, ll m)
{
    if(p==0)
    return 1;

    ll t=fastpower(n, p/2, m);
    ll ans=(t*t)%m;

    if(p%2!=0)
    {
        ans=(ans* n%m)%m;
    }
    return ans;
}




void solve()
{
    ll n;
    cin>>n;
    if(n==1)
    {
        cout<<0<<"\n";
        return;
    }
    if(n==2)
    {
        cout<<"2\n";
        return;
    }
    ll z = fastpower(10, n, mod);
    z-=fastpower(9, n, mod);
    z+=mod;
    z%=mod;
    z-=fastpower(9, n, mod);
    z+=mod;
    z%=mod;
    
    z+=fastpower(8, n, mod);
    //z+=mod;
    z%=mod;
    cout<<z;
    nl
    return;
}
 
 
 
int main()
{
    fastio
 
    ll tc=1;
    //cin>>tc;
    while(tc--)
    {

        //cout<<"ch\n";
        solve();
    }
 
    return 0;
}

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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];
    sort(L.begin(), L.end());
    vector<int> tmp_vec(N, 0);
    vector<vector<int>> min_index(N, tmp_vec);
    for (int i = 0; i < N - 2; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            int tmp = L[i] + L[j];
            min_index[i][j] = upper_bound(L.begin(), L.end(), tmp) - L.begin();
        }
    }
    int total = 0;
    for (int i = 0; i < N - 2; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            int index = min_index[i][j];
            for (int k = j + 1; k < index; ++k) {
                if (L[i] < L[j] + L[k] && L[j] < L[k] + L[i] && L[k] < L[i] + L[j]) ++total;
            }
        }
    }
    cout << total << '\n';
}

Measured memory_bytes: 18048
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[1050] = {}, f[100010];
double syo = 0, su = 0;
long long mur, kmr, yju, counto = 0,counto1=0;
char mado[105];
string rik;
bool mazi[110], gi[110],zi,manji;
pair<int, int>n[110];
vector<int> aa,bb,cc;
map<int, int>kazu;
int main() 
{
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b;
		aa.push_back(b);
	}
	sort(aa.begin(), aa.end());
	for (int i = 0; i < a; i++) {
		cin >> b;
		bb.push_back(b);
	}
	sort(bb.begin(), bb.end());
	for (int i = 0; i < a; i++) {
		cin >> b;
		cc.push_back(b);
	}
	sort(cc.begin(), cc.end());
	//cout << cc.size() << endl;
	for (int i = 0; i < a; i++) {
		 counto = lower_bound(aa.begin(),aa.end(), bb[i])-aa.begin();
		 counto1= a-(upper_bound(cc.begin(), cc.end(), bb[i])-cc.begin());
		mur += counto * counto1;
		//cout << counto << ' ' << counto1 << endl;
		counto = 0;
		counto1 = 0;
	}
	cout << mur << endl;
	//auto counto = lower_bound(aa.begin(), aa.end(), bb[i]) - aa.begin();
	//auto counto1 = aa.end() - upper_bound(cc.begin(), cc.end(), bb[i]);
	return 0;
}

Measured memory_bytes: 1784
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/01/18.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {
	ll ans = 0;


	ll h,w,n;
	
	cin >> h;
	cin >> w;
	cin >> n;

	ll big;
	if (h > w) {
		big = h;
	}
	else {
		big = w;
	}

	ans = n / big;

	if ((n % big) != 0 ){
		ans++;
	}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = 998244353; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vv<int> dp = vvec(N + 1, 6001, 0);
    dp[0][0] = 1;
    rep(i, N) {
        rep(j, 1, S + 1) dp[i + 1][j] = dp[i][j];
        if (A[i] > S) continue;
        else if (A[i] == S) {
            dp[i + 1][S] = (dp[i + 1][S] + (ll)(i + 1) * (N - i)) % MOD;
        }
        else {
            dp[i + 1][A[i]] = (dp[i + 1][A[i]] + i + 1) % MOD;
            rep(j, 1, S - A[i]) {
                dp[i + 1][j + A[i]] = (dp[i + 1][j + A[i]] + dp[i][j]) % MOD;
            }
            dp[i + 1][S] = (dp[i + 1][S] + (ll)dp[i][S - A[i]] * (N - i)) % MOD;
        }
    }
    write(dp[N][S]);
}

Measured memory_bytes: 70784
//atcoder DP-1
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define endl "\n"
#define int long long
typedef long double ld;
typedef vector<vector<int> > matrix;
typedef vector<int> arr;
typedef vector<string> vs;
typedef vector<pair<int,int> > pv;
#define test() int t;cin>>t;while(t--)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
int bx[]={0,0,1,-1,1,-1,-1,1};
int by[]={1,-1,0,0,1,-1,1,-1};

//=================================================================//
int dp[(int) 1e6];
int n,k;

int solve(int pos,int h[]) {
    //base case
    if(pos==n-1) return 0;
    if(pos>=n) return INT_MAX;

    int &ans = dp[pos];
    if(ans!=-1) return ans;
    //recursive case
    int op = INT_MAX;
    for(int i=1;i<=k;i++) {
        op = min(op,abs(h[pos]-h[pos+i])+solve(pos+i,h));
    }
    return ans = op;

}

#undef int
int main(){
#define int long long 
    fast;
    cin>>n>>k;
    int h[n];
    memset(dp, -1, sizeof dp);
    FOR(i,0,n-1) cin>>h[i];
    cout<<solve(0,h);
    return 0;
}

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


int A[100005],B[100005];
int main(){
	int n,a=0,b=0;
	string s;
	cin >> s;
	n=s.size();
	
	for(int i=0;i<100000;i++){
		if(i%2){
			A[i]='0';
			B[i]='1';
		}
		else{
			A[i]='1';
			B[i]='0';
		}
	}
	
	for(int i=0;i<n;i++){
		if(s[i]!=A[i]) a++;
		if(s[i]!=B[i]) b++;
	}
	cout << min(a,b) << endl;
	return 0;
}

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

int main() {
	char str[128]="";
	vector<int> r;
	while (scanf("%s",str) != EOF)
	{
		int i=-1;
		int pn=0,n=0,s=0;
		do
		{
			i++;
			switch (str[i]){
				case 'M':
					n=1000;
					break;
				case 'D':
					n=500;
					break;
				case 'C':
					n=100;
					break;
				case 'L':
					n=50;
					break;
				case 'X':
					n=10;
					break;
				case 'V':
					n=5;
					break;
				case 'I':
					n=1;
					break;
				default:
					n=0;
					break;
			}
			if (pn<n && pn!=0)
			{
				s+=n-pn;
				pn=0;
			} else {
				s+=pn;
				pn=n;
			}
		} while (str[i] != 0);
		r.push_back(s);
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <stack>
using namespace std;

bool func(string t) {
  stack<char> p;
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == '(') {
      p.push(t[i]);
    }
    else if (t[i] == '[') {
      p.push(t[i]);
    }
    else if (t[i] == ')') {
      if (p.empty()) {
        return false;
      }
      else {
        if (p.top() == '(') {
          p.pop();
        }
        else {
          return false;
        }
      }
    }
    else if (t[i] == ']') {
      if (p.empty()) {
        return false;
      }
      else {
        if (p.top() == '[') {
          p.pop();
        }
        else {
          return false;
        }
      }
    }
  }
  if (p.empty()) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
  string s;
  while (getline(cin, s)) {
    if (s[0] == '.') {
      break;
    }
    bool flag = func(s);
    if (flag) {
      cout << "yes" << endl;
    }
    else {
      cout << "no" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  uint64_t a, b, x;
  cin >> a >> b >> x;
  
  uint64_t a1;
  if (a == 0) {
    a1 = 0;
  }
  else {
    a1 = (a - 1) + (x - (a - 1) % x);
  }
  
  uint64_t result;
  if (b < a1) {
    result = 0;
  }
  else {
    result = (b - a1) / x + 1;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 9999999999;
const long long MOD = 1e9 + 7;
const double pi = 3.1415926535897932384626;
const int SIZE = 1 << 17;

int cou[5];
int main() {
	int k[5], l[5];
	for (int i = 0; i < 3; ++i) {
		cin >> k[i] >> l[i];
		++cou[k[i] - 1], ++cou[l[i] - 1];
	}
	sort(cou, cou + 4);
	if (cou[1] == 1 && cou[2] == 2 && cou[3] == 2) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

#include <vector>
#include <queue>
using namespace std;


struct dijkstra
{
  using P=pair<int,int>;
  priority_queue<P,vector<P>,greater<P>> q;
  vector<vector<P>>edge;
  vector<int>dist;
  int sz;
  dijkstra(int size){
    sz=size;
    edge.resize(size);
  }
  void reset(){
    dist.assign(sz,-1);
    q=priority_queue<P,vector<P>,greater<P>>();
  }
  void ae(int to,int from,int cost)
  {
    edge[to].push_back({cost,from});
  }
  int cal(int start,int end){
    reset();
    q.push({0,start});
    while(!q.empty())
    {
      P tp=q.top();q.pop();
      if(dist[tp.second]!=-1)continue;
      dist[tp.second]=tp.first;
      for(P nn:edge[tp.second])
      {
        if(dist[nn.second]!=-1)continue;
        q.push({nn.first+tp.first,nn.second});
      }
    }
    return dist[end];
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<map<int, int>>num(n);
  vector<ed>es(m);
  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    num[a][c]++;
    num[b][c]++;
  }
  int cnt=0;
  rep(i,n)
  {
    int tn=cnt++;
    for(auto &p:num[i])p.second=cnt++;
    num[i][-1]=tn;
  }
  dijkstra dj(cnt+2);
  rep(i,n)
  {
    int t=num[i][-1];
    for(auto p:num[i])
    {
      if(p.first==-1)continue;
      int tn=p.second;
      dj.ae(t,tn,1);
      dj.ae(tn,t,0);
    }
  }
  rep(i,m)
  {
    int to=num[es[i].a][es[i].c],from=num[es[i].b][es[i].c];
    dj.ae(to,from,0);
    dj.ae(from,to,0);
  }
  int start=num[0][-1],end=num[n-1][-1];
  cout<<dj.cal(start,end)<<endl;

  return 0;

}


Measured memory_bytes: 64116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  rep(i, 4) {
    if (s[i] == '+')
      ans++;
    else
      ans--;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(auto & b : a) cin>>b;
    
    ll dp[45][2];
    vector<ll> score(2);
    for(int i=0;i<n;++i){
        score[a[i] & 1] += 1;
    }
    dp[0][1] = max(score[0],score[1]);
    if(k&1){
        dp[0][0] = max(score[0],score[1]);
    }else{
        dp[0][0] = score[1];
    }
    for(int b=1;b<41;++b){
        score.clear();
        score.push_back(0);score.push_back(0);
        for(int i=0;i<n;++i){
            score[(a[i]>>b) & 1] += (1ll<<b);
        }
        dp[b][1] = max(score[0],score[1]) + dp[b-1][1];
        if((k>>b)&1){
            dp[b][0] = max(score[1] +  dp[b-1][1] , score[0] + dp[b-1][0]); 
        }else{
            dp[b][0] = score[1] + dp[b-1][0];
        }
    }
    cout << dp[40][0] << endl;
    return 0;
}



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

int N, K;
ll ans = numeric_limits<ll>::max();

int main()
{
    cin >> N >> K;
    vector<pair<ll, ll>> p, q;
    for (int i = 0; i < N; i++)
    {
        ll x, y;
        cin >> x >> y;
        p.emplace_back(x, y);
    }

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

    for (int x1 = 0; x1 < N; x1++)
    {
        for (int x2 = x1 + 1; x2 < N; x2++)
        {
            for (int y1 = 0; y1 < N; y1++)
            {
                for (int y2 = y1 + 1; y2 < N; y2++)
                {
                    auto p1 = p[x1], p2 = p[x2], p3 = p[y1], p4 = p[y2];

                    if (p3.second > p4.second)
                        swap(p3, p4);
                    if (p3.first < p1.first || p4.first < p1.first)
                        continue;
                    if (p3.first > p2.first || p4.first > p2.first)
                        continue;

                    if (p1.second < p3.second || p2.second < p3.second)
                        continue;
                    if (p1.second > p4.second || p2.second > p4.second)
                        continue;
                    int cnt = 0;
                    for (int i = 0; i < N; i++)
                    {
                        if (p1.first <= p[i].first && p[i].first <= p2.first && p3.second <= p[i].second && p[i].second <= p4.second)
                            cnt++;
                    }
                    if (cnt < K)
                        continue;
                    ans = min(ans, (p2.first - p1.first) * (p4.second - p3.second));
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

k = int(input())

num = deque()
num = deque([i for i in range(1,10)])

for i in range(k):
    x = num.popleft()
    mod = x % 10
    if x % 10 != 0:
        num.append(10*x + mod-1)
    num.append(10*x + mod)
    if x % 10 != 9:
        num.append(10*x + mod+1)
print(x)

Measured memory_bytes: 18792
n,m = map(int,input().split())
A = []
b = []
for i in range(n):
    list = []
    for s in input().split():
        list.append(int(s))
    A.append(list)
for i in range(m):
    b.append(int(input()))
for i in range(n):
    s = 0
    list = A[i]
    for j in range(m):
        s += list[j] * b[j]
    print(str(s))
        


Measured memory_bytes: 6012
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

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

int main() {
  ll N;
  cin >> N;
  ll A;
  cin >> A;
  solve(N, A);
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;

    return 0;
}


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

vector<long long> div(long long n)
{
    vector<long long> ans;
    for(long long i=2; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ans.push_back(i);
            if(n/i!=i) ans.push_back(n/i);
        }
    }
    return ans;
}

int main()
{
    long long ans=2;
    long long n;
    cin>>n;
    if(n==2)
    {
        cout<<1<<endl;
        return 0;
    }
    vector<long long> a=div(n-1);
    ans+=a.size();
    vector<long long> b=div(n);
    for(long long i=0; i<b.size(); i++)
    {
        long long x=n,y=b[i];
        while(x%y==0)
            x/=y;
        if(x%y==1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int i,j;
  string S,T;
  cin >> S >> T;
  
  if(T.size() > S.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  for(i=S.size()-T.size(); i>=0; i--) {
    for(j=i; j<T.size()+i; j++)
      if(S.at(j)!='?' && S.at(j)!=T.at(j-i))
        break;
    if(j==T.size()+i)
      break;
  }

  if(i==-1)
    cout << "UNRESTORABLE";
  else {
    for(j=0; j<S.size(); j++)
      if(S.at(j) == '?')
        if(j>=i && j<i+T.size())
          S.at(j) = T.at(j-i);
        else
          S.at(j) = 'a';
    cout << S;
  }
  cout << endl;
}

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

int main() {
	string ans;
	int a, b;
	cin >> a >> b;
	if (a + b > 9) {
		ans = "error";
	}
	else {
		cout << a+b << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl '\n'
int main()
{
    optimize();
    int cnt_5=2,cnt_7=1,ar[4],c=0,d=0;
    for(int i=0;i<3;i++){
        cin>>ar[i];
    }
    for(int i=0;i<3;i++)
    {
        if(ar[i]==5)
        {
          c++;
        }
        else if(ar[i]==7)
        {
            d++;
        }
        else
        {
            cout<<"NO"<<nl;
        }
    }
    if(cnt_5==c && cnt_7==d)
    {
        cout<<"YES"<<nl;
    }
    else{
         cout<<"NO"<<nl;
    }

return 0;
}



Measured memory_bytes: 3548
N,Q=list(map(int,input().split()))
l=[[] for i in range(N)]
for i in range(N-1):
   a,b=list(map(int,input().split()))
   l[a-1].append(b-1)
   l[b-1].append(a-1)
l_c=[0]*N
for i in range(Q):
   a,b=list(map(int,input().split()))
   l_c[a-1]+=b
visited=[0]*N
from collections import deque
def ans(start):
   que=deque([start])
   visited[start]=1
   while que:
      node=que.popleft()
      for i in l[node]:
         if visited[i]==0:
            l_c[i]+=l_c[node]
            que.append(i)
            visited[i]=1
ans(0)
print(*l_c)

Measured memory_bytes: 56432
arr = Array.new(6, "")

gets.to_i.times do
  case gets.to_f
  when 0...165
    arr[0] += "*"
  when 165...170
    arr[1] += "*"
  when 170...175
    arr[2] += "*"
  when 175...180
    arr[3] += "*"
  when 180...185
    arr[4] += "*"
  else
    arr[5] += "*"
  end
end

6.times do |i|
 puts "#{i + 1}:#{arr[i]}" 
end

Measured memory_bytes: 6124
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    a.sort()
    
    print(abs(a[0]-a[1])+abs(a[1]-a[2]))

Measured memory_bytes: 3956
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from functools import lru_cache
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s

#main
s=input()
Yn(len(set(s))!=1)


Measured memory_bytes: 7780
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> prime = new ArrayList<>();
        int n = Integer.parseInt(sc.next());
        sc.close();
        boolean[] isPrime = new boolean[101];
        for(int i=2;i<=n;i++){
            if(!isPrime[i]){
                prime.add(i);
                for(int j=2*i;j<=n;j+=i){
                    isPrime[j] = true;
                }
            }
        }
        int[] count = new int[prime.size()];
        int[] l = new int[5];
        for(int i=0;i<prime.size();i++){
            int num = n;
            int base = prime.get(i);
            int divide = base;
            while(num/divide>0){
                count[i]+=num/divide;
                divide*=base;
            }
            if(count[i]>=74){
                l[0]++;
                l[1]++;
                l[2]++;
                l[3]++;
                l[4]++;
            }else if(count[i]>=24){
                l[0]++;
                l[1]++;
                l[2]++;
                l[3]++;
            }else if(count[i]>=14){
                l[0]++;
                l[1]++;
                l[2]++;
            }else if(count[i]>=4){
                l[0]++;
                l[1]++;
            }else if(count[i]>=2){
                l[0]++;
            }
        }

        long sum = 0;
        sum+=l[4];
        sum+=(l[0]-1)*l[3];
        sum+=(l[1]-1)*l[2];
        sum+=(l[0]-2)*l[1]*(l[1]-1)/2;
        System.out.println(sum);




    }

    
}

Measured memory_bytes: 23508
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string S;
    int oe;

    cin >> S;

    for(int i=0;i<S.length();i++)
    {
        oe = i % 2;

        switch(oe)
        {
            case 0:
                if(S[i] == 'L')
                {
                    cout <<"No"<< endl;
                    return(0);
                }
                break;
            case 1:
                if(S[i] == 'R')
                {
                    cout <<"No"<< endl;
                    return(0);
                }
                break;
            default:
                break;
        } 
    }

    cout <<"Yes"<< endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;

int main(){
	int n,t;
	cin>>n>>t;
	int c,t1,f=0,min=INT_MAX;
	lp2(i,n){
		cin>>c>>t1;
		if(t>=t1){
			f=1;
			if(min>c)min=c;
	}
	}
	if(f==0)cout<<"TLE"<<endl;
	else cout<<min<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define MOD 1000000007
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }



int main() {
  int cnt=0;
  int n; cin >>n;
  rep(i,n){
    int a,b; cin >>a >>b;
    if(a!=b)cnt=0;
    else{
      cnt++;
      if(cnt==3){
        yn(1); return 0;
      }
    }
  }
  yn(0);
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
#define MAX 808
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int ans,n,m,K,sx,sy;
char g[MAX][MAX];
int Calc(int x,int y){return min(min(x-1,n-x),min(y-1,m-y));}
int dis[MAX][MAX];
int d[4][2]={1,0,0,1,-1,0,0,-1};
void BFS(int sx,int sy)
{
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)dis[i][j]=1e9;
	dis[sx][sy]=0;ans=1e9;
	queue<int> Qx,Qy;Qx.push(sx),Qy.push(sy);
	while(!Qx.empty())
	{
		int x=Qx.front(),y=Qy.front();Qx.pop();Qy.pop();
		ans=min(ans,(Calc(x,y)+K-1)/K);
		if(dis[x][y]>=K)continue;
		for(int i=0;i<4;++i)
		{
			int xx=x+d[i][0],yy=y+d[i][1];
			if(xx<1||xx>n||yy<1||yy>m)continue;
			if(g[xx][yy]=='#')continue;
			if(dis[xx][yy]<=dis[x][y]+1)continue;
			dis[xx][yy]=dis[x][y]+1;
			Qx.push(xx);Qy.push(yy);
		}
	}
}
int main()
{
	n=read();m=read();K=read();
	for(int i=1;i<=n;++i)scanf("%s",g[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(g[i][j]=='S')sx=i,sy=j;
	BFS(sx,sy);
	printf("%d\n",ans+1);
	return 0;
}


Measured memory_bytes: 3456
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, k: usize, mut a: [usize; n]);

    a.sort_unstable();

    let mut ans_vec = Vec::new();

    for i in 0..n {
        ans_vec.push(i);
    }
    let mut left = 0;
    let mut right = a[a.len() - 1];

    let func = |t_max| -> bool {
        let mut cat_sum = 0;
        for i in 0..a.len() {
            if a[i] <= t_max {
                continue;
            }
            cat_sum += a[i] / t_max;

            if cat_sum > k {
                return true;
            }
        }
        cat_sum > k
    };
    while right - left > 1 {
        let buff = (left + right) / 2;

        if func(buff) {
            left = buff;
        } else {
            right = buff;
        }
    }

    println!("{}", right);
}


Measured memory_bytes: 7216
n,m = map(int,input().split())
card = []
l = []
min_num = 0
max_num = 100000

for i in range(m):
	l = list(map(int,input().split()))
	card.append(l)

for i in card:
	if i[0] > min_num:
		min_num = i[0]
	if i[1] < max_num:
		max_num = i[1]
	# print("min_num =",min_num,"max_num =",max_num)

if min_num > max_num:
	print(0)
else:
	print(max_num-min_num+1)

Measured memory_bytes: 27336
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String num = br.readLine();
		int num1 = Integer.parseInt(num);

		num1 = num1*num1*num1;

		System.out.println(num1);







	}

}

Measured memory_bytes: 24124
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
#include <numeric>
using namespace std;

int main(){
    long long int a, b, k;
    
    cin >> a >> b >> k;
    
    for(long long int i = 0; i < k; i++){
        if(i%2 == 0){
            if(a%2 == 1){
                a -= 1;
                b += a/2;
                a /= 2;
            }else{
                b += a/2;
                a /= 2;
            }
        }else{
            if(b%2 == 1){
                b -= 1;
                a += b/2;
                b /= 2;
            }else{
                a += b/2;
                b /= 2;
            }
        }
    }
    
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
main :: IO ()
main = getLine >>= print . solve . map read . words
solve :: [Int] -> Int
solve (l:r:_) 
  | r - l >= 2019 = 0
  | otherwise = minimum [ (i * j) `mod` 2019 | i <- [l..(r-1)], j <- [(i+1)..r] ]


Measured memory_bytes: 892
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> B(N - 1), A(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> B[i];
  }
  A[N - 1] = B[N - 2];
  ll min_a;
  for (int i = N - 3; i >= 0; i--) {
    min_a = min(B[i], B[i + 1]);
    A[i + 1] = min_a;
  }
  A[0] = B[0];
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long d,g,ii,jj,kk;
  vector<long> p,c;

  cin >> d >> g;

  p.resize(d);
  c.resize(d);

  long sum[d][100];
  long flg[d];

  for(ii=0;ii<d;ii++){
	cin >> p[ii] >> c[ii] ;
  }

  
  memset(sum,0,sizeof(sum));
  memset(flg,0,sizeof(flg));

  for(ii=0;ii<d;ii++){
	for(jj=0;jj<p[ii];jj++){
	  sum[ii][jj] = (ii+1)*100*(jj+1);

	}
	//cout << "jj:" << jj << endl;
	sum[ii][jj-1] += c[ii];
	
  }
  //cout << "sum:" << sum[4][0] << endl;
  long totalScore = 0,totalCnt=0;
  long minNum = LONG_MAX;
	
  long mask=0;
  for(ii=0;ii<pow(2,d);ii++){
	// 計算領域初期化
	totalScore = 0;
	totalCnt   = 0;
	memset(flg,0,sizeof(flg));
	
	for(jj=0;jj<d;jj++){
	  //cout << "ii:" << ii  << "jj:" << jj << endl;
	  if((ii & (long)pow(2,jj)) != 0){
		totalScore += sum[jj][p[jj]-1];
		totalCnt   += p[jj];
		flg[jj] = 1;
		//cout << "ii:" << ii  << "jj:" << jj << "c[jj]" << p[jj] << "totalScore:" << totalScore << "totalCnt:" << totalCnt << endl;
	  }
	}
//	if(ii==24){
//	  cout << "totalScore:" << totalScore << endl;
//	}
	if(totalScore >= g){
	  if(minNum > totalCnt){
		minNum = totalCnt;
	  }	  
	}

	else{
	  for(jj=d-1;jj>=0;jj--){
		if(flg[jj] == 0){
		  //if(ii==24){
		  //	cout << "d:"  << "flgjj:" << jj << endl;
		  //}
		  break;
		}
	  }
	  if(jj!=-1){
		for(kk=0;kk<p[jj] -1;kk++){

		  //if(ii==24){
		  //cout << "kk:" << kk << "totalCnt" << totalCnt << "totalScore:" << totalScore << endl;
		  //}
		  
		  if(totalScore + sum[jj][kk] >= g){

			totalCnt += kk+1;
			totalScore += sum[jj][kk];

			break;
		  }
		}
		if(totalScore >= g){
		  if(minNum > totalCnt){
			minNum = totalCnt;
		  }
		}
	  }
	}
  }

  cout << minNum << endl;
  return 0;
}


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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007LL
#define MOD2 998244353LL
const int INF = 1 << 28;



int main() {
    int N; cin >> N;
    vi hash(100005, 0);
    int ans = 0;
    rep(i, N) {
        int a; cin >> a;
        if (a <= 100000) hash[a]++;
        else ans++;
    }

    for (int i = 1; i <= 100000; i++) {
        if (hash[i] == i) continue;
        else if (hash[i] > i) ans += (hash[i] - i);
        else ans += hash[i];
    }

    cout << ans << endl;

}




Measured memory_bytes: 640
from collections import defaultdict

N, M, K = map(int, input().split())
friends = defaultdict(list)
blocked = defaultdict(list)

for i in range(M):
    a, b = map(int, input().split())
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
for j in range(K):
    c, d = map(int, input().split())
    blocked[c - 1].append(d - 1)
    blocked[d - 1].append(c - 1)


class UnionFind:
    def __init__(self, n):
        # total number of nodes.
        self.n = n
        # node id -> root node id
        self._root_table = list(range(n))
        # root node id -> group size
        self._size_table = [1] * n

    def find(self, x):
        """Returns x's root node id."""
        r = self._root_table[x]
        if r != x:
            # Update the cache on query.
            r = self._root_table[x] = self.find(r)
        return r

    def union(self, x, y):
        """Merges two groups."""
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # Ensure that x is the larger (or equal) group.
        if self._size_table[x] < self._size_table[y]:
            x, y = y, x

        self._size_table[x] += self._size_table[y]
        self._root_table[y] = x

    def size(self, x):
        return self._size_table[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._root_table) if x == i]

    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)
for i in range(N):
    for j in friends[i]:
        uf.union(i, j)

ans = []
for i in range(N):
    res = uf.size(i) - len(friends[i]) - 1
    for b in blocked[i]:
        if uf.same(i, b):
            res -= 1
    ans.append(res)
print(*ans)


Measured memory_bytes: 123864
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int N = int.Parse(input[0]);
		int K = int.Parse(input[1]);
		
		GetResult(N, K);
	}
	
	static void GetResult(int N, int K){
	    int result;
	    result = Calculate(N, K);
	    Console.WriteLine(result);
	}
	
	static int Calculate(int N, int K, int cnt = 0){
	    cnt++;
	    if(N / K != 0){
	        return Calculate(N/K, K, cnt);
	    }else{
	        return cnt;
	    }
	        
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin >> A >> B;
    if(B%A==0) cout << A+B << endl;
    else cout << B-A << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int calc(int n) {
  int res = 0;
  while (n) {
    res = res + n % 10;
    n /= 10;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  int a = calc(n);
  cout << (n % a != 0 ? "No" : "Yes") << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    string a, b, c;
    cin >> a >> b >> c;
char d = a.at(0);
char e = b.at(0);
char f = c.at(0);
char dif = 'A' - 'a';
d += dif;
e += dif;
f += dif;
cout << d << e << f << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
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 long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,i,m,j;
    cin>>n;
    vector<int> d(n,0);
    rep(i,n)cin>>d[i];
    cin>>m;
    vi t(m,0);
    rep(i,m)cin>>t[i];
    sort(d.begin(),d.end());
    sort(t.begin(),t.end());

    bool ch=false;
    for(i=0,j=0;i<n&&j<m;){
        if(d[i]==t[j]){
            if(j==m-1)ch=true;
            i++;
            j++;
        }
        else if(d[i]>t[j]){
            cout<<"NO"<<endl;
            return 0;
        }
        else{
            i++;
        }
    }
    if(ch)fin("YES");
    else fin("NO");
    
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> G[n];
    rep(i, m){
        int K;
        scanf("%d", &K);
        rep(_, K){
            int s;
            scanf("%d", &s);
            --s;
            G[s].push_back(i);
        }
    }
    int p[m];
    rep(i, m) scanf("%d", &p[i]);

    int ans = 0;
    rep(S, 1<<n){
        vector<int> bulb(m, 0);
        rep(i, n)if(S>>i & 1){
            for(int j: G[i]) bulb[j] ^= 1;
        }
        bool flag = true;
        rep(i, m)if(bulb[i] != p[i]){
            flag = false;
            break;
        }
        ans += flag;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e6 + 1;//                                                             |
//----------------------------------------------------------------------------------
 



void solve()
{
    
    ll n;cin>>n;
    ll val=1000;
    vl v(n);
    for(auto &i:v) cin>>i;

    ll stocks=0;
    ll i=0;
    while(i<n){
        ll j=i;
        while(j<n-1 && v[j+1]>v[j]){
            j++;
        }
        if(v[j]>v[i]){
            stocks=val/v[i];
            val-=stocks*v[i];
            val+=stocks*v[j];
            stocks;
        }
        i=j+1;
    }
    cout<<val<<"\n";
}
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}

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

using namespace std;

const int MAX_N = 100000;
const int NF = -1; // not find

int N, L;
int Is[MAX_N + 2];
int Tm[MAX_N + 2];

int search ( int i )
{
	if (Tm[i] != NF) {
		return Tm[i];
	}
	if (Is[i] == 0) {
		return Tm[i] = 0;
	}
	if (Is[i-1] < Is[i] && Is[i] > Is[i+1]) {
		return Tm[i] = L - Is[i];
	}
	if (Is[i-1] < Is[i] && Is[i] < Is[i+1]) {
		return Tm[i] = L - Is[i] + search(i+1);
	}
	if (Is[i-1] > Is[i] && Is[i] > Is[i+1]) {
		return Tm[i] = L - Is[i] + search(i-1);
	}
	return Tm[i] = L - Is[i] + max(search(i-1), search(i+1));
}

int main ( void )
{
	while (cin >> N >> L) {
		fill(Is, Is+MAX_N+2, 0);
		fill(Tm, Tm+MAX_N+2, NF);
		for (int i = 0; i < N; ++i) {
			cin >> Is[i+1];
		}

		int mx = 0;
		for (int i = 0; i < N; ++i) {
			//cout << i << '=' << search(i+1) << endl;
			mx = max(mx, search(i+1));
		}

		cout << mx << endl;
	}

	return 0;
}

Measured memory_bytes: 4280
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
int main()
{
	dhoom;
	int x , y , z ;
	cin >> x >> y >> z;
	cout << (x - z)/(y + z) << endl;
	return 0;
}


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

int main() {
	int c[3][3];
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j)
			cin >> c[i][j];
	}

	int A[3], B[3];
	bool ans = true;
	for (int i = 0; i < 3; ++i) {
		int j = (i + 1) % 3;
		int a = c[i][0] - c[j][0];
		if (a != c[i][1] - c[j][1] || a != c[i][2] - c[j][2]) {
			ans = false;
			break;
		}
		A[i] = a;

		int b = c[0][i] - c[0][j];
		if (b != c[1][i] - c[1][j] || b != c[2][i] - c[2][j]) {
			ans = false;
			break;
		}
		B[i] = b;
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256