akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    ll l, r;
    cin >> l >> r;

    if(r - l + 1 >= 2019){
        cout << 0 << endl;
    }
    else{
        ll minx = 10000;

        for(ll i = l;i<=r-1;i++){
            for(ll j = i+1;j<=r;j++){
                minx = min(minx, i * j % 2019);

            }
        }
        cout << minx << endl;
    }

    return 0;
}

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

using namespace std;

#define ll long long

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	ll r = 0, g = 0, b = 0;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') {
			r++;
		} else if (S[i] == 'G') {
			g++;
		} else if (S[i] == 'B') {
			b++;
		}
	}

	ll ans = r * g * b;

	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			int k = j + (j - i);
			if (k >= N) {
				continue;
			}
			if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
				ans--;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int a , b;
    cin>>a>>b;
    if(a > b) cout<<"safe\n";
    else cout<<"unsafe\n";
    return 0;
    
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<complex>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second

char s[10000];
int x,y;
vector<int> a,b;

int main(){
	cin >> s;
	cin >> x >> y;

	bool f = true;
	int cou = 0;
	REP(i,strlen(s)) {
		if(s[i] == 'F') {
			cou++;
		}else {
			if(f) {
				a.pb(cou);
			}else{
				b.pb(cou);
			}
			cou = 0;
			f = !f;
		}
	}
	if(f)
		a.pb(cou);
	else
		b.pb(cou);

	bool ans1;
	if(a.size() > 0) {
		int d = 0;
		for(auto v : a) 
			d += v;

		x += d;

		bool dp[a.size()][d * 2 + 1];

		REP(i,d * 2 + 1) {
			dp[0][i] = (i == d + a[0]);
		}

		FOR(i,1,a.size()) {
			REP(j,d * 2 + 1) {
				bool f1 = false;
				bool f2 = false;

				if(j + a[i] < d * 2 + 1) {
					f1 = dp[i - 1][j + a[i]];
				}
				if(j - a[i] >= 0) {
					f2 = dp[i - 1][j - a[i]];
				} 
				dp[i][j] = (f1 || f2);
			}
		}
		if(x < 0 || x  > d * 2) {
			ans1 = false;
		}else {
			ans1 = dp[a.size() - 1][x];
		}
	}else{
		ans1 = (x == 0);
	}

	bool ans2;

	if(b.size() > 0) {
		int d = 0;
		for(auto v : b) {
			d += v;
		}

		y += d;

		bool dp[b.size() + 1][d * 2 + 1];

		REP(i,d * 2 + 1) {
			dp[0][i] = (i == d);
		}

		FOR(i,1,b.size() + 1) {
			REP(j,d * 2 + 1) {
				bool f1 = false;
				bool f2 = false;

				if(j + b[i - 1] < d * 2 + 1) {
					f1 = dp[i - 1][j + b[i - 1]];
				}
				if(j - b[i - 1] >= 0) {
					f2 = dp[i - 1][j - b[i - 1]];
				}
				dp[i][j] = (f1 || f2);
			}
		}
		if(y < 0 || y > d * 2) {
			ans2 = false;
		}else
			ans2 = dp[b.size()][y];
	}else{
		ans2 = (y == 0);
	}

	if(ans1 && ans2) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 15872
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int b[][6],int xb,int xe,int y,int m,int c){
  int i,j;
  for(i=xb;i<xe;i=j){
    for(;i<xe&&b[i][y]==0;i++);
    for(j=i;j<xe&&b[j][y];j++);
    if((j-i)*c>m)
      m=(j-i)*c;
    m=f(b,i,j,y+1,m,c+1);
  }
  return m;
}
int main(){
  int i,j,k;
  int b[6][6],m,n;
  memset(b,0,sizeof(b));
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;j<5;j++)
      for(k=0;k<5;k++)
	cin>>b[k][j];
    m=0;
    for(j=0;j<5;j++)
      m=f(b,0,5,j,m,1);
    cout<<m<<endl;
  }
  return 0;
}

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

