akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
vector<int>g[1100];
long long dp[1100][1100];
int bfs[1100];
int pr[1100];
int dep[1100];
int D;
int T=510;
int lis[1100];
int dist[1100];
int dc(int a,int b){
	int ret=0;
	int f=0;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		dist[g[a][i]]=dist[a]+1;
		int q=dc(g[a][i],a)+1;
		ret=max(ret,q);
	}
	return ret;
}
void dfs(int a,int b){
	for(int i=-(D-dist[a]);i<=D-dist[a];i++){
		dp[a][T+i]=1;
	}
	for(int i=0;i<g[a].size();i++){
		if(g[a][i]==b)continue;
		dfs(g[a][i],a);
		for(int j=0;j<1100;j++){
			long long tmp=0;
			if(j)tmp=(tmp+dp[g[a][i]][j-1])%mod;
			if(j+1<1100)tmp=(tmp+dp[g[a][i]][j+1])%mod;
			dp[a][j]=dp[a][j]*tmp%mod;
		}
	}
}
int n;
long long calc(int a){
	dist[a]=0;
	dc(a,-1);
	for(int i=0;i<n;i++)for(int j=0;j<1100;j++)dp[i][j]=0;
	dfs(a,-1);
	long long ret=0;
	for(int i=0;i<1100;i++){
		ret=(ret+dp[a][i])%mod;
	}
	return ret;
}
int main(){
	int a;
	scanf("%d",&a);
	n=a;
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	long long r=1;
	for(int i=0;i<a-1;i++)r=r*2%mod;
	queue<int>Q;
	Q.push(0);
	for(int i=0;i<a;i++)bfs[i]=-1;
	bfs[0]=0;
	while(Q.size()){
		int at=Q.front();
		Q.pop();
		for(int i=0;i<g[at].size();i++){
			int to=g[at][i];
			if(bfs[to]!=-1)continue;
			bfs[to]=bfs[at]+1;
			Q.push(to);
		}
	}
	int sz=0;
	int mv=0;
	for(int i=0;i<a;i++){
		if(bfs[mv]<bfs[i])mv=i;
	}
	for(int i=0;i<a;i++)bfs[i]=-1;
	Q.push(mv);
	bfs[mv]=0;
	pr[mv]=-1;
	while(Q.size()){
		int at=Q.front();Q.pop();
		for(int i=0;i<g[at].size();i++){
			int to=g[at][i];
			if(bfs[to]!=-1)continue;
			Q.push(to);
			bfs[to]=bfs[at]+1;
			pr[to]=at;
		}
	}
	int di=0;
	int da=0;
	for(int i=0;i<a;i++){
		if(di<bfs[i]){
			di=bfs[i];
			da=i;
		}
	}
	int at=da;
	while(~at){
		lis[sz++]=at;
		at=pr[at];
	}
	long long ret;
	if(di%2==0){
		D=sz/2;
		ret=calc(lis[sz/2]);
	}else{
		D=(sz+1)/2;
		ret=(calc(lis[sz/2-1])+calc(lis[sz/2]))%mod;
		g[n].push_back(lis[sz/2-1]);
		g[n].push_back(lis[sz/2]);
		for(int i=0;i<g[lis[sz/2-1]].size();i++){
			if(g[lis[sz/2-1]][i]==lis[sz/2])g[lis[sz/2-1]][i]=n;
		}
		for(int i=0;i<g[lis[sz/2]].size();i++){
			if(g[lis[sz/2]][i]==lis[sz/2-1])g[lis[sz/2]][i]=n;
		}
		ret=(ret+mod-calc(n))%mod;
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  vi A(N),B(N),C(N),D(N),E(N);
  rep(i,0,N) cin>>A[i];
  rep(i,0,N) cin>>B[i];
  rep(i,0,N) cin>>C[i];
  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));
  int sum=0,ans=0;
  rep(i,0,N){
    if(B[i]>=C[N-1])
      break;
    D[i]=N-disup(C,B[i]);
    }
  rep(i,0,N){
    sum+=D[N-1-i];
    E[N-1-i]=sum;
    }
  rep(i,0,N){
    int X=disup(B,A[i]);
    ans+=E[X];
    }
  cout<<ans<<endl;
  }


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int N = input[0];
        int M = input[1];
        long[] A = ReadLongs();
        Array.Sort(A);
        List<long[]> bc = new List<long[]>(M);
        for (int i = 0; i < M; i++)
        {
            long[] tmp = ReadLongs();
            bc.Add(new long[] { tmp[0], tmp[1] });
        }
        bc.Sort((a, b) => Math.Sign(b[1] - a[1]));

        int cnt = 0;
        int k = 0;
        while (k < M && cnt<N)
        {
            long b = bc[k][0];
            long c = bc[k][1];
            k++;
            if (c < A[cnt]) break;
            while (b > 0 && cnt < N)
            {
                if (c > A[cnt]) A[cnt] = c;
                else break;
                b--;
                cnt++;
            }
        }

        long ans = A.Sum();
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 30908
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int h,w;
	cin >> h >> w;
	char s[h][w];
	REP(i,h)
		REP(j,w)
			cin >> s[i][j];
	int left[h][w] = {},right[h][w] = {},up[h][w] ={},down[h][w] = {};
	REP(i,h){
		REP(j,w){
			if(j == 0 && s[i][j] == '.') left[i][j] = 1;
			else if(s[i][j] == '.') left[i][j] = left[i][j - 1] + 1;
			else left[i][j] = 0;
		}
	}
	REP(i,h){
		for(int j = w - 1; j >= 0; j--){
			if(j == w - 1 && s[i][j] == '.') right[i][j] = 1;
			else if(s[i][j] == '.') right[i][j] = right[i][j + 1] + 1;
			else right[i][j] = 0;
		}
	}
	REP(j,w){
		REP(i,h){
			if(i == 0 && s[i][j] == '.') up[i][j] = 1;
			else if(s[i][j] == '.') up[i][j] = up[i - 1][j] + 1;
			else up[i][j] = 0;
		}
	}
	REP(j,w){
		for(int i = h - 1; i >= 0; i--){
			if(i == h - 1 && s[i][j] == '.') down[i][j] = 1;
			else if(s[i][j] == '.') down[i][j] = down[i + 1][j] + 1;
			else down[i][j] = 0;
		}
	}
	int ans = 0;
	REP(i,h)
		REP(j,w)
			ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3);
	cout << ans << endl;
}

