akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define rp(i,l,m) for(int i=l; i<m; ++i)
#define Rp(i,l,m) for(int i=l; i<=m; i++)
#define rpD(i,l,m) for(int i=m; i>l; i--)
#define RpD(i,m,l) for(int i=m; i>=l; i--)
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define sz(a) int((a).size())
#define is insert
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = (int) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a, ll b) {ll r; while (b) {r=a%b;a=b;b=r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p=MOD){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%p;n=n*n%p;}return r;}
#define N 200005

int a, b, t;

inline void Init(){
    cin >> a >> b >> t;

}
inline void solve(){
    cout << t/a*b;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    Init();
    solve();
  return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    vector<int> in(5);
    int i;
    rep(i, 5) cin >> in[i];
    rep(i, 5) if (in[i] == 0) cout << i + 1 << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;
int main() {
  int n, x; cin >> n >> x;
  vector <int> l(n+1);
  l[0] = 0;
  for ( int i; i < n; i++ ) {
    int a; cin >> a;
    l[i+1] = l[i] + a;
  }
  int cnt = 0;
  for ( int i = 0; i < n + 1; i++ ) {
    if ( x >= l[i] ) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[105];
int main()
{
	int i;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	for(i=0 ; i<3 ; i++)
	{
		sort(a,a+3);
	}
	if(a[0]+a[1]==a[2]) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
nya = 'keyence'
ln = len(nya)
for i in range(ln+1):
    #print('-',S[:i],S[len(S)-ln+i:])
    #print('--',nya[:i],nya[i:])
    if S[:i] == nya[:i] and S[len(S)-ln+i:] == nya[i:]:
        print('YES')
        exit()

print('NO')


Measured memory_bytes: 10316
def main():
    N, K = map(int,input().split())
    h = list(map(int,input().split()))
    
    dp = [0] * N
    dp[1] = abs(h[0] - h[1])
    
    for i in range(2, N):
        dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0, i - K), i))
    
    print(dp[-1])

if __name__ == '__main__':
    main()

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    int a[100002];
    cin >> N;
    int to;
    REP(i, N) {
        cin >> to;
        a[i + 1] = to;
    }
    int idx = 1;
    int ans = 0;
    while(true) {
        if(a[idx] == 0) {
            cout << "-1" << endl;
            break;
        }
        int temp = a[idx];
        a[idx] = 0;
        idx = temp;
        ans++;
        if(idx == 2) {
            cout << ans << endl;
            break;
        }
    }

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
//upper_bound is maximum index of an array element not greater than the given one
//lower bound is minimum index of an array element not less than the given one

#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
#define endl "\n";
using namespace std;

/*vector<int>adj[200001];
int vis[200001];


int dfs(int node)
{
	vis[node]=1;
	
	int count=1;
	
	for(auto it:adj[node])
	{
		if(!vis[it])
		{
			count+=dfs(it);
		}
	}
	return count;
}*/

void solve()
{	
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
	cout<<"Yes";
	else
	cout<<"No";
}


signed main()
{
    
	nuenxfiu
	int t;
	//cin>>t;
	t=1;
	for(int i=1;i<=t;i++)
	{
	//cout<<"Case #"<<i<<": ";
	solve();
	}
     return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n; cin >>n;
    vector<int> h(n); REP(i,n) cin >> h[i];

    int ans = 0;
    for (int i = 0; i < (int)h.size();) {
        int j = i;
        while (j+1 < (int)h.size() && h[j] >= h[j+1]) {
            j++;
        }
        ans = max(ans, j - i);
        i = j+1;
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << fixed << setprecision(12) << a / (double) b << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))[::-1]

ans = 'Yes'
for i in range(1, N):
    if H[i] == H[i-1] + 1:
        H[i] -= 1
    elif H[i] > H[i-1] + 1:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//


class UnionFind{
    public:
        vector<ll> par; // 親
        vector<ll> rank; // 木の深さ
        ll numComponent; // 木の数
        void init(ll n){
            par.resize(n);
            rank.assign(n, 1LL);
            for(ll i=0; i<n; ++i) par[i] = i;
            numComponent = n;
        }

        ll findRoot(ll x){
            if(par[x] == x) return x;
            else return par[x] = findRoot(par[x]);
        }

        void unite(ll x, ll y){
            x = findRoot(x);
            y = findRoot(y);
            if(x == y) return;
            if(rank[x] < rank[y]) swap(x, y);
            rank[x] += rank[y];
            par[y] = x;
            numComponent--;
            return;
        }

        bool same(ll x, ll y){
            return findRoot(x) == findRoot(y);
        }

        ll size(ll x){
            return rank[findRoot(x)];
        }
};



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n, m;
    cin >> n >> m;
    vector<int> p;
    rep(i, n){
        int a;
        cin >> a;
        a--;
        p.push_back(a);
    }
    UnionFind unionFind;
    unionFind.init(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        unionFind.unite(a, b);
    }
    int ans = 0;
    rep(i, n){
        if(unionFind.same(p[i], p[p[i]])){
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

int main()
{
    int num;
    cin >> num;
    
    string str = to_string(num);
    for(int i; i<2; ++i){
        if(str.at(i) == str.at(i+1) && str.at(i+1) == str.at(i+2)){
        cout << "Yes" << endl;
        return 0;
        }    
        
    }
    cout << "No" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <math.h>
#include <list>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX_N 1005
#define MAX_M 100

int B[MAX_N];

int main()
{
    int A, B, K;
    cin >> A >> B;
    if (A == B)
    {
        cout << 0 << endl;
    }
    else if ((A + B) % 2 == 0)
    {
        cout << (A + B) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import heapq
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def dijkstra(edges, n_nodes, start=0):
    dist = [float("inf")] * n_nodes
    dist[start] = 0

    # 優先度キュー
    q = [(dist[start], start)]
    heapq.heapify(q)

    while q:
        d, i = heapq.heappop(q)

        if dist[i] < d:
            continue

        for weight, j in edges[i]:
            tmp = dist[i] + weight
            if dist[j] > tmp:
                dist[j] = tmp
                heapq.heappush(q, (dist[j], j))

    return dist


def main():
    N = int(input())
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        edges[u].append((w, v))
        edges[v].append((w, u))

    dist = dijkstra(edges, N)

    for d in dist:
        if d % 2 == 0:
            print(0)
        else:
            print(1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42956
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        Console.WriteLine(10 - int.Parse(Console.ReadLine()) / 200);
    }
}

Measured memory_bytes: 27296
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long total = 0;
        if (b <= c) {
            total += b * 2;
            c -= b;
        } else {
            total += b + c;
            c = 0;
        }
        if (a < c) {
            total += a + 1;
        } else {
            total += c;
        }
       System.out.println(total);
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll K, X;
    cin >> K >> X;
    if(K * 500 >= X) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3576
/*
 * Owner   : Tatsuhiro Hashimoto
 * Created : 2020-04-22 (Wed)
 */

#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

int main() {
    int K = 0, N = 0;
    cin >> K >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    A.push_back(A[0] + K);
    int tmp = 0;
    for (int i = 0; i < N; ++i) {
        tmp = max(tmp, A[i + 1] - A[i]);
    }
    cout << K - tmp << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    long long n,k,i,j,ans=0,start,goal,stnum,glnum;
    long long place[200010]={},flag[200010]={},a[200010]={};
    scanf("%lld %lld\n",&n,&k);
    for(i=1; i<=n; i++){
        scanf("%lld",&a[i]);
    }
    place[0]=1;
    for(i=1; i<=n; i++){
        place[i]=a[place[i-1]];
    }
    for(i=0; i<=n; i++){
        flag[place[i]]++;
        if(flag[place[i]]==2){
            goal=place[i];
            glnum=i;
            goto NEXT;
        }
    }
    NEXT:;
    for(i=0; i<=n; i++){
        flag[i]=0;
    }
    for(i=0; i<=n; i++){
        flag[place[i]]++;
        if(flag[goal]==1){
            stnum=i;
            goto TUGI;
        }
    }
    TUGI:;
    if(k<=stnum){
        printf("%lld",place[k]);
        return 0;
    }
    ans=(k-stnum)%(glnum-stnum)+stnum;
    printf("%lld",place[ans]);
    return 0;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, c, k; cin >> n >> c >> k;
  vector<int> T(n);
  for(int i = 0; i < n; i++){
    cin >> T[i];
  }
  sort(T.begin(),T.end());
  int left = T[0], num = 0, ans = 1;
  for(int i = 0; i < n; i++){
    int t = T[i];
    if(left + k < t){
      left = t, num = 1, ans++;
    }else{
      if(num == c){
        left = t, num = 1, ans++;
      }else{
        num++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

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

typedef long long ll;
using namespace std;

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

  int N, tmp_a;
  int A[1000001];

  cin >> N;
  REP(i,N){
    cin >> tmp_a;
    A[tmp_a - 1] = i;
  }

  bool first = true;
  REP(i, N){
    if(first){
      cout << A[i] + 1;
      first = false;
    }else{
      cout << " " << A[i] + 1;
    }
  }
  cout << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
ll x, y;

int main() {
    //freopen("input.txt", "r", stdin);
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll temp = __gcd(n, m);
    ll a = n / temp;
    ll b = m / temp;
    ll cnt = 0;
    ll flag = 0;
    while (1) {
        x = a * cnt;
        y = b * cnt;
        if (x >= n || y >= m) {
            break;
        }
        if (s[a * cnt] != t[b * cnt]) {
            flag = 1;
            break;
        }
        cnt++;
    }
    if (flag) {
        cout << -1 << endl;
    } else {
        cout << n * m / temp << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n;
string s[50];
map<char,int> mp,mp1;
int main()
{
	cin>>n;
	for(char i='a';i<='z';i++)
	  mp1[i]=100,mp[i]=0;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		for(int j=0;j<s[i].size();j++)
		{
			mp[s[i][j]]++;
		}
		for(char j='a';j<='z';j++)
		{
			mp1[j]=min(mp1[j],mp[j]);
			mp[j]=0;
	    }
	}
	for(char i='a';i<='z';i++)
	{
		if(mp1[i] && mp1[i]!=100)
		  for(int j=0;j<mp1[i];j++)
		    cout<<i;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        String[] t = sc.next().split("");
        int count = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i].equals(t[i])) {
                count++;
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 21972
n = int(input())
a = list(map(int, input().split()))

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)







Measured memory_bytes: 24840
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1005

struct Point{
	double x,y;
};

int N;
double dist_table[NUM][NUM],dp[NUM][NUM];
Point point[NUM];


double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
	}

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){

			dist_table[i][k] = calc_dist(point[i],point[k]);
			dist_table[k][i] = dist_table[i][k];
		}
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){

			dp[i][k] = 0;
		}
	}

	for(int to = 1; to <= N-1; to++){
		for(int from = 0; from < to; from++){

			if(from == 0 && to == 1){

				dp[from][to] = dist_table[from][to];

			}else if(from < to-1){

				dp[from][to] = dp[from][to-1]+dist_table[to-1][to];

			}else{

				dp[from][to] = BIG_NUM;

				for(int k = 0; k < from; k++){

					dp[from][to] = min(dp[from][to],dp[k][from]+dist_table[k][to]);
				}
			}
		}
	}

	double ans = BIG_NUM;

	for(int i = 0; i <= N-2; i++){

		ans = min(ans,dp[i][N-1]+dist_table[i][N-1]);
	}

	printf("%.10lf\n",ans);

	return 0;
}



Measured memory_bytes: 18948
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100010];

long long rec(int i) {

    if (dp[i] < INF) return dp[i];
    if (i == 0)  return 0;

    long long res = INF;

    res = min(res, rec(i-1) + abs(h[i] - h[i - 1]));
    if (i > 1) res = min(res, rec(i-2) + abs(h[i] - h[i - 2]));
    return dp[i] = res;
}
 
int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < 100010; i++) {
        dp[i] = INF;
    }
    // dp[0] = 0;
    // for (int i = 1; i < N; i++) {
    //     min(dp[i], dp[i -1] + abs(h[i] - h[i - 1]));
    //     if (i > 1) {
    //         min(dp[i], dp[i -2] + abs(h[i] - h[i - 2]));
    //     }
    // }
   cout << rec(N-1) << endl;

    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

vector<lli> v[100100];

void func(long long N, long long M, std::vector<long long> P, std::vector<long long> Y){

    REP(i,0,M){
        v[P[i]].push_back(Y[i]);
    }

    REP(i,0,N+1){
        if(v[i].size()>0)SORT(v[i]);
    }

    REP(i,0,M){
        lli index = lower_bound(v[P[i]].begin(),v[P[i]].end(),Y[i]) - v[P[i]].begin();
        printf("%06d%06d\n",P[i],index+1);
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> P(M);
    std::vector<long long> Y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&P[i]);
        scanf("%lld",&Y[i]);
    }
    func(N, M, std::move(P), std::move(Y));
    return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
    int N, Q, B[100005], C[100005];
    int A[100005], t[100005] = {0};
    ll sum = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
        t[A[i]]++;
    }
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> B[i] >> C[i];
    }

    for (int i = 0; i < Q; i++) {
        int d = C[i] - B[i];
        int e = d * t[B[i]];
        t[C[i]] += t[B[i]];
        t[B[i]] = 0;
        sum += e;
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}


struct triple {
    int pi;
    string s;
    int index;
    triple(string s, int pi, int index)
    {
        this->s = s;
        this->pi = pi;
        this->index = index;
    }
};

bool compare(triple a, triple b)
{
    if(a.s == b.s)
        if(a.pi > b.pi)
            return true;
    if(a.s < b.s)
        return true;

    return false;
}

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

    int n, i;
    cin >> n;
    vector<triple> v;
    fo(i, n)
    {
        string s;
        int a;
        cin >> s >> a;
        v.push_back(triple(s, a, i + 1));
    }
    sort(v.begin(), v.end(), compare);

    fo(i, n)
    cout << v[i].index << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input()]

