akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;
 
constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
 
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
 
int main() {
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vint A(N);
    ll cond = M * V;
    
    for (auto &v : A) cin >> v;
    
    sort(begin(A), end(A));
    ll ng = -1, ok = N - P;
    while (llabs(ng - ok) > 1ll) {
        ll m = (ng + ok) / 2;
        ll sum = 0ll;
        for (int i = 0; i <= N - P; i++) {
            sum += min(M, A[m] + M - A[i]);
        }
        for (int i = N - P + 1; i < N; i++) {
            sum += M;
        }
        if (sum >= cond && A[m] + M >= A[N - P]) {
            ok = m;
        } else {
            ng = m;
        }
    }
    cout << N - ok << endl;
    return (0);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < 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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;cin >> s>> t;
  ll ans = 0;
  rep(i,3){
      if(s[i]==t[i])ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N,K = map(int, raw_input().split())
a = map(int, raw_input().split())

ans = []
p = -1
for k in range(K+1):
  m = -1
  for i in range(N):
    if i!=p and (m==-1 or a[i]<a[m]):
      m = i
  for i in range(N):
    if i!=p and i!=m:
      if a[i]==0:
        print -1
        exit(0)
      ans += [i]
      a[i] -= 1
  if a[m]==0:
    print -1
    exit(0)
  ans += [m]
  a[m] -= 1
  p = m
print len(ans)
for x in ans:
  print x+1,
print


Measured memory_bytes: 2692
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int H, W;
	int h, w;
	while(cin >> H >> W >> h >> w) {
		bool f = false;
		if(W%w == 0) {
			f = true;
			swap(H, W);
			swap(h, w);
		}
		if(W%w == 0){
			cout << "No" << endl;
			continue;
		}
		cout << "Yes" << endl;
		vector<int> v(W+1);
		v[W] = 1;
		RFOR(i, W+1-w, W+1){
			for(int k = i; k-w >= 0; k -= w){
				v[k-w] = v[k]+1;
			}
		}
		v[0] = 0;
		for(int k = 0; k+w < SZ(v); k += w) {
			v[k+w] = v[k]-1;
		}
		dpite(ALL(v));
		vector<int> d(W);
		REP(i,W){
			d[i] = v[i+1]-v[i];
		}
		if(f){
			REP(j,W) REP(i,H) cout << d[j] << (i == H-1 ? endl : ' ');
		}else{
			REP(i,H) pite(ALL(d));
		}
	}
	return 0;
}


Measured memory_bytes: 1408
// Problem : B - Homework
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()
{
	fastio;
	int n,m,x,s=0;
	cin>>n>>m;
	while(m--)
	{
		cin>>x;
		s+=x;
	}
	if(s<=n)
		cout<<abs(n-s)<<"\n";
	else
		cout<<-1<<"\n";
   	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdlib> 
#include<sstream>
#include<cstdio>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define mod 1000000007
const int N=1111122;
double P = 3.1415926535897932384626;
int main()
{
	//std::ios::sync_with_stdio(false);
	int r;
	cin>>r;
	printf("%.20f\n",2*P*r);
	//system("pause");
	return 0;
}

Measured memory_bytes: 3260
# D - Ki TLE
import sys
sys.setrecursionlimit(10**7)
N,Q = map(int,input().split())

# 有向グラフ
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)
    
lst = []
for _ in range(Q):
    P,X = map(int,input().split())
    P-=1
    lst.append((P,X))

cnt = [0]*N
for p,x in lst:
    cnt[p] += x 
    
seen = [False]*N
def dfs(v):
    seen[v] = True# v を訪問済みにする
    # v から行ける各頂点 next_v について
    for next_v in G[v]:
        # next_v が探索済みならスルー
        if seen[next_v] == True:
             continue
        cnt[next_v] += cnt[v] 
        dfs(next_v)
dfs(0)
print(*cnt)

Measured memory_bytes: 245656
#include<cstdio>
#include<algorithm>
using namespace std;
int result(int a,int b,int m)
{
	long long  d=1,t=a;
	while(b)
	{
		if(b&1)
		d=(d*t)%m;
		b/=2;
		t=(t*t)%m;
	}
	return d;
}                        
int a[100010];
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		for(int i = 1; i <= n; i++)
		{
			scanf("%d",&a[i]);
			
		}
		sort(a+1,a+n+1);
		int f=1;
		if(n%2==1)
		{
			for(int i = 1; i <= n; i++)
			{
				if(i%2==0)
				{
					if(a[i]!=i)
					{
						f=0;break;
					}
				}
				else
				{
					if(a[i]!=i-1)
					{
						f=0;break;
					}
				}
			}	
		}
		else
		{
			for(int i = 1; i <= n; i++)
			{
				if(i%2==0)
				{
					if(a[i]!=i-1)
					{
						f=0;break;
					}
				}
				else
				{
					if(a[i]!=i)
					{
						f=0;break;
					}
				}
			}	
		}
		if(f==0)
		printf("0\n");
		else
		{
			printf("%d\n",result(2,n/2,1000000007));
		}
	}
	return 0;
}

