akhauriyash/Code-Regression huggingface dataset:
k=int(input())
ans=0

gcd_ans=[[-1 for i in range(k+1)] for _ in range(k+1)]

def gcd(a,b):
    if(b==0):
        return a
    else:
        return gcd(b, a%b)

def gcd_lookup(i,j):
    if(gcd_ans[i][j]==-1):
        gcd_ans[i][j]=gcd(i,j)
        gcd_ans[j][i]=gcd_ans[i][j]
    return gcd_ans[i][j]

for i in range(1,k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            if(i==j and j==l):
                ans+=gcd_lookup(gcd_lookup(i,j),l)
            elif((i==j) or (j==l) or (l==i)):
                ans+= 3*(gcd_lookup(gcd_lookup(i,j),l))
            else:
                ans+= 6*(gcd_lookup(gcd_lookup(i,j),l))

print(ans)


Measured memory_bytes: 9560
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}



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);
	return a/g*b;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	LL ans=1LL;
	for(int i=0;i<n;i++){
		LL a;
		cin>>a;
		ans=lcm(ans,a);
	    
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
using namespace std;
using P=pair<int,int>;
using ll=long long;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n),b(n),c(n),d(m),e(m),f(m);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=0;i<m;i++){
        cin>>d[i]>>e[i]>>f[i];
    }
    vector<int> x,y;
    for(int i=0;i<n;i++){
        x.push_back(a[i]);
        x.push_back(b[i]);
        y.push_back(c[i]);
    }
    for(int i=0;i<m;i++){
        x.push_back(d[i]);
        y.push_back(e[i]);
        y.push_back(f[i]);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    x.erase(unique(x.begin(),x.end()),x.end());
    y.erase(unique(y.begin(),y.end()),y.end());
    vector<ll> xp(x.size()),yp(y.size());
    for(int i=0;i<n;i++){
        xp[find(x.begin(),x.end(),a[i])-x.begin()]=a[i];
        xp[find(x.begin(),x.end(),b[i])-x.begin()]=b[i];
        yp[find(y.begin(),y.end(),c[i])-y.begin()]=c[i];
    }
    for(int i=0;i<m;i++){
        xp[find(x.begin(),x.end(),d[i])-x.begin()]=d[i];
        yp[find(y.begin(),y.end(),e[i])-y.begin()]=e[i];
        yp[find(y.begin(),y.end(),f[i])-y.begin()]=f[i];
    }
    vector<vector<bool>> ywall(y.size()-1,vector<bool>(x.size(),false)),
                         xwall(y.size(),vector<bool>(x.size()-1,false));
    for(int i=0;i<n;i++){
        int xs=lower_bound(xp.begin(),xp.end(),a[i])-xp.begin(),
            xg=lower_bound(xp.begin(),xp.end(),b[i])-xp.begin(),
            yy=lower_bound(yp.begin(),yp.end(),c[i])-yp.begin();
        for(int j=xs;j<xg;j++){
            xwall[yy][j]=true;
        }
    }
    for(int i=0;i<m;i++){
        int ys=lower_bound(yp.begin(),yp.end(),e[i])-yp.begin(),
            yg=lower_bound(yp.begin(),yp.end(),f[i])-yp.begin(),
            xx=lower_bound(xp.begin(),xp.end(),d[i])-xp.begin();
        for(int j=ys;j<yg;j++){
            ywall[j][xx]=true;
        }
    }
    int sy=lower_bound(yp.begin(),yp.end(),0)-yp.begin()-1,
        sx=lower_bound(xp.begin(),xp.end(),0)-xp.begin()-1;
    if(sy==-1||sx==-1||sy==yp.size()-1||sx==xp.size()-1){
        cout<<"INF"<<endl;
        return 0;
    }
    vector<vector<bool>> reached(yp.size()-1,vector<bool>(xp.size()-1,false));
    queue<P> task;
    task.push(P(sy,sx));
    ll ret=0;
    while(!task.empty()){
        int nx=task.front().second,ny=task.front().first;
        task.pop();
        if(nx<0||xp.size()-1<=nx||ny<0||yp.size()-1<=ny){
            cout<<"INF"<<endl;
            return 0;
        }
        if(reached[ny][nx])continue;
        reached[ny][nx]=true;
        ret+=(yp[ny+1]-yp[ny])*(xp[nx+1]-xp[nx]);
        if(xwall[ny][nx]==false)task.push(P(ny-1,nx));
        if(xwall[ny+1][nx]==false)task.push(P(ny+1,nx));
        if(ywall[ny][nx]==false)task.push(P(ny,nx-1));
        if(ywall[ny][nx+1]==false)task.push(P(ny,nx+1));
    }
    cout<<ret<<endl;
}



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