holes = []

for i in range(2**n):
    if a[i] == 1:
        continue
    for j in range(i+1, 2**n):
        if (j | i) == j and a[j] == 1:
            print("Impossible")
            exit()
    if any((k | i) == i for k in holes):
        continue
    else:
        holes.append(i)

print("Possible")
if len(holes) == 0:
    print(0)
    print(1, 1)
    exit()

clockwise = []

for i in range(n):
    locus = []
    for j in range(i+1):
        locus.append((j, 0))
    locus += [(i, 1), (i+1, 1), (i+1, 0)]
    for j in range(i, -1, -1):
        locus.append((j, 0))
    clockwise.append(locus)

m = len(holes)
roops = []

for i in range(m):
    x = holes[i]
    curve = []
    is_first = True
    for j in range(n):
        if (x >> j) & 1 and is_first:
            curve += clockwise[j]
            is_first = False
        elif (x >> j) & 1:
            curve = curve + clockwise[j] + curve[::-1] + clockwise[j][::-1]
    roops.append(curve)

ans = []
for x in roops:
    ans += x

L = -1
for i, x in enumerate(ans):
    if i > 0 and ans[i] == ans[i-1]:
        continue
    else:
        L += 1

print(L)
for i, x in enumerate(ans):
    if i > 0 and ans[i] == ans[i-1]:
        continue
    else:
        print(*x)