Measured memory_bytes: 66688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


ll h, w;

int main() {

	cin >> h >> w;

	if (h == 1 || w == 1) {
		cout << 1 << endl;
	}
	else {
		if (h % 2 == 1 && w % 2 == 1) {
			cout << h * w / 2 + 1 << endl;
		}
		else {
			cout << h * w / 2 << endl;
		}
	}

	return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	double N ;
	cin >> N;
	for(int i = 0 ; i <= N ; i++){
		int money = i * 1.08;
		if( (int)(i * 1.08) == N){
			cout << i << endl;
			return 0 ;
		}
	}

		cout << ":("<<endl;
}


Measured memory_bytes: 256
n, m = gets.split(' ').map(&:to_i)
img_a = (1..n).to_a.map do
  gets.chomp
end
img_b = (1..m).to_a.map do
  gets.chomp
end

if img_a == img_b
  print "Yes\n"	
  exit
end

(0..n-m-1).to_a.each do |i|
  j = img_a[i].index(img_b[0])
  if j
    matched = (0..m-1).to_a.all? do |k|
      img_a[i+k].slice(j..(m+j-1)) == img_b[k]
    end
    if matched
      print "Yes\n"
      exit
    end
  end
end
print "No\n"

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    int l = log10(n);
    if (l % 2 == 1)
    {
        l--;
    }
    else
    {
        ans += n - pow(10, l) + 1;
        l -= 2;
    }
    while (l >= 0)
    {
        ans += pow(10, l + 1) - pow(10, l);
        l -= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include<stdio.h>

int main(){
  int a[3],b[3];
  int i;
  int count[5]={0};

  scanf("%d %d",&a[0],&b[0]);
  scanf("%d %d",&a[1],&b[1]);
  scanf("%d %d",&a[2],&b[2]);

  for(i=0;i<3;i++){
      count[a[i]] += 1;
      count[b[i]] += 1;
  }
  
  int flag=0;
  for(i=1;i<5;i++){
    if(count[i]>=3){
      flag=1;
    }
  }
  
  if(flag){
    printf("NO");
  }else printf("YES");
  return 0;

}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=3e5+5;
int x[N],y[N];
vector<int> v[N];


void solve()
{
 multiset<int> s;
 int h,w,m,p,q;
 cin>>h>>w>>m;
 for(int i=1;i<=m;i++)
 {
    cin>>p>>q;
    y[q]++;
    x[p]++;
    v[p].push_back(q);
 } 

 for(int i=1;i<N;i++)
    s.insert(y[i]);
 int ans=0;
 for(int i=1;i<N;i++)
 {
    for(auto j:v[i])
    {
        s.erase(s.find(y[j]));
        s.insert(y[j]-1);
    }
    ans=max(ans,x[i]+(*s.rbegin()));
    for(auto j:v[i])
    {
        s.erase(s.find(y[j]-1));
        s.insert(y[j]);
    }    
 }
 cout<<ans;



}

signed main() {
    
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 38736
#include <bits/stdc++.h>
using namespace std;
 
#define mod             1000000007
#define w(x)            int x; cin>>x; while(x--)
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll              long long
 
int s[100], a[100], b[100], c[100], d[100], n, m ,q;
ll ans;

void dfs(int idx, int num) {
    s[idx] = num;
    if(idx == n) {
        ll sum = 0;
        for(int i = 1; i <= q; i++) {
            if(s[b[i]] - s[a[i]] == c[i]) sum+= d[i];
        }
        ans = max(ans, sum);
    }
    else{
        for(int i = num; i <= m; i++) {
            dfs(idx+1, i);
        }
    }
}

int main() {
    fast
    cin >> n >> m >> q;
    ans = -1;
    for(int i = 1; i <= q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(1, 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))
ans = 0
"""
一番大きい偶数を2で割る
それ以外は3倍
を繰り返す
奇数だけになったら終了
↓
各項が2で何回われるか の合計
"""
for i in range(n):
    cnt = 0
    tmp = a[i]
    while tmp % 2 == 0:
        tmp = tmp // 2
        cnt += 1
    ans += cnt
print(ans)

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

using namespace std;

#define ll long long
#define REP(i, n) for(int i=0; i < (int)(n); ++i)
#define REPR(i, n) for(int i=n; i>= 0; --i)
#define FOR(i, m, n) for(int i=m; i<(n); ++i)

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M), ans(N, 0);
    REP(i, M){
        cin >> a[i] >> b[i];
        ans[a[i]-1]++;
        ans[b[i]-1]++;
    }
    REP(i,N){
        cout << ans[i] << endl;
    }



    return 0;
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

int n, m, l, q;
vector<vector<pair<ll, ll>>> G;
vector<vector<pair<ll, ll>>> G2;
vector<vector<ll>> dist;
vector<vector<ll>> dist2;

void floydWarshall()
{
	for (int u = 0; u < n; ++u) {
		dist[u][u] = 0;
		for (auto v : G[u]) {
			dist[u][v.fi] = v.se;
			dist[v.fi][u] = v.se;
		}
	}

	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				if (dist[i][j] > dist[i][k] + dist[k][j])
					dist[i][j] = dist[i][k] + dist[k][j];
}

void floydWarshall2()
{
	
	for (int u = 0; u < n; ++u) {
		dist2[u][u] = 0;
		for (auto v : G2[u]) {
			dist2[u][v.fi] = v.se;
			dist2[v.fi][u] = v.se;
		}
	}

	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				if (dist2[i][j] > dist2[i][k] + dist2[k][j])
					dist2[i][j] = dist2[i][k] + dist2[k][j];
}

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

	cin >> n >> m >> l;

	G.resize(n);
	G2.resize(n);
	dist.resize(n, vector<ll>(n, 1e18));
	dist2.resize(n, vector<ll>(n, 1e18));
	for (int i = 0; i < m; ++i) {
		ll u, v, c;
		cin >> u >> v >> c;
		u--;
		v--;
		G[u].emplace_back(v, c);
		G[v].emplace_back(u, c);
	}
	floydWarshall();
	
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j)  {
			if (dist[i][j] <= l) {
				G2[i].emplace_back(j, 1);
				G2[j].emplace_back(i, 1);
			}
		}
	}
	floydWarshall2();



	cin >> q;
	for (int i = 0; i < q; ++i) {
		ll u, v;
		cin >> u >> v;
		u--;
		v--;
		cout << (dist2[u][v] == 1e18 ? -1 : dist2[u][v] - 1) << '\n';
	}
}


