akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int d[1001],val[1001];
int dp[1001][(1<<12)],n,m,sz,x;
int fun(int idx,int mask)
{
    if(mask==(1<<n)-1) return 0;
    if(idx==m) return 1e9;
    int &ret=dp[idx][mask];
    if(~ret) return ret;
    return ret=min(val[idx]+fun(idx+1,mask|d[idx]),fun(idx+1,mask));
}
signed main()
{

    memset(dp,-1,sizeof dp);
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {

       scanf("%d%d",&val[i],&sz);
        while(sz--)
        {
            scanf("%d",&x);
            d[i]|=(1<<(x-1));
        }
    }
    int ans=fun(0,0);
    printf("%d",(ans>=1e9?-1:ans));
	return 0;
}


Measured memory_bytes: 19872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#define in(n, m) for (int i=n; i<m;i++)
#define inj(n, m)for (int j=n; j<m;j++)
#define ink(n, m)for (ll k=n; k<m;k++)
using namespace std;
using ll=long long;
using P =pair<ll, ll>;
const ll INF = 1LL << 60;
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; }


int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	if (k > a) {
		if (k - a - b > 0) sum += a - (k - a - b);
		else sum += a;
	}
	else sum += k;

	cout << sum << endl;

	return 0;
}

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

using namespace std;

int main(){
    int N,a,b,count=1;
    cin >> N;
    vector<int> vec(N),P(N),Q(N);
    for(int i=0;i<N;i++){
        vec[i] = i+1;
        cin >> P[i];
    }

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

    do{
        for(int i=0;i<N;i++){
            if(P[i]!=vec[i]){
                break;
            }

            if(i==N-1){
                a = count;
            }
        }

        for(int i=0;i<N;i++){
            if(Q[i]!=vec[i]){
                break;
            }

            if(i==N-1){
                b = count;
            }
        }

        count++;
        
    }while(next_permutation(vec.begin(),vec.end()));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#62

x, y = input().rstrip().split()
g1 = ("1", "3", "5", "7", "8", "10", "12")
g2 = ("4", "6", "9", "11")

if ((x in g1) and (y in g1)) or ((x in g2) and (y in g2)):
    print("Yes")
else:
    print("No")

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod? a : a - mod; }

int a[22][22];
ll dp[1 << 21];
int n;

ll f(int i, int mask){
	if(__builtin_popcount(mask) == n) return 1;
	if(i == n) return 0;
	if(dp[mask] != -1) return dp[mask];
	ll ret = 0;
	for(int k = 0; k < n; k++){
		if(!a[i][k] || mask & (1 << k)) continue;
		ret = add(ret, f(i + 1, mask | (1 << k)));
	}
	return dp[mask] = ret;
}

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

	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	memset(dp, -1, sizeof dp);
	cout << f(0, 0);
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=50001;
const ll INF=1LL<<60;

int main(){

    int N;
    ll W;cin>>N>>W;
    
    ll ans=0;
    
    vector<ll> v(N),w(N);
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }
    
    vector<pair<ll,ll>> A;
    
    for(int bit=0;bit<(1<<(N/2));bit++){
        ll vsum=0,wsum=0;
        for(int i=0;i<N/2;i++){
            if(bit&(1<<i)){
                vsum+=v[i];
                wsum+=w[i];
            }
        }
        A.push_back(make_pair(wsum,vsum));
        if(wsum<=W) ans=max(ans,vsum);
    }

    sort(all(A));
    
    ll maxi=0;
    
    for(int i=0;i<A.size();i++){
        A[i].second=max(maxi,A[i].second);
        maxi=A[i].second;
    }
    
    for(int bit=0;bit<(1<<(N-N/2));bit++){
        ll vsum=0,wsum=0;
        
        for(int i=0;i<N-N/2;i++){
            if(bit&(1<<i)){
                vsum+=v[N/2+i];
                wsum+=w[N/2+i];
            }
        }
        
        if(wsum>W) continue;
        
        wsum=W-wsum;
        
        auto it=lower_bound(all(A),make_pair(wsum+1,-INF));
        it--;
        
        ans=max(ans,(*it).second+vsum);
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 19448
#include<cstdio>
using namespace std;

int n, a[100];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i-1]) a[i] = -1, ans++;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
using System;

namespace AtCoder
{
    static class Solver
    {
        static IO io = new IO();

