akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <istream>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cmath>


using namespace std;


int to_int(char c) {
    return c - '0';
}


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

    vector<int> d(k);
    for (int i=0; i<k; ++i) cin >> d[i];

    bool is_valid;
    for (int i=n; i<=10*n; ++i) {

        is_valid = true;

        for (char c: to_string(i)) {
            if (find(d.begin(), d.end(), to_int(c)) != d.end()) {
                is_valid = false; break;
            }
        }

        if (is_valid) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256
using System;

namespace ABC104A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string str;
            if(a < 2800){
                if(a < 1200){
                    str = "ABC";
                }else{
                    str = "ARC";
                }
            }else{
                str = "AGC";
            }
            Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
using namespace std;

void printsgn(int i) {
	if (i >= 0) {
		printf("+");
	}
	else {
		printf("-");
	}
}

int main() {
	int n, a, b, c, d;
	scanf("%d", &n);
	a = n / 1000;
	b = (n - a * 1000) / 100;
	c = (n - (a * 1000 + b * 100)) / 10;
	d = n - (a * 1000 + b * 100 + c * 10);
	for (int i = -1; i <= 1; i=i+2) {
		for (int j = -1; j <= 1; j=j+2) {
			for (int k = -1; k <= 1; k=k+2) {
				if (a + i*b + j*c + k*d == 7) {
					printf("%d",a);
					printsgn(i);
					printf("%d", b);
					printsgn(j);
					printf("%d", c);
					printsgn(k);
					printf("%d", d);
					printf("=7");
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<ll, int> pii;

int main(){
  ll a, b;
  cin >> a >> b;
  ll tasukazu = b-a+1;
  ll ans=0;
  if(a%2 == 1){
	if(tasukazu <= 4){
  		for(int i=0; i<tasukazu; i++){
	    	ans ^= a;
    	  	cout << ans << endl;
      		a++;
    	}
  	}
  	else{
		for(int i=0; i<(tasukazu-1)%4; i++){
  			ans ^= b;
	  		b--;
		}
      	ans ^= a;
  	}
    
  }
  else{
	if(tasukazu <= 5){
  		for(int i=0; i<tasukazu; i++){
	    	ans ^= a;
      		a++;
    	}
  	}
  	else{
		for(int i=0; i<(tasukazu-2)%4; i++){
  			ans ^= b;
	  		b--;
		}
      	ans ^= (a ^ (a+1));
  	}
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main()
{
    int n,m,a[100005];
    P p[100005];
    cin>>n>>m;
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int j=0;j<m;j++)
        scanf("%d %d",&p[j].second,&p[j].first);
    sort(a,a+n);
    sort(p,p+m);
    int k=m-1,g=0;
    while(g<n)
    {
        if(p[k].first>a[g]&&p[k].second>0)
        {
            a[g]=p[k].first;
            p[k].second--;
            g++;
        }
        else if(k>=0&&p[k].second==0)
            k--;
        else
            break;
    }
    long long s=0;
    for(int i=0;i<n;i++)
        s+=a[i];
    cout<<s;
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
s = input()
mod = 10**9+7
cnt = {}
for x in s:
    if x not in cnt:cnt[x] = 1
    else:cnt[x] +=1
ans = 1
for key in cnt:
    v = cnt[key]
    ans *=(v+1)%mod
    ans %=mod
ans -= 1
print(ans)


Measured memory_bytes: 3188
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/09/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll n; cin>>n;
  vector<int> A(n); for(auto& a:A) cin>>a;
  ll sum = accumulate(A.begin(), A.end(), 0ll);
  auto solve = [&]() {
    if (sum % (n*(n+1)/2) != 0)
      return false;
    ll t = sum/(n*(n+1)/2);
    ll c = 0;
    for (int i = 0; i < n; i++) {
      ll d = A[i]-A[(i+1)%n]+t;
      if (d < 0 or d%n != 0)
        return false;
      c += d/n;
    }
    return c == t;
  };
  cout << (solve() ? "YES" : "NO") << endl;

  return 0;
}


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

int main()
{
   // freopen("AD18.inp","r",stdin);
   int h;
   int w;
   cin>>h>>w;
   int n;
   cin>>n;
   int a,b,c;
   if(h>w)
   {
        a=h;
        b=w;
   }
   else
   {
        a=w;
        b=h;
   }
   int dem=1;
   int i=1;
   c=a;
   while(i<=b && a<n)
   {
       a+=c;
       i++;
       dem++;
   }
   cout<<dem;
}


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

const int N = 100001;

int main(){
  char s[N];
  
  scanf("%s", s);
  
  int n = strlen(s);
  
  int exists = s[0] == '0' || s[n - 2] == '0' || s[n - 1] == '1' ? 0 : 1;
  for(int i = 1; 2 * i <= n - 2; i++){
    if(!exists) break;
    if(s[i] != s[n - 2 - i]) exists = 0;
  }
  
  if(exists){
    int node = 1;
    for(int i = 1; i < n; i++){
      printf("%d %d\n", node, i + 1);
      if(s[i - 1] == '1') node = i + 1;
    }
  }else puts("-1");
  
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int x;cin>>x;
    if(x) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3632
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)]
num=1
ans=[-arr[0]]
for i in range(1,n):
  if -arr[i]>=ans[-1]:
    ans.append(-arr[i])
    num+=1
  else:
    pos=bisect.bisect_right(ans,-arr[i])
    ans[pos]=-arr[i]
print(num)

Measured memory_bytes: 11036
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int main() {
    int n, a[100];
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[i];
    ull dp[110][30];
    for (auto &e:dp)for (auto &f:e)f = 0;
    dp[1][a[0]] = 1;
    for (int i = 1; i < n - 1; i++) {
        for (int j = 0; j <= 20; j++) {
            if (j + a[i] <= 20) dp[i + 1][j + a[i]] += dp[i][j];
            if (j - a[i] >= 0) dp[i + 1][j - a[i]] += dp[i][j];
        }
    }
    cout << dp[n - 1][a[n - 1]] << endl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M, Q;
    cin >> N >> M >> Q;

    vector<Vl> vnum(N + 1, Vl(N + 1));
    for (ll i = 0; i < M; i++) {
        ll l, r;
        cin >> l >> r;
        --l, --r;
        ++vnum[0][r];
        --vnum[l + 1][r];
        --vnum[0][N];
        ++vnum[l + 1][N];
    }

    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; j < N; j++) {
            vnum[i][j + 1] += vnum[i][j];
        }
    }

    for (ll j = 0; j <= N; j++) {
        for (ll i = 0; i < N; i++) {
            vnum[i + 1][j] += vnum[i][j];
        }
    }

    for (ll i = 0; i < Q; i++) {
        ll p, q;
        cin >> p >> q;
        --p, --q;
        cout << vnum[p][q] << endl;
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[200001] = {0};

int main()
{
	long long int a, total=0;
	cin >> a;
	for(int i=0; i<a; i++)
	{
		cin >> arr[i];
	}
	for(int i=1; i<a; i++)
	{
		if(arr[i-1] > arr[i])
		{
			total += arr[i-1]-arr[i];
			arr[i] = arr[i-1];
		}
	}
	cout << total;
}



Measured memory_bytes: 4304
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(){

    string S, ans;
    cin >> S;
    ans = "Yes";

    for (int i = 0; i < S.size(); i++){
        if (i % 2 == 0){
            if (S[i] == 'L'){
                ans = "No";
                break;
            }
        } else {
            if (S[i] == 'R'){
                ans = "No";
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int cnt=0;
    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= c; ++k) {
                if(x == i*500+j*100+k*50) cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        long N = NextInt();
        List<int> ans = new List<int>();
        while (N != 0)
        {
            if (N % 2 == 0) { ans.Add(0); }
            else { N--; ans.Add(1); }
            N /= -2;
        }
        if (ans.Count() == 0) Console.WriteLine(0);
        ans.Reverse();
        ans.ForEach(Console.Write);
        Console.WriteLine();
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vel a(N); rep(i,N) cin >> a[i];
    sort(rall(a));

    ll h = 0,w = 0;
  	int trig;
    rep(i,N-1) if(a[i] == a[i+1]) {h = a[i]; trig = i;break;}
    repk(i,trig+2,N-1) if(a[i] == a[i+1]) {w = a[i]; break;}

    cout << h * w << endl;
    return 0;  
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;

const int MAXN = 2000000 + 10;
char S[MAXN]; int N, ans, cnt;

int main() {
	register int i;
	scanf("%s", S + 1); ans = N = strlen(S + 1);
	for(i = 1; i <= N; ++i)
		if(S[i] == 'S') ++cnt;
		else if(cnt) --cnt, ans -= 2;
	printf("%d\n", ans);
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    set<int> ans;
    ans.insert(a);
    ans.insert(b);
    ans.insert(c);

    if (ans.size() == 2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int f = N / 100;
    int k = f * 100 + f * 10 + f;

    if(N <= k){
        cout << k << endl; 
    }else{
        cout << k + 111 << endl; 
    }
    return 0;
}

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

int main()
{
	int n, l;

	cin >> n >> l;

	if (l >= 0)
		cout << (l * 2 + n) * (n - 1) / 2 << endl;
	else if (l + n - 1 < 0)
		cout << (l * 2 + n - 2) * (n - 1) / 2 << endl;
	else
		cout << (l * 2 + n - 1) * n / 2 << endl;

	return 0;
}

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

#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; }

struct Player {
    int point;
    int id;
    Player(int id, int point) : id(id), point(point) {}
};

bool operator<(const Player& a, const Player& p){
    return a.point == p.point ? a.id < p.id : a.point > p.point;
}
int main()
{
    int n;
    while (n = in()){
        vector<Player> players;
        rep(i, n){
            int id = in();
            bool is_frame_end = true;
            int multi[32] = {};
            int frame = 1;
            int now = 0;
            int point = 0;
            int prev = 0;
            while (frame < 10){
                int b = in();
                point += b + multi[now] * b;
                if (is_frame_end){
                    if (b == 10){
                        multi[now + 1]++;
                        multi[now + 2]++;
                        frame++;
                    }
                    else {
                        prev = b;
                        is_frame_end = false;
                    }
                }
                else {
                    if (b + prev == 10) multi[now + 1]++;
                    frame++;
                    is_frame_end = true;
                }
                now++;
            }
            int f, s, t;
            f = in();
            s = in();
            if (f + s >= 10) t = in();
            else t = 0;
            point += f + s + t;
            point += f * multi[now] + s * multi[now + 1];
            players.push_back(Player(id, point));
        }
        sort(players.begin(), players.end());

        rep(i, n){
            printf("%d %d\n", players[i].id, players[i].point);
        }
    }

    return (0);
}

Measured memory_bytes: 1192
#include <stdio.h>

int main(void) {
	double a, b, c, d, e, f, x, y;

	while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		x = (c*e - b*f) / (a*e - b*d) + 0.0;                          
        y = (a*f - d*c) / (a*e - b*d) + 0.0;
		printf("%.3lf %.3lf\n", x, y);
	}
	return 0;
}

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

int main(){
  
  //input
  int K;
  cin >> K;
  if(K%2==0||K%5==0){
    cout << -1 << endl;
    return 0;
  }
  
  long long Total=1;
  long long div =7;
  if(7%K==0){
    cout << 1 << endl;
    return 0;
  }
  while(div!=0){
    Total++;
    div *= 10;
    div += 7;
    div = div % K;
  }
  
  //output
  cout << Total << endl;
}

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

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    for(long long i = k; i < n; i++){
        if(a[i-k] < a[i]) put("Yes");
        else put("No");
    }
}

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

int main()
{
    int k, n;
    cin >> k >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int m = 0;
    m = k - a[n - 1] + a[0];
    rep(i, n - 1)
    {
        m = max(m, a[i + 1] - a[i]);
    }
    cout << k - m << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define maxn 100005
using namespace std;
int h[maxn], a, b;
int n;
bool check(LL x){
	LL sum = 0;
	for(int i = 1; i <= n; i++){
		LL less = h[i] - b * x;
		if(less <= 0) continue;
		if(less % (a - b) == 0) sum += less / (a - b);
		else sum += less / (a - b) + 1;
		if(sum > x) return 0;
	}
	return 1;
}
int main(){
	scanf("%d%d%d", &n, &a, &b);
	for(int i = 1; i <= n; i++) scanf("%d", &h[i]);
	LL l = 1, r = 1e15, ans = 1e9;
	while(l <= r){
		int mid = l + r >> 1;
		if(check(mid)){
			ans = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int Max = 3000;
long dp[Max][Max];
int main(){
    int n;
    scanf("%d", &n);
    vector<int>a(n);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(int l=n-1; l>=0; l--){
        for(int r=l; r<n; r++){
            dp[l][r] = max(a[l]-(l+1<=r ? dp[l+1][r]:0), a[r]-(r-1>=l?dp[l][r-1]:0));
        }
    }
    printf("%ld", dp[0][n-1]);
    return 0;
}


Measured memory_bytes: 70016
#include <ext/pb_ds/assoc_container.hpp>
  #include <bits/stdc++.h>
  using namespace std;
  using namespace __gnu_pbds;
  template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define TRACE
  #ifdef TRACE
  #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  template <typename Arg1>
  void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
  }
  template <typename Arg1, typename... Args>
  void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
  }
  #else
  #define trace(...) 
  #endif
  template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
  template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
  typedef long long int ll;
  const ll mod =1e18;
  const int maxn = 300002;
  #define endl '\n'
  #define int ll
  #define ld long double
  #define all(x) (x).begin(),(x).end()


  int32_t main()
  { 
    IOS

    int a , b;
    cin >> a >> b;
    if(a*b == 15 ){
      cout<<"*";
    }  
    else if(a+b == 15){
      cout<<"+";
    }
    else{
      cout<<"x";
    }



    
    

    

    
    
    
  }

Measured memory_bytes: 3608
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    
    def BellmanFord(edges,V,source):
        INF = float("inf")
        dist = [INF for _ in range(N)]
        dist[source] = 0
        
        for i in range(V):
            for now,fol,d in edges:
                if dist[now] != INF and dist[fol] > dist[now]+d:
                    dist[fol] = dist[now]+d
                    if i == V-1 and fol == N-1:
                        return "inf"
        return -1*dist[-1]
        
    edge = []
    for _ in range(M):
        a,b,c = map(int,input().split())
        edge.append((a-1,b-1,-c))
    
    print(BellmanFord(edge,N,0))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    AB=LLIN(N)
    ans = 0
    add = 0
    for i in range(N)[::-1]:
        a,b=AB[i]
        a += add
        need = -a%b
        add += need
        ans += need
    print(ans)
if __name__ == '__main__':
    main()

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

using namespace std;

int n, a[200000], t, now, ans[400000];
bool flg;

int main(){
	now = 200000;
	for(int i = 0; i < 400000; ++i) ans[i] = -1;
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	ans[now] = a[0];
	t = (n % 2 == 0 ? -1 : 1);
	for(int i = 1; i < n; ++i){
		ans[now+t] = a[i];
		t *= (-1);
		if(ans[now+t] != -1 && ans[now-t] != -1) t += (t < 0 ? -1 : 1);
	}
	for(int i = min(now-t, now+t); i < max(now-t, now+t); ++i) if(ans[i] != -1) cout << ans[i] << " ";
	cout << endl;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.00000000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int L = 21;
const int M = 2155;

void solve() {
    int k,a,b;
    cin >> k >> a >> b;

    for (int i = a; i <= b; i++){
        if (i % k == 0){
            cout << "OK";
            return;
        }
    }

    cout << "NG";

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

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

int main(void){
    string command,str;
    long long int n;
    cin>>n;
    unordered_map<string,int> dic;
    rep(l,n){
        cin>>command>>str;
        if(command=="insert"){
            dic[str]=1;
        }
        if(command=="find"){
            if(dic.count(str)){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
        }
    }
}


Measured memory_bytes: 36124
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,ans=0;
	cin>>n>>k;
	int a[n];
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		if (a[i]>=k)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
 } 

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

using namespace std;

int main(void) {
	string s;
	cin >> s;
	int i, a;
	vector<int> d(s.size(), 0);
	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'L') {
			a = i;
			while (i < s.size() && s[i] == 'L') {
				if ((i - a) & 1)
					d[a - 1]++;
				else
					d[a]++;
				i++;
			}
		}
	}
	for (i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'R') {
			a = i;
			while (i >= 0 && s[i] == 'R') {
				if ((a - i) & 1)
					d[a + 1]++;
				else
					d[a]++;
				i--;
			}
		}
	}
	for (i = 0; i < s.size(); i++)
		printf("%d ", d[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1024
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}
int solve(){
    int n;cin>>n;
    vector<int> a(n+1);
    rep(i, 1, n+1) { cin>>a[i]; }
    dump(a);

    vector<map<int, int>> dp0(n+1);
    vector<map<int, int>> dp1(n+1);
    rep(j, -5, 10){
        int v = - 3 + j;
        dp0[0][v] = -INF;
        dp1[0][v] = -INF;
    }

    dp0[0][0] = 0;

    rep(i, 1, n+1){
        rep(j, -5, 10){
            int v = i/2 - 3 + j;
            dp0[i][v] = -INF;
            dp1[i][v] = -INF;
        }
        rep(j, 0, 5){
            int v = i/2 - 3 + j;

            // toranai
            chmax(dp0[i][v], dp0[i-1][v]);
            chmax(dp0[i][v], dp1[i-1][v]);

            // toru
            chmax(dp1[i][v], dp0[i-1][v-1]+a[i]);
        }
    }
    // rep(i, n+1){
    //     dump(dp0[i]);
    //     dump(dp1[i]);
    // }
    cout << max(dp0[n][n/2], dp1[n][n/2]) << endl;

    return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
    std::ifstream in(infile);
    std::cin.rdbuf(in.rdbuf());
#endif
    solve();
    return 0;
} //}}}


Measured memory_bytes: 398676
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec d(N); cin >> d;
    int ans = 0;
    REP(i, N) REP(j, i) ans += d[i] * d[j];
    Out(ans);

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 500000;
int G, B, S;
struct coin{
    int g;
    int s;
    int b;
};
bool cmp (coin c1, coin c2){
    return c1.g + c2.b > c2.g + c1.b;
}
coin a[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int x, y, z;
    cin >> x >> y >> z;
    for (int i = 1; i <= x + y + z; i++){
        cin >> a[i].g >> a[i].s >> a[i].b;
    }
    sort(a + 1, a + x + y + z + 1, cmp);
    set <pair < pair < int, int >,  pair < int, int > > > s1, s2, s3, s4;
    for (int i = 1; i <= x; i++){
        s1.insert({{a[i].s - a[i].g, i}, {a[i].g, a[i].s}});
        G += a[i].g;
    }
    for (int i = x + 1; i <= x + y + z; i++){
        s2.insert({{a[i].s - a[i].b, i}, {a[i].b, a[i].s}});
        S += a[i].s;
    }
    int l = 0;
    for (auto i: s2){
        if (l < z){
            S -= i.S.S;
            B += i.S.F;
            l++;
            s3.insert(i);
        } else
        s4.insert(i);
    }
    int ans = G + B + S;
    for (int i = x + 1; i <= x + y; i++){
        pair < pair < int, int >,  pair < int, int > > t = {{a[i].s - a[i].b, i}, {a[i].b, a[i].s}};
        if (s4.find(t) != s4.end()){
            s4.erase(t);
            S -= a[i].s;
        }else{
            B -= a[i].b;
            s3.erase(t);
            auto k = *s4.begin();
            B += k.S.F;
            S -= k.S.S;
            s3.insert(*s4.begin());
            s4.erase(s4.begin());
        }
        t = {{a[i].s - a[i].g, i}, {a[i].g, a[i].s}};
        if (t.F.F < (*s1.rbegin()).F.F){
            auto k = *s1.rbegin();
            G -= k.S.F;
            S += k.S.S;
            G += a[i].g;
            auto zz = s1.end();
            zz--;
            s1.erase(zz);
            s1.insert(t);
        } else S += a[i].s;
        ans = max(ans, G + B + S);
    }
    cout << ans;
}


Measured memory_bytes: 19968
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'

using namespace std;
typedef pair<int, int> P;
typedef long long LL;

static const int INF = INT_MAX;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>v;
    int b = 1;
    while(b < 100) {
        v.push_back(b);
        b *= 2;
    }
    for(int i = v.size() - 1; i >= 0; --i) {
        if(v[i] <= n) { cout << v[i] << endl; break; }
    }

    return 0;
}


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

int main(){
  string s; cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>

#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using pii = std::pair<int,int>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;

const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 10241024;
const ll INFL = (1ll << 62) - 1;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//

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

//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}
//_____________________　following sorce code_________________________//
int n,m,k;
//vvll dp(400, vll(400));
string S;
vll cost(1 << 16);
int a,b,c;
int h,w;
vvi v;
vll pu;
vll mu;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(n);
  map<string, int> mp;
  int gmax = 0;
  rep(i,n){
    string s;IN(s);
    mp[s]++;
    chmax(gmax, mp[s]);
  }
  for(auto c : mp){
    if(c.sec == gmax)OUT(c.first);
  }
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 24672
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,m;
  cin >> n >> m;
  pri(n>8||m>8?":(":"Yay!");
  return 0;
}



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

int main(){
	int n;
	cin >> n;
	do{
		char a[256],b[256];
		for(int i=0; i<n; i++){
			cin >> a[i] >> b[i];
		}

		int num;
		char s;
		cin >> num;
		for(int i=0; i<num; i++){
			cin >> s;
			for(int j=0; j<n; j++){
				if(s==a[j]){
					s=b[j];
					break;
				}
			}
			cout << s;
		}
		cout << endl;
		cin >> n;
	}while(n!=0);
}

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

int main() {
	// your code goes here
	long long a,b,c,d;
	cin >>a >> b>>c>>d;
	
	cout<<max(max(a*c, a*d), max(b*c,b*d));
	
	

	return 0;
}

Measured memory_bytes: 3624
from collections import deque

def main():
    H, W = map(int, input().split())
    maze = [list(input()) for _ in range(H)]

    ans = 0
    for h in range(H):
        for w in range(W):
            if maze[h][w] == '#':
                continue
            goal_dists = [[-1] * W for _ in range(H)]
            goal_dists[h][w] = 0
            d = deque([[h, w]])

            while d:
                ht, wt = d.popleft()
                for dh, dw in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
                    if not (0 <= ht+dh < H and 0 <= wt+dw < W):
                        continue
                    if maze[ht+dh][wt+dw] == '#':
                        continue
                    if goal_dists[ht+dh][wt+dw] == -1:
                        goal_dists[ht+dh][wt+dw] = goal_dists[ht][wt] + 1
                        d.append([ht+dh, wt+dw])
            
            max_dist = [max(goal_dists[h]) for h in range(H)]
            ans = max(ans, max(max_dist))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;
stack<int> seq;
int A[MAXN];
int last[MAXN];
ll dist[MAXN];
int nxt[MAXN];
bool vis[MAXN];
bool instack[MAXN];

int main()
{
    ll n,m,k,a,b,x,y;
    ll sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    ll tot;

    cin>>n>>k;

    for(int i=0;i<n;i++)
        cin>>A[i];

    for(int i=n-1;i>=0;i--)
        last[A[i]] = i+n;

    for(int i=n-1;i>=0;i--){
        nxt[i] = last[A[i]]+1;
        dist[i] = last[A[i]]+1-i;
        last[A[i]] = i;
    }

    for(int i=0;i<n;i++)
        nxt[i]%=n;

    cur = 0;

    tot = n*k;

    while(!vis[cur]){
        vis[cur] = true;
        sum+=dist[cur];
        cur = nxt[cur];
    }

    tot%=sum;

    fill(vis,vis+n+1,false);

    cur = 0;

    while(!vis[cur]){

        vis[cur] = true;
        if(tot<dist[cur])break;
        tot-=dist[cur];
        cur = nxt[cur];
    }
    int st = cur;

    for(int i=st;i<st+tot;i++){

        cur = A[i%n];

        if(instack[cur]){
            while(!seq.empty()&&seq.top()!=cur){
                    instack[seq.top()] = false;
                    seq.pop();
            }
            if(!seq.empty()&&seq.top()==cur)seq.pop();
            instack[cur] = false;
        }
        else {
            seq.push(cur);
            instack[cur] = true;
        }
    }

    vector<int> res;

    while(!seq.empty()){
        res.push_back(seq.top());
        seq.pop();
    }
    reverse(res.begin(),res.end());

    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

    return 0;
}


Measured memory_bytes: 7456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  
  int count = 0;
  for(int i=0; i<3; i++){
    if(s.at(i) == t.at(i)){
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int n,m,w,h,ans;
#define x *
int main(){
	scanf("%d%d%d%d",&n,&m,&w,&h);
	if(n%w==0&&m%h==0)return puts("No"),0;
	puts("Yes");
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)printf("%d%c",((i%w)||(j%h))?-1926:1926*(w x h-1)-1,j==m-1?'\n':' ');
	}
}

Measured memory_bytes: 1664
N = int(input())
mod = 10 ** 9 + 7

e = pow(8, N, mod)
f = pow(9, N, mod)
g = pow(10, N, mod)

# 全体 - (0を含まない + 9を含まない) + 0と9どちらも含まない
ans = (g - 2 * f + e) % mod
print(ans)

Measured memory_bytes: 9172
S = int(input())
x1 = 10 ** 9
x2 = 1
y2 = (S + (10 ** 9) - 1) // (10 ** 9)
y1 = ((10 ** 9) * y2 - S) % (10 ** 9)
x3 = 0
y3 = 0
print(x1, y1, x2, y2, x3, y3)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int AC[100005]={};
    int WA[100005]={};
    int N,M;
    cin >> N >> M;

    int p;
    string S;
    for(int i=0;i<M;i++){
        cin >> p >> S;
        if(S == "AC"){
            AC[p] = 1;
        }else{
            if(AC[p]==0){
                WA[p]++;
            }
        }
    }

    int num_c = 0;
    int num_p = 0;
    for(int i=1;i<=N;i++){
        num_c += AC[i];
        if(AC[i]==1){
            num_p += WA[i];
        }
    }

    cout << num_c << ' ' << num_p << endl;

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i,n) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	cout << d[n/2] - d[n/2-1] << endl;
	return 0;
}


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

int main(void){
	int n,Min,Max,tmp;
	cin >> n;
	Max = -1000001;
	Min = 1000001;
	long long Sam = 0;
	for(int i = 0; i < n; i++){
		cin >> tmp;
		Sam += tmp;
		Max = max(Max,tmp);
		Min = min(Min,tmp);
	}
	cout << Min << " " << Max << " " << Sam << "\n";
	return 0;

}


Measured memory_bytes: 3100
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n : u32 = read();
    let tn :Vec<Vec<i32>> = read_vec2(n);
    let s:Vec<(i32,i32,i32)> = tn.iter().map(|x| (x[0],x[1],x[2]) ).collect();
    let mut n_point = (0,0,0);
    for (time,x,y) in s {
        for _ in 0..(time - n_point.0)  {
            if x < n_point.1 {
                n_point.1 -= 1;
            } else if y < n_point.2 {
                n_point.2 -= 1;
            } else if x > n_point.1 {
                n_point.1 += 1;
            } else if y > n_point.2 {
                n_point.2 += 1;
            } else {
                n_point.1 -= 1;
            }
            n_point.0 += 1;
        }
        if n_point != (time,x,y) {
            println!("No");
            return
        }
    }
    println!("Yes");
}

Measured memory_bytes: 10492
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
  int r, g, b;
  cin >> r >> g >>b;

  if((r*100+g*10+b)%4) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }

  return 0;
}


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

int main(){
    string s; cin >> s;
    bool flag = 1;
    if(s[0]!='A') flag = 0;
    int n=s.size();
    int cind = 0;
    if(flag){
        int count = 0;
        for(int i = 2; i<n-1; i++){
            if(s[i]=='C'){
                count ++;
                cind = i;
            }
        } 
        if(count!=1) flag = 0;
    }
    if(flag){
        for(int i = 0; i<n; i++){
            if(i==0 or i==cind) continue;
            if(s[i]<'a' or s[i]>'z') flag = 0;
        }
    }
    cout << (flag?"AC":"WA") << endl;
}

Measured memory_bytes: 256