Measured memory_bytes: 6784
function main(input) {
  var input=input.trim();
  var a=0,b=0;
  for(var i=0;i<input.length;i++){
    if(input[i] == '0') a++;
    else b++;
  }
  console.log(Math.min(a,b)*2);
}

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


Measured memory_bytes: 7372
a, b, c = map(int, input().split())
k = int(input())
flg = False
c = (2**k) * c
for i in range(k):
  if a < b < c:
    flg = True
    break
  b *= 2
  c //= 2

if flg:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9160
from itertools import combinations
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = 10**10
for i in range(1,n+1):
  for j in combinations(ca,i):
    check = [0]*(m+1)
    for k in j:
      for a in range(m+1):
        check[a] += k[a]
    if min(check[1:]) >= x:
      ans = min(ans, check[0])

if ans == 10**10:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9196
// abc113.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <climits>
#include <iostream>
#include <cstdio>
using namespace std;

double dabs(double a) { return a < 0 ? -a : a; }

int main()
{
	double n, t, a, h, anst = INT_MAX;
	int i,ansn;
	cin >> n >> t >> a;
	for (i = 0; i < n; i++)
	{
		cin >> h;
		//printf("%lf:%lf\n", t - h * 0.006 - a, anst);
		if (dabs(t - h * 0.006 - a) < anst)
		{
			anst = dabs(t - h * 0.006-a);
			ansn = i + 1;
		}
	}
	cout << ansn << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 888
K, N = input().split()
K, N = int(K), int(N)
A = input().split()
for i in range(N):
    A[i] = int(A[i])

A.sort()
X = 0
for i in range(N-1):
    X_ = A[i+1] - A[i]
    if X < X_:
        X = X_

X_ = A[0] + (K - A[N-1])
if X < X_:
    X = X_

print(K - X)


Measured memory_bytes: 18636
package main

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

func main() {
	scanner := makeScanner(8192)
	eGetInt(scanner)
	as := eGetInts(scanner)
	bs := eGetInts(scanner)
	cs := eGetInts(scanner)
	sumb := 0
	for i := 0; i < len(bs); i++ {
		sumb += bs[i]
		if (i < len(bs)-1) && (as[i]+1 == as[i+1]) {
			sumb += cs[as[i]-1]
		}
	}
	fmt.Println(sumb)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val xy = readLine()!!.split(" ").map{it.toInt()}.toList()
    val groupA = listOf(1,3,5,7,8,10,12)
    val groupB = listOf(4,6,9,11)
    val groupC = listOf(2)
    if(groupA.containsAll(xy) || groupB.containsAll(xy)|| groupC.containsAll(xy) ){
        println("Yes")
    }else{
        println("No")
    }
}

Measured memory_bytes: 37864
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
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; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}
#pragma region bfs
#define BFSMAP vector<vector<BFSOBJ> >
struct BFSOBJ{
    ll x;
    ll y;
    vector<BFSOBJ*> next;
    bool is(const BFSOBJ* obj){
        return x==obj->x&&y==obj->y;
    }
    void set4(BFSMAP& ob, int i=-1, int j=-1){
        if(j<0||i<0){
            i=x;
            j=y;
        }
        int H=ob.size();
        int W=ob[0].size();
        if(i-1>=0) next.push_back(&ob[i-1][j]);
        if(j-1>=0) next.push_back(&ob[i][j-1]);
        if(i+1<H) next.push_back(&ob[i+1][j]);
        if(j+1<W) next.push_back(&ob[i][j+1]);
    }
    void set8(BFSMAP& ob, int i=-1, int j=-1){
        if(j<0||i<0){
            i=x;
            j=y;
        }
        int H=ob.size();
        int W=ob[0].size();
        bool n1, n2, n3, n4;
        if(n1=i-1>=0) next.push_back(&ob[i-1][j]);
        if(n2=j-1>=0) next.push_back(&ob[i][j-1]);
        if(n3=i+1<H) next.push_back(&ob[i+1][j]);
        if(n4=j+1<W) next.push_back(&ob[i][j+1]);
        if(n1&&n2) next.push_back(&ob[i-1][j-1]);
        if(n2&&n3) next.push_back(&ob[i+1][j-1]);
        if(n3&&n4) next.push_back(&ob[i+1][j+1]);
        if(n4&&n1) next.push_back(&ob[i-1][j+1]);
    }
};

