akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(a) (a).begin(), (a).end()

using namespace std;
using ll = long long;

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  int all = 0;
  vector<string> c(h);
  rep(i, h) {
    cin >> c[i];
    rep(j, w) {
      if (c[i][j] == '#') all++;
    }
  }

  int ans = 0;
  for (int bit1 = 0; bit1 < (1<<h); ++bit1) {
    for (int bit2 = 0; bit2 < (1<<w); ++bit2) {
      int tmp = all;

      vector<int> row, col;
      rep(i, h) {
        if (bit1 & (1<<i)) {
          row.push_back(i);
        }
      }
      rep(i, w) {
        if (bit2 & (1<<i)) {
          col.push_back(i);
        }
      }

      rep(i, h) {
        rep(j, w) {
          if (c[i][j] == '#') {
            bool flag = false;

            for (auto e: row) {
              if (i == e) {
                flag = true;
                break;
              }
            }
            for (auto e: col) {
              if (j == e) {
                flag = true;
                break;
              }
            }

            if (flag) tmp--;
          }
        }
      }

      if (tmp == k) ans++; 
    }
  }

  cout << ans << endl;
}


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    string S, Fo = "", Ba = "";
    int Q, A = 0;
    cin >> S >> Q;
    vector<int> T(Q), F(Q);
    vector<char> C(Q);
    rep(i, Q) {
        cin >> T[i];
        if (T[i] == 2) {
            cin >> F[i] >> C[i];
            if (A + F[i] == 2) {
                Ba.push_back(C[i]);
            } else {
                Fo.push_back(C[i]);
            }
        } else {
            A = 1 - A;
        }
    }
    if (A == 0) {
        rep(i, Fo.size()) cout << Fo[Fo.size() - 1 - i];
        cout << S;
        rep(i, Ba.size()) cout << Ba[i];
        cout << endl;
    } else {
        rep(i, Ba.size()) cout << Ba[Ba.size() - 1 - i];
        rep(i, S.size()) cout << S[S.size() - 1 - i];
        rep(i, Fo.size()) cout << Fo[i];
        cout << endl;
    }
}

Measured memory_bytes: 2880
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;

string s = "0123456789AB";
vector<vector<int>> adj = {
    {2},
    {2,5},
    {0,1,3,6},
    {2,7},
    {5},
    {1,4,6,9},
    {2,5,7,10},
    {3,6,8,11},
    {7},
    {5,10},
    {6,9,11,12},
    {7,10},
    {10}
};

int solve(string stat, string goal, map<string,int> &dist, bool useterm, map<string,int> &term) {
    dist[stat] = 0;
    queue<string> q;
    q.push(stat);
    while ( ! q.empty()) {
        string s = q.front();
        q.pop();
        if (useterm && term.find(s) != term.end()) {
            return dist[s] + term[s];
        }
        int diff = 0;
        for (int k=0; k<13; ++k) {
            if (s[k] != '0') {
                diff += s[k] != goal[k];
            }
        }
        if ( ! diff) {
            return dist[s];
        }
        if (10 <= dist[s] || 20 < dist[s] + diff) {
            continue;
        }
        for (int i=0; i<13; ++i) {
            if (s[i] != '0') continue;
            for (int j : adj[i]) {
                string next = s;
                next[i] = s[j];
                next[j] = s[i];
                if (dist.find(next) == dist.end()) {
                    dist[next] = dist[s] + 1;
                    q.push(next);
                }
            }
        }
    }
    return 21;
}