Measured memory_bytes: 512
n = int(input())
h = list(map(int, input().split()))

count = 0
max_value = 0
for i in range(n)[1::]:
    if h[i-1] >= h[i]:
        count += 1
    else:
        max_value = max(max_value, count)
        count = 0
max_value = max(max_value, count)
print(max_value)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int num=0;
	char c=s[0];
	for(int i=1;s[i]!=0;i++){
		if(c!=s[i]){
			num++;
			c=s[i];
		}
	} 
	printf("%d\n",num);
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <stack>
#include <tuple>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

vector<int> compute_dist(int root, vector<vector<int> > const & g) {
    int n = g.size();
    vector<int> dist(n, -1);
    stack<int> stk;
    dist[root] = 0;
    stk.push(root);
    while (not stk.empty()) {
        int i = stk.top(); stk.pop();
        for (int j : g[i]) if (dist[j] == -1) {
            dist[j] = dist[i] + 1;
            stk.push(j);
        }
    }
    return dist;
}
vector<int> compute_parent(int root, vector<vector<int> > const & g) {
    int n = g.size();
    vector<int> parent(n, -1);
    stack<int> stk;
    stk.push(root);
    while (not stk.empty()) {
        int i = stk.top(); stk.pop();
        for (int j : g[i]) if (parent[j] == -1 and j != root) {
            parent[j] = i;
            stk.push(j);
        }
    }
    return parent;
}