int bfs(BFSOBJ* start, BFSOBJ* end){
    queue<BFSOBJ*> q;
    map<BFSOBJ*, int> depth;
    q.push(start);
    depth[start] = 0;
    while(!q.empty()){
        BFSOBJ* now = q.front(); q.pop();
        if(now->is(end)){
            return depth[now];
        }
        for(const auto& next : now->next){
            if(depth.end() == depth.find(next)){
                depth[next] = depth[now] + 1;
                q.push(next);
            }
        }
    }
    return -1;
}
#pragma endregion

void Main(){
    int H, W;
    cin >> H >> W;
    BFSMAP mp(H, vv(BFSOBJ)(W));
    int cnt=0;
    REP(i, H){
        string s;
        cin >> s;
        REP(j, W){
            mp[i][j].x=i;mp[i][j].y=j;
            if(s[j]=='.'){
                mp[i][j].set4(mp);
                cnt++;
            }
        }
    }
    int score=bfs(&mp[0][0], &mp[H-1][W-1]);
    if(score==-1){
        cout << -1 << el;
    }else{
        cout << cnt-score-1 << el;
    }
}




Measured memory_bytes: 640
import numpy as np

A,B,H,M = (int(x) for x in input().split())

deg_H = H*np.pi/6+np.pi/6/60*M
deg_M = np.pi/30*M

theta = deg_H-deg_M

x = np.sqrt(A**2 + B**2 -2*A*B*np.cos(theta))
print(x)