int main(){
    long N;
    cin >> N;
    deque<long> A(N);
    for(auto& i : A)cin >> i;
    N >>= 1;
    deque<long> B(A);
    nth_element(begin(A), begin(A) + N - 1, end(A));
    partial_sort(begin(A) + N - 1, begin(A) + N + 1, end(A));
    for(const auto i : B)cout << (i >= A[N] ? A[N - 1] : A[N]) << endl;
    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long n;
	cin >> n;
	
	if(n&1){
		cout << 0 << "\n";
		return 0;
	}
	
	long long tw=(n/2);
	
	long long nn=n/2;
	while(nn>0){
		tw+=nn/2;
		nn/=2;
	}
	
	long long fi=0;
	nn=n/2;
	while(nn>0){
		fi+=nn/5;
		nn/=5;
	}
	cout << min(tw,fi) << "\n";
	return 0;
}

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


int main(){
  long long a,b,c,i;
  cin >> a >> b >> c;
  long long abc;
  abc=a*b*c;
  long long ma=0;
  ma=max(a,b);
  ma=max(ma,c);
  long long me=ma/2;
  long long ans=0;
  if(ma==a){
    ans=abc-(me*b*c);
    ans=abs(ans-(me*b*c));
  }else if(ma==b){
    ans=abc-(a*me*c);
    ans=abs(ans-(a*me*c));
  }else if(ma==c){
    ans=abc-(a*b*me);
    ans=abs(ans-(a*b*me));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    x,a,b=MI()
    if b<=a:
        print("delicious")
    elif b<=a+x:
        print("safe")
    else:
        print("dangerous")
main()

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

void solve(long long N)
{
    if (N % 2 == 1) {
        // 奇数同士はいくらかけても奇数
        cout << 0 << endl;
        return;
    }
    ll ans = 0;
    ll div = 10;
    // 関数は f(N) = 2×4×6×8×…×N と変形できる
    // 0の数=5の素数の数なので、偶数の羅列の中で2*5、2*5*5、2*5*5*5…が何回出るか調べて5が出現する回数の合計が答え
    while (N / div > 0) {
        ans += (N / div);
        div *= 5;
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    cin.tie(nullptr);
    cout.tie(nullptr);
	ios_base::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n;
    cin >> n;
    vll h(n);
    
    ll tmp = 0;
    ll r = 0;
    
    rep(i, n) {
        cin >> h[i];
        tmp = max(h[i], tmp);
        r += tmp - h[i];
    }
    
   
    
    mes(r);
    
    
    
    
}

Measured memory_bytes: 4844
import 'dart:io';

void main() {
  List nab = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  int count; // 総和
  count = 0;
  int sum; // 各桁の総和
  for (int i = 1; i <= nab[0]; i++) {
    int number = i;
    sum = 0;
    while (true) {
      int amari = (number % 10);
      sum = sum + amari;
      int nokori = (number / 10).floor();

      number = nokori;

      if (nokori == 0) {
        break;
      }
    }
    if (nab[1] <= sum && sum <= nab[2]) {
      count = count + i;
    }
  }

  print(count);
}

Measured memory_bytes: 14160
N,M=map(int,input().split())
ids=[]
x=[]
numofpref=1
for i in range(M):
    p,y=map(int,input().split())
    ids.append([p,y,i,0])
#print(ids)
x=sorted(ids,key=lambda x:x[1])	#まず、下軸要素(同着の中では~)をsortedでソートする
x.sort(key=lambda x:x[0])
#print(x)
for i in range(M):
    if i==0:
        x[i][3]="".join((str(x[i][0]).zfill(6),str(numofpref).zfill(6)))
        numofpref=numofpref+1
    else:
        if x[i][0]!=x[i-1][0]:
            numofpref=1
        x[i][3]="".join((str(x[i][0]).zfill(6),str(numofpref).zfill(6)))
        numofpref=numofpref+1
x.sort(key=lambda x:x[2])
for i in range(M):
    print(x[i][3])


Measured memory_bytes: 98008
dishes = list(map(int, [input() for _ in range(5)]))
visited = [0, 0, 0, 0, 0]
inf = 777
def dfs(t):
  global visited
  temp = inf
  for i in range(5):
    if visited[i] == 0:
      visited[i] = 1
      ti = dishes[i] + t
      if sum(visited) != 5:
        temp = min(temp, dfs((ti // 10 + bool(ti % 10)) * 10))
      else:
        temp = t + dishes[i]
      visited[i] = 0
  return temp
print(dfs(0))

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const int MOD = 1000000007ll;
const int mod1 = 1000000009ll;
const int mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

int bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
int bit(lli _mask,int _i){return (_mask&(1ll<<_i))==0?0:1;}
int add(int a,int b,int m=MOD){int x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
int sub(int a,int b,int m=MOD){int x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
int mul(int a,int b,int m=MOD){lli x=a*1ll*b;x%=m;while(x<0)x+=m;return (int)x;}
int ldtoint(ld x){return (int)(x+0.5);}lli ldtolli(ld x){return (lli)(x+0.5);}
int powermod(lli _a,lli _b,int _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=mul(_r,_a,_m);_b>>=1;_a=mul(_a,_a,_m);}return _r;}

template<class T1,class T2>ostream&operator<<(ostream& os,const pair<T1,T2>&p){os<<"["<<p.first<<","<<p.second<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,const vector<T>&v){os << "[";bool first=true;for (T it:v){if (!first)os<<", ";first = false;os<<it;}os<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,set<T>&v){os<<"[";bool first=true;for (T it:v){if(!first)os<<", ";first=false;os<<it;}os<<"]";return os;}
template<class T1,class T2>ostream&operator<<(ostream& os,map<T1,T2>&v){os<<"[";bool first=true;for(pair<T1,T2> it:v){if(!first)os<<", ";first=false;os<<"("<<it.F<<","<<it.S<<")";}os<<"]";return os;}
template<class T>void parr(T a[],int s,int e){cout<<"[";for(int i=s;i<e;i++)cout<<a[i]<<", ";cout<<a[e]<<"]\n";}

lli N;
lli A[100010];
lli B[100010];
lli pref[100010];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));
    //ios::sync_with_stdio(0);cin.tie(0);

    slli(N);
    for(int i=1;i<=N;i++)slli(A[i]);
    sort(A+1,A+N+1);
    for(int i=1;i<=N;i++)pref[i] = pref[i-1] + A[i];
    int ans = 1;

    for(int i=N-1;i>=1;i--){
        if(pref[i]*2 >= A[i+1])
            ans ++;
        else
            break;
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 1792
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

template<size_t Mod = 1000000007, class T = long long int>
struct modint {
  T value;
  constexpr modint() = default;
  constexpr modint(const modint&) = default;
  constexpr modint(modint&&) = default;
  constexpr modint(T value_) : value(value_% Mod) {}
  constexpr modint& operator=(const modint&) = default;
  constexpr modint& operator=(modint&&) = default;
  constexpr modint& operator+=(const modint& rhs);
  constexpr modint& operator-=(const modint& rhs);
  constexpr modint& operator*=(const modint& rhs);
  constexpr modint& operator %=(T rhs);
  constexpr modint& operator %=(const modint& rhs);
  constexpr modint& operator /=(const modint& rhs);
  constexpr modint inv() const;
  static constexpr size_t MOD = Mod;
  using value_type = T;
};

template<size_t Mod, class T>
constexpr modint<Mod, T> modpow(modint<Mod, T> a, modint<Mod, T> b) {
  modint<Mod, T> res(1);
  while (b.value > 0) {
    if (b.value % 2)res = res * a;
    a = a * a;
    b.value /= 2;
  }
  return res;
}

#define MODINT_ASSIGN_DEF(op) \
template<size_t Mod, class T> \
constexpr modint<Mod, T>& modint<Mod, T>::operator op##=(const modint<Mod, T>& rhs) { value = value op rhs.value; while(value < 0)value += Mod; value %= Mod; return *this; }
MODINT_ASSIGN_DEF(+)
MODINT_ASSIGN_DEF(-)
MODINT_ASSIGN_DEF(*)

template<size_t Mod, class T>
constexpr modint<Mod, T>& modint<Mod, T>::operator %=(T rhs) {
  return (*this %= modint<Mod, T>(rhs));
}

template<size_t Mod, class T>
constexpr modint<Mod, T>& modint<Mod, T>::operator %=(const modint<Mod, T>& rhs) {
  value %= rhs.value; return *this;
}

template<size_t Mod, class T>
constexpr modint<Mod, T> modint<Mod, T>::inv() const {
  return modpow<Mod, T>(*this, modint<Mod, T>(Mod - 2));
}

template<size_t Mod, class T>
constexpr modint<Mod, T>& modint<Mod, T>::operator /=(const modint<Mod, T>& rhs) {
  return *this *= rhs.inv();
}

#define MODINT_OP_DEF(op) \
template<size_t Mod, class T> \
constexpr modint<Mod, T> operator op(modint<Mod, T> a, const modint<Mod, T>& b) { return a op##= b; }
MODINT_OP_DEF(+)
MODINT_OP_DEF(-)
MODINT_OP_DEF(*)
MODINT_OP_DEF(/ )
MODINT_OP_DEF(%)


template<size_t Mod, class T>
std::ostream& operator <<(std::ostream& os, const modint<Mod, T>& rhs) {
  os << rhs.value;
  return os;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  long long int N, A, B;
  cin >> N >> A >> B;
  modint<> factA = 1;
  modint<> factB = 1;
  modint<> factNA = 1;
  modint<> factNB = 1;
  for (int i = 1; i <= A; ++i)factA *= i;
  for (int i = 1; i <= B; ++i)factB *= i;
  for (int i = 0; i < A; ++i)factNA *= (N - i);
  for (int i = 0; i < B; ++i)factNB *= (N - i);
  cout << modpow(modint<>(2), modint<>(N)) - modint<>(1) - (factNA / factA) - (factNB / factB) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
const ll MAX_V = 100000;

struct edge{
	ll from, to, cost;
};

vector<edge> G[MAX_V+10];
stack<edge> st;
ll value[MAX_V+10];
bool visited[MAX_V + 10];

ll N, M, L, R, D;

bool dfs() {
	for (int i = 1; i <= N; i++) {
		if (!visited[i]) {
			if (G[i].size() > 0) {
				for (int j = G[i].size() - 1; j >= 0; j--) {
					st.push(G[i][j]);
				}
			}
			visited[i] = true;
			while (st.size() > 0) {
				edge e = st.top();
				st.pop();
				if (!visited[e.to]) {
					value[e.to] = value[e.from] + e.cost;
					for (int j = G[e.to].size() - 1; j >= 0; j--) {
						st.push(G[e.to][j]);
					}
					visited[e.to] = true;
				}
				else {
					if (value[e.to] != value[e.from] + e.cost) return false;
				}
			}
		}
	}
	return true;
}

int main() {
	bool ans;
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> L >> R >> D;
		edge e;
		e.from = L, e.to = R, e.cost = D;
		G[L].push_back(e);
		edge f;
		f.from = R, f.to = L, f.cost = -D;
		G[R].push_back(f);
	}

	ans = dfs();

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

	return 0;
}

Measured memory_bytes: 22272
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

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

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

const int MAXN = 1e5 + 5;

int N;
int a[MAXN];
int cnt[MAXN];

int main(void) 
{
  scanf("%d", &N);
  REP(i, N) scanf("%d", a + i);
  REP(i, N) ++cnt[a[i]];

  int odd = 0;
  int even = 0;
  REP(i, MAXN) {
    if (cnt[i]) {
      odd += cnt[i] % 2;
      even += 1 - cnt[i] % 2;
    }
  }

  int maxalive = odd + even / 2 * 2;
  assert((N - maxalive) % 2 == 0);
  printf("%d\n", maxalive);

  return 0;
}


Measured memory_bytes: 1024
N,K=map(int,input().split())
V = list(map(int,input().split()))

ans = -(10**9)
for A in range(0,K+1,1):
    for B in range(0,min(K,N)-A+1,1):
        tmp = V[0:A] + V[N-B:N]
        tmp.sort()
        for i in range(0,min(K-A-B,A+B),1):
            tmp[i]=max(tmp[i],0)
        ans = max(ans,sum(tmp))
print(ans)

Measured memory_bytes: 41200
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int sum = 0;
        int max = 0;
        if (A == B) {
            System.out.println(2 * A);
        } else{
            if (A > B) {
                sum = A;
                A--;
            } else {
                sum = B;
                B--;
            }
            if (A == B) {
                System.out.println(sum + A);
            } else if (A > B) {
                System.out.println(sum + A);
            } else {
                System.out.println(sum + B);
            }
        }
    }
}


Measured memory_bytes: 23508
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st N;
  ci(N);
  if(N.at(0) == '9' || N.at(1) == '9'){
    co("Yes");
  }
  else{
    co("No");
  }
}

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

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int cnt[n+1];
    memset(cnt, 0, sizeof cnt);
    for(int i=0;i<m;i++){
        int l, r; cin >> l >> r;
        l--; r--;
        cnt[l]++;
        cnt[r+1]--;
    }
    for(int i=1;i<n;i++){
        cnt[i] += cnt[i-1];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(cnt[i] >= m){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,h=0,w=0;
  cin >> n;
  map<long long,int> m;
  for(int i=0;i<n;i++){
    long long a;
    cin >> a;
    m[a]++;
    if(m[a]==2){
      if(a>=h){
        w=h;
        h=a;
      }
      else if(a>w){
        w=a;
      }
      m[a]-=2;
    }
  }
  cout << h*w << endl;
}

Measured memory_bytes: 6528
import sys 
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline()

N, K = map(int , input().split())
an = [int(a) for a in input().split()]
dp = [None] *(K+1)
for i in range(an[0]):
    dp[i] = 1
for i in range(an[0],K+1):
    for a in an:
        if i-a>=0 and dp[i-a]==1:
            dp[i]=0
            break
    else:
        dp[i]=1
        
if dp[K]==0:
    print("First")
else:
    print("Second")
#print(dp)

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int A, B;

int main() {
	scanf("%d%d", &A, &B);
	int ans = 0;
	for (int i = A; i <= B; ++i) {
		int s = i % 10, t = i / 10000 % 10;
		int u = i / 10 % 10, v = i / 1000 % 10;
		if (s == t && u == v) ++ans;
	}
	printf("%d\n", ans);
}


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

int main() {
  long long N,M,X,x,y,ans,g;
  cin>>N>>M;
  g=1;
  for(int i=0;i<M;i++){
    g*=2;
  }
 ans=(1900*M+100*(N-M))*g;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
  int h[5], c[4];

  while(scanf("%d", h) && h[0]){
    c[0] = c[1] = c[2] = c[3] = 0;
    c[h[0]]++;
    for(int i = 1; i < 5; ++i){ scanf("%d", h + i); c[h[i]]++;}

    if(c[1] && c[2] && c[3]) for(int i = 0; i < 5; ++i) puts("3");
    else if(c[1] && c[2]) for(int i = 0; i < 5; ++i) puts(h[i] == 1 ? "1" : "2");
    else if(c[2] && c[3]) for(int i = 0; i < 5; ++i) puts(h[i] == 2 ? "1" : "2");
    else if(c[3] && c[1]) for(int i = 0; i < 5; ++i) puts(h[i] == 3 ? "1" : "2");
    else for(int i = 0; i < 5; ++i) puts("3");
  }
  return 0;
}

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

vector<int> T[100010];
long dp[100010][2];
const int mod=1e9+7;

long dfs(int v, int p, int c)
{
    long& res=dp[v][c];
    if (~res) return res;

    res=1;
    for(int u: T[v]) if (u!=p) {
        if (c==0)
            res*=dfs(u, v, 1);
        else
            res*=(dfs(u, v, 0)+dfs(u, v, 1))%mod;
        res%=mod;
    }
    return res;
}

int main()
{
    int n; cin>>n;
    for(int i=1; i<n; ++i) {
        int x, y; cin>>x>>y;
        T[x].push_back(y);
        T[y].push_back(x);
    }
    memset(dp, -1, sizeof(dp));

    cout<<(dfs(1, -1, 1)+dfs(1, -1, 0))%mod<<endl;
}


Measured memory_bytes: 17024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn max (a: &i64, b:&i64) -> i64{
    if *a < *b {*b} else {*a}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        n: u64,
    }
    let mut result = n / 11 * 2;
    if n % 11 > 6 {
        result += 2;
    }
    else if n % 11 != 0 {
        result += 1;
    }
    print!("{}", result);
}


Measured memory_bytes: 4352
import statistics
import math
n = int(input()) 
s = list(map(int,input().split()))
s.sort()

med_ind = len(s)//2 -1
#print(med_ind)
ans = s[med_ind+1]-s[med_ind]
#print(s[med_ind+1],s[med_ind])
print(ans)


Measured memory_bytes: 16024
N = int(input())
if N <=111:
    print("111")
elif N <=222:
    print("222")
elif N <=333:
    print("333")
elif N <= 444:
    print("444")
elif N <=555:
    print("555")
elif N <=666:
    print("666")
elif N <=777:
    print("777")
elif N <=888:
    print("888")
else:
    print("999")

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

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

    string S;
    cin >> S;

    if(S == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i=0; i<h; i++) {
        cin >> c[i];
    }
    for (int i=0; i<h; i++) {
        cout << c[i] << endl;
        cout << c[i] << endl;
    }
}

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

vector<int> sieve_of_eratosthenes(int n) {
    vector<int> prime(n + 1, 0);
    for (int i = 2; i <= n; ++i) prime[i] = i;
    for (int i = 2; i * i <= n; ++i) {
        if (prime[i]) {
            for (int j = i * i; j <= n; j += i) prime[j] = 0;
        }
    }
    // prime.erase(remove(begin(prime), end(prime), 0), end(prime));
    return prime;
}

int main() {
    auto prime = sieve_of_eratosthenes(1e6);
    for (int n; cin >> n;) {
        int ans = 0;
        for (int i = 0; i <= n; i++) {
            if (prime[i]) ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 6564
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
typedef pair<int,int> P;

int N;
int main(){
    cin >> N;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    if(N==2){
        cout << v[1]-v[0] << endl;
        cout << v[1] << " " << v[0] << endl;
        return 0;
    }
    if(v[0]>=0){
        int sum = 0;
        for(int i=0;i<N;i++){
            if(i==1) sum -= v[i];
            else sum += v[i];
        }
        cout << sum << endl;
        int now = v[1];
        for(int i=1;i<N;i++){
            if(i==0){
                cout << v[0] << " " << v[1] << endl;
                now = v[0]-v[1];
            }else if(i!=N-1){
                cout << now << " " << v[i] << endl;
                now = now-v[i];
            }else{
                cout << v[i] << " " << now << endl;
                now = v[i]-now;
            }
        }
        assert(sum==now);
    }else if(v[N-1]<=0){
        int sum = 0;
        for(int i=0;i<N;i++){
            if(i==N-1) sum += v[i];
            else sum -= v[i];
        }
        cout << sum << endl;
        int now = 0;
        for(int i=N-2;i>=0;i--){
            if(i==N-2){
                cout << v[N-1] << " " << v[N-2] << endl;
                now = v[N-1]-v[N-2];
            }else{
                cout << now << " " << v[i] << endl;
                now = now-v[i];
            }
        }
        assert(sum==now);
    }else{
        int sum = 0,id = -1;
        for(int i=0;i<N;i++){
            if(v[i]<0) sum -= v[i];
            else{
                sum += v[i];
                if(id==-1) id = i;
            }
        }
        cout << sum << endl;
        if(id==N-1){
            int now = v[N-1];
            for(int i=0;i<N-1;i++){
                cout << now << " " << v[i] << endl;
                now = now-v[i];
            }
            assert(sum==now);
        }else{
            int now = v[0];
            for(int i=id;i<N-1;i++){
                cout << now << " " << v[i] << endl;
                now = now-v[i];
            }
            cout << v[N-1] << " " << now << endl;
            now = v[N-1]-now;
            for(int i=1;i<id;i++){
                cout << now << " " << v[i] << endl;
                now = now-v[i];
            }
            assert(sum==now);
        }
    }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = r + max(0, 100*(10 - n));

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


Measured memory_bytes: 256
# from pprint import pprint
import math

# import collections

n = int(input())


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


def f(a, b):
    return max(math.floor(math.log10(a)+1), math.floor(math.log10(b))+1)


a = 1
ans = 11
while a <= math.sqrt(n):
    if n % a == 0 and f(a, n // a) <= ans:
        ans = f(a, n // a)
    a += 1

print(ans)


Measured memory_bytes: 9096
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()

int main(){
	ll n ; 
	cin>>n ; 

    if(n == 2){
    	cout<<1<<"\n" ; 
    	return 0 ; 
    }
	ll ans = (n - 2)*(n + 1) ; 
	ans = ans/2 ; 

	 ans++ ;  
                        
	cout<<ans<<"\n" ;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, T;
  while (cin >> N >> T) {
    int res = -1;
    for (int i = 0; i < N; i++) {
      int c, t;
      cin >> c >> t;
      if (t <= T) {
        if (res == -1 || c < res) {
          res = c;
        }
      }
    }
    if (res == -1) {
      cout << "TLE" << endl;
    } else {
      cout << res << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
use std::cmp::{max, min};

fn solve(src: &str) -> String {
    use std::fmt::Write;
    let mut buf = String::new();
    let mut sc = Scanner::from_str(&src);

    let n : usize = sc.read();
    let m : usize = sc.read();
    let edges: Vec<(usize, usize)> =
        (0..m).map(|_| (sc.read::<usize>()-1, sc.read::<usize>()-1)).collect();
    let child = child(true, n, &edges);
    let cycle = any_cycle(n, &child);
    if cycle == None {
        return "-1".to_string()
    }
    let cycle = cycle.unwrap();

    let mut start = 0;
    let mut end = cycle.len();
    let mut index = vec![None; n];
    for i in 1..cycle.len() {
        let v = cycle[i];
        index[v] = Some(i);
        for &w in child[v].iter() {
            if let Some(j) = index[w] {
                start = max(start, j);
                end = i + 1;
            }
        }
        if start != 0 || end != cycle.len() {
            break
        }
    }

    writeln!(&mut buf, "{}", end-start);
    for i in start..end {
        writeln!(&mut buf, "{}", cycle[i] + 1);
    }

    buf
}

fn child(directed: bool, size: usize, edges: &Vec<(usize,usize)>) -> Vec<Vec<usize>> {
    let mut child = vec![Vec::new(); size];
    for &(v, w) in edges.iter() {
        child[v].push(w);
        if !directed {
            child[w].push(v);
        }
    }
    child
}

fn any_cycle(size: usize, child: &Vec<Vec<usize>>) -> Option<Vec<usize>> {
    let mut path = vec![0; size];
    let mut visited_ever = vec![false; size];
    'search: for s in 0..size {
        let mut visited = vec![false; size];
        let mut stack = vec![s];
        let mut depth = vec![0; size];
        while let Some(v) = stack.pop() {
            path[depth[v]] = v;
            for &w in child[v].iter() {
                if depth[w] < depth[v] && path[depth[w]] == w {
                    let mut path: Vec<_> = path.iter()
                        .skip_while(|&&x| x!=w)
                        .take_while(|&&x| x!=v)
                        .map(|&x| x)
                        .collect();
                    path.push(v);
                    return Some(path)
                }
                if visited_ever[w] { continue; }
                visited[w] = true;
                visited_ever[w] = true;
                depth[w] = depth[v] + 1;
                stack.push(w);
            }
        }
    }
    None
}

fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf);
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes());
}

struct Scanner<I>{
    src: I
}

impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner { src: src.split_whitespace() }
    }
}

impl<'a, I> Scanner<I> where I: std::iter::Iterator<Item = &'a str>{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000001

using namespace std;
#define ll long long
#define dbg if(0)

ll val[40],wei[40],W;

void build(ll bg,ll en,vector< pair<ll,ll> > &t){
    ll m=en-bg;
    for(int i=0; i< (1 << m);i++){
        ll vt=0,wt=0;
        for(int j=0;j<m;j++){
            if( (i>>j) & 1){
                vt+=val[bg+j];
                wt+=wei[bg+j];
            }
        }
        if (wt>W)continue;
        t.push_back( pair<ll,ll>(wt,vt) );
    }
    sort(t.begin(),t.end());
    //無駄な組み合わせを上書きする
    ll vmax=0;
    for(int i=0;i < t.size();i++){
        vmax = max(vmax,t[i].second);
        t[i].second = vmax;
    }
}



int main(){
    ll n;
    cin >> n>> W ;
    vector< pair<ll,ll> > s1,s2;
    for(int i=0;i<n;i++){
        cin >>val[i]>>wei[i];
    }
    dbg cout<<"ghhh"<<endl;
    build(0,n/2,s1);
    dbg cout<<"ghhh"<<endl;
    build(n/2,n,s2);
    dbg cout <<s1.size()<<endl;
    ll ans=0;
    for(auto p1:s1){
        ll w1=p1.first , v1=p1.second , v2;
        v2=(lower_bound(s2.begin(),s2.end(),pair<ll,ll>(W-w1,LLONG_MAX))-1)->second;
        ans=max(ans,v1+v2);
    }

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


Measured memory_bytes: 43752
#include <bits/stdc++.h>
#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 REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    int n,m;
    cin >> n >> m;
    
    int h[n] = {0};
    bool s[n];
    rep(i,n){
        cin >> h[i];
        s[i] = true; 
    }

    int a = 0,b = 0;
    rep(i,m){
        cin >> a >> b;
        if(h[a-1] == h[b-1]){
            s[a-1] = false;
            s[b-1] = false;
        }else if(h[a-1] > h[b-1]){
            s[b-1] = false;
        }else{
            s[a-1] = false;
        }
    }
    
    int ans  = 0;
    rep(i,n){
        if(s[i] == true) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

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

    int N; cin >> N;
    if (N == 0) {
        cout << "0\n";
        return 0;
    }
    string s;
    long long x = 2;
    int y = 1;
    while (N) {
        if (N % x) {
            s.push_back('1');
            N -= y;
        }
        else s.push_back('0');
        x *= 2;
        y *= -2;
    }
    for (int i = s.size()-1; i >= 0; i--) cout << s[i];
    cout << "\n";
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

def sumOfDigits(n):
    total = 0
    while n > 0:
        total += n%10
        n //= 10
    return total

answer = 0
for n in range(1, N+1):
    total = sumOfDigits(n)
    if total >= A and total <= B:
        answer += n
print(answer)


Measured memory_bytes: 2940
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h = gli();
    ll r = 1;
    while (h > 1) {
        h /= 2;
        r *= 2;
        r++;
    }

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b;
bool vis[1000][1000];
int yes[1000][1000];
string s[1000];
bool can(int n,int m){
    if(n<a&&m<b) return true;
    return false;
}
lol dp(int n,int m){
    if(!can(n,m)||s[n][m]=='#') return 0;
    if(vis[n][m]) return yes[n][m];
    if(n==a-1&&m==b-1) return 1;
    vis[n][m]=true;
    return yes[n][m]=(dp(n+1,m)+dp(n,m+1))%inf;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol c=1,d=1,e=0,f=0,g=0,h=0;
  cin >>a>>b;
  for(int n=0;n<a;n++) cin >>s[n];
  cout <<dp(0,0)%inf<<'\n';
  return (0);
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define lowbit(i) ((i)&(-i))
#define ls (p << 1)
#define rs (p << 1 | 1)
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MAXN = 5 * 1e5 + 15;
const ll M = 1e9 + 7;
ll F[MAXN + 15], Finv[MAXN + 15], inv[MAXN + 15], D[MAXN + 15]; 
void init() {
    D[1] = 0; D[2] = 1;
    for(int i = 3; i <= MAXN; i++) {
        D[i] = 1ll * (i - 1) * ((D[i - 1] + D[i - 2]) % M) % M;
    }
    inv[1] = 1;
    for(int i = 2; i <= MAXN; i++) {
        inv[i] = (M - M / i) * 1ll * inv[M % i] % M;
    }
    F[0] = Finv[0] = 1;
    for(int i = 1; i <= MAXN; i++) {
        F[i] = F[i - 1] * 1ll * i % M;
        Finv[i] = Finv[i - 1] * 1ll * inv[i] % M;
    }
}
ll comb(int n, int m) {
	if(m < 0 || m > n) return 0;
    else return F[n] * 1ll * Finv[n - m] % M * Finv[m] % M;
} 
int main() {
#ifdef CitricAcid
    freopen ("input.txt", "rt", stdin);
#endif

    init();
    ll n, m;
    scanf("%lld %lld", &n, &m);

    ll res = comb(m, n) * F[n] % M;
    for(int i = 1; i <= n; i++) {
        if(i & 1) {
            res = res - (comb(n, i) * comb(m - i, n - i) % M * F[n - i] % M);
        }
        else {
            res = res + (comb(n, i) * comb(m - i, n - i) % M * F[n - i] % M);
        }
        res %= M;
    }
    res = (res + M) % M;
    printf("%lld\n", comb(m, n) * F[n] % M * res % M);


#ifdef CitricAcid
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
/*
# author : CitricAcid
# date : 2020/07/27
*/

Measured memory_bytes: 19388
N,X,M=map(int,input().split())
a=[0]*(M)
A=X%M
a[A]=1
ans=A
Ans=[A]
flag=0
for i in range(N-1):
    A=A*A%M
    if A==0:
        break
    if a[A]==1:
        flag=1
        break
    a[A]=1
    ans+=A
    Ans.append(A)
if flag==1:
    for num in range(len(Ans)):
        if A==Ans[num]:
            break
    n=len(Ans)-num
    b=sum(Ans[:num])
    x=(N-num)//n
    y=(N-num)%n
    Sum=b+(ans-b)*(x)+sum(Ans[num:y+num])
else:
    Sum=sum(Ans)
print(Sum)

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

int n, c ;
int d[33][33] ;
int g[505][505] ;

void getInput(){
    cin >> n >> c ;

    for(int i = 1 ; i <= c ; i++){
        for(int j = 1 ; j <= c ; j++){
            cin >> d[i][j] ;
        }
    }

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

int main(){

    getInput() ;

    vector<pair<int, int> > points[3] ;

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n; j++){
            points[(i + j) % 3].push_back({i, j}) ;
        }
    }
///////////////////////////////////////////////////////////////
    vector<pair<int, int> > best3[3] ;

    for(int i = 0 ; i < 3 ; i++){
        vector<pair<int, int> > costs ; // cost, color

        for(int j = 1 ; j <= c ; j++){ // color select
            int cost = 0 ;
            for(auto p : points[i]){
                cost += d[g[p.first][p.second]][j] ;/////////
            }
            costs.push_back({cost, j}) ;
        }

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

        best3[i].push_back(costs[0]) ;
        best3[i].push_back(costs[1]) ;
        best3[i].push_back(costs[2]) ;
    }

    int ans = INT_MAX ;

    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            for(int k = 0 ; k < 3 ; k++){
                if(best3[0][i].second != best3[1][j].second && best3[1][j].second != best3[2][k].second && best3[2][k].second != best3[0][i].second)
                    ans = min(best3[0][i].first + best3[1][j].first + best3[2][k].first, ans) ;
            }
        }
    }

    cout << ans << endl ;

    return 0 ;
}


Measured memory_bytes: 3504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp107 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int cnt_gray = 0;
            int cnt_brown = 0;
            int cnt_green = 0;
            int cnt_skyblue = 0;
            int cnt_blue = 0;
            int cnt_yellow = 0;
            int cnt_orange = 0;
            int cnt_red = 0;
            int cnt_other = 0;

            for (int i = 0; i < N; i++) {
                if (a[i] < 400) {
                    cnt_gray++;
                } else if (a[i] < 800) {
                    cnt_brown++;
                } else if (a[i] < 1200) {
                    cnt_green++;
                } else if (a[i] < 1600) {
                    cnt_skyblue++;
                } else if (a[i] < 2000) {
                    cnt_blue++;
                } else if (a[i] < 2400) {
                    cnt_yellow++;
                } else if (a[i] < 2800) {
                    cnt_orange++;
                } else if (a[i] < 3200) {
                    cnt_red++;
                } else {
                    cnt_other++;
                }
            }

            var color_list = new List<int> { cnt_gray, cnt_brown, cnt_green, cnt_skyblue, cnt_blue, cnt_yellow, cnt_orange, cnt_red };

            int color_num = color_list.Where(x => x != 0).Count();

            Console.WriteLine(Math.Max(color_num, 1) + " " + (color_num + cnt_other));
        }
    }
}


Measured memory_bytes: 13396
s = input()
q = int(input())
for _ in range(q):
    c = input().split()
    if c[0] == 'replace':
        s = s[:int(c[1])] + c[3] + s[int(c[2])+1:]
    elif c[0] == 'reverse':
        s = s[:int(c[1])] + s[int(c[1]):int(c[2])+1][::-1] + s[int(c[2])+1:]
    else:
        print(s[int(c[1]):int(c[2])+1])


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n, k; cin >> n >> k;
  vector<pair<int, long long>> v(n);
  long long sum = 0;
  int index;
  for(int i = 0; i < n; ++i){
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; ++i){
    sum += v[i].second;
    if(sum >= k){
      index = i;
      break;
    }
  }
  cout << v[index].first << endl; 
}

Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int N;
int a[100010];

int main(){
    cin>>N;
    int minAbs=1000000001;
    int mC=0;
    LL ans=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        minAbs=min(minAbs,abs(a[i]));
        ans+=abs(a[i]);
        if(a[i]<0){
            mC++;
        }
    }
    if(mC%2==1){
        ans-=minAbs*2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640