akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 10007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
}

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

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    }
    else {
        cout << "red" << endl;
    }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])
ans = 0
for i, j in ab:
    ans += min(m, j)*i
    m -= min(m, j)
    if m == 0:
        print(ans)
        exit()


Measured memory_bytes: 28716
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
    ll N, K;
    cin >> N >> K;
    vll A(N+1);
    rep(i, 1, N+1) cin >> A[i];
    map<ll, ll> mp;
    rep(i, 1, N+1) mp[i] = A[i];

    map<ll, ll> mp2;
    ll cnt = 0;
    ll now = 1;
    ll loopstart = -inf;
    mp2[now]++;
    rep(i, 0, 100000000000000) {
        now = mp[now];
        ++cnt;
        mp2[now]++;
        if (mp2[now] == 2) {
            loopstart = now;
            break;
        }
    }

    ll loopcnt = 0;
    ll loopnow = loopstart;
    rep(i, 0, 100000000) {
        loopnow = mp[loopnow];
        ++loopcnt;
        if (loopnow == loopstart) break;
    }

    ll x = 1;
    ll fir = 0;
    rep(i, 0, 10000000) {
        x = mp[x];
        ++fir;
        if (x == loopstart) break;
    }

    now = 1;
    if (K <= fir) {
        rep(i, 0, K) {
            now = mp[now];
        }
        cout << now << endl;
        return 0;
    } else {

        ll tmp = K - fir;
        ll rem  = tmp % loopcnt;

        now = loopstart;
        rep(i, 0, rem) {
            now = mp[now];
        }
        cout << now << endl;
    }
}




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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

int main() {FIN;
    int n;
    cin >> n;
    int ar[n];
    fore(i,0,n) cin >> ar[i];
    int weight[n];
    fore(i,0,n) weight[i] = -1;
    weight[0] = 0;
    weight[1] = abs(ar[1]-ar[0]);
    fore(i,2,n){
        weight[i] = min(abs(ar[i] - ar[i-1])+weight[i-1], abs(ar[i] - ar[i-2]) + weight[i-2]);
    }
    cout << weight[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
package main

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

func judge(a []int, b []int) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func solve() {
	n := scanInt()
	p := make([]int, n)
	q := make([]int, n)
	an := make([]int, n)
	var a int
	var b int

	for i := 0; i < n; i++ {
		p[i] = scanInt()
	}
	for i := 0; i < n; i++ {
		q[i] = scanInt()
	}
	for i := 0; i < n; i++ {
		an[i] = i + 1
	}
	perm := Permute(an)
	for index, pe := range perm {
		if judge(pe, p) == true {
			a = index
		}
		if judge(pe, q) == true {
			b = index
		}
	}
	fmt.Println(absInt(a, b))
	return
}

var sc = bufio.NewScanner(os.Stdin)

func scanString() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}
func Permute(nums []int) [][]int {
	n := factorial(len(nums))
	ret := make([][]int, 0, n)
	permute(nums, &ret)
	return ret
}

func permute(nums []int, ret *[][]int) {
	*ret = append(*ret, makeCopy(nums))

	n := len(nums)
	// p := make([]int, n+1)
	var i, j int
	for {
		for i = n - 2; i >= 0; i-- {
			if nums[i] < nums[i+1] {
				break
			}
		}
		if i < 0 {
			return
		}
		for j = n - 1; ; j-- {
			if nums[j] > nums[i] {
				break
			}
		}
		nums[i], nums[j] = nums[j], nums[i]
		for k, l := i+1, n-1; k < l; {
			nums[k], nums[l] = nums[l], nums[k]
			k++
			l--
		}
		*ret = append(*ret, makeCopy(nums))
	}
}

func factorial(n int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret *= i
	}
	return ret
}
func makeCopy(nums []int) []int {
	return append([]int{}, nums...)
}
func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

func main() {
	sc.Split(bufio.ScanWords)
	solve()
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(u->key>k)u=u->left;
    else u=u->right;
  }
  return u;


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else{
    if(z->key<y->key)y->left=z;
    else y->right=z;
  }
}






void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



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

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
 
#define ll long long
#define ld long double
#define pii pair<int,int>
 
#define files1 freopen("input.txt","r",stdin)
#define files2 freopen("output.txt","w",stdout)
#define files files1;files2
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
 
#define endl '\n'
#define ln(i,n) " \n"[(i) == (n) - 1]
 