Measured memory_bytes: 27200
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  deque<ll> a;
  rep(i,n) {
    ll t;
    cin >> t;
    if (i%2 == 0) {
      a.push_front(t);
    }
    else {
      a.push_back(t);
    }
  }
  if (n%2 == 0) {
    for (auto itr = a.end()-1; itr != a.begin()-1; --itr) {
      cout << *itr << ' ';
    }
  }
  else {
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
       cout << *itr << ' ';
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 5260
import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
P=set(P)
A=[]
for i in range(102):
    if i not in P:
        A.append(i)
zahyo=bisect.bisect_left(A,X)
ans=[]
ans.append([abs(X-A[zahyo]),A[zahyo]])
ans.append([abs(X-A[zahyo-1]),A[zahyo-1]])
ans.sort()
print(ans[0][1])

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <string>
#include <tuple>

typedef long long ll;

using namespace std;



int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int& hc : h) cin >> hc;
    int mx = -1;
    int ret = 0;
    for(int i=0; i<n ; ++i){
        mx = max(h[i], mx);
        if (mx <= h[i]){
            ++ret;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
def run():
  H, N = map(int, input().split())
  ab = [list(map(int, input().split())) for n in range(N)]
  dp = [float('inf')]*(H+1)
  for h in range(H+1):
    for n in range(N):
      a, b = ab[n]
      if h <= a:
        dp[h] = min(dp[h], b)
      else:
        dp[h] = min(dp[h], dp[h-a]+b)
  print(dp[-1])
    
if __name__ == '__main__':
    run()

Measured memory_bytes: 42732
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,li[55][30];
string s;

int main(){
	cin >> n;
	REP(i,0,n){
		cin >> s;
		REP(j,0,s.size()){
			li[i][s[j]-'a']++;
		}
	}
	
	REP(j,0,30){
		int mi=INF;
		REP(i,0,n) mi=min(mi, li[i][j]);
		li[n][j]=mi;
	}
	
	REP(i,0,30) REP(j,0,li[n][i]) cout << (char)(i+'a');
	

	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ldb long double
#define mt meke_tuple
template<typename T> bool ckmn(T &a, T b){ T c=a;a=min(a,b);return a!=c;}
template<typename T> bool ckmx(T &a, T b){ T c=a;a=max(a,b);return a!=c;}

int main()
{
	int n,a,b;
	scanf("%i %i %i",&n,&a,&b);
	printf("%i %i\n",min(a,b),max(0,a+b-n));
	return 0;
}


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

int n;
vector<int> P, V;
int dp[101][100005];

int knapsack(int id, int W)
{
	if(id == n) return 0;
	if(dp[id][W] != -1)
		return dp[id][W];
	int ans = 0;
	if(P[id] <= W) ans = V[id] + knapsack(id + 1, W - P[id]);
	ans = max(ans, knapsack(id + 1, W));
	return dp[id][W] = ans;
}

int32_t main()
{
	int w;
	cin >> n >> w;
	for(int i = 0; i < n; i++)
	{
		int p, v;
		cin >> p >> v;
		P.push_back(p);
		V.push_back(v);
	}
	memset(dp, -1, sizeof(dp));
	cout << knapsack(0, w) << '\n';

	return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll fact(ll x){
    if(x==0 || x==1) return 1;
    else return x * (fact(x-1)%MOD) % MOD;
}

int main(){
    ll n,K; cin >> n >> K;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll dp[n+2][n+2][260] = {};
    dp[0][0][0] = 1;
    rep(i,n+1){
        rep(j,i+1){
            rep(k,256){
                REP(l,1,n-i+1){
                    dp[i+l][j+1][k^a[i+l-1]] += dp[i][j][k];
                    dp[i+l][j+1][k^a[i+l-1]] %= MOD;
                }
            }
        }
    }
    ll ans = 0;
    rep(i,n+1){
        REP(j,1,n+1){
            ans += dp[i][j][K] * fact(j);
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 21376
#include<iostream>
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
int main() {
 
    int N, A[100],minj;
    int count = 0;
 
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> A[i];
 
    for (int i = 0; i < N-1 ; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj])
                minj = j;
        }
            swap(A[i], A[minj]);
            if (i != minj) count++;
    }
 
    for (int i = 0; i < N; i++) {
        if (i != 0) cout << " ";
        cout << A[i];
    }
    putchar('\n');
 
    cout << count << endl;
 
    return 0;
 
}

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

int main(){
  
  string s, ans;
  cin >> s;
  if(s[1] == s[2] && ((s[0] == s[1]) || s[2] == s[3])) ans = "Yes";
  else ans = "No";
  cout << ans << endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func countMin(str string) (count int) {
	count = 0
	var c1, c2 int
	for i, x := range str {
		if i%2 == 0 {
			if x == '0' {
				c1++
			}
			if x == '1' {
				c2++
			}
		}
		if i%2 == 1 {
			if x == '0' {
				c2++
			}
			if x == '1' {
				c1++
			}
		}
	}
	if c1 < c2 {
		count = c1
	} else {
		count = c2
	}
	return

}

func main() {
	var str string
	fmt.Scan(&str)
	fmt.Println(countMin(str))
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>

int main() {
	int n, l;

	std::cin >> n >> l;

	int sum = 0;

	for (size_t i = 0; i < n; i++)
	{
		sum += l + (i + 1) - 1;
	}

	int min = 10000000;
	int min_val = 0;

	for (int i = 0; i < n; i++)
	{
		if (min > std::abs(sum - (sum - (l + i)))) {
			min = std::abs(sum - (sum - (l + i)));
			min_val = sum - (l + i);
		}
	}

	std::cout << min_val << std::endl;
	return 0;
}

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

int64_t lucas( int n ) {
	if( n == 1 ) {
		return 1;
	}

	int64_t a = 2;
	int64_t b = 1;
	int64_t c = a + b;

	for( int i = 2; i < n; ++i ) {
		a = b;
		b = c;
		c = a + b;
	}

	return c;
}

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

	cout << lucas( N ) << endl;
}


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

int main(){
    int n, m, cnt = 0,sum = 0;
    cin >> n >> m;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }

    for(int i = 0; i < n; i++){
        if(a[i] >= (sum / double(m * 4))) cnt++;
    }

    if(cnt >= m){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 256
def examA():
    N = I()
    V = LI()
    C = LI()
    ans = 0
    for i in range(N):
        ans += max(0,V[i]-C[i])
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 59756
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int H, W, K; cin >> H >> W >> K; 
	int X1, Y1, X2, Y2; 
	cin >> X1 >> Y1 >> X2 >> Y2; 
	X1--; Y1--; X2--; Y2--;  
	char C[H][W] = {}; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> C[i][j]; 
		}
	}
	int D[H][W] = {}; 
	int inf = 1145141919; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			D[i][j] = inf; 
		}
	}
	D[X1][Y1] = 0; 
	queue<pair<int, int>> que; 
	que.push(make_pair(X1, Y1)); 
	while(que.size()){
		pair<int, int> p = que.front(); 
		que.pop(); 
		int x = p.first; int y = p.second; 
		int d = D[x][y]; 
		for(int i = 1; i <= K; i++){
			if(x+i >= H) break; 
			if(C[x+i][y] == '@') break; 
			if(D[x+i][y] <= d) break; 
			if(D[x+i][y] == inf) que.push(make_pair(x+i, y)); 
			D[x+i][y] = d + 1; 
		}
		for(int i = 1; i <= K; i++){
			if(x-i < 0) break; 
			if(C[x-i][y] == '@') break; 
			if(D[x-i][y] <= d) break; 
			if(D[x-i][y] == inf) que.push(make_pair(x-i, y)); 
			D[x-i][y] = d + 1; 
		}
		for(int i = 1; i <= K; i++){
			if(y+i >= W) break; 
			if(C[x][y+i] == '@') break; 
			if(D[x][y+i] <= d) break; 
			if(D[x][y+i] == inf) que.push(make_pair(x, y+i)); 
			D[x][y+i] = d + 1; 
		}
		for(int i = 1; i <= K; i++){
			if(y-i < 0) break; 
			if(C[x][y-i] == '@') break; 
			if(D[x][y-i] <= d) break; 
			if(D[x][y-i] == inf) que.push(make_pair(x, y-i)); 
			D[x][y-i] = d + 1; 
		}
	}
	if(D[X2][Y2] == inf) cout << -1 << "\n"; 
	else cout << D[X2][Y2] << "\n"; 
}

Measured memory_bytes: 9212
#include<iostream>
using namespace std;
int main(){
  int N, X;
  cin >> N >> X;
  int ret = 1;
  int xi = 0;
  for(int i=0; i<N; i++){
    int li;
    cin >> li;
    xi += li;
    if(xi<=X) ret+=1;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N;
    cin >> N;
    vector<vector<int> > A(2, vector<int>(N));
    for (auto &V : A) {
        for (auto &x : V) cin >> x;
    }

    vector<vector<int> > dp(2, vector<int>(N, 0));
    dp.at(0).at(0) = A.at(0).at(0);
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i) dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i - 1).at(j) + A.at(i).at(j));
            if (j) dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i).at(j - 1) + A.at(i).at(j));
        }
    }

    cout << dp.at(1).at(N - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def bit_search(n):
    res = []
    for i in range(2**n):
        st = set()
        for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
        res.append(st)
    return res

def main():
    N,M=mi()
    X = {}
    for i in range(M):
        inp = list(mi())
        X[i] = inp[1:]
    
    P = list(mi())

    ans = 0
    for combs in bit_search(N):
        res = 0
        for i in range(M):
            on_count = 0
            for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
            if on_count % 2 == P[i]:
                res += 1

        if res == M:
            ans += 1


    print(ans)
                    





if __name__ == "__main__":
    main()

Measured memory_bytes: 74736
#include <iostream>
using namespace std;
int main()
{
  int n,i,j,k;
  cin >> n;
  for(i=1;i<=n;i++){
    cin >> j;
    cout << "Case " << i << ":" << endl;
    for(k=0; k<10; k++){
      j *= j;
      j = (j % 1000000) / 100;
      cout << j << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if(a==5&&b==5&&c==7) {
			System.out.println("YES");
		}else if(a==5&&b==7&&c==5) {
			System.out.println("YES");
		}else if(a==7&&b==5&&c==5) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 35836
#include<stdio.h>
int main(){
	int h,m,s,S;
	scanf("%d",&S);

	h=S/3600;
	m=(S-h*3600)/60;
	s=S-(h*3600+m*60);

	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう,
signed main(){
    int n,z,w;cin>>n>>z>>w;
    int a[114514];
    rep(i,0,n){
        cin>>a[i];
    }
    if(n==1)cout<<abs(a[0]-w)<<endl;
    else cout<<max(abs(a[n-1]-a[n-2]),abs(w-a[n-1]))<<endl;
    return 0;
}

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

int main(){
    string x;
    cin >> x;
    stack<char> a;
    int cnt = 0;
    for(int i=0;i<x.size();i++){
        if(x[i]=='S') a.push('T');
        else if(!a.empty()){
             cnt++;
             a.pop();
        }
    }
    cout << x.size()-2*cnt << endl;
}

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




int main(){
  int n, k;
  cin >> n >> k;
  vector<int> x(n, 0);
  set<int> st;
  rep(i, k){
    int d;
    cin >> d;
    rep(j, d){

      int a;
      cin >> a;
      st.insert(a);
    }
  }
  cout << n - st.size() << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];
    vector<vector<int>> l(H, vector<int>(W)), r(H, vector<int>(W)),
        u(H, vector<int>(W)), d(H, vector<int>(W));
    rep(i, H) {
        int tmp = 0;
        rep(j, W) {
            if(grid[i][j] == '#') {
                l[i][j] = INF;
                tmp = 0;
            } else {
                l[i][j] = tmp;
                tmp++;
            }
        }
    }
    rep(i, H) {
        int tmp = 0;
        for(int j = W - 1; j >= 0; j--) {
            if(grid[i][j] == '#') {
                r[i][j] = INF;
                tmp = 0;
            } else {
                r[i][j] = tmp;
                tmp++;
            }
        }
    }
    rep(j, W) {
        int tmp = 0;
        rep(i, H) {
            if(grid[i][j] == '#') {
                u[i][j] = INF;
                tmp = 0;
            } else {
                u[i][j] = tmp;
                tmp++;
            }
        }
    }
    rep(j, W) {
        int tmp = 0;
        for(int i = H - 1; i >= 0; i--) {
            if(grid[i][j] == '#') {
                d[i][j] = INF;
                tmp = 0;
            } else {
                d[i][j] = tmp;
                tmp++;
            }
        }
    }
    int res = 0;
    rep(i, H) rep(j, W) {
        res = max(res, l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 73720
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
ll digitPoor(ll n)
{
    assert(INT_MAX == 2147483647);
    assert(n >= 0);

    if (n < 10)         return 1;
    if (n < 100)        return 2;
    if (n < 1000)       return 3;
    if (n < 10000)      return 4;
    if (n < 100000)     return 5;
    if (n < 1000000)    return 6;
    if (n < 10000000)   return 7;
    if (n < 100000000)  return 8;
    if (n < 1000000000) return 9;
    return 10;
}
struct p{
  ll x;
  bool b;
};
int main(){
    ll N,A,B,Ag,Bg;
    string S;
    cin>>N>>A>>B>>Ag>>Bg>>S;
    
    
    ll cntr=0,cnts=0;
    ll maxcnts=0;
    REP(i,N){
       if(S[i]=='#'){
           if(i>=A-1&&max(Ag,Bg)>i)cntr++;
           maxcnts=max(maxcnts,cnts);
           cnts=0;
       } else {
           if(cntr>=2){
               cout<<"No";
               return 0;
           }
           cntr=0;
           if(i>=B-2&&min(Ag,Bg)+1>i)cnts++;
       }
    }
    maxcnts=max(maxcnts,cnts);
    if(Ag<Bg){
        cout<<"Yes";
        
    }else{
        
        if(maxcnts>=3){
            cout<<"Yes";
        }else{
            cout<<"No";  
        }
    }
    return 0;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

int main()
{
  string s[3];
  rep(i, 3) cin >> s[i];
  int a = 0, b = 0, c = 0, p = 0;
  char ch;
  int A = s[0].size(), B = s[1].size(), C = s[2].size();
  while(1){
    if(p == 0 && a == A){
      cout << "A" << endl;
      return 0;
    }
    if(p == 1 && b == B){
      cout << "B" << endl;
      return 0;
    }
    if(p == 2 && c == C){
      cout << "C" << endl;
      return 0;
    }
    if(p == 0) ch = s[0][a++];
    else if(p == 1) ch = s[1][b++];
    else ch = s[2][c++];
    p = ch - 'a';
    //cout << "p:" << p << endl;
  }
    
    
  return 0;
}

Measured memory_bytes: 3532
//C-Modulo_Summation
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  long long int a,sum=0;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>a;
    sum+=a-1;
    
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;

int main() {
	int H,W;cin>>H>>W;
	vector<vector<int>>field(H+2,vector<int>(W+2,1));
	for(int i=0;i<H;++i){
		string st;cin>>st;
		for(int j=0;j<W;++j){
			char ch(st[j]);
			if(ch=='#'){
				field[1+i][1+j]=true;
			}else{
				field[1+i][1+j]=false;
			}
		}
	}
	queue<pair<int,int>>que;
	que.push(make_pair(1,1));

	int dx[]={-1,0,1,0};
	int dy[]={0,1,0,-1};

	vector<vector<int>>memo(H+2,vector<int>(W+2,1e9));
	memo[1][1]=0;
	while(!que.empty()){
		auto p(que.front());
		que.pop();
		int nx(p.first);
		int ny(p.second);
		for(int way=0;way<4;++way){
			if(!field[ny+dy[way]][nx+dx[way]]){
				int nexty=ny+dy[way];
				int nextx=nx+dx[way];
				if(memo[nexty][nextx]>memo[ny][nx]+1){
					memo[nexty][nextx]=memo[ny][nx]+1;
					que.push(make_pair(nextx,nexty));
				}
			}
		}
	}
	if(memo[H][W]==1e9){
		cout<<-1<<endl;
	}else{
		int ans=H*W;
		for(int i=0;i<H;++i){
			for(int j=0;j<W;++j){
				if(field[1+i][1+j]){
					ans--;
				}
			}
		}
		ans-=memo[H][W];
		cout<<ans-1<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;
char s[100001];

void rec(int len){
    if(s[0] == s[1]){
        cout <<  "1 2" << endl;
        return;
    }
    REP2(i,2,len-1){
        if (s[i] == s[i-1]) {
            cout << i << ' ' << i+1 << endl;
            return;
        }else if(s[i] == s[i-2]){
            cout << i-1 << ' ' << i+1 << endl;
            return;
        }
    }
    
    cout << "-1 -1" << endl;
}

int main(){
    cin >> s;
    int len = strlen(s);
    rec(len);
    return 0;
}

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

int main() {
	int n,m;
	cin>>n>>m;
	long a[n][2];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i][0]>>a[i][1];
	   
	}
	long b[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
	    b[i][0]=0;
	    
	}
	for(int i=0;i<=m;i++)
	{
	    b[0][i]=0;
	}
	long k=0;
	for(int i=1;i<=n;i++)
	{
	    for(int j=1;j<=m;j++)
	    {   if(j-a[i-1][0]>=0)
	    {  // cout<<b[i-1][j-a[i-1][0]]+a[i-1][1]<<"    ";
	        b[i][j]=max(b[i-1][j],b[i-1][j-a[i-1][0]]+a[i-1][1]);
	    }
	    else
	    {b[i][j]=b[i-1][j];
	   
	    }
	       //cout<<b[i][j]<<" ";
	    }
	  // cout<<endl;
	    }
	
	cout<<b[n][m];
	
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

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

const int64 mod = 1e9+7;

int main(void){
	int64 H, W, h, w;
	cin >> H >> W >> h >> w;
	if(W%w){
		cout << "Yes" << endl;
		vector<int64> r(W+1);
		r[0] = 0;
		FOR(i, 1, w) r[i] = 500;
		FOR(i, w, W+1) r[i] = r[i-w]-1;
		REP(i, H){
			REP(j, W) cout << r[j+1]-r[j] << " ";
			cout << endl;
		}
		return 0;
	}else if(H%h){
		cout << "Yes" << endl;
		vector<int64> c(H+1);
		c[0] = 0;
		FOR(i, 1, h) c[i] = 500;
		FOR(i, h, H+1) c[i] = c[i-h]-1;
		REP(i, H){
			REP(j, W) cout << c[i+1]-c[i] << " ";
			cout << endl;
		}

		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y,i,j,mi,ma,ans,m1,m2;
    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
    if(a+b<c*2)
        ans=a*x+b*y;
    else
    {
        if(x>=y)
        {
            m1=(x-y)*a+y*2*c;
            m2=x*2*c;
        }
        else
        {
            m1=(y-x)*b+x*2*c;
            m2=y*2*c;
        }
        ans=min(m1,m2);

    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		long A = sc.nextLong();
		long B = sc.nextLong();
		long X = sc.nextLong();

		long subtract = A == 0 ? 0 : Math.floorDiv(A - 1, X) + 1;
		long result = Math.floorDiv(B, X) + 1 - subtract;
		System.out.println(result);
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23124
#include<cstdio>

int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h = S / 3600;
    m = (S - 3600 * h) / 60;
    s = S % 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2732