int main() {
	ll n; cin >> n;
	string x; cin >> x;
	vector<ll>a(n,0);
	for (ll i = 1; i < n; i++) {
		ll pc = __builtin_popcountll(i);
		a.at(i) = a.at(i % pc) + 1;
	}
	ll npc = 0;
	for (ll i = 0; i < n; i++) {
		if (x.at(i) == '1')npc++;
	}
	vector<ll>modlow(n,0);
	vector<ll>modhigh(n,0);
	for (ll i = n - 1; i >= 0; i--) {
		if (i == n - 1) {
			modlow.at(i) = 1;
			modhigh.at(i) = 1;
		}
		else {
			if (npc != 1) modlow.at(i) = (modlow.at(i + 1) * 2) % (npc - 1);
			else modlow.at(i) = 0;
			modhigh.at(i) = (modhigh.at(i + 1) * 2) % (npc + 1);
		}
	}
	ll lowm = 0;
	ll highm = 0;
	for (ll i = 0; i < n; i++) {
		if (x.at(i) == '1') {
			lowm += modlow.at(i);
			highm += modhigh.at(i);
		}
	}
	if (npc != 1)lowm %= (npc - 1);
	highm %= (npc + 1);
	for (ll i = 0; i < n; i++) {
		if (x.at(i) == '1') {
			ll lx = lowm - modlow.at(i);
			if (npc != 1) lx %= (npc - 1);
			else {
				cout << 0 << endl;
				continue;
			}
			if (lx < 0)lx += npc - 1;
			cout << a.at(lx)+1 << endl;
		}
		else {
			ll hx = highm + modhigh.at(i);
			hx %= npc + 1;
			if (hx < 0)hx += npc + 1;
			cout << a.at(hx)+1 << endl;
		}
	}
}

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

ll fact(ll a, ll mod) {
  ll ret = 1;
  for (ll i = 1; i <= a; ++i) {ret *= i; ret %= mod;}
  return ret;
}