void bad(string mes = "Impossible"){cout << mes;exit(0);}
template<typename ... T> void shit(T& ... x){}
template<typename ... T> void dec(T& ... x){shit(--x...);}
template<typename ... T> void inc(T& ... x){shit(++x...);}
#include <unordered_map>
// #include <unordered_mda>
 
template<typename T>
string bin(T x, int st = 2){
    string ans = "";
    while (x > 0){
        ans += char('0' + x % st);
        x /= st;
    }
    reverse(ans.begin(), ans.end());
    return ans.empty() ? "0" : ans;
}
 
template<typename T>
T input(){
    T ans = 0, m = 1;
    char c = ' ';
 
    while (!((c >= '0' && c <= '9') || c == '-')) {
        c = getchar();
    }
 
    if (c == '-')
        m = -1, c = getchar();
    while (c >= '0' && c <= '9'){
        ans = ans * 10 + (c - '0'), c = getchar();
    }
    return ans * m;
}
 
template<typename T>
void read(T& a) {
    a = input<T>();
}
 
template<typename T>
void read(T& a, T& b) {
    read(a), read(b);
}
 
template<typename T>
void read(T& a, T& b, T& c) {
    read(a, b), read(c);
}
 
template<typename T>
void read(T& a, T& b, T& c, T& d) {
    read(a, b), read(c, d);
}
 
const int inf = 1e9;
const double eps = 1e-9;
const int maxn = 1e5 + 10, base = 1e9 + 7;
const ll llinf = 1e18 + 1;
 
template<typename T>
T binpow(T n, T s)
{
    if (s <= 0)
        return 1LL;
    if (s % 2 == 0){
        T b = binpow(n, s / 2);
        return ( 1LL * b * b ) % base;
    } else {
        return (1LL* binpow(n, s - 1) * n) % base;
    }
}