        public static void Solve()
        {
            io.ReadSplit();
            int N = io.Int();
            int A = io.Int();
            int B = io.Int();

            io.WriteLine(Ans(N, A, B).ToString());
        }

        static long Ans(long N, long A, long B)
        {
            if (N == 1)
            {
                if (A != B)
                {
                    return 0;
                }
                else
                {
                    return 1;
                }
            }
            else if (B < A)
            {
                return 0;
            }
            else
            {
                return B * (N - 2) - A * (N - 2) + 1;
            }
        }
    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver.Solve();
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

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

using namespace std;

using ll = long long;

int res = 0;
int P, Q, A, N;

// gcd(a, b)
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

// 残り p/q, ここまでで積 a, 残り n 個, mi 以上を使う
void dfs(int p, int q, int a, int n, int mi)
{
    if (p == 0)
    {
        res++;
        return;
    }
    if (n == 0)
        return;

    // p/q > 1/mi * n
    if (p * mi > q * n)
        return;

    for (int i = mi; i * a <= A; i++)
    {
        // p/q - 1/i = (p*i-q)/q*i
        if (p * i - q < 0)
            continue;
        int g = gcd(p * i - q, q * i);
        dfs((p * i - q) / g, q * i / g, i * a, n - 1, i);
    }
}

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

    // 分割は n 個以下, 積 a 以下
    while (cin >> P >> Q >> A >> N, P || Q || A || N)
    {
        res = 0;
        dfs(P, Q, 1, N, 1);
        cout << res << endl;
    }
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string n;
  cin >> n;

  for (int i = 0; i < 3; i++) {
    if (n[i] == '1') {
      n[i] = '9';
    } else if (n[i] == '9') {
      n[i] = '1'; 
    }
  }