int main() {
    // input
    int n, x, y; scanf("%d%d%d", &n, &x, &y); -- x; -- y;
    vector<vector<int> > g(n);
    repeat (i, n-1) {
        int a, b; scanf("%d%d", &a, &b); -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<vector<int> > h(n);
    repeat (i, n-1) {
        int c, d; scanf("%d%d", &c, &d); -- c; -- d;
        h[c].push_back(d);
        h[d].push_back(c);
    }
    // solve
    vector<int> dist_h = compute_dist(y, h);
    vector<int> parent_h = compute_parent(y, h);
    vector<bool> escapable(n);
    repeat (i, n) for (int j : g[i]) {
        if (parent_h[i] != j
                and parent_h[j] != i
                and parent_h[i] != parent_h[j]
                and (parent_h[i] == -1 or parent_h[parent_h[i]] != j)
                and (parent_h[j] == -1 or parent_h[parent_h[j]] != i)) { // dist(i, j) >= 3
            escapable[i] = true;
            escapable[j] = true;
        }
    }
    int result = 0;
    vector<bool> used(n);
    stack<pair<int, int> > que;
    que.emplace(x, 0);
    while (not que.empty()) {
        int i, dist; tie(i, dist) = que.top(); que.pop();
        setmax(result, dist_h[i] * 2);
        if (escapable[i]) {
            result = -1;
            break;
        }
        for (int j : g[i]) if (not used[j]) {
            used[j] = true;
            if (dist_h[j] <= dist + 1) continue;
            que.emplace(j, dist + 1);
        }
    }
    // output
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 26740
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  int k=100000;
  int idx;
  for(int i=1;i<=n;i++){
    int a=l+i-1;
    if(abs(a)<k){
      k=abs(a);
      idx=i;
    }
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    if(i==idx)continue;
    ans+=l+i-1;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var c1 = ReadLine();
            var c2 = string.Join("", ReadLine().Reverse().ToArray());
            if (c1 == c2)
                WriteLine("YES");
            else
                WriteLine("NO");

        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 26448
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;
using bigfloat = boost::multiprecision::cpp_dec_float_50;

using namespace std;

int main() {
  ll A;
  bigfloat B;
  cin >> A >> B;
  cout << ll(floor(A * B)) << endl;
}


Measured memory_bytes: 3716
#include <stdio.h>
int main(){
  int a,b,c,d,n,ans;
  while(scanf("%d",&n)!=EOF){
    ans=0;
    for(a=0;a<10;a++){
      for(b=0;b<10;b++){
	for(c=0;c<10;c++){
	  for(d=0;d<10;d++){
	    if((a+b+c+d)==n)ans++;
	  }
	}
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

int main(int argc, char const *argv[]) {
  int N, A_i;
  cin >> N;
  vector<int> attend_order(N);
  for (int i = 0; i < N; i++) {
    cin >> A_i;
    attend_order[A_i - 1] = i + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << attend_order[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(void){
  // Your code here!
  int n;
  cin>>n;
  vector<int> sy(n);
  
  int zyo;
  for(int i=0;i<n-1;i++){ 
    cin>>zyo;
    sy[zyo-1]++;
  } 
  
  
  for(int i=0;i<n;i++) cout<<sy[i]<<endl;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long
using namespace std;
int n,l,r,mn=inf;
main(){
	scanf("%lld %lld",&l,&r);
	if(r-l+1>=2019){
		printf("0\n");
		return 0;
	}
	for(int i=l;i<=r;i++){
		for(int j=i+1;j<=r;j++){
			mn=min(mn,((i%2019)*(j%2019))%2019);
		}
	}
	printf("%lld\n",mn);
	return 0;
}




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

public class Solution
{
    public static void Main()
    {
        var s = Console.ReadLine();
        int result = 0;
        switch (s)
        {
            case "SUN":
                result = 7;
                break;
            case "MON":
                result = 6;
                break;
            case "TUE":
                result = 5;
                break;
            case "WED":
                result = 4;
                break;
            case "THU":
                result = 3;
                break;
            case "FRI":
                result = 2;
                break;
            case "SAT":
                result = 1;
                break;
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13152
import java.util.*;
public class Main{   
public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
  String  a = scanner.next();
        char[] chars = a.toCharArray();
        int sum =0;
        for (char aChar : chars) {
            sum+= aChar-'0';
        }

        if(sum%9==0)
        {
            System.out.println("Yes");
        }else
        {
            System.out.println("No");
        }
    
    }
}

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

int A[303][303];
string S[303];

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

    int H, W, K;
    cin >> H >> W >> K;

    for(int i=0; i<H; i++)
        cin >> S[i];

    int col = 1;

    for(int i=0; i<H; i++)
    {
        int prev = 0;

        for(int j=0; j<W; j++)
        {
            if(S[i][j] == '.')
                continue;
            
            while(prev <= j)
                A[i][prev++] = col;
            
            col++;
        }

        if(prev)
        {
            while(prev < W)
            {
                A[i][prev] = A[i][prev-1];
                prev++;
            }
        }
    }

    for(int i=1; i<H; i++)
    {
        if(A[i][0] == 0)
        {
            for(int j=0; j<W; j++)
                A[i][j] = A[i-1][j];
        }
    }

    for(int i=H-2; i>=0; i--)
    {
        if(A[i][0] == 0)
        {
            for(int j=0; j<W; j++)
                A[i][j] = A[i+1][j];
        }
    }

    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
            cout << A[i][j] << " "; 
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;


ll K, A, B,ans=1;

int main(void) {
	cin >> K>>A>>B;
	if (A + 1 >= B) { ct(1 + K); return 0; }
	else {
		ll unko = B - A;
		if (K <= A - 1) { ct(1 + K); return 0; }
		K -= A - 1; ans = A;
		if (K % 2 == 1) { K--; ans++; }
		ans += (K / 2)*unko;


	}
	ct(ans);


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int N,M,X,i,t,l=0,r=0;
scanf("%d %d %d",&N,&M,&X);
for(i=0;i<M;i++){
scanf("%d",&t);
if(t>X)r++;
else if(t<X)l++;
}
if(r>l)printf("%d",l);
else printf("%d",r);
return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
	ll x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << ' ' << y << ' ' << z;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

fn main() {
    let k: i64 = read();
    let x: i64 = read();

    let l = max(-1000000, x - k + 1);
    let r = min(1000000, x + k - 1);
    let mut po = false;
    for i in l..(r+1) {
        if po {
            print!(" ");
        }
        po = true;
        print!("{}", i);
    }
    println!();
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

vector<int> book[10];

int dp[10][2001];

int dfs(int r,int k){
	if(r==10) return 0;
	if(~dp[r][k]) return dp[r][k];
	int ans = dfs(r+1,k) , sum = 0;
	for(int i = 0 ; i < min<int>( k , book[r].size() ) ; i++){
		sum += book[r][i];
		ans = max(ans,dfs(r+1,k-(i+1))+sum+(i)*(i+1));
	}
	return dp[r][k] = ans;
}


int main(){
	memset(dp,-1,sizeof(dp));
	int N,K; 
	scanf("%d%d",&N,&K);
	for(int i = 0 ; i < N ; i++){
		int c,g;
		scanf("%d%d",&c,&g);
		book[g-1].push_back(c);
	}
	for(int i = 0 ; i < 10 ; i++) sort(book[i].rbegin(),book[i].rend());
	printf("%d\n",dfs(0,K));
}

Measured memory_bytes: 0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def main():
    n = int(input())
    if n == 1:
        print(0)
    else:
        x = factorization(n)
        #print(x)
        ans = 0
        for lis in x:
            num = lis[1]
            tmp = 0
            while num > tmp:
                tmp += 1
                ans += 1
                num -= tmp
        print(ans)

    
    
 
 
 
if __name__ == "__main__":
    main()

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

int main(){
    int A,B,ans= 0;
    cin >> A >> B;

    for(int i = 0; i <2; i++){
        if(A>B){
            ans += A;
            A--;
        }else{
            ans += B;
            B--;
        }
        

    }
    cout << ans << endl;
}

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

typedef long long ll;
#define OO 1e9
using namespace std;

int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int a[3][n];
  int dp[3][n];
  for(int i = 0;i < n;i++)
    scanf("%d %d %d", a[0] + i, a[1] + i, a[2] + i);

  dp[0][0] = a[0][0];
  dp[1][0] = a[1][0];
  dp[2][0] = a[2][0];

  for(int i = 1;i < n;i++){
    for(int k = 0;k < 3;k++){
      dp[k][i] = -1;
      for(int j = 0;j < 3;j++){
        if(j == k)
          continue;
        dp[k][i] = max(dp[k][i], dp[j][i - 1] + a[k][i]);
      }
//      cout << k << ' ' << i << ' ' << dp[k][i] << endl;
    }
  }
  cout << max(max(dp[0][n - 1], dp[1][n - 1]), dp[2][n - 1]);
}


Measured memory_bytes: 2560
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        ll a,b,c;
        cin>>a>>b>>c;
        cout<<c<<" "<<a<<" "<<b;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<double> vec(n, 0);
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
	}
	sort(vec.begin(), vec.end());
	double t = vec[0];
	for(int i = 1; i < n; ++i){
		t += vec[i];
		t /= 2;
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
#include <algorithm>
#include <bitset>
#include <set>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;
typedef long long int lint;

vector<string> keys;
vector<char> vals;
map<string, char> encoder;

bool AOJ0127()
{
	string str, ret;
	if(!(cin >> str)) return false;

	if (str.size() % 2) {
		cout << "NA" << endl;
		return true;
	}

	REP(i, str.size() / 2) {
		string buf = str.substr(2 * i, 2);
		if (encoder.find(buf) == encoder.end()) {
			cout << "NA" << endl;
			return true;
		}
		ret.push_back(encoder[buf]);
	}
	cout << ret << endl;

	return true;
}

int main()
{
	FOR(i, 1, 7) {
		FOR(j, 1, 6) {
			string key;
			key.push_back('0' + i);
			key.push_back('0' + j);
			keys.push_back(key);
		}
	}

	for (char c = 'a'; c <= 'z'; c++) {
		vals.push_back(c);
	}
	vals.push_back('.');
	vals.push_back('?');
	vals.push_back('!');
	vals.push_back(' ');

	REP(i, keys.size()) {
		encoder[keys[i]] = vals[i];
	}

	while (AOJ0127()) {

	}

	return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>

int main(){
int S, h, m, 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
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	fmt.Println(abc146b(n, s))
}

func abc146b(n int, s string) string {
	var result string
	aInt := int("A"[0])
	zInt := int("Z"[0])
	for i := range s {
		char := s[i]
		if int(char)+n <= zInt {
			result += string(int(char) + n)
		} else {
			result += string(int(char) + n - zInt + aInt - 1)
		}
	}
	return result
}


Measured memory_bytes: 6656
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int[] foo = new int[N];
         for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        }
        
        int sum = 0; 
        Arrays.sort(foo);
        
        for(int i = 0; i < K;i++) {
            sum+= foo[i];
        }
        System.out.println(sum);
    }
}


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

int main() {
    int a, b, c, x,
        cnt = 0;
    cin >> a >> b >> c >> x;

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	auto count = 0;
	for (auto i = 0; i < H; ++i)
	{
		cin >> s[i];
		for (auto j = 0; j < W; ++j)
		{
			if (s[i][j] == '.')
			{
				++count;
			}
		}
	}

	queue<pair<int, int>> q;
	auto result = -1;
	q.push(make_pair(0, 1));
	int next[4][2] = { {0, 1}, {-1, 0}, {0, -1}, {1, 0} };
	while (!q.empty())
	{
		auto& p = q.front();
		q.pop();
		auto i = p.first / W;
		auto j = p.first % W;
		if (i == H - 1 && j == W - 1)
		{
			result = p.second;
			break;
		}

		if (s[i][j] == ' ')
		{
			continue;
		}

		s[i][j] = ' ';
		for (auto k = 0; k < 4; ++k)
		{
			auto nextI = i + next[k][0];
			auto nextJ = j + next[k][1];
			if (nextI < 0 || nextI >= H || nextJ < 0 || nextJ >= W)
			{
				continue;
			}

			if (s[nextI][nextJ] == '.')
			{
				q.push(make_pair(nextI * W + nextJ, p.second + 1));
			}
		}
	}

	if (result >= 0)
	{
		cout << count - result << endl;
	}
	else
	{
		cout << result << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	vector<int> science(4);
	vector<int> social(2);
	cin >> science[0] >> science[1] >> science[2] >> science[3] >> social[0] >> social[1];
	sort(science.rbegin(), science.rend());
	sort(social.rbegin(), social.rend());
	cout << science[0] + science[1] + science[2] + social[0] << endl;
}


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

int main(){
    int N,K;cin>>N>>K;
    vector<long long> V(N);
    for(int i=0;i<N;i++)cin>>V[i];

    long long res=0;
    for(int p=0;p<=min(K,N);p++){
        for(int q=0;p+q<=min(K,N);q++){
            vector<long long> v;
            long long cur=0;
            for(int i=0;i<p;i++)v.push_back(V[i]),cur+=V[i];
            for(int i=0;i<q;i++)v.push_back(V[N-1-i]),cur+=V[N-1-i];

            sort(v.begin(),v.end());
            for(int i=0;i<min(K-p-q,(int)v.size());i++){
                if(v[i]<0)cur-=v[i];
            }
            res=max(res,cur);
        }
        
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();
        int A = int.Parse(s.Split(' ')[0]);
        int B = int.Parse(s.Split(' ')[1]);
        int C = int.Parse(s.Split(' ')[2]);


        if (B + C - A >= 0) {
            Console.WriteLine(B + C - A);
        } else {
            Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 13140
def inverse(k):
    return fast_pow(k, MOD - 2)


def comb(n, k):
    return FACT[n] * INVERSE_FACT[n - k] * INVERSE_FACT[k] % MOD


def fast_pow(x, y):
    if y == 0:
        return 1
    p = fast_pow(x, y // 2) % MOD
    p = p * p % MOD
    if y % 2:
        p = p * x % MOD
    return p


MOD = 1000000007

n, a, b, c = map(int, input().split())

FACT = [0] * (n + 1)
INVERSE_FACT = [0] * (n + 1)

FACT[0] = 1
INVERSE_FACT[0] = 1
for i in range(1, n + 1):
    FACT[i] = FACT[i - 1] * i % MOD
    INVERSE_FACT[i] = inverse(FACT[i])

ans = 0
if b % 2 != 0:
    print(0)
    exit()

for y in range(0, min(a + 1, c + 1)):
    for z in range(0, (c - y) // 3 + 1):
        x = a - y
        rest3 = c - y - 3 * z

        if b == 0 and rest3 != 0:
            continue

        cur_ans = FACT[x + y + z] * INVERSE_FACT[x] % MOD
        cur_ans = cur_ans * INVERSE_FACT[y] % MOD
        cur_ans = cur_ans * INVERSE_FACT[z] % MOD
        cur_ans = cur_ans * comb(x + y + z + 1 + b // 2 - 1, b // 2) % MOD
        cur_ans = cur_ans * comb(b // 2 + rest3 - 1, rest3) % MOD

        ans = (ans + cur_ans) % MOD

print(ans)


Measured memory_bytes: 71664
using AtCoderBeginnerContest137.Questions;
using AtCoderBeginnerContest137.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Security.Cryptography.X509Certificates;

namespace AtCoderBeginnerContest137.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var kx = inputStream.ReadIntArray();
            var k = kx[0];
            var x = kx[1];
            yield return string.Join(" ", Enumerable.Range(x - k + 1, 2 * k - 1));
        }
    }
}


namespace AtCoderBeginnerContest137
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest137.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest137.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int N, W, H, X, Y, S, T, P[500][500];

int main(void) {
  while(cin >> N, N) {
    cin >> W >> H;
    REP(i, 0, H) REP(j, 0, W) P[i][j] = 0;
    REP(i, 0, N) {
      cin >> X >> Y;
      P[Y - 1][X - 1]++;
    }
    cin >> S >> T;

    int ans = 0;
    REP(i, 0, H) REP(j, 0, W) {
      int ii = i + T, jj = j + S;
      if(ii <= H && jj <= W) {
        int sum = 0;
        REP(k, i, ii) REP(l, j, jj) sum += P[k][l];
        ans = max(ans, sum);
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,C;
    cin >> n >> C;
    vector<vector<int>> d(C,vector<int>(C));
    rep(i,C) rep(j,C) cin >> d[i][j];
//    rep(k,C) rep(i,C) rep(j,C) {
//        chmin(d[i][j],d[i][k]+d[k][j]);
//    }
    vector<vector<int>> c(n,vector<int>(n));
    rep(i,n) rep(j,n) {
        int nc;
        cin >> nc;
        nc--;
        c[i][j] = nc;
    }
    int ans = inf;
    vector<vector<int>> dif(3,vector<int>(C,0));
    rep(i,n) rep(j,n) rep(k,C) {
        int mod = (i+j)%3;
        if(mod == 0) dif[0][k] += d[c[i][j]][k];
        else if(mod == 1) dif[1][k] += d[c[i][j]][k];
        else dif[2][k] += d[c[i][j]][k];
    }
    rep(i,C) rep(j,C) rep(k,C) {
        if(i==j || j==k || k==i) continue;
        int now = 0;
        now += dif[0][i];
        now += dif[1][j];
        now += dif[2][k];
        chmin(ans,now);
    }
//    rep(i,C) rep(j,C) cout << i << " " << j << " " << d[i][j] << endl;
    cout << ans << endl;
}


Measured memory_bytes: 1280
using System;

namespace ABC055C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            long N = Int64.Parse(bufs[0]);
            long M = Int64.Parse(bufs[1]);
            long res = 0;

            if (N > (M / 2))
            {
                res = M / 2;
            }
            else
            {
                res = N;
                M -= N * 2;
                res += M / 4;
            }

            Console.WriteLine(res);
        }
    }
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; ++i)
        cin >> s[i];
    vector<int> col(n, -1);
    bool fl = true;
    function<void(int)> f = [&](int x){
        for(int i = 0; i < n; ++i){
            if(s[x][i] == '0')
                continue;
            if(col[i] == -1){
                col[i] = !col[x];
                f(i);
            }
            if(col[i] == col[x])
                fl = false;
        }
    };
    col[0] = 0;
    f(0);
    if(!fl){
        cout << -1 << endl;
        return 0;
    }
    vector<int> dist(n, MOD);
    function<void(int)> g = [&](int x){
        for(int i = 0; i < n; ++i){
            if(s[x][i] == '0')
                continue;
            if(chmin(dist[i], dist[x] + 1))
                g(i);
        }
    };
    int ans = 0;
    for(int i = 0; i < n; ++i){
        dist.assign(n, MOD);
        dist[i] = 0;
        g(i);
        chmax(ans, *max_element(dist.begin(), dist.end()));
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Atcoder
{

    public class Class1
    {
        static void Main(string[] args)
        {
            int count = 0;
            int c = 1;
            var f = 0;
            var b = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ');

            for (;;)
            {
                for (int i = 0; i < b; i++)
                {
                    var d = int.Parse(a[i]) / c;
                    if (d % 2 != 0)
                    {
                        f++;
                        break;

                    }

                    if (i == b - 1)
                    {
                        count++;
                        c=2*c;

                    }
                }
                if (f != 0)
                {
                    break;
                }
            }
          

            Console.WriteLine(count);
        }
    }

}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
ll read()
{
    char s;
    ll k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
} 
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
const int maxn=1e5+100;
int n,Max,Min;
int a[maxn];
ll s,ans;
int main()
{
	n=read();
	Max=-5100;
	Min=5100;
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++)
	{
		s+=abs(a[i]-a[i-1]);
	}
	s+=abs(0-a[n]);
	for (int i=1;i<=n;i++)
	{
		ans=s-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1]);
		printf("%lld\n",ans);
	}
	return 0;
} 

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

int main() {
    int x[5];
    int ans;
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for(int i=0; i<5; i++)
    {
        if(x[i] == 0)
        {
            ans = i+1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[4], i;
	memset (a, 0, sizeof(a));
	string s;
	cin >> s;
	if (s.size()!=3)
	{
		cout << "No" << endl;
		return 0;
	}
	for (i=0; i<3; i++)
	{
		if (s[i]=='a') a[1]--;
		else if (s[i]=='b') a[2]--;
		else if (s[i]=='c') a[3]--;
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}
	for (i=1; i<=3; i++)
		if (a[i]!=-1)
		{
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) 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 MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


h, w = MI()
s = [IS() for _ in range(h)]
L = [[0 for _ in range(w)] for _ in range(h)]
R = [[0 for _ in range(w)] for _ in range(h)]
D = [[0 for _ in range(w)] for _ in range(h)]
U = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            L[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            elif j > 0:
                L[i][j] = L[i][j - 1] + 1

for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == '#':
            R[i][j] = 0
        else:
            if j == w - 1:
                R[i][j] = 1
            elif j < w - 1:
                R[i][j] = R[i][j + 1] + 1

for j in range(w):
    for i in range(h):
        if s[i][j] == '#':
            U[i][j] = 0
        else:
            if i == 0:
                U[i][j] = 1
            elif i > 0:
                U[i][j] = U[i - 1][j] + 1

for j in range(w):
    for i in range(h - 1, -1, -1):
        if s[i][j] == '#':
            D[i][j] = 0
        else:
            if i == h - 1:
                D[i][j] = 1
            elif i < h - 1:
                D[i][j] = D[i + 1][j] + 1

# pprint(L, width=40)
# pprint(R, width=40)
# pprint(U, width=40)
# pprint(D, width=40)

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, ans)
print(ans)


Measured memory_bytes: 195952
s = input()
s = int(s)

def f(n):
  if n%2 is 0:
    return n//2
  return 3*n +1

p = set()
p.add(s)

count = 1
n = s
while True:
  count += 1
  n = f(n)
  if n in p:
    print(count)
    break
  p.add(n)

Measured memory_bytes: 3060
function Main(input) {
  input=input.split("\n");
　const STRING=input[0];
　var array=[];
  var temp;
  for(var i=0;i<STRING.length;i++){
    temp=array.findIndex(e=>{
      return e===STRING[i];
    });
    if(temp===-1){
      array.push(STRING[i]);
    }else{
      array.splice(temp,1);
    }
  }
  console.log(array.length===0?"Yes":"No");
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int c; cin >> c; s.insert(c);
    }
    if (s.size() == n) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

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

struct dice{
    int x[6];
    void roll(char c){
        int a;
        if(c=='N'){
            a=x[0];
            x[0]=x[1];
            x[1]=x[5];
            x[5]=x[4];
            x[4]=a;
        }
        if(c=='S'){
            a=x[0];
            x[0]=x[4];
            x[4]=x[5];
            x[5]=x[1];
            x[1]=a;
        }
        if(c=='E'){
            a=x[0];
            x[0]=x[3];
            x[3]=x[5];
            x[5]=x[2];
            x[2]=a;
        }
        if(c=='W'){
            a=x[0];
            x[0]=x[2];
            x[2]=x[5];
            x[5]=x[3];
            x[3]=a;
        }
    }
    int top(void){
        return x[0];
    }
};

int main(){
    dice d;
    for(int i=0; i<6; ++i)cin>>d.x[i];
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0; i<n; ++i){
        d.roll(s[i]);
    }
    cout<<d.top()<<endl;
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

// ===========Disjoint Set Union================
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};
// =======================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
    A.at(i) -= 1;
  }
  dsu d(N);
  for (ll i = 0; i < M; ++i) {
    ll x, y;
    cin >> x >> y;
    x -= 1, y -= 1;
    d.merge(x, y);
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    if (d.leader(A.at(i)) == d.leader(i)) {
      ans += 1;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 4400