int main() {
    map<string, int> term;
    int dummy = solve("0123456789AB0", "0BA9876543210", term, false, term);
    while (1) {
        map<string, int> dist;
        string stat = "";
        int k;
        for (int i=0; i<13; ++i) {
            if (cin >> k && !~k) return 0;
            stat += s[k];
        }
        int ans = solve(stat, "0123456789AB0", dist, true, term);
        if (ans <= 20) {
            cout << ans << endl;
            continue;
        }
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 5396
/*
By Tianyi Chen. All rights reserved.
Date: 2016-08-13
*/
#include<bits/stdc++.h>
using namespace std;
string s,a;
int main() {
 cin>>s;
 for (auto&&x:s)if (x=='B') {
  if (a.size())a.pop_back();
 } else a.push_back(x);
 cout<<a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n; cin>>n;
    int p[n];
    int mini=INT_MAX;
    int cnt=0;
    rep(i,n)
    {
        cin>>p[i];
        if(mini>=p[i])cnt++;
        mini=min(mini,p[i]);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        if d <= 9:
            continue
        d = str(d)
        d1 = int(d[0])
        d2 = int(d[1])
        if d1 >= 2 and d2 >= 2 and m == d1*d2:
            #print(m, d1, d2)
            ans += 1
print(ans)


Measured memory_bytes: 39408
#include <iostream>
using namespace std;
int main () {
    string s, op;
    int no, a, b;
    cin >> s >> no;
    for (int i = 0; i < no; i++) {
        cin >> op >> a >> b;
        if (op == "print") {
            for (int i = a; i <= b; i++)
                cout << s[i];
            cout << '\n';
        } else if (op == "reverse") {
            char temp;
            for (int i = 0; i < (b - a + 1) / 2; i++) {
                temp = s[a + i];
                s[a + i] = s[b - i];
                s[b - i] = temp;
            }
        } else {
            string str;
            cin >> str;
            for (int i = a; i <= b; i++)
                s[i] = str[i - a];
        }
    }
}


Measured memory_bytes: 3216
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
result = 0
for i in range(N-1):
    if A[i]+1 == A[i+1]:
        result += C[A[i]-1]
    else:
        None
print(sum(B)+result)

Measured memory_bytes: 3064
#include <iostream>
#include <set>
using namespace std;
int main() {
    multiset<int> s;
    for (int i = 0; i < 10; ++i) {
        int h;
        cin >> h;
        s.insert(h);
    }
    int i = 0;
    for (auto iter = s.crbegin(); i < 3; ++iter) {
        cout << *iter << endl;
        ++i;
    }
    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  long long A,B,C;
  cin >> A >> B >> C;

  if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    cout << 0 << endl;
  }else {
    cout << min(A*B,min(B*C,C*A)) << endl;
  }
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll x;
	cin>>x;
	ll i = x;
	while(1)
	{
	   ll f=0;
	   for(ll j=2;j*j<=i;j++)
	   {
	       if(i%j == 0) {f=1;break;}
	   }
	   if(f==0) {cout<<i;break;}
	   else i++;
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int ans=0;
    int m=N/2;
    for(int i=d[0]; i <=  d[N-1]; i++){
        int abc = lower_bound(d.begin(),d.end(),i) - d.begin();
        if(abc == m) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
Ts = []
for i in range(N):
  S = input()
  T = "".join(sorted(S))
  Ts.append(T)
Ts.sort()
r = 0
c = 1
for i in range(N-1):
  if Ts[i] == Ts[i+1]:
    c += 1
  else:
    r += c*(c-1)//2
    c = 1
r += c*(c-1)//2
print(r)


Measured memory_bytes: 10584
from collections import *
h,w=map(int,input().split())
a=[input() for _ in range(h)]
b=[[h*w]*w for _ in range(h)]
b[0][0]=1
d=deque([[0,0]])
while d:
    y,x=d.pop()
    if y<h-1:
        if a[y+1][x]=="." and b[y+1][x]>b[y][x]+1:
            d.append([y+1,x])
            b[y+1][x]=b[y][x]+1
    if x<w-1:
        if a[y][x+1]=="." and b[y][x+1]>b[y][x]+1:
            d.append([y,x+1])
            b[y][x+1]=b[y][x]+1
    if y>0:
        if a[y-1][x]=="." and b[y-1][x]>b[y][x]+1:
            d.append([y-1,x])
            b[y-1][x]=b[y][x]+1
    if x>0:
        if a[y][x-1]=="." and b[y][x-1]>b[y][x]+1:
            d.append([y,x-1])
            b[y][x-1]=b[y][x]+1
c=sum([i.count(".") for i in a])
print(max(-1,c-b[-1][-1]))

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll h,w;cin>>h>>w;
    vector<vector<ll>>a(h,vector<ll>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >>a[i][j];
        }
    }
    ll opt=0;
    vector<vector<ll>>ans(4,vector<ll>());
    for (int i =h-1; i >=0 ; --i) {
        for (int j = 0; j < w; ++j) {
            if(i-1<0)continue;
            if(a[i][j]%2==0)continue;
                a[i-1][j]++;
                a[i][j]--;
                opt++;
                ans[0].push_back(i);
                ans[1].push_back(j);
                ans[2].push_back(i-1);
                ans[3].push_back(j);
        }
    }
    for (int i = 0; i < w; ++i) {
        if(a[0][i]%2==0)continue;
        if(i+1>=w)continue;
        a[0][i+1]++;a[0][i]--;
        opt++;
        ans[0].push_back(0);
        ans[1].push_back(i);
        ans[2].push_back(0);
        ans[3].push_back(i+1);
    }
    cout <<opt<<endl;
    for (int i = 0; i < opt; ++i) {
        cout <<ans[0][i]+1<<" "<<ans[1][i]+1<<" "<<ans[2][i]+1<<" "<<ans[3][i]+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 8152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

vector<ll> sosu;
void Sosu(ll x){
    bool s[x+1];
    fill(s,s+x+1,true);
    ll i;
    for(i=2;i*i<=x;i=i+2){
        if(s[i]){
            sosu.pb(i);
            for(ll j=2;j*i<=x;j++){
                s[j*i]=false;
            }
        }
        if(i==2)i--;
    }
    for(i=i;i<=x;i=i+2){
        if(s[i]){
            sosu.pb(i);
        }
    }
}

int main(){fastio
    Sosu(powl(10,6));
    ll n;cin>>n;
    vector<ll> v;
    rep(i,0,sosu.size()-1){
        ll sum=0;
        while(n%sosu[i]==0){
            n/=sosu[i];
            sum++;
        }
        if(sum>0){
            v.pb(sum);
        }
    }
    if(n>1){
        v.pb(1);
    }
    ll ans=0;
    rep(i,0,(ll)v.size()-1){
        ll l=0;
        ll r=100;
        while(r-l>1){
            ll mid=(r+l)/2;
            if((mid)*(mid+1)/2<=v[i]){
                l=mid;
            }else{
                r=mid;
            }
        }
        ans+=l;
    }
    cout<<ans<<endl;
    
    return 0;
}





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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define mem(x,n) memset(x,n,sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main()
{
	faster;

	string s;
	cin >> s;

	for(int i = 0; i < s.size(); i++){
		cout << "x";
	}

	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int A[514514];
int imos[514514];
LL B[1 << 20];
LL dp[1 << 20];
int precnt[1 << 20];
bool appeared[1 << 20];

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base%MOD;
  return res;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  reps(i, 1, N+1) {
    cin >> A[i];
    imos[i] = imos[i-1] ^ A[i];
  }

  //fill(B, B+(1<<20), 1);
  int cnt = 0;
  LL ans = 0;
  reps(i, 1, N) {
    int t = imos[i];
    assert(t < (1 << 20));
    if (t == 0) cnt++;
    else if (appeared[t]) {
      LL k = cnt - precnt[t];
      B[t] += k * dp[t];
      B[t] %= MOD;
      dp[t] += B[t];
      if (dp[t] >= MOD) dp[t] -= MOD;
      precnt[t] = cnt;
    } else {
      appeared[t] = 1;
      dp[t] = 1;
      B[t] = 1;
      precnt[t] = cnt;
    }
  }

  int t = imos[N];
  if (t == 0) {
    cnt++;
    rep(t, 1 << 20) {
      ans += dp[t];
      if (ans >= MOD) ans -= MOD;
    }
    ans += mypow(2, cnt-1);
    ans %= MOD;
  } else if (appeared[t]) {
    LL k = cnt - precnt[t];
    B[t] += k * dp[t];
    B[t] %= MOD;
    ans = B[t];
  } else {
    ans = 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 25728
#include <cstdio>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
using namespace std;
typedef long long int lint;
static inline int in() {
	int x;
	scanf("%d", &x);
	return x;
}
static inline lint inl() {
	lint x;
	scanf("%lld", &x);
	return x;
}
int main() {
	int a, b;
	while (~scanf("%d %d", &a, &b)) {
		printf("%d\n", a + b);
	}
	return (0);
}

Measured memory_bytes: 2580
#include<stdio.h>

int main(void){
    int N,b=0,all=0;
    scanf("%d",&N);
    int a[N];
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
        all+=a[i];
        if(a[i]>b)b=a[i];
    }
    int price=b/2+all-b;
    printf("%d\n",price);
    return 0;
}


Measured memory_bytes: 128
#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define F first
#define S second 
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, n-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


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

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;


i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;

    int n; cin >> n; n += n;
    string s; cin >> s; int t = 1, op = 0, cur = 0;
    for (int j = 0; j < n; j++) {
        int d = (s[j] == 'B');
        if (d == cur) { t *= op; op--; cur ^= 1; }
        else { op++; cur ^= 1; }
        t %= mod;
    }
    if (op > 0) { cout << 0 << endl; return 0; }
    for (int j = 1; j <= n/2; j++) t = (t * j) % mod;
    cout << t << endl;
}




Measured memory_bytes: 720
#include <bits/stdc++.h> 
/*#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif
*/

using namespace std;
#define z 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int l,r,d;
    cin>>l>>r>>d;
    int a=(l+d-1)/d;
    int b=r/d;
    cout<<b-a+1<<endl;
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int n , t ;
int a , b ;
int mn = Int_max ;

int main() {
    cin >> n >> t ;
    while( n-- ){
        cin >> a >> b ;
        if( b <= t ) mn = min( mn , a ) ;
    }
    if( mn == Int_max ){
        cout << "TLE\n" ;
        return 0;
    }
    cout << mn ;
    return 0 ;
}


Measured memory_bytes: 256
N,X = map(int,input().split())
L = list(map(int,input().split()))
for i in range(N):
  L[i] = abs(L[i]-X)
L.sort()
L.reverse()
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)
def listgcd(L):
  p = L[0]
  for i in range(1,N):
    p = gcd(p,L[i])
  return p
if len(L) >= 2:
  print(listgcd(L))
else:
  print(L[0])

Measured memory_bytes: 14224
s=input()
mod=10**9+7
n,a,b,c=1,0,0,0
for i in s:
  if i=="A":
    a+=n
  if i=="B":
    b+=a
  if i=="C":
    c+=b
  if i=="?":
    n,a,b,c=3*n,3*a+n,3*b+a,3*c+b
  n%=mod
  a%=mod
  b%=mod
  c%=mod
print(c)

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

int a[100000];
int n, x, y, mx = 0;
int solve(int mid){
	if(mid == 0)return 0;
	int cnt = 0;
	for(int i = 0;i < n;i++){
		int tmp = a[i]-mid*y;
		if(tmp <= 0)continue;
		int a = (tmp+x-1)/x;
		cnt += a;
	}
	return cnt <= mid;
}

signed main(){
	scanf("%lld%lld%lld", &n, &x, &y);
	for(int i = 0;i < n;i++){
		scanf("%lld", &a[i]);
		mx = max(mx, a[i]);
	}
	x = x-y;
	int lb = -1, ub = mx;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		int res = solve(mid);
		if(res)ub = mid;
		else lb = mid;
	}
	printf("%lld\n", ub);
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007LL
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll


signed main() {
	fast;

	int h,w,k;
	cin>>h>>w>>k;

	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	x1--; y1--;
	x2--; y2--;

	vector<vector<char>> mat(h,vector<char>(w,'.'));
	vector<vector<int>> vis(h,vector<int>(w,-1));
	vector<vector<bool>> touch(h,vector<bool>(w,false));

	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) cin>>mat[i][j];
	}

	queue<pair<pii,int>> q;
	q.push({{x1,y1},0});

	while(!q.empty()) {
		pii cell;
		int d;
		tie(cell,d) = q.front();
		q.pop();

		if(vis[cell.f][cell.s]!=-1) continue;
		else vis[cell.f][cell.s] = d;

		if(x2==cell.f && y2==cell.s) {
			cout<<d;
			return 0;
		}

		for(int i=1;i<=k;i++) {
			if(cell.f-i < 0) break;
			if(mat[cell.f-i][cell.s]=='@') break;
			if(vis[cell.f-i][cell.s]!=-1) break;
			if(!touch[cell.f-i][cell.s]) q.push({{cell.f-i,cell.s},d+1});
			touch[cell.f-i][cell.s] = 1;
		}

		for(int i=1;i<=k;i++) {
			if(cell.f+i >= h) break;
			if(mat[cell.f+i][cell.s]=='@') break;
			if(vis[cell.f+i][cell.s]!=-1) break;
			if(!touch[cell.f+i][cell.s]) q.push({{cell.f+i,cell.s},d+1});
			touch[cell.f+i][cell.s] = 1;
		}

		for(int i=1;i<=k;i++) {
			if(cell.s-i < 0) break;
			if(mat[cell.f][cell.s-i]=='@') break;
			if(vis[cell.f][cell.s-i]!=-1) break;
			if(!touch[cell.f][cell.s-i]) q.push({{cell.f,cell.s-i},d+1});
			touch[cell.f][cell.s-i] = 1;
		}

		for(int i=1;i<=k;i++) {
			if(cell.s+i >= w) break;
			if(mat[cell.f][cell.s+i]=='@') break;
			if(vis[cell.f][cell.s+i]!=-1) break;
			if(!touch[cell.f][cell.s+i]) q.push({{cell.f,cell.s+i},d+1});
			touch[cell.f][cell.s+i] = 1;
		}
	}

	cout<<vis[x2][y2];

}

Measured memory_bytes: 19880
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

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

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const 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 };

/*
// 最大公約数
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;
}*/

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

	int m, f, b;
	cin >> m >> f >> b;

	if (m + f < b) {
		cout << "NA" << endl;
		return 0;
	}

	cout << max(b - m, 0) << endl;

	return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>


using namespace std;

int main(){

    long long a, b;
    char c;

    cin >> a >> c >> b;

    if (c == '-'){
        cout << a - b << endl;
    }
    else{
        cout << a + b << endl;
    }


    return 0;
}



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

#define int             long long
#define	ll				long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

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

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	int n,a,b;cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>

int main(void){
	char str[21];
	int len;
	
	scanf("%s",str);
	
	for(len=strlen(str)-1;len>=0;len--){
		printf("%c",str[len]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int A[3][3], N;
bool F[3][3] = { false };
vector<int> B;
int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}

	cin >> N;
	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;
		B.push_back(b);
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (A[i][j] == b) {
					F[i][j] = true;
				}
			}
		}
	}

	for (int i = 0; i < 3; i++) {
		if (F[i][0] && F[i][1] && F[i][2]) {
			cout << "Yes";
			return 0;
		}
	}
	for (int j = 0; j < 3; j++) {
		if (F[0][j] && F[1][j] && F[2][j]) {
			cout << "Yes";
			return 0;
		}
	}
	if (F[0][0] && F[1][1] && F[2][2]) {
		cout << "Yes";
		return 0;
	}
	if (F[0][2] && F[1][1] && F[2][0]) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;

}

Measured memory_bytes: 384
#include <iostream>

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

    int ans = 0;
    for(int i = 2; i <= n; ++i) {
        if(i % 2 == 0) {
            continue;
        }
        int cnt = 0;
        for(int j = 1; j <= n; ++j) {
            if(i % j == 0) {
                ++cnt;
            }
        }

        if(cnt == 8) {
            ++ans;
        }
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

int n,q;
int main(){
	cin >> n;
	int S[n];
	int count = 0;
	int data;
	for(int i = 0;i < n;i++){
		cin >> S[i];
	}
	cin >> q;
	for(int j = 0;j < q;j++){
		int d;
		cin >> d;
		for(int k = 0;k < n;k++){
			if(S[k] == d){
				count++;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1200
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <algorithm>
// #include "./Debug.h"

namespace AtCoder {
	using Input = std::vector<std::string>;
	using Num = std::vector<int>;

	Input input(void) {
		Input result;
		{
			std::string buf = "", row = "";
			std::getline(std::cin, buf);
			for (unsigned int i = 0; i < buf.size(); i++) {
				if (' ' == buf[i]) {
					result.push_back(row);
					row = "";
				} else {
					row += buf[i];
				}
			}
			result.push_back(row);
		}
		return result;
	}

	Num replaceToInteger(Input original = { "" }) {
		Num result;
		for (unsigned int i = 0; i < original.size(); i++) {
			result.push_back(atoi(original[i].c_str()));
		}
		return result;
	}
}

int main(void) {

	AtCoder::Input s = AtCoder::input();

	int w = 0, l = 0, buf = 0;
	unsigned int length = s[0].length();
	for (unsigned int i = 0; i < length; i++) {
		if ('o' == s[0][i]) {
			w++;
		} else {
			l++;
		}
	}
	buf = int(15 - s[0].length());
	
	if (8 <= (w + buf)) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 888
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const LL p=924844033,yg=5;
LL n;
struct node{
	LL y,next;
}a[400010];LL len=0,last[200010];
LL f[200010],inv[200010],A[800010],B[800010],bin[800010];
void ins(LL x,LL y)
{
	a[++len].y=y;
	a[len].next=last[x];last[x]=len;
}
void pre()
{
    f[0]=f[1]=inv[0]=inv[1]=1;
    for(LL i=2;i<=200000;i++) f[i]=f[i-1]*i%p,inv[i]=(p-p/i)*inv[p%i]%p;
    for(LL i=2;i<=200000;i++) inv[i]=inv[i-1]*inv[i]%p;
}
LL pow(LL a,LL b)
{
	LL ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%p;
		a=a*a%p;b>>=1;
	}
	return ans;
}
LL size[200010];
void ntt(LL *a,LL n,LL op)
{
    for(LL i=0;i<n;i++) bin[i]=(bin[i>>1]>>1)|((i&1)*(n>>1));
    for(LL i=0;i<n;i++) if(i<bin[i]) swap(a[i],a[bin[i]]);
    for(LL i=1;i<n;i<<=1)
    {
        LL wn=pow(yg,op==1?(p-1)/(2*i):(p-1)-(p-1)/(2*i)),w,t;
        for(LL j=0;j<n;j+=i<<1)
        {
            w=1;
            for(LL k=0;k<i;k++)
            {
                t=a[i+j+k]*w%p;w=w*wn%p;
                a[i+j+k]=(a[j+k]-t+p)%p;a[j+k]=(a[j+k]+t)%p;
            }
        }
    }
    if(op==-1)
    {
        LL Inv=pow(n,p-2);
        for(LL i=0;i<n;i++) a[i]=a[i]*Inv%p;
    }
}
void dfs(LL x,LL fa)
{
	size[x]=1;A[n]++;
	for(LL i=last[x];i;i=a[i].next)
	{
		LL y=a[i].y;
		if(y==fa) continue;
		dfs(y,x);size[x]+=size[y];
		A[size[y]]--;
	}
	if(n-size[x]) A[n-size[x]]--;
}
//LL C(LL m,LL n) {return f[m]*inv[m-n]%p*inv[n]%p;}
int main()
{
	scanf("%lld",&n);
	for(LL i=1;i<n;i++)
	{
		LL x,y;scanf("%lld %lld",&x,&y);
		ins(x,y);ins(y,x);
	}
	pre();dfs(1,0);
	for(LL i=0;i<=n;i++) B[i]=inv[i],A[i]+=A[i]<0?p:0,A[i]=A[i]*f[i]%p;
	reverse(B,B+n+1);
	LL N=1;while(N<(n+1)<<1) N<<=1;
	ntt(A,N,1);ntt(B,N,1);
	for(LL i=0;i<N;i++) A[i]=A[i]*B[i]%p;
	ntt(A,N,-1);
	for(LL i=1;i<=n;i++) printf("%lld\n",inv[i]*A[n+i]%p);
}

Measured memory_bytes: 41344
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC061
{
    class B
    {
        static void Main(string[] args)
        {

            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = input[0];
            int M = input[1];

            Dictionary<int, int> dict = new Dictionary<int, int>();

            int a = 0;
            int b = 0;

            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();

                a = input[0];
                b = input[1];

                if (!dict.ContainsKey(a)) { dict.Add(a, 0); }
                if (!dict.ContainsKey(b)) { dict.Add(b, 0); }

                if (dict.ContainsKey(a)) { dict[a]++; }
                if (dict.ContainsKey(b)) { dict[b]++; }

            }

            var res = dict.OrderBy(x => x.Key);

            for (int i = 1; i <= N; i++)
            {
                if (!dict.ContainsKey(i)) Console.WriteLine(0);
                else Console.WriteLine(dict[i]);
            }
        }
    }
}


Measured memory_bytes: 11604
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    for(int i=0;i<10001;i++){
        int h = sc.nextInt();
        int w = sc.nextInt();
        if(h==0 && w==0){
            break;
        } else {
           for(int j=0;j<h;j++){
               for(int k=0;k<w;k++){
                   System.out.print("#");
               }
               System.out.println();
           }
           System.out.println(); 
        }
    }
    sc.close();
  }
}



Measured memory_bytes: 37544
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[int(input())-1])

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main(void)
{
	int a[6];
	for (int i = 0; i < 6; i++) {
		cin >> a[i];
	}
	cout << ((a[4] - a[0] > a[5]) ? ":(" : "Yay!") << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _1295
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() == 0) break;
                int[] a = new int[30];
                int[] h1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
                foreach (int item in h1) a[item]++;
                int[] b = new int[30];
                int[] h2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
                foreach (int item in h2) b[item]++;
                int ret = 0;
                for (int i = 0; i < 30; i++) ret += i * Math.Max(a[i],b[i]);
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9584
<?php
fscanf(STDIN, "%s %s", $N,$Q);
fscanf(STDIN, "%s", $s);
$lr = [];
$ppp = [];
mas($s, $ppp);

for ($i = 0; $i<$Q; $i++) {
    fscanf(STDIN, "%s %s",$l,$r);
    
    if (substr($s, $l - 1, 1) === 'C' && substr($s, $l - 2, 1) === 'A' )
    {
        $ff = $ppp[$r-1] - $ppp[$l-1];
    } else {
        $ff = $ppp[$r-1] - $ppp[$l-1];
    }
    
    echo $ff."\n";
}

function mas($a, &$ppp) {
    $a = preg_split('//', $a, -1, PREG_SPLIT_NO_EMPTY);
    $ss = 0;
    $is_A_flag = 0;
    foreach ($a as $k => $s) {
        if ($s === 'A'){
            $is_A_flag = 1;
        } else if ($s === 'C' && $is_A_flag){
            $ss++;
            $is_A_flag = 0;
        } else {
            $is_A_flag = 0;
        }
        $ppp[$k] = $ss;
    }
}


Measured memory_bytes: 33036
from bisect import bisect_left
s = list(input())
t = list(input())
N = len(s)
if not set(t) <= set(s):
    print(-1)
    exit()
lis = [[] for _ in range(26)]
s = s+s
for i in range(2*N):
    alp = ord(s[i])-97
    lis[alp].append(i+1)
nex = [[0]*N for _ in range(26)]
for now in range(N):
    for alp in range(26):
        if not lis[alp]:
            continue
        i = bisect_left(lis[alp],now+1)
        #print(lis[alp],now+1,i)
        nex[alp][now] = lis[alp][i] - now
ans = 0
now = 0
tN = len(t)
for i in range(tN):
    alp = ord(t[i])-97
    ne = nex[alp][now]
    ans += ne
    if now+ne >= N:
        now += ne-N
    else:
        now += ne
    #print(now,ans)
print(ans)

Measured memory_bytes: 83208
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let n: usize = util::get();
    let s = (0..n).map(|_| util::get::<usize>());

    let mut dp: HashSet<usize> = HashSet::new();
    dp.insert(0);

    for x in s {
        let prev: Vec<usize> = dp.iter().cloned().collect();

        for y in prev.iter() {
            dp.insert(x + y);
        }
    }

    let mut total: Vec<usize> = dp.iter().cloned().collect();
    total.sort();

    println!("{}",
             total.into_iter().rev().find(|&x| x % 10 != 0).unwrap_or(0));
}


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

using namespace std;

int main()
{
   long long int n, m;
  cin>>n>>m;
   long long int temp;
  temp = n % m;
  if(temp > abs(temp - m))
    cout<<abs(temp-m);
  else
    cout<<temp;
  return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, M = sc.nextInt()
    val A = Array.fill(N)(Set[Int]())

    (0 until N) foreach { i =>
      val k = sc.nextInt()
      (0 until k) foreach { _ =>
        val a = sc.nextInt()
        A(i) = A(i) + a
      }
    }

    val r = (1 to M) count { a =>
      A.forall(_.contains(a))
    }

    println(r)
  }

}