int main() {
    string s;
    // files1;
    cin >> s;
    cout << string(s.substr(0, 4) + " " + s.substr(4, 8)) << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

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

int N;
vector<lint> As;

lint minmax(lint P, lint Q, lint R, lint S)
{
    vector<lint> a{P, Q, R, S};
    sort(a.begin(), a.end());
    return a[3] - a[0];
}

int main()
{
    cin >> N;
    As.resize(N+1, 0);
    for (int i = 1; i <= N; i++)
    {
        lint tmp;
        cin >> tmp;
        As[i] = As[i - 1] + tmp;
    }
    lint ans = As[N];
    for (int i = 3; i <= N - 1; i++)
    {
        auto it1 = lower_bound(As.begin(), As.end(), As[i - 1] / 2);
        lint Q1 = As[i - 1] - *it1;
        lint Q2 = As[i - 1] - *(it1 - 1);
        lint P1 = As[i - 1] - Q1;
        lint P2 = As[i - 1] - Q2;

        auto it2 = lower_bound(As.begin(), As.end(), (As[i - 1] + As[N]) / 2);
        lint S1 = As[N] - *it2;
        lint S2 = As[N] - *(it2 - 1);
        lint RS = As[N] - As[i - 1];
        lint R1 = RS - S1;
        lint R2 = RS - S2;

        lint tmp1 = minmax(P1, Q1, R1, S1);
        lint tmp2 = minmax(P1, Q1, R2, S2);
        lint tmp3 = minmax(P2, Q2, R1, S1);
        lint tmp4 = minmax(P2, Q2, R2, S2);
        vector<lint> tmp{tmp1, tmp2, tmp3, tmp4};
        sort(tmp.begin(), tmp.end());
        ans = min(ans, tmp[0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string N;
  cin >> N;
  cout << "ABC" + N << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e6+5;
const int MM=4e6+5;
int n,m,tot;
int to[MM],nxt[MM],c[MM],h[MM+MN],cnt;
inline void ins(int s,int t,int c){
	to[++cnt]=t;nxt[cnt]=h[s];::c[cnt]=c;h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];::c[cnt]=c;h[t]=cnt;
}
int dis[MN+MM];
map<int,int>mp[MN];
typedef pair<int,int>pii;
priority_queue<pii,vector<pii>,greater<pii> >q;
int main(){
	scanf("%d%d",&n,&m);tot=n;
	for(reg int i=1,s,t,c;i<=m;i++){
		scanf("%d%d%d",&s,&t,&c);
		if(!mp[s][c])mp[s][c]=++tot,ins(mp[s][c],s,1);
		if(!mp[t][c])mp[t][c]=++tot,ins(mp[t][c],t,1);
		ins(mp[s][c],mp[t][c],0);
	}
	memset(dis,0x3f,sizeof(dis));
	dis[1]=0;q.push(make_pair(0,1));
	while(!q.empty()){
		reg pii v=q.top();q.pop();
		if(v.first!=dis[v.second])continue;
		for(reg int i=h[v.second];i;i=nxt[i])
			if(dis[to[i]]>v.first+c[i])
				dis[to[i]]=v.first+c[i],
				q.push(make_pair(dis[to[i]],to[i]));
	}
	if(dis[n]==0x3f3f3f3f)puts("-1");
	else printf("%d\n",dis[n]/2);
	return 0;
}

Measured memory_bytes: 110456
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll k,n;
    cin>>k>>n;
    ll i,j,count,x,y;
    vector<ll> a(n);
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	ll res=0LL;
	i=0;
	j=0;
	count=1;
	while(count<n)
	{
		if(a[i+1]-a[i]<((j==0)?k-a[n-1]+a[j]:a[j]-a[((j-1)+n)%n]))
		{
			res+=(a[i+1]-a[i]);
			i++;
			count++;
		//	cout<<"h1";
		}
		else
		{
			if(j==0)
			{
				res+=(k-a[n-1]+a[j]);
			//	cout<<"h2";
			}
			else
			{
				res+=(a[j]-a[((j-1)+n)%n]);
			//	cout<<"h3";
			}
			j =((j-1)+n)%n;
			count++;
		}
	}
	cout<<res;
	return 0;
    
}

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

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  int s[W][H]={};
  for(int i=0;i<N;i++){
    int x,y,a;
  	cin >> x >> y >> a;
  	if(a==1){
  		for(int i=0;i<H;i++){
    		for(int j=0;j<x;j++){
      			s[j][i]++;
    		}
  		}
  	}
  	if(a==2){
  		for(int i=0;i<H;i++){
    		for(int j=x;j<W;j++){
      			s[j][i]++;
    		}
  		}
  	}
  	if(a==3){
  		for(int i=0;i<y;i++){
    		for(int j=0;j<W;j++){
      			s[j][i]++;
    		}
  		}
  	}
  	if(a==4){
  		for(int i=y;i<H;i++){
    		for(int j=0;j<W;j++){
      			s[j][i]++;
    		}	
  		}
  	}
  }
  int ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      	if(s[j][i]==0)
          ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int a[3],i;
for(i=0;i<3;++i)
cin>>a[i];
int diff1,diff2;
diff1=a[1]-a[0];
diff2  =a[2]-a[1];
if(diff2==diff1)
cout<<"YES";
else
cout<<"NO";
return 0;


}

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

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

int n,k;
long double ans;

signed main() {
    cin >> n >> k;
    rep1(i,n) {
        int hoge=i;
        long double tmp = 1.0/n;
        while(hoge < k) hoge*=2,tmp *= 1.0/2.0;
        ans += tmp;
    }
    cout << setprecision(20) << ans << endl;
}


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

const int INF = 1e9 + 5;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b ,c;

    cin >> a >> b >> c; 

    int ans = 0;

    for(int i = b; i <= c; i++){
        if(i % a == 0){
            ans = 1;

        }
    }

    if(ans == 1){
        cout << "OK";
    }else{
        cout << "NG";
    }

    return 0;
}

Measured memory_bytes: 3640
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof (a))
#define endl '\n'
#define pb push_back
typedef long long ll;
const int maxn=200010;
const int inf=1e9;
const ll mod=998244353;
const double pi=3.14159265358979;
const double ep=0.0;
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>vec,vec1,vec2;
    for (int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        vec1.pb(x);
    }
    for (int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        vec2.pb(x);
    }
    int a=0,b=0;
    for (int i=0;i<n;i++)
    {
        vec.pb(i+1);
    }
    int x=0;
    do
    {
        if (vec==vec1)
            a=x;
        if (vec==vec2)
            b=x;
        x++;
    }while (next_permutation(vec.begin(),vec.end()));
    cout<<abs(a-b)<<endl;
    return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;

