akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;


int changeNum(string s){
  int num=0;
  
  for(int i=0;i<s.size();i++){
    if(s[i]=='m'){
      if(i==0||(s[i-1]<'1'&&'9'<s[i-1]))num+=1000;
      else num+=(s[i-1]-'0')*1000;
    }else if(s[i]=='c'){
      if(i==0||(s[i-1]<'1'&&'9'<s[i-1])||s[i-1]=='m')num+=100;
      else num+=(s[i-1]-'0')*100;
    }else if(s[i]=='x'){
      if(i==0||(s[i-1]<'1'&&'9'<s[i-1])||s[i-1]=='m'||s[i-1]=='c')num+=10;
      else num+=(s[i-1]-'0')*10;
    }else if(s[i]=='i'){
      if(i==0||(s[i-1]<'1'&&'9'<s[i-1])||s[i-1]=='m'||s[i-1]=='c'||s[i-1]=='x')num+=1;
      else num+=(s[i-1]-'0');
    }
   
  }
  return num;
}

int main(){
  int num1,num2,ans;
  string s1,s2;
  int Number;

  cin>>Number;
  for(int i=0;i<Number;i++){
    cin>>s1>>s2;

    num1=changeNum(s1);
    num2=changeNum(s2);
    ans=num1+num2;

    if(ans/1000!=0){
      if(ans/1000!=1)cout<<ans/1000<<"m";
      else cout<<"m";
      ans%=1000;
    }
    if(ans/100!=0){
      if(ans/100!=1) cout<<ans/100<<"c";
      else cout<<"c";
      ans%=100;
    }
    if(ans/10!=0){
      if(ans/10!=1)cout<<ans/10<<"x";
      else cout<<"x";
      ans%=10;
    }

    if(ans!=0){
      if(ans!=1)cout<<ans<<"i";
      else cout<<"i";
    }
    
    cout<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll A,B;
    cin>>A>>B;
    cout<<A*B<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int h,w;

bool comp(int h1,int w1,int h2,int w2) {
    if(h1*h1+w1*w1 < h2*h2+w2*w2) {
        return true;
    }
    else if(h1*h1+w1*w1 > h2*h2+w2*w2) {
        return false;
    }
    return h1<h2;
}

void solve() {
    vector<pair<int,int> > vec;
    for(int i=1;i<=300;i++) {
        for(int j=1;j<=300;j++) {
            if(j>i&&comp(h,w,i,j)) {
                vec.push_back(make_pair(i,j));
            }

        }
    }
    int ansH,ansW;
    ansH=vec[0].first;
    ansW=vec[0].second;
    for(int i=1;i<vec.size();i++) {
        if(comp(vec[i].first,vec[i].second,ansH,ansW)) {
            ansH=vec[i].first;
            ansW=vec[i].second;
        }
    }
    cout<<ansH<<" "<<ansW<<endl;
    

}
int main() {
    while(cin>>h>>w) {
        if(h+w==0) return 0;
        solve();
    }

}

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

int a, b;
char c = '+';

int main() {
    for (;c != '?';) {
        cin >> a >> c >> b;
        if (c == '+') cout << a + b << endl;
        if (c == '-') cout << a - b << endl;
        if (c == '*') cout << a * b << endl;
        if (c == '/') cout << a / b << endl;
    }
}


Measured memory_bytes: 3120
if __name__ == '__main__':
    x1, y1, x2, y2 = map(int, input().split())

    dx = x2 - x1
    dy = y2 - y1

    x3 = x2 - dy
    y3 = y2 + dx

    x4 = x3 - dx
    y4 = y3 - dy

    print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))




Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b,sum,MIN=5000;
  cin >> a >> b;
  rep(i,a){
    sum += b+i;
    if(abs(MIN)>abs(b+i))MIN=b+i;
  }
  cout << sum - MIN;
}


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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  double a=0;
  for (int i = 0; i < N; i++) {
    a += 1.0/A.at(i);
  }

  cout << 1/a;
  
}

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

using namespace std;

#define int long long
#define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll dp[100001];