Measured memory_bytes: 47576
n, k = map(int, input().split())
mod = 1000000007

b = mod-2
blis = []
c = 0
while b >0:
  if b & 1 == 1:
    blis.append(c)
  c += 1
  b >>= 1

def modinv(a):
  if a == 1:
    return 1
  else:
    res = 1
    li = []
    for _ in range(c):
      li.append(a%mod)
      a = a*a%mod
    for item in blis:
      res = res *li[item] %mod
    return res

if k >=n:
  L = 2*n-1
  ansbunsi =1
  for j in range(n-1):
    ansbunsi = ansbunsi*L%mod
    L -= 1
  ansbunbo = 1
  L = n - 1
  for j in range(n-1):
    ansbunbo = ansbunbo*L%mod
    L -= 1
  ansbunbo = modinv(ansbunbo)
  print(ansbunsi*ansbunbo%mod)

else:
  kaijou = [1, 1]
  for j in range(2, n):
    kaijou.append(kaijou[-1]*j%mod)
  
  ans = 0

  for m in range(k+1):
    ansbunsi = (kaijou[n-1]**2)*n%mod
    ansbunbo = kaijou[n-m-1]*kaijou[m]%mod
    ansbunbo = ansbunbo*ansbunbo%mod*(n-m)%mod
    ansbunbo = modinv(ansbunbo)
    ans += ansbunbo*ansbunsi%mod
    ans %= mod
  
  print(ans)
    