int main()
{
  int r, D, x;
  cin >> r >> D >> x;

  for (int i = 0; i < 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  int odd = (n+1)/2;
  double ans = odd/(double) n;
  printf("%.10f\n", ans);
  return 0;
}

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

using namespace std;
string X;
int main(void) {

	cin >> X;

	int N = X.size();

	int count = 0;

	int num_S = 0;

	for (int i = 0; i < N; i++) {
		if (X[i] == 'S') { num_S++; }
		else if (num_S > 0) { num_S--; count++; }
	}

	int ans = N - 2 * count;

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 640
from collections import deque
 
H, W = map(int, input().split())
S = [input() for _ in range(H)]
INF = 10**15

answer = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      continue
    else:
      dist = [[INF for _ in range(W)] for _ in range(H)] # 始点からの距離
      dist[i][j] = 0 # 始点を定義
      stack = deque([(i, j)]) # 始点を"先入れ先出し"の配列に入れる
      
      while stack:
      # BFS
      # * 計算量 O(4HW:辺の数)
        si, sj = stack.popleft() 
        # "先入れ先出し"
        # * ⇔後入れ後出し。DFS
        #   si, sj = stack.pop()
        
        for ni, nj in [(si + 1, sj), (si - 1, sj), (si, sj + 1), (si, sj - 1)]:
        # 経路に重みがない場合、BFSでは先に入れた方がそのマスに対する最短経路になる...☆
        # * DFSを使用すると更新の必要があり、
        #    計算量が(4HW*HW:辺の数×グリッドの数)->TLE
        # ** 木だと経路は1つしかないため、BFSもDFSも計算量は同じ
        #     グラフでは基本的にBFS推奨[要出典]
        # * 経路に重みがある場合も更新の必要があり、計算量はO(4HW*HW)
        # ** Dijkstra法を使えば、計算量はO(4HW+HWlogHW)
        #     O(E + VlogV): E -> Edge, V -> Vertex
          if 0 <= ni <= H - 1 and 0 <= nj <= W - 1 and S[ni][nj] != "#":
            if dist[ni][nj] > dist[si][sj] + 1:
              dist[ni][nj] = dist[si][sj] + 1
              stack.append((ni, nj))
          # ☆より、最短経路をとるマスからの隣接が次の最短経路の候補となる
          # すでに最短経路を取っているものは排除
              
              
      max_dist = 0
      for ii in range(H):
        for jj in range(W):
          if dist[ii][jj] != INF:
            max_dist = max(max_dist, dist[ii][jj])
      answer = max(max_dist, answer)
      # * 添え字被りに注意
      
print(answer)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	static int top;
	static int[] S = new int[1000];

	public static void push(int x) {
		top++;
		S[top] = x;
	}

	public static int pop() {
		top--;
		return S[top + 1];
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		String s;
		top = 0;
		while (sc.hasNext()) {
			s = sc.next();
			if (s.charAt(0) == '+') {
				b = pop();
				a = pop();
				push(a + b);
			} else if (s.charAt(0) == '-') {
				b = pop();
				a = pop();
				push(a - b);
			} else if (s.charAt(0) == '*') {
				b = pop();
				a = pop();
				push(a * b);
			} else {
				push(Integer.parseInt(s));
			}
		}
		System.out.println(pop());
		sc.close();
	}
}



Measured memory_bytes: 26268
import itertools
inf = float('inf')
ans = inf

# dist[i][j]: iからjへのコスト,  n:頂点数
def warshall_floyd(dist,n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if dist[i][j] > dist[i][k]+dist[k][j]:
                    dist[i][j] = dist[i][k]+dist[k][j]

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
info = [list(map(int,input().split())) for i in range(M)]

dist = [[inf]*N for i in range(N)]

for a,b,c in info:
    a -= 1; b -= 1
    dist[a][b] = c
    dist[b][a] = c

warshall_floyd(dist,N)

for order in itertools.permutations(r,R):
    cost = 0
    for i in range(R-1):
        pre = order[i]-1; fol = order[i+1]-1
        cost += dist[pre][fol]
    if cost < ans:
        ans = cost

print(ans)

Measured memory_bytes: 8812
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    mk = {}
    mk['T'] = 10
    mk['J'] = 11
    mk['Q'] = 12
    mk['K'] = 13
    mk['A'] = 14
    for i in range(1,10):
        mk[str(i)] = i

    while True:
        t = S()
        if t == '#':
            break
        a = [list(map(lambda x: (mk[x[0]], x[1]), LS())) for _ in range(4)]
        d = 0
        ns = 0
        ew = 0
        for i in range(13):
            m = -1
            mi = -1
            it = a[d][i][1]
            for j in range(4):
                k = a[j][i][0]
                if a[j][i][1] == t:
                    k += 100
                if a[j][i][1] == it:
                    k += 50
                if m < k:
                    m = k
                    mi = j
            d = mi
            if mi % 2 == 0:
                ns += 1
            else:
                ew += 1
        if ns > 6:
            rr.append('NS {}'.format(ns - 6))
        else:
            rr.append('EW {}'.format(ew - 6))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9060
n=int(input())
a=[int(i) for i in input().split()]

sunuke=0
araiguma=sum(a)

min_sa=100000000000000

for i in range(n-1):
    sunuke+=a[i]
    araiguma-=a[i]
    min_sa=min(min_sa,abs(araiguma-sunuke))
print(min_sa)

Measured memory_bytes: 31384
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = nextInt();
        int B = nextInt();

        int count = 1;
        for(int i=0;; i++){
            if(count >= B){
                println(i);
                return;
            }
            count += A-1;
        }
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 22100
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const ll LINF = 1e18;

int main() {
  ll a, b, c, d, ans = -LINF;
  cin >> a >> b >> c >> d;

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

  cout << ans << endl;
}


Measured memory_bytes: 3192
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, x;
  cin >> a >> b >> x;
  if (a <= x && x <= a + b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

const int mod = 1e9 + 7;

int main() {
	int n, m; cin >> n >> m;
	vector<int>stairs(n+1,true);
	for (int i = 0; i < m; i++) {
		int a; cin >> a;
		stairs[a] = false;
	}

	vector<long long>dp(n + 1);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		for (int next = i + 1; next <= min(n, i + 2); next++) {
			if (stairs[next]) { dp[next] += dp[i]; dp[next] %= mod; }
		}
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

vector<ll> comp(vector<ll> &a) {
    ll n = a.size();
    map<ll, ll> comp;
    Rep (i, n) comp[a[i]] = 0;
    ll tmp = 0;
    for (auto &e : comp) {
        e.second = tmp;
        tmp++;
    }
    vector<ll> b;
    Rep (i, n) {
        b.emplace_back(comp[a[i]]);
    }
    return b;
}

template <class T>
class SegTree {
    int n;
    vector<T> data;
    T def;
    function<T(T, T)> operation;
    function<T(T, T)> update;

    T _query(int a, int b, int k, int l, int r) {
        if (r <= a or b <= l) return def;
        if (a <= l and r <= b) return data[k];
        else {
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }

    public:
    SegTree(ll _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n <= _n) {
            n *= 2;
        }
        data = vector<T>(2*n-1, def);
    }

    void change(int i, T x) {
        i += n-1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i-1) / 2;
            data[i] = operation(data[i*2+1], data[i*2+2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[] (int i) {
        return data[i+n-1];
    }
};

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

    ll N, K;
    cin >> N >> K;
    vec a(N), s(N+1, 0);
    Rep (i, N) {
        cin >> a[i];
        a[i] -= K;
        s[i+1] = s[i] + a[i];
    }

    s = comp(s);

    SegTree<ll> st(N, 0, [](ll a, ll b){return a+b;}, [](ll a, ll b){return a+b;});

    ll ans = 0;
    Rep (i, N+1) {
        ans += st.query(0, s[i]+1);
        st.change(s[i], 1);
    }

    cout << ans << "\n";


}

Measured memory_bytes: 18036
//Source:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define un unsigned
#define vi vector<int>
#define pb push_back

using namespace std;
//******************************************************************************
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(NULL);

  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin); //Read external file
  //freopen("output.txt", "w", stdout); //Write to external file
  #endif

  long double a,b;
  cin>>a>>b;
  cerr << a << " " << b << "\n";

  cout << (long long)floor(a*b);

  return 0;
}
//******************************************************************************
//******************************************************************************


Measured memory_bytes: 3780
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		//If max is greater than sum of rest, the first person can hog biggest to win
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		for (int i = 0; i < N; i++) b[i] = I.nextInt();
		long bad = 0;
		long TWO = 0;
		for (int i = 0; i < N; i++) {
			if (a[i]>b[i]) {
				bad+=a[i]-b[i];
			}else if (b[i]>a[i]) {
				TWO+=(b[i]-a[i])/2;
			}
		}
		O.pln(TWO>=bad?"Yes":"No"); //Leftovers can be adjusted using the +1 differential
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 31064
#include <stdio.h>

int N, M;

int next_num[100];
int next[100][100];

int memo[100][1000];

int search(int current, int visited) {
	int ret = 0;
	int i;
	int new_visited;
	if ((visited >> current) & 1) return 0; /* dupe */
	if (memo[current][visited]) return ~memo[current][visited];
	new_visited = visited | (1 << current);
	if (new_visited == (1 << N) - 1) return 1; /* completed */

	for (i = 0; i < next_num[current]; i++) {
		ret += search(next[current][i], new_visited);
	}

	return ~(memo[current][visited] = ~ret);
}

int main(void) {
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int a, b;
		if (scanf("%d%d", &a, &b) != 2) return 1;
		a--;
		b--;
		next[a][next_num[a]++] = b;
		next[b][next_num[b]++] = a;
	}
	printf("%d\n", search(0, 0));
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(a * b, c * d) << endl;


    return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
if x == 1 or x == 2 * n - 1:
    print('No')
else:
    print('Yes')
    m = 2
    for i in range(2 * n - 1):
        if i == n - 2:
            print(1)
        elif i == n - 1:
            print(x)
        elif i == n:
            print(2 * n - 1)
        else:
            if m == x:
                m += 1
            print(m)
            m += 1


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


int main() {
 #define int long long
  int X,A;
  string s,a;
  
  cin >> s;
  a="No";
  if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
    a="Yes";
  }
  cout << a<< endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <random>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;


int square_sum(const vector<int>& x, int p) {
  int sum = 0;
  for (int xi : x) {
    sum += (xi - p) * (xi - p);
  }
  return sum;
}

int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }

  int min = INT_MAX;
  for (int p = 1; p <= 100; ++p) {
    min = std::min(square_sum(x, p), min);
  }
  cout << min;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define int long long
#define ll long long
#define mod 998244353
#define endl "\n"
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 

using namespace std;


int32_t main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t=1,ca=0;
        //cin>>t;
        while(t--)
        {
            ca+=1;
            int n,k;
            cin>>n>>k;
            int ans=n%k;
            ans=min(abs(ans-k),ans);
            cout<<ans<<endl;
            
        }
    return 0;
}




Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
char s[N];int st[N],n,res,top;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	fp(i,1,n)if(s[i]!='x')st[++top]=i;
	for(R int i=1,j=top;i<j;++i,--j)
		if(s[st[i]]!=s[st[j]])return puts("-1"),0;
	st[top+1]=n+1;
	for(R int i=0,j=top+1;i<j-1;++i,--j)
		res+=abs((st[i+1]-st[i]-1)-(st[j]-st[j-1]-1));
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 768
import java.text.DecimalFormat;
import java.util.Scanner;


public class Main {

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

		DecimalFormat df = new DecimalFormat("0.000");
		while (in.hasNext()) {
			double[][] A = new double[2][2];
			double[] b = new double[2];
			
			A[0][0] = in.nextInt();
			A[0][1] = in.nextInt();
			b[0] = in.nextInt();
			A[1][0] = in.nextInt();
			A[1][1] = in.nextInt();
			b[1] = in.nextInt();
			
			double[] x = gaussJordan(A, b);
			System.out.println(df.format(x[0])+" "+df.format(x[1]));
		}
	}

	// solve Ax=b
	static double[] gaussJordan(double[][] A, double[] b) {
		int n = A.length;
		double[][] B = new double[n][n+1];
		for (int i=0;i<n;i++) {
			for (int j=0;j<n;j++) {
				B[i][j] = A[i][j];
			}
			B[i][n] = b[i];
		}
		
		for (int v=0;v<n;v++) { // for each variable(column)
			// search for variable whose abs(coefficient) is max
			int pivot = v;
			for (int r=pivot;r<n;r++) {
				if (Math.abs(B[r][v])>Math.abs(B[pivot][v])) {
					pivot = r;
				}
			}
			
			swapRowD(B, v, pivot);
			for (int c=v+1;c<n+1;c++) {
				B[v][c] /= B[v][v];
			}
			for (int r=0;r<n;r++) {
				if (r==v) continue;
				for (int c=v+1;c<n+1;c++) {
					B[r][c] -= B[v][c]*B[r][v];
				}
			}
		}
		
		double[] res = new double[n];
		for (int i=0;i<n;i++) {
			res[i] = B[i][n];
		}
		return res;
	}
	
	static void swapRowD(double[][] A, int m, int n) {
		double[] tmp = A[m];
		A[m] = A[n];
		A[n] = tmp;
	}
}