signed main() {
    LCIN(N);
    VL h(N);
    VECCIN(h);
    Fill(dp, LINF);
    dp[0] = 0;
    FOR(i, 1, N) {
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i - 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << "\n";
}


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


int main (){
    int N;
    cin>>N;
    int Hund=N/100;
    int Zoro=Hund*100+Hund*10+Hund;
  	if(Zoro<N){
    	Hund ++;
  	}
  	cout<<Hund*100+Hund*10+Hund<<endl;
}

Measured memory_bytes: 256
import sys


# Python3

class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

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

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


n, m = map(int, input().split())
bridges = list(sys.stdin)
bridges.reverse()
buf = [n * (n - 1) // 2]
uft = UnionFind(n)
for line in bridges[:-1]:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    if uft.find(a, b):
        buf.append(buf[-1])
        continue
    ra = uft.table[uft._root(a)]
    rb = uft.table[uft._root(b)]
    buf.append(buf[-1] - ra * rb)
    uft.union(a, b)
buf.reverse()
print('\n'.join(map(str, buf)))


Measured memory_bytes: 24280
#include <stdio.h>
int main(void)
{
    int n, rank, i;
    char mark;
    int s[13] = {0};
    int h[13] = {0};
    int c[13] = {0};
    int d[13] = {0};

    scanf("%d", &n);

    for (i = 1; i <= n; i++)
    {
        scanf(" %c", &mark);
        scanf("%d", &rank);

        if (mark == 'S')
        {
            s[rank - 1] = 1;
        }
        if (mark == 'H')
        {
            h[rank - 1] = 1;
        }
        if (mark == 'C')
        {
            c[rank - 1] = 1;
        }
        if (mark == 'D')
        {
            d[rank - 1] = 1;
        }
    }
    for (rank = 1; rank <= 13; rank++)
    {
        if (s[rank - 1] == 0)
        {
            printf("S %d\n", rank);
        }
    }
    for (rank = 1; rank <= 13; rank++)
    {
        if (h[rank - 1] == 0)
        {
            printf("H %d\n", rank);
        }
    }
    for (rank = 1; rank <= 13; rank++)
    {
        if (c[rank - 1] == 0)
        {
            printf("C %d\n", rank);
        }
    }
    for (rank = 1; rank <= 13; rank++)
    {
        if (d[rank - 1] == 0)
        {
            printf("D %d\n", rank);
        }
    }
}


Measured memory_bytes: 2740
def cmb(n):
    return int(n * (n-1) / 2)

def main():

    N = int(input())

    a_l = [0] * N

    nums = list(map(int, input().split()))
    for i in nums:
        a_l[i-1] += 1

    total = 0
    for j in a_l:
        if j > 1:
            total += cmb(j)

    for k in nums:
        if a_l[k-1] > 1:
            print(total - cmb(a_l[k-1]) + cmb(a_l[k-1] - 1))
        else:
            print(total)


if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int N;
vi L;

ll solve() {
    sort(ALL(L));
    ll ans = 0;
    REP (a, N) FOR (b, a+1, N) {
        int cc = L[a] + L[b];
        int ok = b, ng = N;
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if (L[mid] < cc) ok = mid;
            else ng = mid;
        }
        ans += ok - b;
    }
    return ans;
}

int main() {
    cin >> N;
    L = vi(N);
    REP (i, N) cin >> L[i];
    cout << solve() << endl;
}

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

int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]-'0'==1){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int N; cin >> N;
    int x[N], y[N];
    long long h[N];
    // 高さが0でない座標の要素番号
    int m = 0;
    for(int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) m = i;
    }
    for (int cx = 0; cx < 101; cx++) {
        for (int cy = 0; cy < 101; cy++) {
            long long tmpH = h[m] + abs(x[m] - cx) + abs(y[m] - cy);
            bool f = true;
            for (int i = 0; i < N; ++i) {
                if (h[i] > 0) f &= tmpH == h[i] + abs(x[i] - cx) + abs(y[i] - cy);
                else f &= 0 >= tmpH - abs(x[i] - cx) - abs(y[i] - cy);
            }
            if (f) {
                cout << cx << " " << cy << " " << tmpH << endl;
                break;
            };
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string a, b;
  cin >> a >> b;
  int s = stoi(a + b);
  for(int i = 1; i <= 1000; i++){
    if(s == i * i){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,k,x,y,an[300];

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

    if(a>b){
        if(a-b<2*k){
            for(x=b;x<=a;x++){
                printf(" %d\n",x);
            }
            return 0;
        }
    }
    else{
        if(b-a<2*k){
            for(x=a;x<=b;x++){
                printf(" %d\n",x);
            }
            return 0;
        }
    }

    for(x=a;x<a+k;x++)
        printf("%d\n",x);
    for(x=b-k+1;x<=b;x++)
        printf("%d\n",x);


    return 0;
}


Measured memory_bytes: 256
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(i):
                print(j + 1)
            for j in range(n - 1, i, -1):
                print(j)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 14052
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
int main()
{
	int a, b,c,d,ans=-1;
	cin >> a >> b;
	
	for (int i = 1;i<10001; i++)
	{
		c = i * 0.08;
		d = 0.1 * i;
		if (a == c && b == d)
		{
			ans =i;
			break;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 303, M = 998244353;
ll qpow(ll a,ll b)
{
    ll r = 1;
    for (;b;b>>=1,a=a*a%M)
        if (b & 1)
            r = r * a % M;
    return r;
}
bitset<N> a[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    cin >> n >> m;
    for (ll i = 0; i < n; ++i)
        for (ll j = 0; j < m; ++j) {
            ll x;
            cin >> x;
            a[i][j] = x;
        }
    ll r = 0;
    for (ll i = 0; i < n; ++i) {
        ll j = a[i]._Find_first();
        if (j >= m)
            continue;
        ++r;
        for (ll k = i + 1; k < n; ++k)
            if (a[k][j])
                a[k] ^= a[i];
    }
    cout << (qpow(2,n) + M - qpow(2,n-r)) * qpow(2,m-1) % M << endl;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
    "math"
)

func main() {
    var N int
    var txy [][]int
    fmt.Scan(&N)
    txy = make([][]int, N)
    for i := 0; i < N; i++ {
        txy[i] = make([]int, 3)
        var t, x, y int
        fmt.Scan(&t, &x, &y)
        txy[i][0] = t
        txy[i][1] = x
        txy[i][2] = y
    }
    flag := true
    for i := 0; i < N; i++ {
        var t, x, y int
        if i == 0 {
            t = txy[i][0]
            x = txy[i][1]
            y = txy[i][2]
        } else {
            t = int(math.Abs(float64(txy[i][0] - txy[i-1][0])))
            x = int(math.Abs(float64(txy[i][1] - txy[i-1][1])))
            y = int(math.Abs(float64(txy[i][2] - txy[i-1][2])))
        }
        diff := x + y
        if t < diff {
            flag = false
        }
        if int(math.Abs(float64(t-diff)))%2 != 0 {
            flag = false
        }
    }
    if flag {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

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

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, a[100007], dp[100007];

int main () {
    fastIO;
    cin >> n;
    for(li i = 0; i < n; i ++) { cin >> a[i]; dp[i]=1e9; }
    dp[0]=0;
    for(li i = 0; i < n; i ++) {
        dp[i+1]=min(dp[i+1], dp[i]+abs(a[i]-a[i+1]));
        dp[i+2]=min(dp[i+2], dp[i]+abs(a[i]-a[i+2]));
    }
    cout << dp[n-1];
}


Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

int move[60][200005];


int main(){
  int N;
  scanf("%d", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
    A[i]--;
  }
  int D=60;
  for (int j=0; j<N; j++){
    move[0][j]=A[j];
  }
  for (int i=1; i<D; i++){
    // 2^iを計算
    for (int j=0; j<N; j++){
      move[i][j]=move[i-1][move[i-1][j]];
    }
  }
  int pos=0;
  for (int i=0; i<D; i++){
    if ((((long long)1<<i) & K) != 0){
      //printf("i=%d, pos=%d\n", i, pos);
      pos = move[i][pos];
      //printf("i=%d, pos=%d\n", i, pos);
    }
  }
  std::cout << pos+1 << std::endl;

  return 0;
}

Measured memory_bytes: 50696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

ll ME = 5050;
vector<vp> g(2600);
ll n, m;
vll a(ME), b(ME), c(ME), score(ME);
ll ans = -INF;

void bf(){
    score[1] = 0;
    repr(i, 2, n+1){
        score[i] = INF;
    }
    for(ll i = 0;; i++){
        bool finf = 0;
        bool finfv = 0;
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            if(score[v] > score[u] + c[j]){
                score[v] = score[u] + c[j];
                finf = 1;
                if(v == n){
                    finfv = 1;
                }
            }
        }
        if(!finf){
            ans = score[n];
            return;
        }
        if(finfv && i >= n){
            ans = INF;
            return;
        }
        if(i >= 3 * n){
            ans = score[n];
            return;
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll p;
    cin >> n >> m >> p;
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        c[i] -= p;
        c[i] = -c[i];
        g[a[i]].emplace_back(b[i], c[i]);
    }
    bf();
    if(ans < INF){
        cout << max(-score[n], 0LL) << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  printf("%d\n", (n-1)*(m-1));
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            // 入力
            var fIntArr = cin.ReadIntArray(2);
            var n = fIntArr[0];
            var x = fIntArr[1];

            var lList = cin.ReadIntArray(n).ToList();
            var point = 0;
            var result = 1;
            for (int i = 1; i < n + 1; i++)
            {
                point += lList[i - 1];
                if (point <= x)
                {
                    result += 1;
                }
            }
            WriteLine(result);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    List<Statement>[] statements = new List[N];
    for (int i = 0; i < N; i++) {
      statements[i] = new ArrayList<>();
      int a = scanner.nextInt();
      for (int j = 0; j < a; j++) {
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        statements[i].add(new Statement(x - 1, y == 1));
      }
    }

    int max = 0;
    loop:
    for (int i = 0; i < (1 << N); i++) {
      for (int j = 0; j < N; j++) {
        if (((1 << j) & i) != 0) {
          for (Statement s : statements[j]) {
            if (((1 << s.who) & i) == 0 && s.honest) continue loop;
            if (((1 << s.who) & i) != 0 && !s.honest) continue loop;
          }
        }
      }
      max = Math.max(max, Integer.bitCount(i));
    }
    System.out.println(max);
  }

  private static class Statement {
    final int who;
    final boolean honest;

    private Statement(int who, boolean honest) {
      this.who = who;
      this.honest = honest;
    }
  }
}


Measured memory_bytes: 25940
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	
	set<int> cur;
	for (int i = 1; i <= m; i++) cur.insert(i);
	
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		
		set<int> S;
		for (int j = 0; j < x; j++) {
			int t; cin >> t;
			if (cur.count(t)) S.insert(t);
		}
		cur = S;
	}
	cout << (int)cur.size() << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n;
  cin>>n;
  cin>>s;
  //int n=s.length();
  int left=0,right=0;
  int ans=0;
  while(left<n){
	while(s[left]==s[right] && right<n)
      right++;
    ans++;
    left=right;
  }
  cout<<ans;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> v[i];
    sum += v[i];
  }
  int m;
  cin >> m;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    int k;
    k = sum - v[a - 1] + b;
    cout << k << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);

		str = br.readLine().split(" ");

		long a[] = new long[n + 10];
		long s[] = new long[n + 10];

		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		s[0] = a[0];
		for (int i = 1; i < n; i++) {
			s[i] = s[i - 1] + a[i];
		}

		for (int i = k; i < n; i++) {
			long right = s[i] - s[i - k];
			long left = s[i - 1];

			if (i - k > 0) {
				left -= s[i - k - 1];
			}

			if (left < right) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 65644
#!/usr/bin/env pypy3

#import numpy as np
#import scipy, scipy.special

# Python 3 modules: https://docs.python.org/3/library/

import math, itertools, operator
from math import *
from math import factorial as fact
from operator import itemgetter, attrgetter
from itertools import permutations, combinations
from functools import reduce
# Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
# Before Python 3.5
from fractions import gcd

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

################################################################################

N = int(input())

l = []
for n in range(N):
    s, p = input().split()
    p = int(p)
    l.append((s, p, n))
l.sort(key = lambda x: (x[0], -x[1]))
for i in l:
    print(i[2]+1)


Measured memory_bytes: 5636
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

from collections import Counter

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, s = [int(s) for s in input().strip().split()]
    A = [int(s) for s in input().strip().split()]

    M = 998244353
    dp = Counter()
    dp[0] = 1
    result = 0
    for a in A:
        dp2 = Counter(dp)
        dp2[0] += 1
        for k, v in dp.items():
            if k + a <= s:
                dp2[k + a] = (dp2[k + a] + dp[k]) % M
        dp = dp2
        # print(dp)
        result = (result + dp[s]) % M
    print(result)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n;i++){
    cout << s.at(i) << t.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, p;
    cin >> a >> p;
    cout << (a*3 + p) / 2 << endl;
    return 0;
}


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

using namespace std;


int main()
{
	int N;
	vector<int> As;

	cin >> N;

	int a;
	for (int ai = 0; ai < N; ai++) {
		cin >> a;
		As.push_back(a);
	}
	As.push_back(-1);

	int cnt = 1;
	int ans = 0;
	for (int ai = 1; ai < N+1; ai++) {
		if (As[ai] == As[ai - 1]) { 
			cnt++; 
		}
		else {
			ans += cnt / 2;
			cnt = 1;
		}
	}

	cout << ans;

	return 0;
}



Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var numsS = Array.ConvertAll(Console.ReadLine().TrimEnd().Split(), int.Parse);
            Console.ReadLine();
            var numsT = Array.ConvertAll(Console.ReadLine().TrimEnd().Split(), int.Parse);
            int ans = 0;

            for (int i = 0; i < numsT.Length; i++)
            {
                var right = numsS.Length;
                var left = 0;

                if ((numsT[i] <= numsS[right - 1]) && (numsT[i] >= numsS[left]))
                {
                    var mid = numsS.Length / 2;

                    while (left < right)
                    {
                        if (numsT[i] < numsS[mid])
                        {
                            right = mid;
                            mid = (right - left) / 2 + left;
                        }
                        else if (numsT[i] > numsS[mid])
                        {
                            left = mid + 1;
                            mid = (right - left) / 2 + left;
                        }
                        else
                        {
                            ans++;
                            break;
                        }
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 19956
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    for (int i = 0; ; i++) {
        int rest = n - 4 * i;
        if (rest < 0) {
            break;
        }
        if (rest % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int kotae = 0;
	int N;
	cin >> N;
	int ima = 0;
	rep(i, N) {
		int h;
		cin >> h;
		if (h >= ima) kotae++;
		ima = max(ima, h);
	}
	co(kotae);

	Would you please return 0;
}

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

using namespace std;

int main() {
	long long int a, b, c, d;

	cin >> a >> b >> c >> d;

	long long int ans = -1e18L+5;

	ans = max(ans, a*c);
	ans = max(ans, b*c);
	ans = max(ans, a*d);
	ans = max(ans, b*d);

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return (x * 1ll * y) % MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        string str,ptr;
        cin>>str>>ptr;
        lld ans=1;
        for(i=0;i<str.length();i++)
            if(str[i]!=ptr[i])
            ans=0;
        if(ans)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}



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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = first[b]; a; a = edge[a].nxt)

int n;

map<string, int> M;

string a;

void _main () {
    scanf ("%d", &n);

    long long ans = 0;
    REP (i, 1, n) {
        cin >> a;
        sort(a.begin(), a.end());
        ans += M[a];
        ++M[a];
    }
    printf ("%lld\n", ans);
}

int main () {
//#ifdef LOCAL
    //freopen("in.txt", "r", stdin);
//#endif
    _main();   
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
using namespace std;
int main(void){
	int list[3];
	int tmp;
	cin >> list[0] >> list[1] >> list[2];

	for(int i = 0; i < 2; i++){
		for(int j = 1; j < 3; j++){
			if(list[i] > list[j]){
				tmp = list[i];
				list[i] = list[j];
				list[j] = tmp;
			}
		}
	}
	cout << list[0] << " " << list[1] << " " << list[2] << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int a, b; cin >> a >> b;
  if (a<10 && b<10) {
    cout << a*b << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M;
  cin >> N >> M;
  ll xyz[N + 1][3];
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> xyz[i][j];
    }
  }

  ll maxn = -(1LL << 60);
  for (int i = 0; i < 8; i++) {
    vector<ll> vec;
    for (int j = 1; j <= N; j++) {
      ll S = 0;
      for (int k = 0; k < 3; k++) {
        if ((i / (1 << k)) % 2 == 0)
          S += xyz[j][k];
        else
          S -= xyz[j][k];
      }
      vec.push_back(S);
    }
    sort(vec.begin(), vec.end(), greater<ll>());
    ll ans = 0;
    for (int j = 0; j < M; j++)
      ans += vec[j];
    maxn = max(maxn, ans);
  }
  cout << maxn << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int X;
    scanf("%d",&X);
    if(X == 1 || X == 8 || X == 15 || X == 22 || X == 29)
    	printf("fri\n");
    else if(X == 2 || X == 9 || X == 16 || X == 23 || X == 30)
    	printf("sat\n");
    else if(X == 3 || X == 10 || X == 17 || X == 24)
    	printf("sun\n");
    else if(X == 4 || X == 11 || X == 18 || X == 25)
    	printf("mon\n");
    else if(X == 5 || X == 12 || X == 19 || X == 26)
    	printf("tue\n");
    else if(X == 6 || X == 13 || X == 20 || X == 27)
    	printf("wed\n");
    else if(X == 7 || X == 14 || X == 21 || X == 28)
    	printf("thu\n");
    return 0;
}


Measured memory_bytes: 2128
import java.util.Scanner;

public class Main {
    static long MOD = 109 + 7;

    static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }


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

        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();

        int gcd = a[0];
        int max = a[0];
        for(int i = 1; i < n; i++) {
            gcd = gcd(gcd, a[i]);
            max = Math.max(max, a[i]);
        }

        String POSSIBLE = "POSSIBLE";
        String IMPOSSIBLE = "IMPOSSIBLE";
        if(k > max) {
            System.out.println(IMPOSSIBLE);
        } else if(k % gcd != 0) {
            System.out.println(IMPOSSIBLE);
        } else {
            System.out.println(POSSIBLE);
        }
    }
}

Measured memory_bytes: 49008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a[30]={},sum=0;
	string s;
	cin>>s;
	for(int i=0;i<4;i++)
	{
		a[s[i]-'A']++;
	}
	for(int i=0;i<26;i++)
	{
		if(a[i]==2)sum++;
	}
	if(sum==2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 384
import math
import sys
n=int(input())
s=int(input())
root=int(math.ceil(math.sqrt(n)))

buf=10**12
if s==n:
    print(n+1)
    sys.exit()
for i in range(1,root):
    res=s-i
    x=(n-res)//i
    if x*i+res==n and x>1 and x>res and res>=0:
        #print(x,i,res,s,n)
        buf=min(buf,x)
#print(buf)
for i in range(2,root+1):
    count=0
    b=n
    while(b!=0):
        count+=b%i
        b=b//i
    if count==s:
        buf=i
        break
print(buf if buf!=10**12 else -1)

Measured memory_bytes: 41648
N = int(input())

D1, D2 = [0] * N, [0] * N

for i in range(N):
    a, b = map(int, input().split())

    D1[i], D2[i] = a, b

for i in range(2, N):

    if D1[i-2] == D2[i-2] and D1[i-1] == D2[i-1] and D1[i] == D2[i]:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 62344
n=int(input())
a=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(62):
	cnt=0
	for j in range(n):
		if (a[j]>>i)&1:
			cnt+=1
	ans += cnt*(n-cnt)%mod*pow(2,i,mod)%mod
	ans%=mod
print(ans)

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

int main(){
  ll n,x;
  cin >> n >> x;
  vector<ll> a(n);
  ll total = 0;
  rep(i,n){
    cin >> a[i];
    total += a[i];
  }
  ll ans = 0;
  if(total < x) ans = n-1;
  else if(total == x) ans = n;
  else{
    sort(a.begin(),a.end());
    rep(i,n){
      if(x == a[i]){
        ans = i+1;
        break;
      }
      else if(x < a[i]){
        ans = i;
        break;
      }
      x -= a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
S=[]
for _ in range(H):
    S.append(list(input()))

from collections import deque

que=deque()
maxx=0

for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            continue
        ans=[[500]*W for _ in range(H)]
        ans[i][j]=0
        que.append((i,j))
        while que:
            h,w=que.popleft()
            if h!=0 and S[h-1][w]==".":
                if ans[h-1][w]==500:
                    ans[h-1][w]=min(ans[h-1][w],ans[h][w]+1)
                    que.append((h-1,w))
            if h!=H-1 and S[h+1][w]==".":
                if ans[h+1][w]==500:
                    ans[h+1][w]=min(ans[h+1][w],ans[h][w]+1)
                    que.append((h+1,w))
            if w!=0 and S[h][w-1]==".":
                if ans[h][w-1]==500:
                    ans[h][w-1]=min(ans[h][w-1],ans[h][w]+1)
                    que.append((h,w-1))
            if w!=W-1 and S[h][w+1]==".":
                if ans[h][w+1]==500:
                    ans[h][w+1]=min(ans[h][w+1],ans[h][w]+1)
                    que.append((h,w+1))
            maxx=max(maxx,ans[h][w])
print(maxx)  


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
   // freopen("input.txt","r",stdin);
    FastIO;

    string s;
    while(cin>>s){
        int n = s.size();
        vector<int>R(n,0), L(n,0);
        R[0] = L[n-1] = 1;
        for(int i=1; i<s.size(); i++){
            if(s[i] == 'R') R[i] = R[i-1] + 1;
        }
        for(int i=n-2; i>=0; i--){
            if(s[i] == 'L') L[i] = L[i+1] + 1;
        }

        vector<int>res(n,0);
        for(int i=0; (i+1) < n; i++){

            if(!(s[i]=='R' && s[i+1] == 'L')) continue;
            int h = (R[i]+L[i+1])/2;

            if((R[i]+L[i+1])%2 == 0){
                res[i] = res[i+1] = h;
            }
            else{
                    res[i] = h+(R[i]>L[i+1]);
                    res[i+1] = h+(R[i]<L[i+1]);
                    int mx = max(R[i],L[i+1])-1;
                    if(mx%2) swap(res[i],res[i+1]);
            }
        }
        for(int i : res) cout<<i<<" ";
        cout<<endl;
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


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

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(3100, vector<int>(3100, -1));
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }
    string ans;
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) --i;
        else if (dp[i][j] == dp[i][j - 1]) --j;
        else {
            ans.append(1, s[i - 1]);
            --i, --j;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 38016
#include <cstdio>
#include <cstdlib>

int n,l;

int main()
{
	scanf("%d %d",&n,&l);
	int p=999999999;
	for(int i=1;i<=n;i++)
		if(abs(i+l-1)<abs(p+l-1))p=i;
	printf("%d",(l-1+n+l)*n/2-(p+l-1));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110];
int main(){
    ll n,ans=0;
    cin>>n;
    bool p=false;
    rep(i,1,n+1){
        ld x=1.08*i;
        ll z=(ll)x;
        if(z==n){p=true;ans=i;break;}
    }
    if(p)cout<<ans;
    else cout<<":(";
}


Measured memory_bytes: 256
def solve(n, y):
    for man in range(n + 1):
        for gosen in range(n - man + 1):
            sen = n - man - gosen
            if 10000*man + gosen*5000 + sen*1000 == y and man + gosen + sen == n:
                print('{} {} {}'.format(man, gosen, sen))
                return
    print("-1 -1 -1")
    return            

#main
n, y = map(int, raw_input().split())
solve(n, y)




Measured memory_bytes: 2692