Measured memory_bytes: 16868
import sys
from collections import defaultdict

lines = sys.stdin.read().splitlines()

total_num_employee = int(lines[0])
list_of_zyoshi = lines[1].split()
num_of_buka = defaultdict(int)
result = ""
for zyoshi_id in list_of_zyoshi:
    num_of_buka[zyoshi_id] += 1

for employee_id in range(1, total_num_employee + 1):
    result += str(num_of_buka[str(employee_id)]) + "\n"
print(result)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<pair<int, pii>> data(n);
    rep(i, n) {
        cin >> data[i].sfir >> data[i].ssec;
        data[i].fir = data[i].sfir + data[i].ssec;
    }

    sort(all(data));
    reverse(all(data));

    int ans = 0;
    rep(i, n) {
        if (i % 2) {
            ans -= data[i].ssec;
        } else {
            ans += data[i].sfir;
        }
    }

    std::cout << ans << std::endl;




    return 0;
}


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


int main(){
  int N;
  double A,ans;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A;
    ans += 1.0/A;
  }
  ans = 1.0/ans;
  cout << fixed <<setprecision(20) <<  ans << endl;
}
      


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,x,y = mi()

a = []
for i in range(n):
    a.append(i+1)

inf = 10 **9
date = [[inf]*n for _ in range(n)]
date[0][x-1] = x-1
date[0][y-1] = x
for i in range(1,n):
    date[0][i] = min(i,date[0][y-1] + abs(y-1-i))