Measured memory_bytes: 26412
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

int fact[200001];

int binpow(int n, int p) {
    if (p == 0)
        return 1;
    int t;
    if (p % 2) {
        return (binpow(n, p - 1) * n) % M;
    } else {
        t = binpow(n, p / 2);
        return (t * t) % M;
    }
}

int C(int n, int k) {
    return (((fact[n] * binpow(fact[k], M - 2)) % M) * binpow(fact[n - k], M - 2)) % M;
}

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

    fact[0] = 1;
    FOR(i, 1, 200001)
        fact[i] = (fact[i - 1] * i) % M;
    int H, W, A, B, ans = 0;
    cin >> H >> W >> A >> B;
    int i = H - A;
    FOR(j, B + 1, W + 1)
        ans = (ans + C(i + j - 2, i - 1) * C((H - i) + (W - j + 1) - 2, H - i - 1)) % M;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int R,C,K;
ll d[3003][3003];
ll dp[3003][3003][4];

int main(){
	//ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>R>>C>>K;
	for(int i=0;i<K;i++){
		int r,c; ll v;
		cin>>r>>c>>v;
		d[r][c]=v;
	}
	for(int i=1;i<=R;i++) for(int j=1;j<=C;j++){
		for(int k=0;k<4;k++) dp[i][j][k]=dp[i][j-1][k];
		for(int k=0;k<4;k++) dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
		for(int k=0;k<4;k++) dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+d[i][j]);
		for(int k=1;k<4;k++) dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+d[i][j]);
	}
	ll ans=0;
	for(int k=0;k<4;k++) ans=max(ans,dp[R][C][k]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 355184
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
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 operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=list(ss())

if "7" in n:
    print("Yes")
else:
    print("No")








Measured memory_bytes: 72492
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  vector<int> A(3);
  rep(i,3) cin>>A[i];
  sort(A.begin(),A.end());
  A.erase(unique(A.begin(),A.end()),A.end());
  if(A.size()==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())

astart, aend = int(a//0.08+1), int((a+1)//0.08) #[astart, aend)
bstart, bend = int(b//0.10+1), int((b+1)//0.10)

alst = set(range(astart,aend))
blst = set(range(bstart,bend))
share = alst & blst

if len(share) == 0:
    print(-1)
else:
    print(list(share)[0])

Measured memory_bytes: 61960
#include <iostream>
using namespace std;
int main(){
  int N,T,A,X;
  cin >> N >> T >> A;
  int res = 0;
  double cc = 1e18;//最小のものを判断して入うためにも、比較対象を出来るだけ大きく
  for(int i = 1;i <= N;i++){
    cin >> X;//配列入力は同時にできる
    int d = (T*1000-X*6)-A*1000;//1000倍してdoubleを使わない
    if(d<0)d=-d;//絶対値にする
    if(cc>d)cc=d,res=i;//小さいものだけを残していく
  }
  cout << res;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Poll
            int N = int.Parse(Console.ReadLine());

            var words = new Dictionary<string, int>();

            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();

                if (words.ContainsKey(s))
                {
                    words[s]++;
                }
                else
                {
                    words.Add(s, 1);
                }
            }

            int max = words.Max(x => x.Value);

            var ans = words.Where(x => x.Value == max)
                           .ToDictionary(x => x.Key, x => x.Value).Keys.ToList();

            //var ans = new List<string>();

            //foreach (var w in words)
            //{
            //    if (w.Value == max)
            //    {
            //        ans.Add(w.Key);
            //    }
            //}

            ans.Sort(StringComparer.Ordinal);

            foreach (var a in ans)
            {
                Console.WriteLine(a);
            }
        }
    }
}


Measured memory_bytes: 49528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		for(int i = 0; i < B; i++) {
			int x = A * i % B;
			if(x == C) {
				System.out.println("YES");
				return;
			} 	
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout(v) if(false);
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;



void Main()
{
	int A,B;
	cin>>A>>B;
	int num = 1;
	int cnt = 0;
	while(num<B){
		num+=(A-1);
		cnt++;
	}

	cout<<cnt<<endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256