  cout << n << endl;
 
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    string A,B;
    cin>>A>>B;
    bool ans=false;
    for(int i=0;i<A.size();i++){
        if(A==B){
            ans=true;
            break;
        }
        A=A.back()+A.substr(0,A.size()-1);
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

//a=97,z=122

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

using namespace std;

int main(){
	vector<int> list;
	int n;
	long long x;
	
	cin >> n >> x;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		list.push_back(a);
	}
	
	vector<int> mtime(n);
	for(int i = 0;i < n;i++){
		mtime[i] = list[i];
	}
	
	long long res = 0;
	for(int i = 0;i < n;i++){
		res += mtime[i];
	}
	
	for(int i = 1;i < n;i++){
		long long tmp = 0;
		for(int j = 0;j < n;j++){
			mtime[j] = min(mtime[j], list[(n + j-i)%n]);
			tmp += mtime[j];
		}
		
		tmp += x*i;
		
		res = min(res, tmp);
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define sort(x) sort(x.begin(), x.end())
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;


int main(){
   ll n;
   cin >> n;
   cout << n*n*n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b;
    for (int i=0;i<100000;i++){
        cin >> a >> b;
        if(a==0&&b==0){
            break;
        }
        for(int j=0;j<a;j++){
            for (int k=0;k<b;k++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vl a(n), b(n), c(n);

	REP(i, n)cin >> a[i] >> b[i] >> c[i];
	ll ans = 0;
	REP(i, 2) {
		REP(j, 2) {
			REP(k, 2) {
				vl ta = a, tb = b, tc = c;
				if (i)REP(l, n)ta[l] *= -1;
				if (j)REP(l, n)tb[l] *= -1;
				if (k)REP(l, n)tc[l] *= -1;
				vector<pll> tmp(n);
				REP(l, n) {
					tmp[l] = { ta[l] + tb[l] + tc[l],l };
				}
				ll cnta = 0, cntb = 0, cntc = 0;
				sort(ALL(tmp),greater<pll>());
				REP(l, m) {
					cnta += a[tmp[l].second];
					cntb += b[tmp[l].second];
					cntc += c[tmp[l].second];
				}
				ans = max(ans, abs(cnta) + abs(cntb) + abs(cntc));
			}
		}
	}
	cout << ans << endl;
}



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


const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007;
const int INF = 1000000000 + 1;

long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}

ll gcd(ll x, ll y) {
  if (x == 0) return y;
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}

double dfs(int v, vector<bool>& visited, vector<vector<int>>& gr) {
  visited[v] = true;
  double res = 0.;
  int num = 0;
  for (int next : gr[v]) {
    if (!visited[next]) {
      num++;
      double resv = dfs(next, visited, gr);
      res += resv;
    }
  }
  if (num == 0) {
    return 0;
  }
  res /= num;
  return res + 1;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;
  cout << fixed << setprecision(6);

  while (q-- >0) {
    ll a;
    int b;
    cin >> a;
    long double ff;
    cin >> ff;
    b = round(ff * 100);
    ll res = (a * b) / 100;
    cout << res << endl;


  }
  return 0;
}



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

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for(int i = 0;i <= A;i++){
    for(int j = 0;j <= B;j++){
      for(int k = 0;k <= C;k++){
        int total = 500*i+100*j+50*k;
        if(X == total)res++;
      }
    }
  }
  cout << res << endl;
}
          
          

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N, K;
    cin >> N >> K;
    int a = (N-1)*(N-2)/2;
    int ans;
    if ( K > a ) {
        cout << -1 << "\n";
    } else {
        vector<pair<int,int>> e;
        int ct = 0;
        bool end=false;
        for ( int i = 1; i < N-1; i++ ) {
            for ( int j = i+1; j <= N-1; j++ ) {
                if ( ct >= a - K ) {
                    end = true;
                    break;
                }
                ct++;
                e.push_back(make_pair(i,j));
            }
            if ( end ) break;
        }
        for ( int i = 1; i < N; i++ ) {
            ct++;
            e.push_back(make_pair(i,N));
        }

        cout << ct << "\n";
        for ( int i = 0; i < ct; i++ ) {
            cout << e[i].first << " " << e[i].second << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    vector <int> a(2), b(2);
    cin >> a >> b;
    int x = a[0] * 60 + a[1],
        y = b[0] * 60 + b[1];
    int k;
    cin >> k;
    cout << y - x - k;
    return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end() å
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int x, a;

signed main()
{
    cin >> x >> a;

    if (x < a)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 10 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N,M=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(M):
  ks=[int(x) for x in input().rstrip().split()]
  l.append(ks)
p=[int(x) for x in input().rstrip().split()]

ans=0
onof=[False for i in range(N)]
for i in range(2**N):
  for j in range(N):
    if i>>j & 1:
      onof[j]=True
  
  cnt=0
  
  for s in range(M):
    bulb=l[s]
    now=0
    for t in range(len(bulb)-1):
      if onof[bulb[t+1]-1]==True:
        now+=1
    if now%2==p[s]:
      cnt+=1
  if cnt==M:
    ans+=1
  onof=[False for b in range(N)]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,cmp,tmp,cnt=0;
  cin >> n;
  pair<long long,long long>p[n];
  long long a[n],ans[n]={};
  for(int i=0;i<n;i++){
  	cin >> a[i];  	
  	p[i]=make_pair(a[i],i);
  }  
  sort(p,p+n);

// for(int i=0;i<n;i++){
// 	cout << p[i].first << ' ' << p[i].second << endl;
// }
  tmp=p[n-1].first;
  cmp=p[n-1].second;
  for(int i=n-1;i>=0;i--){
  	if(p[i].first!=tmp){
  	  ans[cmp]+=cnt*(tmp-p[i].first);
  	  //cout << "cnt : " << cnt << endl;
  	  tmp=min(tmp,p[i].first);
  	}
  	cnt++;
  	cmp=min(cmp,p[i].second);
  	//cout << " " << cmp << endl;
  }
  ans[0]+=n*p[0].first;
  for(int i=0;i<n;i++){
  	cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int vis[15],a[10];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1,x;i<=k;i++)
		scanf("%d",&x),vis[x]=1;
	for(int i=n;;i++){
		int a[15]={};
		int x=i,cnt=0;
		while(x){
			a[++cnt]=x%10;
			x/=10;
		}
		int ok=1;
		for(int i=1;i<=cnt;i++)
			if(vis[a[i]]){
				ok=0;
				break;
			}
		if(ok) {
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

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

int main(){
  
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  
  string S;
  cin >> S;
  
  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());
  
  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }
    
  if (can) 
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;
}

Measured memory_bytes: 512
n = int(input())
h = list(map(int, input().split()))

cnt = 0
max_cnt = 0
for i in range(n - 1):
    if h[i] >= h[i+1]:
        cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
    else:
         cnt = 0

print(max_cnt)

Measured memory_bytes: 14252
n = int(input())
a = sorted(zip(map(int, input().split()), range(n)))
b = [0] * n
for i in range(n//2):
  b[i], b[n - i - 1] = (a[n//2][0], a[i][1]), (a[n//2 - 1][0], a[n - i - 1][1])
print('\n'.join(map(lambda x: str(x[0]), sorted(b, key = lambda x: x[1]))))


Measured memory_bytes: 64832
a = int(input())
if a >= 1800:
    print('1')
elif a >= 1600:
    print('2')
elif a >= 1400:
    print('3')
elif a >= 1200:
    print('4')
elif a >= 1000:
    print('5')
elif a >= 800:
    print('6')
elif a >= 600:
    print('7')
elif a >= 400:
    print('8')
else:
    print('error')

Measured memory_bytes: 9192
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 998244353LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}


int N, M;
ll inv(ll v) {
    ll res = 1;
    for (int t = MOD-2; t > 0; t >>= 1) {
        if (t&1) res = res*v%MOD;
        v = v*v%MOD;
    }
    return res;
}

ll A[5000001] = {1};
ll B[5000001];

ll comb(int a, int b) {
    if (a < b) return 0;
    return A[a]*B[b]%MOD*B[a-b]%MOD;
}

ll calc(int x) {
    if ((x^M)&1) return 0;

    ll x1 = comb((3*M-x)/2+N-1, N-1)%MOD;
    ll x2 = x*comb((M-x)/2+N-1, N-1)%MOD;
    ll x3 = (x<M?(N-x)*comb((M-x-2)/2+N-1, N-1):0)%MOD;
    debug(x, x1, x2, x3);
    return comb(N, x)*(x1+2*MOD-x2-x3)%MOD;
}


int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    repp(i, 1, 5000001) A[i] = A[i-1]*i%MOD;
    B[5000000] = inv(A[5000000]);
    repr(i, 5000000, 0) B[i] = B[i+1]*(i+1)%MOD;
    
    cin >> N >> M;
    ll res = 0;
    rep(i, min(N+1, M+1)) res = (res+calc(i))%MOD, debug(res);

    cout << res << endl;
}

Measured memory_bytes: 78336
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

ans = [0 for _ in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, p):
    for u in tree[v]:
        if u == p:
            continue
        else:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print(*ans)


Measured memory_bytes: 230920
#include<bits/stdc++.h>
using namespace std;
#define ll long
#define ld long double
#define eps 1e-9
#define maxp 11040000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll freq[maxp];
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
void pf(ll n){
	while(n%2==0){
		freq[2]++;
		n/=2;
	}
	for(ll i=3;i*i<=n;i+=2){

		if(n%i==0){
			ll lo=1,hi=n,mid;
			ll ans=0;
			while(lo<=hi){
				mid=(lo+hi)/2;
				ll val=power(i,mid);
				if(n%val==0){
					ans=mid;
					lo=mid+1;
				}else{
					hi=mid-1;
				}
			}
			n/=power(i,ans);
			freq[i]=ans;
		}
	}
	if(n>2){
		freq[0]++;
	}
}
ll sm(ll n){
	return (n*(n+1))/2;
}
ll get(ll n){
	ll sq=sqrt(1+8*n);
	return (sq-1)/2;
}
void solve(){
	ll n,i;
	in(n);
	memset(freq,0,sizeof freq);
	pf(n);
	ll ans=0;
	for(i=0;i<maxp;i++){
		if(freq[i]){
			ans+=get(freq[i]);
		}
	}
	cout<<ans<<'\n';
}	
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	clock_t t1=clock();
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
	clock_t t2=clock();
	cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}	


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

int main() {
  int A, B;
  cin >> A >> B;
  vector<int> ns(3);
  ns[A - 1]++;
  ns[B - 1]++;
  for(int i = 0; i < 3; ++i) {
    if(ns[i] == 0) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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


///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    string s,t; cin >> s >> t;
    int N = s.length();
    REP(i,N){
        if (s[i] != t[i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


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

int main(){
	int l,r,d,ans=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r; i++){
		if(i%d==0){
			ans++;
		}
	}
	cout<<ans<<endl;
}
	

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

using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(vr) vr.begin(),vr.end()
#define pi pair<int,int>

typedef long long ll;
namespace myrand
{
    mt19937 mt(chrono::system_clock::now().time_since_epoch() / chrono::microseconds(1));
    ll Int(ll l,ll r) { return uniform_int_distribution<ll> (l,r)(mt); }
}
using namespace myrand;
auto ss=chrono::system_clock::now();
double remain_time()
{
    auto en=chrono::system_clock::now();
    return (chrono::duration_cast<chrono::nanoseconds>(en-ss).count()*1e-9);
}

int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);
   int n,m;
   cin >> n >> m;
   cout << n*(n-1)/ 2+ m*(m-1)/2 << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  R n;
  map<ll,ll> ma;
  rep(i,n) {
    ll x;
    R x;
    ma[x]++;
  }
  R m;
  rep(i,m) {
    ll x;
    R x;
    ma[x]--;
    if(ma[x]<0) {
      pr("NO");
      return;
    }
  }
  pr("YES");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 12800
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 1e5 + 500;

int kol[500], n;
char s[N];

int main(){
    scanf("%s", s);
    n = strlen(s);
    for(int i = 0;i<n;i++)
        kol[s[i]] = 1;
    if((kol['N'] + kol['S']) % 2 == 0 && (kol['E'] + kol['W']) % 2 == 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;
    int MAX_M = 100000;
    int MAX_N = 100000;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        ArrayList<ArrayList<Integer>> ba = new ArrayList<ArrayList<Integer>>(M) {
            {
                for (int i = 0; i < M; i++) {
                    add(new ArrayList<Integer>() {
                    });
                }
            }
        };
        for (int i = 0; i < N; i++) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            if (A-- <= M) {
                ba.get(A).add(B);
            }
        }
        int ans = 0;
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        for (int i = 0; i < M; i++) {
            pq.addAll(ba.get(i));
            if (!pq.isEmpty()) {
                ans += pq.poll();
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 95936
#include<stdio.h>
using namespace std;

int a[200005],l[100005],r[100005];

long long m(int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    long long cnt=0;
    for(int i=0;i<n1;i++) l[i]=a[i+left];
    for(int i=0;i<n2;i++) r[i]=a[i+mid];
    l[n1]=r[n2]=2000000000;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(l[i]<=r[j])
            a[k]=l[i++];
        else{
            a[k]=r[j++];
            cnt+=n1-i;
        }
    }
    return cnt;
}

long long ms(int left,int right){
    int mid;
    long long v1,v2,v3;
    if(left+1<right){
        mid=(left+right)/2;
        v1=ms(left,mid);
        v2=ms(mid,right);
        v3=m(left,mid,right);
        return v1+v2+v3;
    }
    return 0;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    printf("%lld\n",ms(0,n));
    return 0;
}

Measured memory_bytes: 4308
MOD=10**9+7
class Fp(int):
    def __new__(self,x=0):return super().__new__(self,x%MOD)
    def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
    def __add__(self,value):return self.__class__(super().__add__(value))
    def __sub__(self,value):return self.__class__(super().__sub__(value))
    def __mul__(self,value):return self.__class__(super().__mul__(value))
    def __floordiv__(self,value):return self.__class__(self*self.__class__(value).inv())
    def __pow__(self,value):return self.__class__(super().__pow__(value%(MOD-1), MOD))
    __radd__=__add__
    __rmul__=__mul__
    def __rsub__(self,value):return self.__class__(-super().__sub__(value))
    def __rfloordiv__(self,value):return self.__class__(self.inv()*value)
    def __iadd__(self,value):self=self+value;return self
    def __isub__(self,value):self=self-value;return self
    def __imul__(self,value):self=self*value;return self
    def __ifloordiv__(self,value):self=self //value;return self
    def __ipow__(self,value):self=self**value;return self
    def __neg__(self):return self.__class__(super().__neg__())

N=int(input())
T=list(map(int, input().split()))+[0]
A=list(map(int, input().split()))+[0]
ans=Fp(1)
for i in range(N):
    if T[i-1]<T[i] and A[i]>A[i+1]:
        ans*=T[i]==A[i]
    elif T[i-1]<T[i]:
        ans*=T[i]<=A[i]
    elif A[i]>A[i+1]:
        ans*=A[i]<=T[i]
    else:
        ans*=min(T[i],A[i])
print(ans)

Measured memory_bytes: 19376
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    char[] c = new char[26];
    for(int i=0; i<26; i++){
      c[i] = x.charAt(i);
    }
    for(int i=0; i<s.length(); i++){
      char y = s.charAt(i);
      int z = 0;
      for(int j=1; j<26; j++){
        if(c[j]==y){
          z = j;
        }
      }
      System.out.print(c[(n+z)%26]);
    }
  }
}

Measured memory_bytes: 24184
#include <iostream>
#include <string>

using namespace std;

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

    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;
    for (int i = 0; i < n; i++)
        cout << s1[i] << s2[i];
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll k,x;
  cin >> k >> x;
  for(int i = x - k + 1;i <= x + k - 2;i++)cout << i << " ";
  cout << x + k - 1 << endl;
}

Measured memory_bytes: 3632
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))

import collections
n = int(input())
a = lmp()
plus = []
minus = []
for i in range(n):
    plus.append(i+1+a[i])
for i in range(n):
    minus.append(i+1-a[i])
p = list(collections.Counter(plus).items())
m = collections.Counter(minus)
# print(p)
# print(m)
ans = 0
for i in range(len(p)):
    tar = p[i][0]
    num = p[i][1]
    if tar in m:
        ans += num * m[tar]
print(ans)




Measured memory_bytes: 145284
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur!=nil&&cur->key!=key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd =0;
    scanf("%d", &n);
    init();
    for(i = 0; i < n ;i++){
        scanf("%s%d", com, &key);
        if(com[0]=='i'){insert(key); np++; size++;}
        else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6]== 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else{
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    printList();

    return 0;

}


Measured memory_bytes: 33916
#include <cstdio>

using namespace std;

int count(int n, int s, int begin) {
  if (n == 1) { return begin <= s && s <= 9 ? 1 : 0; }
  int acc = 0;
  for (int i = begin; i < s - i; ++i) {
    acc += count(n - 1, s - i, i + 1);
  }
  return acc;
}

int main() {
  while (true) {
    int n, s;
    scanf("%d %d", &n, &s);
    if (n == 0 && s == 0) { break; }
    printf("%d\n", count(n, s, 0));
  }

  return 0;
}

Measured memory_bytes: 1012
package main

import (
	"fmt"
	"strings"
)

func sepWords(n string) []string {
	temp := strings.Split(n, "")
	return temp
}
func countNum(n []string, num string) int {
	count := 0
	for _, v := range n {
		if v == num {
			count++
		}
	}
	return count
}
func min(i, j int) int {
	if i < j {
		return i
	} else {
		return j
	}
}
func main() {
	var n string
	fmt.Scan(&n)
	mat := sepWords(n)
	numZ := countNum(mat, "0")
	numO := countNum(mat, "1")
	fmt.Println(2 * min(numO, numZ))
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
 
char fie[1001][1001];
int H,W,N;
int memo[1001][1001];
char S[1000001];
int Ds[1000001][4];
 
int dx[]={0,1,0,-1};//R -> +1 , L -> +1
int dy[]={-1,0,1,0};
 
int sx,sy,gx,gy;
 
struct state{
  int x,y,c;
  bool operator>(const state &st) const{
    return c > st.c;
  }
 
};
 
bool check( int x,int y,int nc){
  if( x < 0 || y < 0 || x >= W || y >= H ) return false;
  if( fie[x][y] == '#' ) return false;
  if( memo[x][y] == -1 ) return true;
  if( memo[x][y] <= nc ) return false;
  return true;
}
 
 
 
bool bfs(){
 
  memset(memo,-1,sizeof(memo));
 
  priority_queue<state,vector<state>,greater<state> > q;
 
  q.push( (state){sx,sy,0} );
  memo[sx][sy] = 0;
  while( !q.empty() ){
    state p = q.top(); q.pop();
    int x = p.x;
    int y = p.y;
    int c = p.c;
 
    //  cout << x<< " " << y << " "<< c << endl;
 
    for(int i=0;i<4;i++){
      int nd = i;
      int nc = Ds[c][nd];
      if( nc > N ) continue;
      int nx = x+dx[nd];
      int ny = y+dy[nd];
      if( check(nx,ny,nc) ){
    q.push( (state){nx,ny,nc} );
    memo[nx][ny] = nc;
      }
    }
  }
  if( memo[gx][gy] == -1 )
    return false;
  return true;
}
 
int main(){
  while(cin >> H >> W >> N && (H||W||N) ){
    for(int i=1;i<=N;i++){
      cin >> S[i];
    }
    S[0] = 0;
    int dnc = 0;
    for(int i=1;i<=N;i++){
      if( S[i] == 'L' ){
    dnc+=3; 
      } else {
    dnc++;
      }
      dnc %= 4;
      S[i] = (char)dnc;
    }
     
    int dc[4] = {N+1,N+1,N+1,N+1};
    for(int i=N;i>-1;i--){
      dc[(int)S[i]] = i;
      for(int j=0;j<4;j++){
    Ds[i][j] = dc[j];
    //  printf("%d, %d  %d\n",i-1,j,(int)Ds[i-1][j]);
      }
    }
 
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
    cin >> fie[j][i];
    if( fie[j][i] == 'G' ){
      gx=j;
      gy=i;
    }
    if( fie[j][i] == 'S' ){
      sx = j;
      sy = i;
    }
      }
    }
     
    if( bfs() ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 8876
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin>>n>>m;
  char b[n][m];
  long long dp[n][m];
  memset(dp,0,sizeof(dp));
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      cin>>b[i][j];
  for(int i=0;i<n;i++)
    if(b[i][0]=='.')
      dp[i][0]=1;
    else
      break;
  for(int i=0;i<m;i++)
    if(b[0][i]=='.')
      dp[0][i]=1;
    else
      break;
  for(int i=1;i<n;i++)
    for(int j=1;j<m;j++){
      if(b[i][j]=='#')
        continue; 
      dp[i][j]=((b[i-1][j]=='.'?dp[i-1][j]:0)+(b[i][j-1]=='.'?dp[i][j-1]:0))%1000000007;
      //cout<<i<<" "<<j<<" "<<dp[i-1][j]<<" "<<dp[i][j-1]<<endl;
    }
  cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#if 0
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

int cost[14348907]; // 3^15

int get_state(array<int, 3>& t) {
  int state = 0;
  REP(i, 15) {
    REP(j, 3) {
      if (t[j]&(1<<i)) {
        state += pow(3,i)*j;
      }
    }
  }
  return state;
}

int get_cost(array<int, 3>& t) {
  return cost[get_state(t)];
}

void set_cost(array<int, 3> t, int c) {
  cost[get_state(t)] = c;
}

int get_highest_bit(int a) {
  int ret = 0;
  REP(i, 15) {
    ret = (a & (1<<i)) ? a & (1<<i) : ret;
  }
  return ret;
}

//BFS
int bfs(array<int, 3> t, int n){
  fill_n(cost, sizeof(cost)/sizeof(int), NIL);
  set_cost(t, 0);

  deque<array<int, 3>> q;
  q.push_back(t);
  int goal = (1<<n) - 1;

  while(!q.empty()) {

    auto now = q.front(); q.pop_front();
    if (now[0] == goal || now[2] == goal) {
      return get_cost(now);
    }

    vector<pair<int, int>> c; // 次にqに入れる候補
    //A->B
    if(now[0]>now[1]) {
      c.push_back(make_pair(0,1));
    }
    // B->C
    if(now[1]>now[2]) {
      c.push_back(make_pair(1,2));
    }
    // C->B
    if(now[2]>now[1]) {
      c.push_back(make_pair(2,1));
    }
    // B->A
    if(now[1]>now[0]) {
      c.push_back(make_pair(1,0));
    }

    for(pair<int,int>& p: c) {
      auto next = now;
      next[p.fi] &= ~get_highest_bit(now[p.fi]);
      next[p.se] |= get_highest_bit(now[p.fi]);

      if(get_cost(next) == NIL) {
        set_cost(next, get_cost(now)+1);
        q.push_back(next);
      }
    }
  }
  return NIL;
}

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  while(1) {
    int n, m;
    cin >> n >> m;
    if (!n && !m) break;

    //それぞれビットで、i+1番目のビットは大きさiのコップの存在を示す
    array<int, 3> t;
    fill_n(t.begin(), 3, 0);
    REP(i, 3) {
      int k;
      cin >> k;
      REP(j, k) {
        int b;
        cin >> b; b--; // t番目の大きさのカップ
        t[i] |= 1<<b;
      }
    }

    int cost = bfs(t, n);
    if (cost != NIL && cost <= m) {
      cout << cost << endl;
    }
    else {
      cout << "-1" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 59164
#include<stdio.h>

int main(void)
{
    int a, b, c, n, i;

n = 0;

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

for(i = a; i <= b; i++){
if(c % i == 0)
n++;
}
printf("%d\n", n);
   return 0;
}


Measured memory_bytes: 2000
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005,mod=998244353;
int f[N][3][3],n,res;
char s[N];

int chk(){
	rep(i,1,n-1)
		if(s[i]!=s[i+1])return 0;
	return 1;
}

int chk2(){
	rep(i,1,n-1)
		if(s[i]==s[i-1])return 0;
	return 1;
}

int power(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mod)
		if(p&1)res=(ll)res*x%mod;
	return res;
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(chk())return puts("1"),0;
	if(n==2)return puts("2"),0;
	if(n==3){
		if(s[1]==s[2]||s[2]==s[3])puts("6");
		else if(s[1]==s[3])puts("7");
		else puts("3");
		return 0;
	}
	int sum=0;
	rep(i,1,n)sum=(sum+s[i]-'a')%3;
	f[1][0][0]=f[1][1][1]=f[1][2][2]=1;
	rep(i,1,n-1)rep(a,0,2)rep(b,0,2)
		rep(c,0,2)if(b!=c)
			f[i+1][(a+c)%3][c]=(f[i+1][(a+c)%3][c]+f[i][a][b])%mod;
	res=(f[n][sum][0]+f[n][sum][1]+1ll*f[n][sum][2])%mod;
	res=(power(3,n-1)+mod-res)%mod;
	if(chk2())res=(res+1)%mod;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> v;
    auto comp = [](int a, int b) {
        return a>b;
    };
    rep(i, n) {
        if (v.size()==0) {
            v.push_back(a[i]);
            continue;
        }
        if (a[i]<=v.back()) {
            v.push_back(a[i]);
        }
        else {
            auto it = upper_bound(v.begin(), v.end(), a[i], comp);
            *it = a[i];
        }
    }
    int ans = v.size();
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>
int main(void){
    int n,k;
    long long ans=0;
    scanf("%d%d",&n,&k);
    int a[n], d[n][256][n+1];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        for (int j=0; j<256; j++){
            for (int l=0; l<n+1; l++){
                d[i][j][l]=0;
            }
        }
    }
    d[0][0][0]=1;
    d[0][a[0]][1]=1;
    for (int i=1; i<n; i++){
        for (int j=0; j<256; j++){
            for (int l=0; l<n; l++){
                d[i][j][l+1]=(d[i][j][l+1]+d[i-1][j^a[i]][l])%1000000007;
                d[i][j][l]=(d[i][j][l]+d[i-1][j][l])%1000000007;
            }
        }
    }
    for (int i=1; i<=n; i++){
        long long tmp=1;
        for (int j=1; j<=i; j++){
            tmp=tmp*j%1000000007;
        }
        ans=(ans+d[n-1][k][i]*tmp)%1000000007;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 10240
import sys

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

#n=54
#a=[0,0,1,0,1,2,1,2,3,2,3,3,4,4,5,4,6,5,7,8,
#   5,6,6,7,7,8,8,9,9,10,10,11,9,12,10,13,14,
#   11,11,12,12,13,13,14,14,15,15,15,16,16,16,
#   17,17,17]
#ans=115295190

#n=10
#a=[3,2,5,1,7,3,6,4,5,4]
#ans=0

if a[0]!=0:
    print(0)
    sys.exit()
 
mod=10**9+7
acnt=dict()
acnt[a[0]]=1
acntkeymax=0
t=3
for i in range(1,n):

    if a[i] in acnt:
        acnt[a[i]]+=1
        if acnt[a[i]]>3:
            print(0)
            sys.exit()
    else:
        if acntkeymax+1==a[i]:
            acntkeymax=a[i]
            acnt[a[i]]=1
        else:
            print(0)
            sys.exit()

    if a[i]!=0:
        if acnt[a[i]-1]==1:
            if acnt[a[i]]!=1:
                print(0)
                sys.exit()
        elif acnt[a[i]-1]==2:
            if acnt[a[i]]==1:
                t=(t*2)%mod
            elif acnt[a[i]]!=2:
                print(0)
                sys.exit()
        elif acnt[a[i]-1]==3:
            if acnt[a[i]]==1:
                t=(t*3)%mod
            elif acnt[a[i]]==2:
                t=(t*2)%mod
            elif acnt[a[i]]!=3:
                print(0)
                sys.exit()
    else:
        if acnt[0]==2:
            t=(t*2)%mod
        elif acnt[0]!=3:
            print(0)
            sys.exit()

#    print("i:",i,"a[i]:",a[i],"acnt[a[i]]:",acnt[a[i]],"t:",t)
                
print(t)       
        
        

Measured memory_bytes: 18272