for i in range(1,n):
    for k in range(i+1,n):
        if i < x:
            date[i][k] = date[i-1][k] -1
        elif i < y:
            date[i][k] = min(i-x+1 + date[x-1][k],k-i)
        else:
            date[i][k] = k-i
aaa = [0]*n
for i in range(n):
    for k in range(i+1,n):
        if date[i][k] != inf:
            aaa[date[i][k] -1] += 1
for i in range(n-1):
    print(aaa[i])


Measured memory_bytes: 77404
#include <bits/stdc++.h>
//#include "Jin.hpp"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;

int main(){

	int N, D; std::cin >> N >> D;
	std::vector<std::vector<int>> X(D, std::vector<int>(N, 0));
	rep(j, N)rep(i, D){
		std::cin >> X[i][j];
	}

	int ans = 0;

	rep(i, N)rep(j, N){
		if(i >= j)continue;
		int res = 0;
		rep(k, D){
			res += pow(X[k][i] - X[k][j], 2);
		}
		int root = (int)sqrt((double)res);
		if(root * root == res)ans++;
	}
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
ans = ''
if N == 0:
    print(0)
    sys.exit()
while N != 0:
    if N % 2 != 0:
        N -= 1
        ans = '1' + ans
    else:
        ans = '0' + ans

    N = N // (-2)
print(ans)

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

int main(){
  ll a,b,c,x,y,z=0;
  cin >> a >> b >> c >> x >> y;
  c*=2;
  if(c>=a+b)cout << x*a+y*b<<endl;
  else if(c<=a&&c<=b)cout << c*max(x,y)<<endl;
  else if(a<=c&&b<=c&&a+b>=c){
    if(x>=y)cout << (x-y)*a+y*c<<endl;
    else cout << (y-x)*b+x*c<<endl;
  }
  else if(a<=c&&c<=b){
    cout << y*c+a*max(x-y,z)<<endl;
  }
  else if(b<=c&&c<=a){
    cout << x*c+b*max(y-x,z)<<endl;
  }
}

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

int main(){
	int x, n;
	scanf("%i %i", &x, &n);
	if(n == 0){
		printf("%i\n", x);
		return 0;
	}else{
		int a[n];
		for(int i = 0; i < n; i++){
			scanf("%i", &a[i]);
		}
		for(int i = 0; i <= n; i++){
			for(int j = 0; j < n; j++){
				if(x - i == a[j]){
					break;
				}
				if(j == n - 1){
					printf("%i\n", x - i);
					return 0;
				}
			}
			for(int j = 0; j < n; j++){
				if(x + i == a[j]){
					break;
				}
				if(j == n - 1){
					printf("%i\n", x + i);
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1736
//
// Created by Nihith on 22-02-2020.
//
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int N,K,ans=0;
    cin>>N>>K;
    while(N>0){
        N/=K;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<utility>
using namespace std;
int main()
{
    int h,w;
    cin>>h>>w;

    int maze[w+2][h+2];
    int mazed[w+2][h+2];
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            maze[j][i]=0;
        }
    }//初期化
    int sx,sy;//スタートの座標
    sx=1;
    sy=1;
    int d[w+2][h+2];//最短距離list
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            d[j][i]=0;
        }
    }//初期化
    string s;
    int black=0;//黒マスの総数
    for(int i=1;i<=h;i++){
        cin>>s;
        for(int j=1;j<=w;j++){
            if(s[j-1]=='.'){
                maze[j][i]=1;
            }
            else{
                black++;
            }
        }
    }
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            mazed[j][i]=maze[j][i];
        }
    }
    //check
    /*for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            cout<<mazed[j][i];
        }
        cout<<endl;
    }*/

    //最短距離の計算
    int max=0;
    for(int i=0;i<h*w;i++){
        int sx=i%w+1;
        int sy=i/w+1;
        if(mazed[sx][sy]==0)continue;
        for(int l=0;l<h+2;l++){
            for(int j=0;j<w+2;j++){
                maze[j][l]=mazed[j][l];
            }
        }
        queue<pair<int,int> > q;
        pair<int,int> p;
        pair<int,int>p_nx;
        p.first=sx;p.second=sy;
        q.push(p);
        d[sx][sy]=0;
        maze[sx][sy]=0;
        while(!q.empty()){
            p=q.front();
            q.pop();
            //上
            p_nx.first=p.first;
            p_nx.second=p.second-1;
            if(maze[p_nx.first][p_nx.second]==1){
                q.push(p_nx);
                d[p_nx.first][p_nx.second]=d[p.first][p.second]+1;
                maze[p_nx.first][p_nx.second]=0;
            }
            //下
            p_nx.first=p.first;
            p_nx.second=p.second+1;
            if(maze[p_nx.first][p_nx.second]==1){
                q.push(p_nx);
                d[p_nx.first][p_nx.second]=d[p.first][p.second]+1;
                maze[p_nx.first][p_nx.second]=0;
            }
            //左
            p_nx.first=p.first-1;
            p_nx.second=p.second;
            if(maze[p_nx.first][p_nx.second]==1){
                q.push(p_nx);
                d[p_nx.first][p_nx.second]=d[p.first][p.second]+1;
                maze[p_nx.first][p_nx.second]=0;
            }
            //右
            p_nx.first=p.first+1;
            p_nx.second=p.second;
            if(maze[p_nx.first][p_nx.second]==1){
                q.push(p_nx);
                d[p_nx.first][p_nx.second]=d[p.first][p.second]+1;
                maze[p_nx.first][p_nx.second]=0;
            }
        }
        for(int j=0;j<h*w;j++){
            if(d[j%w+1][j/w+1]>max){max=d[j%w+1][j/w+1];}
        }
    }
    cout<<max<<endl;
    return 0;
}


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

const long long MOD = 998244353;

int A[305];
int cnt[305];

char S[305];
int K, N;

long long memo[305][305][305];

long long dp(int i, int k, int skipped){
    if(skipped < 0){return 0;}
    if(k < 0){return 0;}
    if(i == 0){return skipped == 0 && k == 0;}

    if(memo[i][k][skipped] != -1){
        return memo[i][k][skipped];
    }

    long long res = 0;
    for(int j = 0; j <= 300; j ++){
        if(j >= cnt[i]){
            res += dp(i-1, k, skipped-(j-cnt[i]));
            if(skipped-(j-cnt[i]) < 0){break;}
        }else{
            res += dp(i-1, k-(cnt[i]-j), skipped+(cnt[i]-j));
        }
    }
    res %= MOD;
    //printf("dp(%d, %d, %d)=%lld\n", i, k, skipped, res);

    return memo[i][k][skipped] = res;
}

int main(){
    scanf(" %s %d", S, &K);
    N = strlen(S);
    K = min(K, N);

    memset(cnt, 0, sizeof(cnt));
    int cntZero = 0;
    int indx = 0;
    for(int i = 0; i < N; i ++){
        if(S[i] == '0'){
            cntZero ++;
        }else{
            A[indx] = cntZero+1;
            cnt[A[indx]] ++;
            indx ++;
        }
    }

    memset(memo, -1, sizeof(memo));
    long long ans = 0;
    for(int i = 0; i <= K; i ++){
        ans += dp(cntZero+1, i, 0);
    }
    ans %= MOD;
    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 225476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    int n,k;
    string s;
    cin>>n>>k>>s;

    if(s.at(k-1)=='A'){
        s.at(k-1)='a';
    }
    if(s.at(k-1)=='B'){
        s.at(k-1)='b';
    }if(s.at(k-1)=='C'){
        s.at(k-1)='c';
    }

    cout << s << endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e18;

struct Edge {
    ll from;
    ll to;
    ll cost;
    ll time;
};

//! 頂点iにコインn枚でたどり着く最短時間
ll dp[55][10005];
pll A[55];
Edge E[205];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, S;
    cin >> N >> M >> S;
    ll sum = 0;
    REP(i, M) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        sum += c * 2;
        E[i * 2 + 0].to = E[i * 2 + 1].from = a;
        E[i * 2 + 0].from = E[i * 2 + 1].to = b;
        E[i * 2 + 0].cost = E[i * 2 + 1].cost = c;
        E[i * 2 + 0].time = E[i * 2 + 1].time = d;
    }

    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }

    REP(i, N) {
        REP(j, sum + 1) {
            dp[i][j] = INF;
        }
    }
    dp[0][std::min(S, sum)] = 0;
    S = sum;//std::min(S, sum);

    while (true) {
        bool update = false;
        REP(i, 2 * M) {
            const auto &e = E[i];
            for (ll cost = S; cost - e.cost >= 0; --cost) {
                if (dp[e.from][cost] == INF)
                    continue;
                ll c = cost - e.cost;
                ll t = dp[e.from][cost] + e.time;

                if (dp[e.to][c] > t) {
                    update = true;
                    dp[e.to][c] = t;
                }
            }
        }

        REP(i, N) {
            REP(j, S + 1) {
                ll c = j + A[i].first;
                if (c > S)
                    break;
                if (dp[i][c] > dp[i][j] + A[i].second) {
                    update = true;
                    dp[i][c] = dp[i][j] + A[i].second;
                }
            }
        }
#if false
        REP(i, N) {
            REP(j, S + 1) {
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
#endif
        if (!update)
            break;
    }

    REP(i, N - 1) {
        ll min = INF;
        REP(j, S + 1) {
            min = std::min(min, dp[i + 1][j]);
        }
        cout << min << endl;
    }
    return 0;
}

Measured memory_bytes: 5800
mod = 10**9 + 7;

def inv(x):
  m = mod
  u = 1
  v = 0
  while m:
    t = x // m
    x -= t * m
    x, m = m, x
    u -= t * v
    u, v = v, u
  return u % mod

n = int(input())

fac = [1]
for i in range(1, n + 2):
  fac.append(fac[i - 1] * i % mod)

a = list(map(int, input().split()))
num = [0] * (n + 1)
for x in a:
  num[x] += 1

two = -1
for i, c in enumerate(num):
  if c == 2:
    two = i
    break

l = -1
r = -1;
for i in range(n + 1):
  if l == -1 and a[i] == two:
    l = i
  elif l != -1 and a[i] == two:
    r = n - i

for k in range(1, n + 2):
  if k - 1 <= l + r:
    print((fac[n + 1] * inv(fac[k] * fac[n + 1 - k]) - fac[l + r] * inv(fac[k - 1] * fac[l + r - k + 1])) % mod)
  else:
    print(fac[n + 1] * inv(fac[k] * fac[n + 1 - k]) % mod)


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int h, w;
    cin >> h >> w;

    vvb grid(h, vb(w, false));
    vvb tgrid(w, vb(h, false));

    rep(i, 0, h) {
        rep(j, 0, w) {
            char c;
            cin >> c;
            if (c == '#') {
                grid[i][j] = true;
                tgrid[j][i] = true;
            }
        }
    }

    vvi rows(h, vi(w, 0));
    rep(i, 0, h) {
        int s = 0, t = 0;
        while (s < w) {
            while (t < w && !grid[i][t]) { ++t; }
            int n = t - s;
            while (s < t) { rows[i][s++] = n; }
            ++s;
            ++t;
        }
    }

    vvi cols(h, vi(w, 0));
    rep(i, 0, w) {
        int s = 0, t = 0;
        while (s < h) {
            while (t < h && !grid[t][i]) { ++t; }
            int n = t - s;
            while (s < t) { cols[s++][i] = n; }
            ++s;
            ++t;
        }
    }

    // rep(i, 0, h) {
    //     rep(j, 0, w) { cout << rows[i][j] << " "; }
    //     cout << endl;
    // }
    // cout << endl;
    // rep(i, 0, h) {
    //     rep(j, 0, w) { cout << cols[i][j] << " "; }
    //     cout << endl;
    // }

    int ans = 0;
    rep(i, 0, h) {
        rep(j, 0, w) { ans = max(ans, rows[i][j] + cols[i][j] - 1); }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 33024
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def solve():
    x, y, z, k = getList()
    an = getList()
    bn = getList()
    cn = getList()

    ans = []
    for aa in an:
        for bb in bn:
            ans.append(aa + bb)

    ans.sort(reverse=True)
    ans = ans[:k]
    anans = []
    for aa in ans:
        for bb in cn:
            anans.append(aa + bb)

    anans.sort(reverse=True)
    for aaa in anans[:k]:
        print(aaa)

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()







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

int main(void){
    char a[1001],b[1001];
    int lena,lenb,i,j,flg;
    scanf("%s",a);
    scanf("%s",b);
    lena = strlen(a);
    lenb = strlen(b);
    for(i=0;i<lena-lenb+1;i++){
        flg = 0;
        for(j=0;j<lenb;j++){
            if(a[i+j]!=b[j]){
                flg = 1;
                break;
            }
        }
        if(flg==0){
            printf("%d\n",i);
        }
    }
}


Measured memory_bytes: 2092
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  int a, b;
  while(cin>>a>>b){
    if(a == 0 && b == 0){
      break;
    }
    if(a<=b){
      cout<<a<<" "<<b<<endl;
    }else{
      cout<<b<<" "<<a<<endl;
    }
  }
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int N,Ma,Mb;

    vector<int> a(41);
    vector<int> b(41);
    vector<int> c(41);

    cin >> N >> Ma >> Mb;

    REP(i,N) cin >> a[i] >> b[i] >> c[i];

    auto dp = make_vec<int>(45,420,420);
    fill_v(dp,inf);
    dp[0][0][0]=0;

    REP(i,N) rep(ca,0,401) rep(cb,0,401){
        chmin(dp[i+1][ca][cb],dp[i][ca][cb]);
        chmin(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
    }

    int ans = inf;
    rep(ca,1,401) rep(cb,1,401){
        if(Ma*cb==Mb*ca) chmin(ans,dp[N][ca][cb]);
    }

    pl((ans==inf?-1:ans))


    return 0;
}

Measured memory_bytes: 32640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

int m = 1e9 + 7;

struct modCalc {
  int mod;
  int n;
  vector<int> fact, invfact;

  modCalc(){};

  modCalc(int _mod, int _n) {
    mod = _mod, n = _n;
    fact.resize(n + 1, 1);
    invfact.resize(n + 1, 1);

    for (int i = 0; i < n; i++) fact[i + 1] = fact[i] * (i + 1) % mod;
    invfact[n] = modinv(fact[n]);
    for (int i = n; i > 1; i--) invfact[i - 1] = invfact[i] * i % mod;
  };

  int modpow(int x, int n) {
    int ret = 1;
    while (n > 0) {
      if (n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return ret;
  }
  int modinv(int x) { return modpow(x, mod - 2); }
  int nCm(int x, int y) {
    if (y == 0)
      return 1;
    else if (x == 0)
      return 1;
    else
      return fact[x] * invfact[y] % mod * invfact[x - y] % mod;
  }
  int nPm(int x, int y = -1) {
    if (y == -1) y = x;
    return fact[x] * invfact[x - y] % mod;
  }
};

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

  modCalc mc(m, n);

  for (int i = 1; i <= k; i++) {
	int a,b;
    a = mc.nCm(k - 1, i - 1);
	if(n-k+1 <i)b=0;
    else b = mc.nCm(n - k + 1, i);
    int ret = a * b % m;
    cout << ret << endl;
  }
}


Measured memory_bytes: 256