akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  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 {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= 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 {
    mint res(*this);
    return res /= a;
  }
};

mint factorial(ll n) {
  mint answer = 1;
  while (n > 1) {
    answer *= n;
    n--;
  }
  return answer;
}

mint combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

mint permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

// setprecision(8) 桁数指定
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans;
  int s = max(a, c);
  int e = min(b, d);
  ans = max(e - s, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b;cin>>a>>b;
    int ans = 0, now = 1;
    while(now<b){
        now--; now+=a; ++ans;
    }
    cout<<ans <<endl;return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    int N, M; cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    rep(i, M) {
        cin >> p[i] >> S[i];
    }
    vector<int> waed(N);
    vector<bool> aced(N, false);

    int ac = 0, wa = 0;
    rep(i, M) {
        if (S[i] == "AC" && !aced[p[i]]) {
            ac += 1;
            wa += waed[p[i]-1];
            aced[p[i]] = true;
        }
        if (S[i] == "WA") {
            waed[p[i]-1] += 1;
        }
    }

    cout << ac << " " << wa << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
using namespace std;
char s[4];
int main(){

    while(scanf("%s",s) == 1)
    {
        int ans = 0;
        int ok = 0;
        int best = 0;
        for(int i = 0; i < 3; ++i)
        {
            if(s[i] == 'R') {
                ans ++;
            }
            if(s[i] == 'S')
            {
                best = max(best,ans);
                ans = 0;
            }
        }
        best = max(best,ans);
        printf("%d\n",best);
    }
    return 0;
}


Measured memory_bytes: 3788
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
total = 0

for j in range(N):
  total = total + B[j]

for i in range(N):
  if i > 0 and A[i] == A[i-1] + 1:
    total = total +C[A[i-1]-1]
print(total)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int X = nextLong();
  ll ans = 0;
  int a[] = { 0, 1800, 1600, 1400, 1200, 1000, 800, 600, 400 };
  for (int i = 8; i >= 1; i--) {
    if (X >= a[i]) ans = i;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3756
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

N, X, Y = map(int,input().split())
l = [[0]*(N) for _ in range(N)]
for i in range(N-1):
    l[i][i+1] = 1
    l[i+1][i] = 1
l[X-1][Y-1] = 1
l[Y-1][X-1] = 1
csr = csr_matrix(l)
step = np.array(np.ravel(dijkstra(csr, unweighted=True)), dtype=int)
memo = np.bincount(step)//2
ma = np.max(step)
for i in range(1,ma+1):
    print(memo[i])
for i in range(ma+1, N):
    print(0)

Measured memory_bytes: 107840
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<pair<string,int>> hoge(n);
    
    for(int i=0;i<n;i++){
        cin>>hoge.at(i).first>>hoge.at(i).second;
    }
    
    string tmp;
    cin>>tmp;
    
    long long ans=0;
    bool sleep=false;
    
    for(int i=1;i<n;i++){
        if(hoge.at(i-1).first==tmp || sleep){
            sleep=true;
            ans+=hoge.at(i).second;
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

class data {
public:
  int x, y, a;
};

int main() {
  int w, h, n;
  data d[100];
  cin >> w >> h >> n;

  if(w == 0 && h == 0) {
    cout << 0 << endl;
    return 0;
  }

  for(int i = 0; i < n; i++) {
    cin >> d[i].x >> d[i].y >> d[i].a;
  }

  int x_min = 0;
  int x_max = w;
  int y_min = 0;
  int y_max = h;
  for(int i = 0; i < n; i++) {
    if(d[i].a == 1) {
      x_min = max(x_min, d[i].x);
      x_max = max(x_max, d[i].x);
    }else if(d[i].a == 2) {
      x_min = min(x_min ,d[i].x);
      x_max = min(x_max, d[i].x);
    }else if(d[i].a == 3) {
      y_min = max(y_min, d[i].y);
      y_max = max(y_max, d[i].y);
    }else if(d[i].a == 4) {
      y_min = min(y_min, d[i].y);
      y_max = min(y_max, d[i].y);
    }
  }

  if((x_max - x_min) * (y_max - y_min) > 0) {
    cout << (x_max - x_min) * (y_max - y_min) << endl;
  }else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

ll N , A, B ;
ll _A, A_B, B_;

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

    cin >> N >> A >> B ;

    
    rep(i,N){
        ll inp;
        cin >> inp;
        if(inp <= A) _A ++;
        else if(inp <= B) A_B ++;
        else B_++;
    }
    
    cout << min(min(_A, A_B), B_)<< endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main() {
    string s; cin >> s;
    deque<char> deq;
    for (char c : s) {
        deq.push_back(c);
    }
    bool flip = false;
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int type; cin >> type;
        if (type == 1) {
            flip = !flip; // 左右反転
        } else {
            int f; char c;
            cin >> f >> c;
            if (flip) {
                f = 3-f;
            }
            if (f == 1) {
                deq.push_front(c);
            } else {
                deq.push_back(c);
            }
        }
    }
    if (flip) {
        reverse(deq.begin(), deq.end());
    }
    string ans;
    for (char c : deq) {
        ans += c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
char inp[100010];
int w;
int main()
{
	scanf(" %s", inp);
	scanf("%d", &w);
	int n = strlen(inp);
	for (int i = 0; i < n; i += w) printf("%c", inp[i]);
	printf("\n");
}

Measured memory_bytes: 256
n = int(input())
f = [0] * n
for i in range(n):
    f[i] = list(map(int, input().split()))
p = [0] * n
for i in range(n):
    p[i] = list(map(int, input().split()))
ans = - 10 ** 7 * 10 * n - 1
for i in range(1, 2**10):
    profit = 0
    open_ = [0] * 10
    for j in range(10):
        if ((i >> j) & 1):
            open_[j] = 1
    for k in range(n):
        cnt = 0
        for l in range(10):
            if open_[l] == 1 and f[k][l] == open_[l]:
                cnt += 1
        profit += p[k][cnt]
    ans = max(profit, ans)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c,k; cin >> n >> c >> k;
    vector<ll> t(n);
    REP(i,n) cin >> t[i];
    sort(ALL(t));
    ll ans = 0, right = 0, passenger;
    REP(left,n) {
        passenger=1;
        while (right+1 < n && t[right+1]-t[left] <= k && passenger+1 <= c) {
            ++ passenger;
            ++ right;
        }
        ++ ans;
        left = right;
        ++ right;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import math

n,m = map(int, input().split(' '))
res = 0
if n >= 2:
    res += math.factorial(n) // (math.factorial(n-2) * math.factorial(2))
if m >= 2:
    res += math.factorial(m) // (math.factorial(m-2) * math.factorial(2))
print(res)

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

using namespace std;

// function to solve
void solve(int n, int k, string s){

  s[k-1] = tolower(s[k-1]);
  cout << s << endl;
}

// Driver program to test above function  
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    // Keep this, testcases
    // int t;
    // cin >> t;

    // Now we can run our algo
    // for (int i = 1; i <= t; ++i){
    //   cout << "Case #" << i << ": ";
    //   solveC();
    // }
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    solve(n, k, s);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder.ABC
{
	class QuestionC
	{
		public static void Main(string[] args)
		{
			var a = new int[3][];
			a[0] = Console.ReadLine().Split(" ").Select(q => int.Parse(q)).ToArray();
			a[1] = Console.ReadLine().Split(" ").Select(q => int.Parse(q)).ToArray();
			a[2] = Console.ReadLine().Split(" ").Select(q => int.Parse(q)).ToArray();

			var n = int.Parse(Console.ReadLine());

			var b = new HashSet<int>();

			for(int i = 0; i < n; i++) {
				b.Add(int.Parse(Console.ReadLine()));
			}

			var ret = "No";

			for(int i = 0; i < 3; i++) {
				if (b.Contains(a[i][0]) && b.Contains(a[i][1]) && b.Contains(a[i][2])) {
					ret = "Yes";
					break;
				}
			}

			for (int i = 0; i < 3; i++) {
				if (b.Contains(a[0][i]) && b.Contains(a[1][i]) && b.Contains(a[2][i])) {
					ret = "Yes";
					break;
				}
			}

			if (b.Contains(a[0][0]) && b.Contains(a[1][1]) && b.Contains(a[2][2])) {
				ret = "Yes";
			}

			if (b.Contains(a[2][0]) && b.Contains(a[1][1]) && b.Contains(a[0][2])) {
				ret = "Yes";
			}

			Console.WriteLine(ret);
		}
	}
}


Measured memory_bytes: 28108
a = gets.split().map(&:to_i)
if a[2] < 0 || a[3] < 0
   puts "No"
else
   if (a[2] + a[4]) > a[0] || (a[3] + a[4]) > a[1]
      puts "No"
   elsif a[0] == a[2] || a[1] == a[3]
      puts "No"
   else
      puts "Yes"
   end
end


Measured memory_bytes: 6872
def main():
    H, W = map(int, input().split())
    s = ["." * (W + 2)]
    s += ["." + input() + "." for i in range(H)]
    s.append("." * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == ".":
                continue
            if "...." == s[y + 1][x]\
                    + s[y][x + 1]\
                    + s[y - 1][x]\
                    + s[y][x - 1]:
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int A[4];
    for (int i=0;i<4;++i){
        char x; cin >> x;
        A[i] = x-'0';
    }
    int tmp;
    string ans;
    for (int bit=0; bit<(1<<3); ++bit){
        tmp = A[0];
        ans = A[0]+'0';
        for (int i=0;i<3;++i){
            if (bit&(1<<i)) {
                tmp += A[i+1];
                ans += '+';
            }else {
                tmp -= A[i+1];
                ans += '-';
            }
            ans += ('0'+A[i+1]);
        }
        if (tmp==7) {
            cout << ans << "=7" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  map<string, int> m;
  rep(i, n){
    string s;
    cin >> s;
    m[s]++;
  }
  auto begin = m.begin(), end = m.end();
  int count = 0;
  for(auto iter = begin; iter != end; iter++){
    count = max(count, iter->second);
  }
  vector<string> ans;
  for(auto iter = begin; iter != end; iter++){
    if(iter->second == count) ans.push_back(iter->first);
  }
  sort(ans.begin(), ans.end());
  rep(i, ans.size()){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 28020
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main()
{
	int N;
	bool b = false;

	cin >> N;

	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			if (i*j == N)
			{
				b = true;
			}
		}
	}

	if (b)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <cmath>
#include <numeric>
#include <stack>
#include <iomanip>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}

int main() {

    int n, k;
    cin >> n >> k;
    vector<int> num(n, 0);

    rep(i, k) {
        int d = inp1;
        vector<int> a = inp(d);
        rep(i, d) {
            num[a[i] - 1]++;
        }
    }

    int ans = 0;
    rep(i, n) if (num[i] == 0) ++ans;

    Cout(ans);


    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
string reverse(string s,int a,int b){
    int temp,times=(b-a+1)/2;
    for(int i=0;i<times;i++){
        temp=s[a];
        s[a++]=s[b];
        s[b--]=temp;
    }
  return s;
}
int main(){
  string s,com,p;
  int n,a,b;
  cin>>s>>n;
  for(int i=0;i<n;i++){
      cin>>com;
      if(com=="print"){
        cin>>a>>b;
        for(int j=a;j<=b;j++)
          cout<<s[j];
        cout<<endl;
      }
      if(com=="replace"){
        cin>>a>>b>>p;
        s.replace(a,b-a+1,p);
      }
      if(com=="reverse"){
        cin>>a>>b;
        s=reverse(s,a,b);
      }
  }
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

ll n;
vector<ll> v;
ll calc(ll a, ll b, ll i) {
  return max({v[a], v[i + 1] - v[a], v[b] - v[i + 1], v[n] - v[b]}) - min({v[a], v[i + 1] - v[a], v[b] - v[i + 1], v[n] - v[b]});
}

int main() {
  cin >> n;
  v.pb(0);
  REP(i, n) {
    ll h;
    cin >> h;
    v.pb(h);
  }
  REP(i, n) {
    v[i + 1] += v[i];
  }
  ll ret = INF;
  REP(i, n) {
    ll ok = 0, ng = i + 1;
    while (ng - ok > 1) {
      ll m = (ng + ok) / 2;
      if (v[m] < v[i + 1] - v[m]) {
        ok = m;
      } else {
        ng = m;
      }
    }

    ll OK = i + 1, NG = n + 1;
    while (NG - OK > 1) {
      ll m = (NG + OK) / 2;
      if (v[m] - v[i + 1] < v[n] - v[m]) {
        OK = m;
      } else {
        NG = m;
      }
    }

    ret = min(ret, calc(ok, OK, i));
    ret = min(ret, calc(ok + 1, OK, i));
    ret = min(ret, calc(ok + 1, OK + 1, i));
    ret = min(ret, calc(ok, OK + 1, i));
  }
  cout << ret << endl;
}

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

int main(int argc,char** argv){
	int n=0,N,temp;
	cin >> N;
	temp = N;
	while(N!=0){
		n+=N%10;
		N/=10;
	}
	if(temp%n == 0)
		cout<<"Yes";
	else
		cout << "No";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
def main1
  n,m,x = gets.chomp.split(/ /).map {|i| i.to_i}

  c = []
  ns = []
  (1..n).each {|i|
    c << i
    ns << gets.chomp.split(/ /).map {|i| i.to_i}
  }
  #p ns

  min = -1
  (1..c.length).each {|i|
    #p c.combination(i).to_a

    c.combination(i) {|cn|
      #p cn
      price = 0
      learn = Array.new(m, 0)
      cn.each {|j|
        price += ns[j-1][0]

        (0...m).each { |mm|
          learn[mm] += ns[j-1][mm+1]
        }
      }

      #p learn
      if learn.min >= x
        if min == -1 or min > price
          min = price
        end
      end

    }
  }

  puts min
end


main1


    


Measured memory_bytes: 14420
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] L = new int[N];
        for (int i=0; i<N; i++) {
            L[i] = sc.nextInt();
        }

        System.out.println(solve2(N, L));
    }

    /**
     * 愚直な実装でこれだとTLE
     * @param N
     * @param L
     * @return
     */
    private static int solve(int N, int[] L) {
        int count = 0;

        for (int i=0; i<N; i++) {
            for (int j=i+1; j<N; j++) {
                for (int k=j+1; k<N; k++) {
                    if (L[i] < L[j] + L[k] && L[j] < L[k] + L[i] && L[k] < L[i] + L[j]) {
                        count++;
                    }
                }
            }
        }

        return count;
    }

    private static long solve2(int N, int[] L) {
        long count = 0;


        int[] numGreaterOrEqualToL = new int[1000 + 2];
        Arrays.sort(L);
        int idx = 0;
        for (int i=1000; i>=0; i--) {
            numGreaterOrEqualToL[i] = numGreaterOrEqualToL[i+1];
            while (idx < N && i == L[N - idx - 1]) {
                numGreaterOrEqualToL[i]++;
                idx++;

                // System.err.println("OL[" + i + "] = " + numGreaterOrEqualToL[i]);
            }
        }

        for (int i=0; i<N; i++) {
            for (int j=i+1; j<N; j++) {
                int kMax = Math.min(1000+1, L[i]+L[j]);
                int kMin = Math.abs(L[i]-L[j]);

                count += numGreaterOrEqualToL[kMin+1] - numGreaterOrEqualToL[kMax];
                if (kMin < L[i] && L[i] < kMax) count--;
                if (kMin < L[j] && L[j] < kMax) count--;

                // System.err.println("i=" + L[i] + ", j=" + L[j] + " = " + count);
            }
        }

        return count/3;
    }
}

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

unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) + (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) + (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) + (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) + (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) + (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) + (x & 0x00000000ffffffffUL);
  return x;
}

long long n, cnt = 0, sum[3] = {};
vector<long long> res, memo;
vector<long long> calc[3];
string x;

void solve();

int main() {
  cin >> n >> x;
  for (long long i = 0; i < n; ++i)
    if (x[i] == '1') ++cnt;
  res.resize(n);
  solve();
  for (long long i = 0; i < n; ++i) cout << res[i] << endl;
  return 0;
}

void solve() {
  if (cnt == 0) {
    for (int i = 0; i < n; ++i) res[i] = 1;
    return;
  }
  if (cnt == 1) {
    bool ch = x[n - 1] == '1';
    for (int i = 0; i < n; ++i)
      if (x[i] == '1')
        res[i] = 0;
      else {
        if (ch || i == n - 1)
          res[i] = 2;
        else
          res[i] = 1;
      }
    return;
  }
  memo.assign(200005, 0);
  long long len = memo.size();
  for (long long i = 1; i < len; ++i) {
    long long now = i % popcount(i);
    memo[i] = memo[now] + 1;
  }
  reverse(x.begin(), x.end());
  for (int t = 0; t < 3; ++t) {
    long long now = cnt + t - 1, num = 1;
    num %= now;
    calc[t].assign(n, 0);
    for (int i = 0; i < n; ++i) {
      calc[t][i] = num;
      if (x[i] == '1') (sum[t] += num) %= now;
      (num <<= 1) %= now;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (x[i] == '1') {
      int id = 0;
      long long now = sum[id] - (calc[id][i] % (cnt - 1)) + (cnt - 1);
      now %= cnt - 1;
      res[i] = memo[now] + 1;
    } else {
      int id = 2;
      long long now = sum[id] + (calc[id][i] % (cnt + 1)) + cnt + 1;
      now %= cnt + 1;
      res[i] = memo[now] + 1;
    }
  }
  reverse(res.begin(), res.end());
}

Measured memory_bytes: 11284
import numpy as np
from collections import defaultdict

memo = defaultdict(int)

N = int(input())
for _ in range(N):
    s = sorted(input())
    s = "".join(s)
    memo[s] += 1

ans = np.array(list(memo.values()))
tmp = ans - 1
ans = (ans*tmp)/2

print(int(ans.sum()))

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

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

    ll res = 1;
    for (int i=0; i<n; ++i) {
        res = res * (i+1) % 1000000007;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <string>
using namespace std;
typedef unsigned long long ull;
int main(){
	ull K;
	cin >> K;

	int N = 50;
	ull A[50];
	for (int i = 0; i < N; i++) A[i] = i;
	ull a = K / N;
	ull b = K % N;
	for (int i = 0; i < N; i++) A[i] += a;

	for (int i = 0; i < b; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) A[j] += N;
			else A[j] -= 1;
		}
	}

	cout << 50 << endl;
	for (int i = 0; i < N; i++) {
		if (i != 0) cout << " ";
		cout << A[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, h;
	int max = 0, ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &h);
		if (h >= max) {
			max = h;
			ans += 1;
		}
	}
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
function Main(input: any) {
  const inputs = input.split('')
  const val = inputs.reduce((acc, i) => {
    if (i === '1') {
      return acc + 1
    }
    return acc
  }, 0)
  console.log(val)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
X,N = map(int,input().split())
if N > 0:
  P = input().split()
  P = [int(x) for x in P]
else:
    P = []

ans = 101
s = 101-X
for i in range(101)[::-1]:
  a = abs(i - X)
  if a <= s:
    if not(i in P):
      ans = i
      s = a

print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  ll sum = 0;

  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &d[i]);

    sum += d[i];
  }

  vector<int> ans(n);

  ll ans0 = sum;
  for (int i = 1; i < n; i += 2) {
    ans0 -= d[i] * 2;
    ans[0] = ans0;
  }

  for (int i = 1; i < n; i++) {
    ans[i] = d[i - 1] * 2 - ans[i - 1];
  }

  for (int i = 0; i < ans.size(); i++) {
    if (i > 0) {
      cout << " " << endl;
    }
    cout << ans[i];
  }
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
string A, B;
cin >> A >> B;


if(A.length() > B.length()) cout << "GREATER" << endl;
else if(A.length() < B.length()) cout << "LESS" << endl;
else if(A > B) cout << "GREATER" << endl;
else if (A < B) cout << "LESS" << endl;
else if(A == B) cout << "EQUAL" << endl;
}

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


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> d(k);
    rep(i,k) cin>>d[i];
    for(int x=n;x<100000;x++){
        int tmp=x;
        set<int>s;
        while(tmp>0){
            s.insert(tmp%10);
            tmp/=10;
        }
        bool flag=true;
        rep(i,k){
            if(s.count(d[i])) flag=false;
        }
        if(flag){
            cout<<x<<endl;
            break;
        }
    }
    
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
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


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m,x = lr()
a = [0 for i in range(n+1)]
l = lr()
for num in l:
    a[num] = 1
a1 = [0]
for num in a:
    a1.append(num+a1[-1])
print(min(a1[x+1]-a1[0], a1[n+1]-a1[x+1]))

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

int main(){
  const int Nmod= 1000000007;
  int N;
  cin >> N;
  
  unordered_map<int, int64_t> map;
  for(int i=2; i<=N; i++){
    int tmp= i;
    for(auto e:map){
      auto p= e.first;
      while( tmp%p==0 ){
        map.at(p)++;
        tmp/= p;
      }
    }
    if(tmp>1){
      map[tmp]= 1;
    }
  }

  int ans= 1;
  for(auto e:map){
    auto n_p= e.second;
    ans= ans* (1+ n_p)% Nmod;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b;
    
    scanf("%d %d", &a, &b);
    if (a > b) {
        printf("a > b\n");
    } else if (a < b) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
vector<int> e[200000];
int dist[200000];

int main() {
    cin >> n;
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    fill(dist, dist+n, inf);
    dist[0] = 0;
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int p = que.front(); que.pop();
        for (int to : e[p]) {
            if (dist[to] != inf) continue;
            dist[to] = dist[p] + 1;
            que.push(to);
        }
    }
    int nxt = 0, M = 0;
    rep(i,n) {
        if (dist[i] > M) {
            M = dist[i];
            nxt = i;
        }
    }
    cerr << nxt << " " << M << endl;
    fill(dist, dist+n, inf);
    dist[nxt] = 0;
    que.push(nxt);
    while (!que.empty()) {
        int p = que.front(); que.pop();
        for (int to : e[p]) {
            if (dist[to] != inf) continue;
            dist[to] = dist[p] + 1;
            que.push(to);
        }
    }
    M = 0;
    rep(i,n) M = max(M, dist[i]);
    if (M%3  == 1) cout << "Second" << endl;
    else cout << "First" << endl;
}

Measured memory_bytes: 13556
#include "bits/stdc++.h"
using namespace std;
int MAIN(){
    int n;
    if(!~scanf("%d", &n)) return 1;
    vector<int> arr(n);
    for(int &v:arr) scanf("%d", &v);
    sort(arr.begin(), arr.end());
    if(arr[0] == arr.back()){
        if(arr[0] == n-1 || arr[0]*2 <= n) return printf("Yes\n"), 0;
    } else if(arr[0] + 1 == arr.back()){
        int A = arr.back();
        int x = count(arr.begin(), arr.end(), arr[0]);
        int y = count(arr.begin(), arr.end(), arr.back());
        if(x+1 <= A && A <= x + y/2) return printf("Yes\n"), 0;
    }
    printf("No\n");
    return 0;
}
int main(){
    while(!MAIN());
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define all(v) (v).begin(),(v).end()
#define deb(a) cout << #a << " = " << a << endl
#define MAX 51
using namespace std;

struct P
{
  int x,y;
  P(int x=inf,int y=inf):x(x),y(y){}
  bool operator == (const P& a)const
  {
    return x == a.x && y == a.y;
  }
  bool operator < (const P& a)const
  {
    return (x!=a.x?x < a.x:y < a.y);
  }
};

struct Pox
{
  P p;
  vector<P> path;
  Pox(P p = P()):p(p){ path.clear(); }
};

int R,C,M;
char G[MAX][MAX];
int cost[3][MAX][MAX];// 0-> per unit of time, 1 -> turn on, 2 -> turn off
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int dp[MAX][MAX];
int visited[MAX][MAX];

vector<P> task;
vector<P> route;

void findRoute()
{
  bool used[R][C];

  route.push_back(task[0]);

  rep(i,M-1)
    {
      rep(y,R)rep(x,C)used[y][x] = false;
      deque<Pox> deq;
      deq.push_back(Pox(task[i]));
      used[task[i].y][task[i].x] = true;
      P goal = task[i+1];
      
      bool found = false;
      //cout << "target : " << goal.x << "," << goal.y << endl; 
      while(!deq.empty())
	{
	  Pox pox = deq.front(); deq.pop_front();      
	  //cout << "pox = " << pox.p.x << "," << pox.p.y << endl;
	  if(pox.p == goal)
	    {
	   
	      rep(j,pox.path.size())
		{
		  //cout << "add " << pox.path[j].x << "," << pox.path[j].y << endl;
		  route.push_back(pox.path[j]);
		}
	      found = true;
	      break;
	    }

	  rep(j,4)
	    {
	      int nx = pox.p.x + dx[j];
	      int ny = pox.p.y + dy[j];
	      if(!( 0 <= nx && nx < C && 0 <= ny && ny < R ))continue;
	      if(G[ny][nx] == '#')continue;
	      if(!used[ny][nx])
		{
		  //cout << "goto " << nx << "," << ny << endl;
		  used[ny][nx] = true;
		  Pox npox = pox;
		  npox.path.push_back(P(nx,ny));	
		  npox.p = P(nx,ny);
		  deq.push_back(npox);
		}
	    }

	}
      assert(found);
    }
}

void compute()
{
  findRoute();
  int N = route.size();
  //rep(i,N)
    //cout << "route["<<i<<"] = (" <<route[i].x << "," << route[i].y << ")\n";
  
  rep(y,R)rep(x,C)dp[y][x] = visited[y][x] = inf;
  

  rep(i,N)
    {  
      int x = route[i].x;
      int y = route[i].y; 
            
      if(visited[y][x] == inf)
	{
	  dp[y][x] = cost[1][y][x] + cost[2][y][x];
	}
      else
	{
	  dp[y][x] = min(dp[y][x]+cost[1][y][x]+cost[2][y][x],
			 dp[y][x]+(i-visited[y][x])*cost[0][y][x]);
	}

      visited[y][x] = i;
    }
  sort(all(route));
  route.erase(unique(all(route)),route.end());
  int ans = 0;
  rep(i,route.size())ans += dp[route[i].y][route[i].x];
  cout << ans <<endl;
}

int main()
{
  cin >> R >> C >> M;
  task.resize(M);
  rep(i,R)rep(j,C)cin >> G[i][j];
  rep(i,3)rep(j,R)rep(k,C)cin >> cost[i][j][k];
  rep(i,M)cin >> task[i].y >> task[i].x;
  compute();

  return 0;
}

Measured memory_bytes: 19512
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	ans := 1 << 62
	for A := 1; A*A <= N; A++ {
		B := N / A
		if A*B != N {
			continue
		}
		ans = Min(ans, digits(Max(A, B)))
	}
	fmt.Println(ans)
}

func digits(a int) int {
	d := 0
	for a > 0 {
		d++
		a /= 10
	}
	return d
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


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

int main()
{
    ll x;
    cin >> x;
    //x--;

    ll ans = x / 11;
    ans *= 2;

    ll rem = x % 11;
    //cout << rem << endl;
    if (rem) {
        if (rem <= 6) ans += 1;
        else ans += 2;
    }


    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int X;
    cin >> X;
    if (X%7==0){
        cout << "thu" << endl;
    } else if (X%7==1){
        cout << "fri" << endl;
    } else if (X%7==2){
        cout << "sat" << endl;
    } else if (X%7==3){
        cout << "sun" << endl;
    } else if (X%7==4){
        cout << "mon" << endl;
    } else if (X%7==5){
        cout << "tue" << endl;
    } else {
        cout << "wed" << endl;
    }
}



Measured memory_bytes: 3124
#include <iostream>
#include <string>
using namespace std;
int main(){ 
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    char c1=s1[0]-32;
    char c2=s2[0]-32;
    char c3=s3[0]-32;
    cout << c1 << c2 << c3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  unsigned long long ans=0;
  ans=(x/11)*2;
  if(x%11>6){
    ans+=2;
  }else if(x%11>0){
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d%d", $N, $K);

$p_list = array_map("intval", explode(" ", trim(fgets(STDIN))));
$f_list = array_map("intval", explode(" ", trim(fgets(STDIN))));
rsort($p_list);
sort($f_list);
//$max=10**12;//
//foreach($p_list as $key=>$value){
//    $max =max($max, $value * $f_list[$key]);
//}

$a = -1;
$b = 1000000000000;
//$ans = [-1,intdiv($max,2), $max];

while(($b-1) > $a){
    $mid = $a + (($b-$a) >> 1);

    if(check($mid)){
        $a = $mid;
//            $mid = $a + (($b-$a)>> 1);

    }else{
        $b = $mid;
    }

//    $mid = $a + (($b-$a) >> 1);
}

    echo $b;

function check($mid){
    global $K, $N, $p_list, $f_list;
    $need = 0;
    for($i=0;$i<$N;$i++){
        $need += max($p_list[$i] - (int)($mid / $f_list[$i]), 0);
//        if($need > $K){
//            $over = 1;
//            break;
//        }

    }
    return $need > $K ;
}

Measured memory_bytes: 37360
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[1010][1010];

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

	ll h, w, n;
	ll sr, sc;

	cin >> h >> w >> n;
	cin >> sr >> sc;

	string s, t;
	cin >> s >> t;

	ll l = 1;
	ll r = w;
	REP(i, n) {
		
		if (t[n - 1 - i] == 'L' && r < w) r++;
		if (t[n - 1 - i] == 'R' && l > 1) l--;
		//cout << l << " " << r << endl;
		
		if (s[n - 1 - i] == 'L') l++;
		if (s[n - 1 - i] == 'R') r--;
		if (l > r) {
			cout << "NO" << endl;
			return 0;
		}
	}

	ll u = 1;
	ll d = h;
	REP(i, n) {
		if (t[n - 1 - i] == 'U' && d < h) d++;
		if (t[n - 1 - i] == 'D' && u > 1) u--;
		//cout << u << " " << d << endl;
		
		if (s[n - 1 - i] == 'U') u++;
		if (s[n - 1 - i] == 'D') d--;
		if (u > d) {
			cout << "NO" << endl;
			return 0;
		}
	}

	if (l <= sc && sc <= r && u <= sr && sr <= d) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 920
# include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
typedef long long LL;
const int maxn = 23000000;
short dig[maxn+1];
inline void add(int &x, int y)
{
    x+=y;
    if(x>=mod) x-=mod;
}
int qmod(LL a, int b)
{
    LL res = 1;
    for(;b;b>>=1)
    {
        if(b&1) res=res*a%mod;
        a=a*a%mod;
    }
    return (int)res;
}
int main()
{
    for(int i=1; i<=maxn; ++i) dig[i] = dig[i/10]+1;
    int n, ans=0;
    scanf("%d",&n);
    for(int i=1, j=1, s=0; i<1e7; ++i)
    {
        while(s<n) s+=dig[j],++j;
        if(s==n) add(ans, 1);
        s -= dig[i];
    }
    for(int i=1; i<=n/8; ++i)
    {
        if(n%i==0) add(ans, ((qmod(10,n/i)-qmod(10,n/i-1)-i+1)%mod+mod)%mod);
        else add(ans, 1);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 45312
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


S = input()
print('Yes' if 'a' in S and 'b' in S and 'c' in S else 'No')


Measured memory_bytes: 38384