Measured memory_bytes: 27588
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
const int N=105;
short f[N][N][N][N],col[N][N],row[N][N],res;
char mp[N][N];int n,m,x,y;
inline int min(R int x,R int y){return x<y?x:y;}
inline int max(R int x,R int y){return x>y?x:y;}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m);
	fp(i,1,n){
		scanf("%s",mp[i]+1);
		fp(j,1,m){
			if(mp[i][j]=='E')x=i,y=j;
			col[i][j]=col[i][j-1]+(mp[i][j]=='o'),
			row[i][j]=row[i-1][j]+(mp[i][j]=='o');
		}
	}
	fp(u,0,x-1)fp(d,0,n-x)if(u+d<max(x,n-x+1))
		fp(l,0,y-1)fp(r,0,m-y)if(l+r<max(y,m-y+1)){
			R short &ret=f[u][d][l][r];
			int tl=max(r+1,y-l),tr=min(y+r,m-l),tu=max(d+1,x-u),td=min(x+d,n-u);
			if(u+1+d<x)cmax(f[u+1][d][l][r],short(ret+col[x-u-1][tr]-col[x-u-1][tl-1]));
			if(d+1+u<=n-x)cmax(f[u][d+1][l][r],short(ret+col[x+d+1][tr]-col[x+d+1][tl-1]));
			if(l+1+r<y)cmax(f[u][d][l+1][r],short(ret+row[td][y-l-1]-row[tu-1][y-l-1]));
			if(r+1+l<=m-y)cmax(f[u][d][l][r+1],short(ret+row[td][y+r+1]-row[tu-1][y+r+1]));
			cmax(res,ret);
//			printf("%d %d %d %d %d\n",u,d,l,r,f[u][d][l][r]);
//			printf("%d %d %d %d\n",tl,tr,tu,td);
		}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 205056
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