int main() {
  ll n,m; cin >> n >> m;
  ll mod = 1000000000+7;
  if (abs(n-m) > 1) cout << 0 << endl;
  else {
    ll ans = 0;
  	if (n==m) ans = 2*fact(n,mod)*fact(n,mod);
    else ans = fact(n,mod)*fact(m,mod);
    cout << ans%mod << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main(){
	int x;
	cin >> x;

	for(int i = 2; i < 10; i++){
		if(x >= 200 * i && x < 200 * (i+1)){
			cout << 8 - (i - 2) << "\n";
		}
	}
}


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

int N, X, Y;
int A[2010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> X >> Y;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  if (N == 1) {
    cout << abs(A[0] - Y) << endl;
    return 0;
  }
  cout << max(abs(A[N-1] - Y), abs(A[N-1] - A[N-2])) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n;
ll a[120000];
ll b[120000];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lld%lld", a + i, b + i);
	ll now = 0;
	for (int i = n - 1; i >= 0; --i) {
		a[i] += now;
		ll k = (a[i] + b[i] - 1) / b[i];
		now += k * b[i] - a[i];
	}
	cout << now << "\n";
	return 0;
}




Measured memory_bytes: 1792
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
typedef pair<int, int> pii;

int N, K;

void solve() {
	cin >> N >> K;
	if (K > (N - 1) * (N - 2) / 2) {
		cout << -1 << endl;
		return;
	}
	K = (N - 1) * (N - 2) / 2 - K;
	cout << (N - 1) + K << endl;
	for (int i = 2; i <= N; i++)cout << "1 " << i << endl;
	for (int i = 2; i <= N && K > 0; i++) {
		for (int j = i+1; j <= N && K > 0; j++) {
			cout << i << " " << j << endl;
			K--;
		}
	}
	int a = 1;
	return;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int n, tmp; sc(n);
    ll ans = 0;
    vector<int> l(n);
    rep(i, 0, n) sc(l[i]);
    sort(l.begin(), l.end());
    for (auto x = l.begin(); x != l.end()-1; x++){
        for (auto y = x+1; y != l.end(); y++){
            auto it = lower_bound(y, l.end(), *x+*y)-1;
            tmp = it-y;
            ans += max(0, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# encoding: utf-8
import sys

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

### TLE test in NlogN ###

# num of Ai each Bi can lift
capacity_B = [0] * N
idx_A = 0
idx_B = 0
for i in range(2 * N):
    if idx_B == N: break
    elif idx_A == N:
        for i in range(idx_B, N): capacity_B[i] = N
        break # oh...
    elif A[idx_A] >= B[idx_B]:
        capacity_B[idx_B] = idx_A
        idx_B += 1
    else:
        idx_A += 1
        
# print("#", capacity_B)

# num of Bi each Ci can lift
capacity_C = [0] * N
idx_B = 0
idx_C = 0
for i in range(2 * N):
    if idx_C == N: break
    elif idx_B == N:
        for i in range(idx_C, N): capacity_C[i] = N
        break # oh...
    elif B[idx_B] >= C[idx_C]:
        capacity_C[idx_C] = idx_B
        idx_C += 1
    else:
        idx_B += 1

# print("#", capacity_C)

# sum of [num of (Ai, Bi) each Ci can lift]
ans = 0
idx_AB = 0
idx_BC = 0
sum_tmp = 0
for i in range(2 * N):
    if idx_BC == N: break
    elif idx_AB == N:
        for i in range(idx_BC, N): ans += sum_tmp
        break # oh...
    elif idx_AB >= capacity_C[idx_BC]:
        ans += sum_tmp
        idx_BC += 1
    else:
        sum_tmp += capacity_B[idx_AB]
        idx_AB += 1

# print("#", stacked)

print(ans)

Measured memory_bytes: 23232
import java.math.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    BigInteger a = new BigInteger(sc.next());
    BigInteger b = new BigInteger(sc.next());
    BigInteger c = new BigInteger(sc.next());
    BigInteger d = new BigInteger(sc.next());
    BigInteger r1 = a.multiply(c);
    BigInteger r2 = a.multiply(d);
    BigInteger r3 = b.multiply(c);
    BigInteger r4 = b.multiply(d);
    BigInteger result = r1.max(r2).max(r3).max(r4);
    System.out.println((a.compareTo(BigInteger.ZERO) <= 0 && b.compareTo(BigInteger.ZERO) >= 0) || (c.compareTo(BigInteger.ZERO) <= 0 && d.compareTo(BigInteger.ZERO) >= 0) ? result.max(BigInteger.ZERO) : result);
  }
}


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

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

    vector<ll> yakusu(N+1, 1);
    ll ans = 1;
    for(int i=2; i<=N; i++)
    {
        for(int j=i; j<=N; j+=i)
        {
            yakusu[j]++;
        }
        ans += i * yakusu[i];
    }
    cout << ans << endl;

    return 0;
}


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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);
    sort(a.begin(), a.end());

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (x - a.at(i) >= 0) {
            if (i+1 == n && x != a.at(i)) break;
            x -= a.at(i);
            cnt++;
        } else {
            break;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

#define lli long long int
#define ld long double
#define DEFO(n) lli n = 0;
#define MAX(n) lli n = 9000000000000000000;
#define MIN(n) lli n = -9000000000000000000;
#define MAX_D(n) ld n = 4500;
#define MIN_D(n) ld n = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n) \
  ld n;       \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LLIV2(a, b, n)         \
  vector<lli> a(n), b(n);      \
  for (lli i = 0; i < n; i++)  \
  {                            \
    cin >> a.at(i) >> b.at(i); \
  };
#define LLIV3(a, b, c, n)                 \
  vector<lli> a(n), b(n), c(n);           \
  for (lli i = 0; i < n; i++)             \
  {                                       \
    cin >> a.at(i) >> b.at(i) >> c.at(i); \
  };
#define LDV(a, n)             \
  vector<ld> a(n);            \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define STRV(a, n)            \
  vector<string> a(n);        \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define SUM(n) accumulate(n.begin(), n.end(), 0);
#define SORT(n) sort(n.begin(), n.end());
#define REVE(n) reverse(n.begin(), n.end());
#define yes              \
  cout << "Yes" << endl; \
  return 0;
#define no              \
  cout << "No" << endl; \
  return 0;
#define none              \
  cout << "None" << endl; \
  return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(lli n)
{
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(n)LLI(k)LLI(x)LLI(y)
  DEFO(sum)
  for(lli i = 1;i <= n;i++) {
    if(i <= k) sum += x;
    else sum += y;
  }
  OUT(sum)
}


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

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

    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    
    int ans = 0;
    
    rep(i, n){
        if(a[a[i] - 1] == i+1) ans++;
    }
    
    cout << ans/2 << endl;

    return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (r1, c1, r2, c2) = readLine()!!.split(" ").map(String::toInt)
    val combi = Combination(2000002)
    val ans = combi(r2 + c2 + 2, c2 + 1) - combi(r2 + c1 + 1, c1) - combi(r1 + c2 + 1, c2 + 1) + combi(r1 + c1, c1)
    println(ans)
}

class MInt {
    private val MOD = 1000000007L
    var v: Long

    constructor(v: Long) {
        this.v = v % MOD
    }

    constructor(v: Int) {
        this.v = v.toLong() % MOD
    }

    operator fun plus(b: MInt): MInt {
        val a = MInt(v)
        a += b
        return a
    }

    operator fun minus(b: MInt): MInt {
        val a = MInt(v)
        a -= b
        return a
    }

    operator fun times(b: MInt): MInt {
        val a = MInt(v)
        a *= b
        return a
    }

    operator fun div(b: MInt): MInt {
        val a = MInt(v)
        a /= b
        return a
    }

    operator fun plusAssign(b: MInt) {
        v += b.v
        if (v >= MOD) v -= MOD
    }

    operator fun minusAssign(b: MInt) {
        v -= b.v
        if (v < 0) v += MOD
    }

    operator fun timesAssign(b: MInt) {
        v *= b.v
        v %= MOD
    }

    operator fun divAssign(b: MInt) {
        this *= b.inv()
    }

    fun inv(): MInt {
        var a = v
        var b = MOD
        var u = 1L
        var w = 0L
        while (b != 0L) {
            val t = a / b
            a -= t * b
            u -= t * w
            var tmp = a
            a = b
            b = tmp
            tmp = u
            u = w
            w = tmp
        }
        u %= MOD
        if (u < 0) u += MOD
        return MInt(u)
    }

    fun pow(n: Int): MInt {
        var a = MInt(1)
        for (i in 1..n) a = a * this
        return a
    }

    override fun toString(): String {
        return v.toString()
    }
}

class Combination(n: Int) {
    private val fact = arrayOfNulls<MInt>(n + 1)
    private val ifact = arrayOfNulls<MInt>(n + 1)

    init {
        fact[0] = MInt(1)
        (1..n).forEach { i -> fact[i] = fact[i - 1]!! * MInt(i) }
        ifact[n] = fact[n]!!.inv()
        (n downTo 1).forEach { i -> ifact[i - 1] = ifact[i]!! * MInt(i) }
    }

    operator fun invoke(n: Int, k: Int): MInt {
        if (k < 0 || n < k) return MInt(0)
        return (fact[n]!! * ifact[k]!! * ifact[n - k]!!)
    }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll sum,a;
  while(cin >> sum && sum){
    rep(i,9){
      cin >> a;
      sum -= a;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  rep(i,3)cin >> a[i];
  sort(a,a+3);
  cout << (a[0]*a[1])/2 << endl;
  return 0;
}

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

const int mod = 1000000000 + 7;
const int N = 1000;

int dp[N][N];

int solve(int x, int y, int m, int n, char a[][1000]) {
	if (x == m - 1 && y == n - 1)return dp[x][y] = 1;
	if (a[x][y] == '#')return dp[x][y] = 0;

	if (dp[x][y] != -1)return dp[x][y];

	// middle
	if (x < m - 1 && y < n - 1) {
		if (dp[x][y + 1] == -1)solve(x, y + 1, m, n, a);
		if (dp[x + 1][y] == -1)solve(x + 1, y, m, n, a);

		dp[x][y] = (dp[x + 1][y] + dp[x][y + 1]) % mod;
	}
	// bottom
	else if (x == m - 1 && y < n - 1) {
		if (dp[x][y + 1] == -1)solve(x, y + 1, m, n, a);
		dp[x][y] = dp[x][y + 1];
	}
	else {
		if (dp[x + 1][y] == -1)solve(x + 1, y, m, n, a);
		dp[x][y] = dp[x + 1][y];
	}

	return dp[x][y];

}

int32_t main() {
	int m, n;
	cin >> m >> n;
	int i, j;

	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			dp[i][j] = -1;
		}
	}


	char a[m][1000];
	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	int ans = solve(0, 0, m, n, a);
	cout << ans << endl;

}

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

int main(){
  
  int n,m;
  cin >> n >> m;
  
  priority_queue<int> prices;
  
  for(int i=0; i<n; i++){
    int price;
    cin >> price;
    prices.push(price);
  }
  
  for(int i=0; i<m; i++){
    int a = prices.top() / 2;
    prices.pop();
    prices.push(a);
  }
  
  long answer = 0;
  while(!prices.empty()){
    answer += prices.top();
    prices.pop();
  }
  
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    for(int i=0;i<=1000;i++){
        if(i*8/100==a&&i*10/100==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
from decimal import *
i = list(map(int, input().split()))

a = int(i[0])
b = int(i[1])
c = int(i[2])

a1 = Decimal(a).sqrt()
b1 = Decimal(b).sqrt()
c1 = Decimal(c).sqrt()

if a1 + b1 < c1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5076
K=gets.to_i

MEMO={}
COUNT={}
L_MAX={}
def count(k, n)
    return 1 if k == 0
    key = "#{k}_#{n}"
    return COUNT[key] if COUNT[key]

    ret = 0
    ret += count(k-1, n+1) if n != 9
    ret += count(k-1, n)
    ret += count(k-1, n-1) if n != 0
    COUNT[key] = ret
    return ret
end

def lunlun_max(k,n)
    return n if k == 0
    key = "#{k}_#{n}"
    return L_MAX[key] if L_MAX[key]

    base = n*10**k
    ret = nil
    if n == 9
        ret = base + lunlun_max(k-1,9)
    else
        ret = base + lunlun_max(k-1,n+1)
    end
    L_MAX[k] = ret
    return ret
end

MEMO[0] = 0
max_i = 0
max_pre_i = 0
break_flg = false
k=0
loop do
    (1..9).each do |i|
        c = count(k,i)
        max_i = lunlun_max(k,i)
        ret = MEMO[max_pre_i] + count(k,i)
        MEMO[max_i] = ret
        max_pre_i = max_i

        if ret >= K
            break_flg = true
            break
        end
    end
    break if break_flg
    k+=1
end

sup = max_i
inf = max_pre_i
rets = Array.new(k+1, nil)
rets[k] = max_i.to_s[0].to_i
k -= 1
memo = MEMO[sup]
loop do
    break if k < 0
    if rets[k+1] != 9
        c = count(k, rets[k+1]+1)
        if memo -c < K
            rets[k] = rets[k+1]+1
            k-=1
            next
        end
        memo -= c
    end

    c = count(k, rets[k+1])
    if memo -c < K
        rets[k] = rets[k+1]
        k-=1
        next
    end
    memo -= c

    c = count(k, rets[k+1])
    if rets[k+1] != 0
        c = count(k, rets[k+1]-1)
        rets[k] = rets[k+1]-1
        k-=1
        next
    end
end

ret = 0
rets.reverse.each do |i|
    ret *= 10
    ret += i
end
puts ret


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,ans,a,b,ab;
string s[10000];

signed main() {
    cin >> n;
    rep(i,n) {
        int hoge=0;
        cin >> s[i];
        if (s[i][0] == 'B') a++,hoge++;
        if (s[i][s[i].size()-1] == 'A') b++,hoge++;
        if (hoge == 2) ab++,a--,b--;
        rep11(j,s[i].size()) if (s[i][j-1] == 'A' && s[i][j] == 'B') ans++;
    }
    if (ab) {
        if (a&&b) ans += ab+1,a--,b--;
        else if (a) ans += ab,a--;
        else if (b) ans += ab,b--;
        else ans += ab-1;
    }
    ans += min(n-1,min(a,b));
    cout << ans << endl;
}












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

void _130() {
    int n, x;
    int l[100];
    cin >> n >> x;
    for (int i = 0; i < n; ++i) { 
        cin >> l[i];
    }

    int d = 0;
    for (int i = 0; i < n; ++i) {
        d = d + l[i];
        // cout << d << endl;
        if (d > x) {
            cout << i + 1 << endl;
            return;
        }
    }
    cout << n + 1 << endl;
}

void _131() {
    int n, l;
    cin >> n >> l;

    int sum = (l - 1) * n + (1 + n) * n / 2;
    // cout << sum << endl;

    int taste = 0;
    int min_taste = 100;
    for (int i = 0; i < n; ++i) {
        taste = l + (i + 1) - 1;
        // cout << "taste" << taste << endl;
        if (abs(taste) < abs(min_taste))
            min_taste = taste;
        // cout << min_taste << endl;
    }
    cout << sum - min_taste << endl;
}

void _132() {
    int n;
    cin >> n;
    int p[20];
    for (int i = 0; i < n; ++i) 
        cin >> p[i];

    int count = 0;
    int second_value = 0;
    for (int i = 0; i < n - 2; ++i) {
        if ((p[i] < p[i + 1]) && (p[i + 1] < p[i + 2])){
            // cout << "1:" << p[i] << " " << p[i + 1] << " " << p[i + 2] << endl;
            count++;
        }
        else if ((p[i] > p[i + 1]) && (p[i + 1] > p[i + 2])){
            // cout << "2:" << p[i] << " " << p[i + 1] << " " << p[i + 2] << endl;
            count++;
        }
    }
    cout << count << endl;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i, n) for (int i = 0; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
	string S;
	cin >> S;
	int s = S.size()-1;
	int ans=0;
	rep(i,S.size()/2){
		if(S[i] != S[s-i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int N, K;
	int i, j;
	
	scanf("%d %d",&N,&K);
	
	int I[N];
	
	for(i = 0; i < N; i++) {
		scanf("%d",&I[i]);
	}
	
	for(i = 0; i < N-1; i++) {
		for (j = N-1; j > i; j--) {
			if(I[i] > I[j]) {
				int tmp = I[i];
				I[i] = I[j];
				I[j] = tmp;
			}
		}
	}
	
/*	for(i = 0; i < N; i++) {
		printf("%d ",I[i]);
	}
*/	
	int sum = 0;
	for(i = N-1; i > N-1-K; i--) {
		sum = sum + I[i];
	}
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n;
arr<int> G;
vector<bool> seen;
arr<ll> dp;

void dfs(int s, int p){
    // pr(s);
    seen[s] = true;
    if(p != -1 && G[s].size()==1){
        dp[s][0] = 1;
        dp[s][1] = 1;
    }else{
        for(int i: G[s]){
            if(seen[i]) continue;
            dfs(i, s);
        }

        ll white = 1, black = 1;
        for(int i: G[s]){
            if(i==p) continue;
            // 0は黒
            white *= (dp[i][0] + dp[i][1]);
            white %= MOD;
            black *= (dp[i][1]);
            black %= MOD;
        }

        dp[s][0] = black;
        dp[s][1] = white;
    }
    // prarr(dp);
}

int main()
{
    cin >> n;
    G.resize(n);
    rep(i, n-1){
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dp.assign(n, vector<ll>(2, 1));
    seen.assign(n, false);
    dfs(0, -1);
    
    pr((dp[0][0] + dp[0][1])%MOD);
    return 0;}

Measured memory_bytes: 19656
s = int(input())

a = s // 100
b = s % 100

if 1 <= a <= 12:
    if 1 <= b <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= b <= 12:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  vector<int> A(1e5+1,0);
  for(int i=0; i<N; i++){
    int a;
    cin >>a;
    if(a>0) A[a-1]++;
    A[a]++;
    A[a+1]++;
  }
  int ans=0;
  for(int i=0; i<=1e5; i++){
    ans=max(ans,A[i]);
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 640
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

//const int N = 100 +5;

void Mo35(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
Mo35();

    string s; cin>> s;
    int sz = s.size();
    if(sz < 2) return cout<< "-1 -1", 0;
    for(int i=0; i<sz; ++i){
        if(i<sz-1 && s[i] == s[i+1]) return cout<< i+1<< " "<< i+2, 0;
        if(i<sz-2 && s[i] == s[i+2]) return cout<< i+1<< " "<< i+3, 0;
    }
    cout<< "-1 -1";

return 0;
}

Measured memory_bytes: 3788
N,Y = map(int,input().split())
ans = [-1,-1,-1]
flg = False
for a in range(N+1) :
    if flg :
        break
    for b in range(N+1-a) :
        c = N-a-b
        if c < 0 :
            break
        calc = 10000*a + 5000*b + 1000*c
        if calc == Y :
            ans = [a,b,c]
            flg = True
            break
print(*ans)


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

const int mod = 1000000007;
struct mint {  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(2000005);




int main(){
    ll k,kk=1;
    ll n;
    cin >> n >> k;
    mint ans;
    ans=c(2*n-1,n); 
    if(k>=(n-1)){
        cout << ans << endl;
    }
    else{
        while(k!=(n-1)){
            ++k;
            ans-=c(n,kk)*c(n-1,kk-1);
            //ans=(ans%(1000000007));
            ++kk;
        }
        
        cout << ans << endl;
    }

    

    return 0;
}

Measured memory_bytes: 34160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
ll p[100005];
int main(){
    int n;
    ll m;
    scanf("%d%lld",&n,&m);
    p[0] = 0;
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for (int i = 0; i < n; i++){
        p[i+1] = p[i] + a[i];
    }
    int lo = 0, hi = 2e5+1;
    ll ans = 0;
    while (lo + 1 < hi){
        int mid = (lo+hi)/2;
        ll numtaken = 0;
        ll sum = 0;
        for (int i = 0; i < n; i++){
            int k = a+n-lower_bound(a,a+n,mid-a[i]);
            numtaken += k;
            sum += p[n]-p[n-k]+(ll)k*a[i];
        }
        //printf("%lld %lld %lld %lld %lld\n",lo,hi,mid,numtaken,sum);
        if (numtaken >= m){
            lo = mid;
        }
        else hi = mid;
    }
    if (lo+1 == hi){
        ll numtaken = 0;
        ll sum = 0;
        for (int i = 0; i < n; i++){
            int k = a+n-lower_bound(a,a+n,hi-a[i]);
            numtaken += k;
            sum += p[n]-p[n-k]+(ll)k*a[i];
        }
        //printf("%lld %lld %lld %lld %lld\n",lo,hi,mid,numtaken,sum);
        if (numtaken >= m){
            lo = hi;
        }
        else hi = lo;
    }
    ll numtaken = 0;
    ll sum = 0;
    for (int i = 0; i < n; i++){
        int k = a+n-lower_bound(a,a+n,lo-a[i]);
        numtaken += k;
        sum += p[n]-p[n-k]+(ll)k*a[i];
    }
    //printf("%lld %lld %lld %lld %lld\n",lo,numtaken,sum);
    ans = sum-(numtaken-m)*lo;
    printf("%lld",ans);
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        }
    }
    
    private static void solve(String s, int m) {
        int c = 0;
        int l = s.length();
        for (int i = 0;i < m;i++) c += sc.nextInt();
        c %= l;
        if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        }
    }
}



Measured memory_bytes: 26252
import sys
import math
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

N = int(ns())

a1 = na()
a2 = na()

res=0
ans=0
for i in range(N):
    res=sum(a1[:i+1])
    res+=sum(a2[i:])
    ans = max(ans,res)
print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())
nums = {}
for i in range(1, M+1):
    nums[i] = 0

for i in range(N):
    scan = input().split()
    for x in range(1, len(scan)):
        nums[int(scan[x])] += 1

ans = 0
for i in nums:
    if nums[i] == N:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false)
#define ll long long
#define nl "\n"
#define PI 3.14159265358979323846
#define sz 1000005
#define mod 1000000007
#define toint(a) atoll(a.c_str())
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
ll power(ll a,ll b){return b==0?:a*power(a,b-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return a*(b/gcd(a,b));}

int main()
{
    BeatMeScanf;
    int n;
    cin>>n;
    ll ans=1;

    for(int i=1;i<=3;i++){
        ans=(n*n*n);
    }
    cout<<ans;
    return 0;
}


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

const int mod = 1e9 + 7;
const int MN = 3010;

int N, Q;
int A[MN], X[MN], Y[MN], prec[MN][MN], po[MN];
vector<int> V[MN];

int cc[MN][MN][2][2];
int dp(int q, int a, int x, int t) {
    int &ret = cc[q][a][x][t];
    if(ret != -1) return ret;

    ret = 0;
    int b = x? X[q] : Y[q];
    if(t) swap(a, b);

    int pa = prec[a][q];
    int pb = prec[b][q];
    if(V[a][pa] == Q && V[b][pb] == Q) {
        ret += 1LL * po[Q - q - 1] * (a < b) % mod;
    }
    else if(V[a][pa] < V[b][pb]) {
        int nq = V[a][pa];
        ret += 1LL * po[nq - q - 1] * dp(nq, b, X[nq] == a, 1) % mod;
    }
    else {
        int nq = V[b][pb];
        ret += 1LL * po[nq - q - 1] * dp(nq, a, X[nq] == b, 0) % mod;
    }

    a = a == X[q]? Y[q] : (a == Y[q]? X[q] : a);
    b = b == X[q]? Y[q] : (b == Y[q]? X[q] : b);

    pa = prec[a][q];
    pb = prec[b][q];
    if(V[a][pa] == Q && V[b][pb] == Q) {
        ret += 1LL * po[Q - q - 1] * (a < b) % mod;
    }
    else if(V[a][pa] < V[b][pb]) {
        int nq = V[a][pa];
        ret += 1LL * po[nq - q - 1] * dp(nq, b, X[nq] == a, 1) % mod;
    }
    else {
        int nq = V[b][pb];
        ret += 1LL * po[nq - q - 1] * dp(nq, a, X[nq] == b, 0) % mod;
    }
    return ret %= mod;
}

int main() {
    po[0] = 1;
    for(int i = 1; i < MN; i++) {
        po[i] = 1LL * po[i - 1] * 2 % mod;
    }

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

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

    for(int i = 0; i < Q; i++) {
        scanf("%d %d", &X[i], &Y[i]);
        X[i]--; Y[i]--;

        V[ X[i] ].push_back(i);
        V[ Y[i] ].push_back(i);
    }
    for(int i = 0; i < N; i++) {
        V[i].push_back(Q);
    }

    for(int i = 0; i < N; i++) {
        int pos = 0;
        for(int j = 0; j < Q; j++) {
            if(pos < V[i].size() && V[i][pos] <= j) pos++;
            prec[i][j] = pos;
        }
    }

    memset(cc, -1, sizeof(cc));

    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(A[j] < A[i]) {
                if(V[i][0] == Q && V[j][0] == Q) {
                    ans += 1LL * po[Q] * (i < j) % mod;
                    ans %= mod;
                    continue;
                }
                if(V[i][0] < V[j][0]) {
                    int q = V[i][0];
                    ans += 1LL * po[q] * dp(q, j, X[q] == i, 1) % mod;
                    ans %= mod;
                }
                else {
                    int q = V[j][0];
                    ans += 1LL * po[q] * dp(q, i, X[q] == j, 0) % mod;
                    ans %= mod;
                }
            }
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 177664
h, w = map(int, input().split())
cells = [input() for _ in range(h)]

us = [[0] * w for i in range(h)]
ds = [[0] * w for i in range(h)]
ls = [[0] * w for i in range(h)]
rs = [[0] * w for i in range(h)]

for x in range(w):
    u_cnt = 0
    for y in range(h):
        us[y][x] = u_cnt
        if cells[y][x] == '.':
            u_cnt += 1
        else:
            u_cnt = 0
    d_cnt = 0
    for y in range(h - 1, -1, -1):
        ds[y][x] = d_cnt
        if cells[y][x] == '.':
            d_cnt += 1
        else:
            d_cnt = 0
for y in range(h):
    l_cnt = 0
    for x in range(w):
        ls[y][x] = l_cnt
        if cells[y][x] == '.':
            l_cnt += 1
        else:
            l_cnt = 0

    r_cnt = 0
    for x in range(w - 1, -1, -1):
        rs[y][x] = r_cnt
        if cells[y][x] == '.':
            r_cnt += 1
        else:
            r_cnt = 0

maxv = 0
for y in range(h):
    for x in range(w):
        if cells[y][x] == '#':
            continue
        maxv = max(maxv, us[y][x] + ds[y][x] + ls[y][x] +
                   rs[y][x] + (1 if cells[y][x] == '.' else 0))
print(maxv)


Measured memory_bytes: 179844
import java.io.InputStream;
import java.util.Scanner;

class Main {
	
	public static void main(String[] args){
		
		Scanner In = new Scanner(System.in);
		
		int x = In.nextInt();

		int num = (int)Math.pow(x,3);
		
		System.out.println(num);
		
}
}

Measured memory_bytes: 26080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n; cin >> n;
	
	n %= 10;
	if(n == 3){
		print("bon")
	}
	else if(n == 0 || n == 1 || n == 6 || n == 8){
		print("pon")
	}
	else{
		print("hon")
	}

	return 0;
}

Measured memory_bytes: 3648
class Dice(object):
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    def east(self):
        prev_s6 = self.s6
        self.s6 = self.s3
        self.s3 = self.s1
        self.s1 = self.s4
        self.s4 = prev_s6
    def west(self):
        prev_s6 = self.s6
        self.s6 = self.s4
        self.s4 = self.s1
        self.s1 = self.s3
        self.s3 = prev_s6
    def north(self):
        prev_s6 = self.s6
        self.s6 = self.s5
        self.s5 = self.s1
        self.s1 = self.s2
        self.s2 = prev_s6
    def south(self):
        prev_s6 = self.s6
        self.s6 = self.s2
        self.s2 = self.s1
        self.s1 = self.s5
        self.s5 = prev_s6
    def rotate(self):
        prev_s2 = self.s2
        self.s2 = self.s4
        self.s4 = self.s5
        self.s5 = self.s3
        self.s3 = prev_s2
    def top(self):
        return self.s1
    def front(self):
        return self.s2
    def right(self):
        return self.s3

    def isSameDice(self, anotherDice):
        for i in range(6):
            if i % 2 == 0:
                self.north()
            else:
                self.west()
            for j in range(4):
                self.rotate()
                if self.s1 == anotherDice.s1 and \
                   self.s2 == anotherDice.s2 and \
                   self.s3 == anotherDice.s3 and \
                   self.s4 == anotherDice.s4 and \
                   self.s5 == anotherDice.s5 and \
                   self.s6 == anotherDice.s6:
                    return True
        return False


dices = []
n = int(input())
for i in range(n):
    s1, s2, s3, s4, s5, s6 = map(int, input().split())
    dices.append(Dice(s1, s2, s3, s4, s5, s6))

flag = False
for i in range(n):
    j = i+1
    while j < n:
        if dices[i].isSameDice(dices[j]):
            flag = True
            break
        j += 1

if flag:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 6812
#include <stdio.h>
#include <string.h>
#define ONE_WEEK 7

int main(void)
{
	char day[7][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	char s[4];
	int i;

	scanf("%s", s);

	for (i = 0; i < ONE_WEEK; i++)
	{
		if (strcmp(s, day[i]) == 0)
		{
			printf("%d\n", ONE_WEEK - i);
			return 0;
		}
	}
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
string s;
int cnt[2][11];
main()
{
	while(cin>>s,s!="0")
	{
		for(int i=0;i<2;i++)for(int j=0;j<11;j++)cnt[i][j]=0;
		cnt[1][0]=1;
		int ans=0;
		int now=0;
		for(int i=0;i<s.size();i++)
		{
			now=(now*10+s[i]-'0')%11;
			ans+=cnt[i%2][now];
			ans+=cnt[1-i%2][(11-now)%11];
			cnt[i%2][now]+=s[i+1]!='0';
		}
		cout<<ans<<endl;
	}
}



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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans = 0;
  int W, a, b;
  cin >> W >> a >> b;

  if (a + W < b) {
    ans = b - (a + W);
  } else if (b + W < a) {
    ans = a - (b + W);
  }

  cout << ans << '\n';

  return 0;
}

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

int main(){
    string S, T;  cin >> S >> T;
    int N = S.length();
    vector<vector<int>> trans;
    trans = vector<vector<int>>(26, vector<int>(26, 0));
    for(int i=0; i<N; i++){
        int s = S[i] - 'a';
        int t = T[i] - 'a';
        trans[s][t] = 1;
    }

    for(int i=0; i<26; i++){
        int cnt = 0;
        for(int j=0; j<26; j++){
            cnt+=trans[i][j];
        }
        if(cnt >= 2){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=0; i<26; i++){
        int cnt = 0;
        for(int j=0; j<26; j++){
            cnt+=trans[j][i];
        }
        if(cnt >= 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 776
from sys import stdin
n = int(stdin.readline().rstrip())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
li = make_divisors(n)
point = 0
for i in li:
    minashi = i-1
    if minashi == 0:
        continue
    elif n%minashi == n//minashi:
        point += minashi
print(point)

Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,a,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        ans+=a-1;
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3608
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N;
  map<ll, ll> amap;
  ll D;
  for(int i=0;i<N;++i) {
    cin>>D;
    amap[D]++;
  }
  cin>>M;
  ll T;
  bool can = true;
  for(int i=0;i<M;++i) {
    cin>>T;
    if(amap[T]==0) can = false;
    amap[T]--;
  }
  if(can) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 16104