signed main(){
	int n,k=0;
	cin>>n;
	bool judge;
	ll ans=0,cnt=0;
	vector<ll>fact(n+1,0);
	rep(i,n)fact[i+1]=fact[i]+(i+1);
	vector<string>s(n);
	rep(i,n){
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s.begin(),s.end());
	for(int i=1;i<n;++i){
		judge=true;
		rep(j,11){
			if(s[i][j]!=s[k][j]){
				judge=false;
				k=i;
				break;
			}
		}
		if(judge)++cnt;
		else {
			ans+=fact[cnt];
			cnt=0;
		}
	}
	ans+=fact[cnt];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;

#define MAX_N 100010
//d,edge,g,P,q
lint d[MAX_N];
struct edge{
	int to;
	lint cost;
};
vector<edge> g[MAX_N];
typedef pair<lint,int> P;
priority_queue<P,vector<P>,greater<P> > q;

void pfs(int s){
	d[s]=0;q.push({0,s});
	lint cd;int v;
	while(q.size()){
		cd=q.top().first;v=q.top().second;q.pop();
		if(d[v]<cd)continue;
		for(edge &e:g[v])if(cd+e.cost<d[e.to]){
			d[e.to]=cd+e.cost;
			q.push({d[e.to],e.to});
		}
	}
}

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

	lint v,e,r;cin>>v>>e>>r;
	for(int i=0;i<v;++i)d[i]=INT_MAX;
	int a,b;lint c;
	for(int i=0;i<e;++i){
		cin>>a>>b>>c;
		g[a].push_back({b,c});
	}pfs(r);
	for(int i=0;i<v;++i){
		if(d[i]==INT_MAX)cout<<"INF\n";
		else cout<<d[i]<<endl;
	}
}



Measured memory_bytes: 19492
#include <iostream>
using namespace std;
 
int main() {
  
  
  int a, b, c;
  
  cin >> a >> b >> c;
  
  if(a + b + c < 22){
    cout << "win";
  }
  else
    cout << "bust";
  
  cout << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 100
#define M_MAX 1000
#define INF 10000000
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int d[M_MAX];
int n, m;

int i, j, k;

int e[M_MAX][2];

void deb(){
	return;
}

void solve(){
	return;
}

int main (void) {
	char x;
	scanf("%d %c %d\n", &i, &x, &k);

	printf("%d\n", i + ((x == '+')? k : -k));

	solve();
	return 0;
}




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

using namespace std;

const int INF = 1e9 + 7;

int n, m;

void solve()
{
  cin >> n >> m;
  if (max(n, m) - min(n, m) > 1) {
    cout << "0\n";
    return;
  }
  long long ans = 1 * (1 + (n == m));
  for(int i = 1; i <= n; i++) {
    ans *= i;
    ans %= INF;
  }
  for(int i = 1; i <= m; i++) {
    ans *= i;
    ans %= INF;
  }
  cout << ans << "\n";
}

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

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

using namespace std;

//#define int long long
typedef long long ll;
typedef long double db;
const int inf = 2e9;

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

    // srand(time(0));
    /*
    freopen("anniversary.in", "w", stdout);
    freopen("anniversary.out", "w", stdo);
    */

    ll a;
    db b;
    cin >> a >> b;
    cout << ll((a*rint(b*100))/100);
    return 0;
}


Measured memory_bytes: 3724
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

n,m,R=MI()
r=LI_()
g=[[] for _ in range(n)]
for i in range(m):
    a,b,c=LI_()
    g[a].append((b,c+1))
    g[b].append((a,c+1))

show(g)
inf=float('inf')
def wf(e):
    n=len(e)
    d=[[inf]*n for _ in range(n)]
    for a in range(n):
        for b,c in g[a]:
            d[a][b]=c
            d[b][a]=c
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j]>d[i][k]+d[j][k]:
                    d[i][j]=d[i][k]+d[j][k]
    
    return d

ans=inf
md=wf(g)
dists=[]
def search(st,d,ls):
    if len(ls)==1:
        dists.append(d+md[st][ls[0]])
        return
    for gl in ls:
        search(gl,d+md[st][gl],[i for i in ls if i!=gl])
    return

for i in r:search(i,0,[j for j in r if i!=j])
print(min(dists))


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

int dp[5005][5005];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    string s;
    cin >> n >> s;
    rrep(i, n) rrep(j, n) if (s[i] == s[j]) dp[i][j] = dp[i+1][j+1] + 1;
    int ans = 0;
    rep(i, n) rep(j, n) {
        if (i >= j) continue;
        int tmp = min(dp[i][j], j - i);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 98048
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

long long gcd(long long a, long long b){
	if (b == 0) return a;
	return gcd(b, a % b);
}
 
long long lcm(long long a, long long b){
	if (b > a) swap(a, b);
	return a / gcd(a, b) * b;
}


int main(){
	
	long long N,M;
	cin>>N>>M;
	
	vector<long long> A(N);
	
	long long L = 1;
	
	for(int i=0;i<N;i++){
		cin>>A[i];
		L = lcm(L,A[i]/2);
		if(L>M){
			cout<<0<<endl;
			return 0;
		}
	}
	
	for(int i=0;i<N;i++){
		if(L % A[i] != A[i]/2){
			cout<<0<<endl;
			return 0;
		}
	}
	
	cout<<(1+(M/L))/2<<endl;
	
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> per(n);
    for (int i=0; i<n; i++) cin >> p[i];
    for (int i=0; i<n; i++) cin >> q[i];
    per = p;

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

    int cnt = 1;
    int pi,qi;
    do {
        if (p == per) pi = cnt;
        if (q == per) qi = cnt;
        cnt++;
    } while (next_permutation(per.begin(), per.end()));

    cout << abs(pi - qi) << endl;
}

Measured memory_bytes: 888