akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long double>v(N);
	for (auto &i : v)cin >> i;
	vector < vector<long double >>dp(N, vector<long double>(N + 1));
	dp[0][0] = (long double)1 - v[0];
	dp[0][1] = v[0];
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] += dp[i - 1][j] * ((long double)1 - v[i]);
			dp[i][j + 1] += dp[i - 1][j] * v[i];
		}
	}
	long double ans = 0;
	for (int i = N / 2 + 1; i <= N; i++)ans += dp.back()[i];
	cout << setprecision(20) << ans << endl;
	return 0;
} 

Measured memory_bytes: 141824
// ABC160C - Traveling Salesman around Lake

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

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

	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	int temp = 0;
	for (int i = 0; i < N - 1; i++) {
		temp = max(temp, A.at(i+1) - A.at(i));
	}
	temp = max(temp, K - A.at(N - 1) + A.at(0));

	cout << K - temp << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

LL modpow(LL a, LL n) {
  LL result = 1;
  if (n == 0) {
    return 1;
  } else {
    for (int i = 0; i < n; i++) {
      result = (result * a) % 998244353;
    }
  }

  return result;
}

int main(void){
  int n;
  cin >> n;

  vector<int> distance(100000);
  int d;
  int dmax = 0;

  rep(i, n) {
    cin >> d;
    if ((i == 0 && d != 0) || (i != 0 && d == 0)) {
      cout << 0 << endl;
      return 0;
    }
    dmax = max(d, dmax);
    distance[d] ++;
  }

  LL ans = 1;
  for (int i = 1; i < dmax; i++) {
    LL sets = modpow(distance[i], distance[i+1]);
    ans = (ans * sets) % 998244353;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const int MAX = 1000000;

int main()
{
	bool isprime[MAX + 1];
	fill(isprime, isprime+MAX+1, true);
	isprime[0] = isprime[1] = false;
	reps(i, 2, MAX){
		if(isprime[i]){
			for(int j=i*2; j<=MAX; j+=i)
				isprime[j] = false;
		}
	}

	int n;
	while(scanf("%d", &n), n){
		int x;
		scanf("%d", &x);

		int p[30];
		rep(i, n)
			scanf("%d", &p[i]);

		int ans = -1;
		bool dp[1000001] = {false};
		dp[0] = true;
		reps(i, 1, x+1){
			rep(j, n)
				dp[i] |= i>=p[j] && dp[i-p[j]];
			if(dp[i] && isprime[i])
				ans = i;
		}

		if(ans == -1)
			puts("NA");
		else
			printf("%d\n", ans);
	}

	return 0;
}

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

#define vi vector<int>

int solve(int k, vi& xs){
    sort(xs.begin(), xs.end()); //ordena o vector

    //xs.back() --> Returns a reference to the last element in the vector
    xs.back() *= (1<<k); // shiftar 1 vez pra esquerda eh multiplicar por 2

    return accumulate(xs.begin(), xs.end(), 0);
}

int main(){
    vi xs(3);

    for(int i=0;i<3;i++)
        cin>>xs[i];

    int k;

    cin>>k;

    auto ans = solve(k, xs);

    cout<<ans<<'\n'<<endl;

    return 0;
}

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

void printQueens(int queens[])
{
    for (int i = 0; i < 8; i++)
    {
        for (int j = 0; j < 8; j++)
        {
            if (queens[i] == j)
            {
                cout << 'Q';
            }
            else
            {
                cout << '.';
            }
        }
        cout << endl;
    }
}

bool canPlace(int queens[], pair<const int, const int> placement_posn)
{
    if (queens[placement_posn.first] != -1) return false;
    for (int i = 0; i < 8; i++)
    {
        if (queens[i] == -1)
        {
            continue;
        }
        else if (placement_posn.first == i)
        {
            continue;
        }
        else if (placement_posn.second == queens[i])
        {
            return false;
        }
        else if (abs(i - placement_posn.first) == abs(queens[i] - placement_posn.second))
        {
            return false;
        }
    }
    return true;
} 

bool placeQueens(int queens[])
{
    for (int row = 0; row < 8; row++)
    {
        if (queens[row] == -1) break;
        else if (row == 7) return true;
    }
    for (int row = 0; row < 8; row++)
    {
        for (int col = 0; col < 8; col++)
        {
            if (canPlace(queens, pair<int, int> (row, col)))
            {
                queens[row] = col;
                if (placeQueens(queens)) return true;
                else queens[row] = -1;
            }
        }
    }
    return false;
}

int main(int argc, char const *argv[])
{
    int n;
    int queens[8];
    for (int i = 0; i < 8; i++)
        queens[i] = -1;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int posn;
        cin >> posn;
        cin >> queens[posn];
    }
    placeQueens(queens);
    printQueens(queens);
    return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ppb pop_back
#define st first
#define nd second
#define ll long long
#define N 500005
#define inf 2000000005
#define MOD 1000000007
#define LOG 14
#define EPS 0.000000001
using namespace std;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		ans += (i % 2 and x % 2);
	}
	cout << ans;

}

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

int main() {
    int R0, W, C, R;
    while(cin >> R0 >> W >> C >> R, R0) {
        if(R0 / W >= C) {
            cout << 0 << endl;
        } else {
            for(int i=1; ; ++i) {
                if((R0 + R*i)/W >= C) {
                    cout << i << endl;
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    while(--t >= 0){
        int n;
        cin >> n;
        int up = 0, down = 0;
        int prev;
        cin >> prev;
        while(--n > 0){
            int curr;
            cin >> curr;
            up = max(up, curr-prev);
            down = max(down, prev-curr);
            prev = curr;
        }
        cout << up << ' ' << down << endl;
    }
}

Measured memory_bytes: 0
n,k=map(int,input().split())
s="R"+input()+"L"
now="X"
l=[]
le=None
for i in range(n+2):
    if now!=s[i]:
        l.append(le)
        now=s[i]
        le=1
    else:
        le+=1
l.append(le)
l=l[1:]
nn=len(l)
lr=[]
ll=[]
su=0
for i in range(0,nn,2):
    lr.append(l[i])
    su+=l[i]-1
for i in range(1,nn,2):
    ll.append(l[i])
    su+=l[i]-1
if lr[0]>1:
    su-=1
if ll[-1]>1:
    su-=1
maxgain=n-1-su
if 2*k<maxgain:
    print(su+2*k)
else:
    print(su+maxgain)


Measured memory_bytes: 46064
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	string s;
	cin>>s;

	if(s=="ABC")
	{
		cout<<"ARC"<<endl;
	}
	else
	{
		cout<<"ABC"<<endl;
	}

}

Measured memory_bytes: 3608
import java.util.*;
public class Main {
    static int n;
    static String s;
    static int q;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        q = sc.nextInt();
        s = sc.next();
        char[] t = new char[q];
        char[] d = new char[q];
        for (int i = 0; i < q; i++) {
            t[i] = sc.next().charAt(0);
            d[i] = sc.next().charAt(0);
        }
        int left = binSearch(t, d, -1, n);
        // System.out.println("left = " + left);
        int right = binSearch(t, d, n, -1);
        // System.out.println("right = " + right);
        int ans = Math.max(0, right - left - 1);
        System.out.println(ans);
    }
    public static int binSearch(char[] t, char[] d, int ok, int ng) {
        int out = ok;
        while (Math.abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (solve(mid, t, d, out)) {
                ok = mid;
            } else {
                ng = mid;
            }
            // System.out.printf("ok = %d,ng = %d %n", ok, ng);
        }
        return ok;
    }
    public static boolean solve(int mid, char[] t, char[] d, int out) {
        for (int i = 0; i < q; i++) {
            if (mid == -1 || mid == n) {
                return false;
            }
            char ch = s.charAt(mid);
            // System.out.println("ch = " + ch);
            // System.out.println("mid = " + mid);
            // System.out.printf("t[%d] = %s %n", i, t[i]);
            // System.out.printf("d[%d] = %s %n", i, d[i]);
            if (ch != t[i]) {
                continue;
            }
            if (d[i] == 'L') {
                mid--;
            } else if (d[i] == 'R') {
                mid++;
            }
            if (mid == out) {
                //    System.out.println("out mid = " + mid);
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 65168
import sys
from collections import defaultdict

# 再帰制限を緩和するおまじない
sys.setrecursionlimit(10**6)

def sum(n):return n*(n+1)//2

# 部分木のサイズと、「色iを封鎖したときに到達できない頂点の個数」を持つ辞書を返す
def dfs(v,p):
    ret=defaultdict(int)
    size=1
    for vv in g[v]:
        if vv==p:
            continue
        ss,d=dfs(vv,v)
        size+=ss
        ans[c[v]]+=sum(ss-d[c[v]])
        
        # マージテク
        if len(ret)<len(d):
            ret,d=d,ret
        for vvv in d:
            ret[vvv]+=d[vvv]
    ret[c[v]]=size
    return size,ret

n=int(input())
c=list(map(int,input().split()))
g=[[] for _ in range(n+1)]
ans=[0]*(n+1)
for _ in range(n-1):
    s,t=map(int, input().split())
    s-=1
    t-=1
    g[s].append(t)
    g[t].append(s)
_,ret=dfs(0,-1)
for i in range(1,n+1):
    print(sum(n)-ans[i]-sum(n-ret[i]))


Measured memory_bytes: 283836
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 998244353;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

ll dp[302][302 * 302] = {};

ll MAXS = 302 * 302;

int main() {
	IOS();
	ll a, b, c;
	cin >> a >> b >> c;
	dump(a > c && c > b || a < c && c < b ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
score = int(input())

if score >= 400 and score < 600:
  print(8)
elif score >= 600 and score < 800:
  print(7)
elif score >= 800 and score < 1000:
  print(6)
elif score >= 1000 and score < 1200:
  print(5)
elif score >= 1200 and score < 1400:
  print(4)
elif score >= 1400 and score < 1600:
  print(3)
elif score >= 1600 and score < 1800:
  print(2)
elif score >= 1800 and score < 2000:
  print(1)

Measured memory_bytes: 9196
# -*- coding: utf-8 -*-

def main():

    S = input()

    if S == 'Sunny':
        ans = 'Cloudy'

    elif S == 'Cloudy':
        ans = 'Rainy'

    else:
        ans = 'Sunny'

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 8860
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int a,b; cin >> a >> b;
    cout << a * b << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

const int maxn = 200005;
int a[maxn], b[maxn];
int main() {
    int n;
    cin >> n;
    ii cin >> a[i] >> b[i];
    sort(al(a));
    sort(al(b));
    if(n&1) {
        int m = (n+1)/2;
        cout << b[m] - a[m] + 1 << endl;
    } else {
        int m = n/2;
        cout << b[m] + b[m+1] - a[m] - a[m+1] + 1 << endl;
    }

}

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

int main()
{
	long long a[6];
	cin >> a[0];
	cin >> a[1];
	cin >> a[2];
	cin >> a[3];
	cin >> a[4];
	cin >> a[5];
	int b=1;
	for(int i=2;i<6;i++){
		if(a[b]>a[i]){
			b=i;
		}
	}
	cout << (a[0]-1)/a[b]+5;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    while(N%10!=7&&N!=0){
        N/=10;
    }
    if(N%10==7)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3132
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;cin>>a>>b>>c>>d;
    c+=b-1;
    a+=d-1;
    c/=b,a/=d;
    if(a>=c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <stdlib.h>

struct Coodinate {
    double x;
    double y;
    Coodinate* next;
};
Coodinate* initCoodinate()
{
    Coodinate* c = (Coodinate*)malloc(sizeof(Coodinate));
    c->x = -1;
    c->y = -1;
    c->next = c;
    return c;
}

void kochCurve(Coodinate* start, Coodinate* end, int n)
{
    if (n == 0) {
	return;
    }
    Coodinate* s = initCoodinate();
    Coodinate* t = initCoodinate();
    Coodinate* u = initCoodinate();
    start->next = s;
    s->x = (2.0 * start->x + 1.0 * end->x) / 3;
    s->y = (2.0 * start->y + 1.0 * end->y) / 3;
    s->next = t;
    u->x = (1.0 * start->x + 2.0 * end->x) / 3;
    u->y = (1.0 * start->y + 2.0 * end->y) / 3;
    u->next = end;
    double th = M_PI * 60.0 / 180.0;
    t->x = (u->x - s->x) * cos(th) - (u->y - s->y) * sin(th) + s->x;
    t->y = (u->x - s->x) * sin(th) + (u->y - s->y) * cos(th) + s->y;
    t->next = u;
    n--;
    kochCurve(start, s, n);
    kochCurve(s, t, n);
    kochCurve(t, u, n);
    kochCurve(u, end, n);
}
int main()
{
    int n = 0;
    std::cin >> n;
    Coodinate* start = (Coodinate*)malloc(sizeof(Coodinate));
    Coodinate* end = (Coodinate*)malloc(sizeof(Coodinate));
    Coodinate* nil = initCoodinate();

    start->x = 0;
    start->y = 0;
    start->next = end;
    end->x = 100;
    end->y = 0;
    end->next = nil;

    kochCurve(start, end, n);
    Coodinate* i = start;
    while (i->next != i) {
	std::cout << i->x << " " << i->y << std::endl;
	i = i->next;
    }
    return 0;
}

Measured memory_bytes: 1396
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

t = rl()
li = []
for i in range(len(t)):
    if t[i] == '?':
        li.append('D')
    else:
        li.append(t[i])
print(''.join(li))

Measured memory_bytes: 28952
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>        //sort(v.begin(), v.end(), [std::greater()]);  第3引数をなしにすると昇順。
#include <utility>  
#include <vector>           
#include <iterator>         //vector入力で使う istream_iterator(cin)
#include <iomanip>          //doubleやfloatなどの少数の桁数を指定する setprecision(桁数) 

/*----------- 定義 -----------*/
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

typedef long long int lli;
/*----------------------------*/


/*----------- 入力 -----------*/
lli r,N;
vector<int> vec;
/*----------------------------*/
 
 
 
int main(void){
    cin >> r;
    
    lli S = 0;
    lli S_1 = 1*1;
    
    S = r * r;
    
    N = S / S_1;
    
    cout << N ;
    

    return 0;
}


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

int dp[3][100005];

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

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i = 1; i < n; i++) {
        dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
    }
    cout << max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]) <<endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main (void){

	bool flag[32] = {false};
	int num;

	for(int i=0;i<28;i++){
		scanf("%d",&num);
		flag[num] = true;
	}
	for(int i=1;i<=30;i++){
		(flag[i])?:printf("%d\n",i);
	}


	return 0;
}


/*
9   	
30   	
6  	
12   	
10   	
20   	
21   	
11   	
7   	
5   	
28   	
4   	
18   	
29   	
17   	
19   	
27   	
13   	
16   	
26   	
14   	
23   	
22   	
15   	
3   	
1   	
24   	
25   	

*/

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
     bool visited[200005];
     vector<int>adj[200005];
     void dfs(int src,int &x)
     {
        visited[src]=1;
        x++;
        for(auto j:adj[src])
        {
            if(!visited[j])
                dfs(j,x);
        }
     }



    int main() {
        fastio;

        int n,m;
        cin>>n>>m;
        int ans=n;
        for(int i=0;i<m;i++)
        {
           int a,b;

           cin>>a>>b;
           adj[a].pb(b);
           adj[b].pb(a);
        }
        int t=0;
        for(int i=1;i<=n;i++)
        {
            if(!visited[i])
            {   int c=0;
                dfs(i,c);
                t=max(c,t);
            }
        }
        ans=min(ans,t);
        cout<<ans<<endl;
    }

Measured memory_bytes: 24076
<?php

fscanf(STDIN,"%d %d",$k,$x);


//座標の最小値
$a = $x - $k + 1;
//座標の最大値
$b = $x + $k - 1;

for ($i = $a; $i <= $b; $i++){
    echo "$a ";
    $a++;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  string s;
  cin >> n >> s;
  bool ok = true;
  if(s.size()%2==1) ok = false;
  rep(i,n/2){
    if(s[i]!=s[i+n/2]) ok = false;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
         
         
  
}


Measured memory_bytes: 256
'use strict'

function main(input){
  const lines = input.split('\n');
  const ABCDEF = lines.shift().split(' ').map(x => parseInt(x));
  const A = ABCDEF[0];
  const B = ABCDEF[1];

  const C = ABCDEF[2];
  const D = ABCDEF[3];

  const E = ABCDEF[4];
  const F = ABCDEF[5];

  let water = [];
  let sugers = [];
  for(var i=0;i<=F;i++){
    for(var j=0;j<=F;j++){
      let c_water = 100*(A*i+B*j);
      if(c_water<=F){ water.push(c_water); }

      let suger = C*i + D*j;
      if(suger<=F){ sugers.push(suger); }
    }
  }

  let results = [];
  // とりうる砂糖水と砂糖の量を列挙
  for(let i = 0; i <= water.length; i++){
    for(let j = 0; j <= sugers.length; j++){
      let total = water[i] + sugers[j];
      let melt_suger = 100*sugers[j]/water[i];
      if( total <= F && melt_suger <= E){
        results.push([total, sugers[j]]);
      }
    }
  }  

  // 各砂糖水と砂糖の量から、濃度を求める
  let tmp_density = 0.0;
  let ret = 0;
  for(var i = 0; i < results.length; i++){
    var noudoTmp = (100 * results[i][1]) / results[i][0]; // 砂糖水の濃度
    if(noudoTmp > tmp_density){
      tmp_density = noudoTmp;
      ret = i;
    }
  }
  
  console.log(results[ret][0] + ' ' + results[ret][1]);
}
main( require('fs').readFileSync( '/dev/stdin', 'utf8') );


Measured memory_bytes: 98716
import java.util.*;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    int p[] = new int[N];
    for(int i = 0; i<N;i++){
      p[i] = Integer.parseInt(sc.next());   
    }
    Arrays.sort(p);
    int sum = 0;
    for(int i = 0; i<K;i++){
      sum += p[i];
    }
    System.out.println(sum);
  }
}


// 1000000000000000001

Measured memory_bytes: 37880
# coding: utf-8
class PotUnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数
        self.diff_p = [0 for i in range(size)]#親ノードを基準としたポテンシャル

    def root(self, x): #root(x): xの根ノードを返す
        if self.parent[x] < 0:
            return x
        else:
            rx = self.root(self.parent[x]) #xをxの根rxに直接つなぎたい
            self.diff_p[x] += self.diff_p[self.parent[x]] #そのために，diff(rx,x)を計算
            self.parent[x] = rx #xをrxに直接つなげる
            return rx

    def weight(self, x):
        self.root(x)
        return self.diff_p[x]

    def merge(self, x, y, dxy): #ポテンシャル差の条件p(y)-p(x)=dxyでxとyのグループをまとめる
        dxy += self.weight(x) - self.weight(y) #dxyをdiff(rx,ry)で置き換え
        x = self.root(x) #rxを新たにxと名づける
        y = self.root(y) #ryを新たにyと名づける
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y,dxy=y,x,-dxy
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        self.diff_p[y] = dxy #yの相対ポテンシャルを更新
        return True

    def issame(self, x, y): #issame(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def diff(self,x,y): #diff(x,y): xを基準としたyのポテンシャルを返す 
        if self.root(x) == self.root(y): #この時点でxの親はroot(x)
            return self.diff_p[y] - self.diff_p[x]
        else:
            return None

    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]

n = int(input())

T=PotUnionFind(n)
for _ in [0]*(n-1):
    u,v,w = [int(i) for i in input().split()]
    T.merge(u-1,v-1,w)

for i in range(n):
    print(T.diff(0,i)%2)



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

using namespace std;
using ull = unsigned long long;

const int MAX_N = 400;
const ull MAX_VAL = numeric_limits<ull>::max();
ull costs[MAX_N + 1][MAX_N + 1];
ull sums[MAX_N + 1][MAX_N + 1];
ull inp[MAX_N + 1];

int main() {
	ios_base::sync_with_stdio(false);
	int N; cin >> N;
	for (int i = 0; i <= MAX_N; i++) {
		for (int j = 0; j <= MAX_N; j++) {
			costs[i][j] = MAX_VAL;
		}
	}
	for (int i = 1; i <= N; i++) {
		cin >> inp[i];
		costs[i][i] = 0;
	}

	for (int i = 1; i <= N; i++) {
		sums[i][i] = inp[i];
		for (int j = i + 1; j <= N; j++) {
			sums[i][j] = inp[j] + sums[i][j - 1];
		}
	}
	
	for (int L = 1; L <= N; L++) {
		for (int start = 1; start + L <= N; start++) {
			for (int div = 0; div + 1 <= L; div++) {
				costs[start][start + L] = min(costs[start][start + L], costs[start][start + div] + costs[start + div + 1][start + L] + sums[start][start + div] + sums[start + div + 1][start + L]);
			}
		}
	}
	cout << costs[1][N] << endl;
	return 0;
}

Measured memory_bytes: 2816
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

// 1 2 3 4 5

long long gcd(long long a,long long  b) { if (b == 0) return a; return gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

// n以下の整数でmod1でもmod2でも割れないものの数
ll countUnder(ll n,ll mod1,ll mod2){
    return n/mod1 + n/mod2 - n/lcm(mod1,mod2);
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    ll L,R,mod1,mod2;
    cin >> L >> R >> mod1 >> mod2;
    cout <<   (R - L + 1LL) - (countUnder(R,mod1,mod2) - countUnder(L-1,mod1,mod2)) << nn;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
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;}
const int MOD = 1e9+7;

signed main(){
  int n,q;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    int v,w;
    cin>>v>>w;
    if(n==1){
	 cout<<min(v,w)<<endl;
	 continue;
    }
    vector<int> vv,wv;
    while(v>1){
	 vv.pb(v);
	 v=(v+n-2)/n;
    }
    while(w>1){
	 wv.pb(w);
	 w=(w+n-2)/n;
    }
    sort(all(vv));
    sort(all(wv));
    int ans=1;
    for(int j=0;j<sz(vv)&&j<sz(wv);j++){
	 if(vv[j]!=wv[j])break;
	 ans=vv[j];
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
    char b[8][8];
    int a[8][8];
    char en;
int main(void){
 
 
 
    while(cin>>b[0]){
        cin>>b[1]>>b[2]>>b[3]>>b[4]>>b[5]>>b[6]>>b[7];
 
 
    for(int n=0;n<8;n++){
        for(int m=0;m<8;m++){
            if(b[n][m]=='1')a[n][m]=1;
            else a[n][m]=0;
        }
    }
    int i,j;
    int flag=0;
    char t;
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(a[i][j]==1){
             //   cout<<i<<j;
                flag=1;
                break;
            }
        }
        if(flag==1)break;
    }
    if(a[i][j]==a[i][j+1]){
        //cout<<".";
        if(a[i][j+1]==a[i][j+2])t='C';
        else if(a[i][j+1]==a[i+1][j]){
            if(a[i+1][j]==a[i+1][j+1])t='A';
            else if(a[i+1][j]==a[i+1][j-1])t='G';
        }
        else if(a[i][j+1]==a[i+1][j+2])t='E';
    }
    else if(a[i][j]==a[i+1][j]){
        if(a[i+1][j]==a[i+2][j])t='B';
        else if(a[i+1][j]==a[i+1][j+1])t='F';
        else if(a[i+1][j]==a[i+1][j-1])t='D';
    }
    //else cout<<".....";
 
    cout<<t<<endl;
 
 
    }
 
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int sol = 0;

    for(int i = 0; i < (int)s.size(); i++) {
        if(s[i] == 'R') {
            int j = i;
            while(j < (int)s.size() && s[j] == 'R') {
                j++;
            }
            j--;
            sol = max(sol, j - i + 1);
            i = j;
        }
    }
    cout << sol;
    return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    vector<int> N(3);
    N[0] = A + A - 1;
    N[1] = A + B;
    N[2] = B + B - 1;
    sort(N.begin(),N.end());

    cout << N[2] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using vi = vector<int>;
template <class T>
using Grid = vector<vector<T>>;

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

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int N;
	int K;
	int S;
	cin >> N >> K >> S;

	vector<int> v(N - K + 1, 0);

	if (S >= (N - K + 1)) {
		for (int i = 0; i < v.size() - 1; i++) {
			v[i] = 1;
			S--;
		}
		v[N - K] = S;
		for (int i = N - K + 1; i < N; i++) {
			v.push_back(v[i - N + K - 1]);
		}
	}
	else {
		for (int i = 0; i < v.size() - 1; i++) {
			v[i] = S + 1;
		}
		v[N - K] = S;
		for (int i = N - K + 1; i < N; i++) {
			v.push_back(S);
		}
	}
	
	

	for (int i = 0; i < N; i++) {
		cout << v[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 4056
use std::io::*;

fn main(){
    let k : usize = input();
    let s : i32 = input();
    let mut ans = 0;
    let n : usize = std::cmp::min(k + 1, 2501);
    for x in 0..n{
        for y in 0..n{
            let z : i32 = s - x as i32 - y as i32;
            if (0 <= z) && (z <= k as i32){
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .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
n=int(input())
b=list(map(int,input().split()))
s=[]


while b:
    flag=0
    buf=0
    for j in range(len(b)):
        if(b[j]==j+1):
            if(buf<j):
                buf=j
            flag=1         
    if (flag==0):
        print(-1)
        break
    s.append(b.pop(buf))
    #print(b)
if (flag==1):
    for i in range(n):
        print(s[n-i-1],end='\n')

Measured memory_bytes: 3064
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

vector<int> adj[MAXN];

int arr[MAXN];

int n;

bool dfs(int v, int pr) {
    vector<int> vv;
    ll k = arr[v] * 2;

    for (int to : adj[v]) {
        if (to == pr) {
            continue;
        }

        if (!dfs(to, v)) {
            return 0;
        }

        k -= arr[to];
        vv.pb(arr[to]);
    }

    if (vv.empty()) {
        return 1;
    }

    if (vv.size() == 1) {
        return arr[v] == vv[0];
    }

    if (k < 0 || k > arr[v]) {
        return 0;
    }

    vv.pb(k);
    ll sum = 0;

    for (int x : vv) {
        sum += x;
    }

    if (sum & 1) {
        return 0;
    }

    if (*max_element(all(vv)) > sum / 2) {
        return 0;
    }

    arr[v] = k;

    if (pr == -1 && arr[v] != 0) {
        return 0;
    }

    return 1;
}

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
    }

    for (int i = 1, u, v; i < n; ++i) {
        scanf("%d %d", &u, &v);
        adj[u].pb(v);
        adj[v].pb(u);
    }

    if (n == 2) {
        printf(arr[1] == arr[2] ? "YES\n" : "NO\n");
        return;
    }

    int root = 1;

    while (adj[root].size() == 1) {
        ++root;
    }

    printf(dfs(root, -1) ? "YES\n" : "NO\n");
}

int main() {
    int tt = 1;

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

    return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(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 pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}


int main()
{
    string s;
    cin >> s;

    ll cnt=0;
    rep(i,SIZE(s)-1){
        if(s[i] != s[i+1])cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

int main(void) 
{
	int a;
	char str[10];

	scanf("%d", &a);
	scanf("%s", str);

	if (a >= 3200) {
		printf("%s\n", str);
	}
	else {
		printf("red\n");
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	ll n, X;
	cin >> n >> X;
	
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		a[i] = abs(X - x[i]);
		
	}
	if (n == 1) {
		cout << abs(X - x[0]) << endl;
		return 0;
	}
	ll ans = gcd(a[0],a[1]);
	for (int i = 2; i < n-1; i++) {
		ans = gcd(ans,a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6400
require 'scanf'

while true
	h,m,s = gets.scanf("%d %d %d");
	break if h == -1 && m == -1 && s == -1

	rest = 120 * 60 - h * 60 * 60 - m * 60 - s
	rest3 = rest * 3

	printf("%02d:%02d:%02d\n", rest / 3600, rest / 60 % 60, rest % 60)
	printf("%02d:%02d:%02d\n", rest3 / 3600, rest3 / 60 % 60, rest3 % 60)
end

Measured memory_bytes: 6444
# include "iostream"
# include "cstdio"
# include "cstring" 

using namespace std;

const int maxm=100000+10;
int f[maxm],n;
int thing[maxm],tot; 

int main(){
	thing[++tot]=1;
	register int i,j;
	memset(f,0x3f,sizeof(f)); 
	scanf("%d",&n); 
	i=6; 
	while(i<n){
		thing[++tot]=i;
		i*=6; 
	}
	if(i==n){
		printf("1"); 
		return 0; 
	} 
	i=9; 
	while(i<n){
		thing[++tot]=i;
		i*=9; 
	}
	if(i==n){
		printf("1");
		return 0; 
	} 
	f[0]=0; 
	for(i=1;i<=tot;i++){
		for(j=thing[i];j<=n;j++){
			f[j]=min(f[j],f[j-thing[i]]+1); 
		} 
	}
	printf("%d",f[n]); 
	return 0; 
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

string s[2005];
int mas[2005][2005];
inline void solve(){
    int h, w;
    
    cin >> h >> w;
    FOR(i,h){
        cin >> s[i];
    }

    FOR(i,h){
        int sum = 0;
        FOR(j,w){
            if(s[i][j]=='.')
                sum++;
            else
                sum=0;
            mas[i][j] = sum;
        }
        
        sum = 0;
        for(int j = w-1;j >= 0; j--){
            if(s[i][j]=='.')
                sum++;
            else
                sum=0;
            mas[i][j] += sum-1;
        }
    }
    
    FOR(j,w){
        int sum = 0;
        FOR(i,h){
            if(s[i][j]=='.')
                sum++;
            else
                sum=0;
            mas[i][j] += sum-1;
        }
        sum = 0;
        for(int i = h-1;i>=0;i--){
            if(s[i][j]=='.')
                sum++;
            else
                sum=0;
            mas[i][j] += sum-1;
        }
    }
    int maxi=-1;
    FOR(y,h){
        FOR(x,w){
            chmax(maxi,mas[y][x]);
        }
    }

    cout << maxi fin;    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;
signed main(){solve();return 0;}


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

using namespace std;

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    int min_k = (a / k ) * k;
    if (min_k == a || (min_k + k) <= b)
        cout << "OK\n";
    else
        cout << "NG\n";
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n,INF), b(n,INF);
  ll apos=0, bpos=0;
  rep(i,n){
    ll x; cin>>x;
    if(x<0){
      a[apos]=-x;
      apos++;
    }else{
      b[bpos]=x;
      bpos++;
    }
  }
  vsort(a);
  ll ans=INF;
  rep(i,k){
    if(i==k-1) chmin(ans,a[i]);
    else chmin(ans,a[i]*2+b[k-i-2]);
    // cout<<a[i]<<" "<<b[k-i-1]<<" "<<ans<<endl;
  }
  // cout<<endl;
  rep(i,k){
    if(i==k-1) chmin(ans,b[i]);
    else chmin(ans,b[i]*2+a[k-i-2]);
    // cout<<i<<" "<<a[k-i-1]<<" "<<ans<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
 
using namespace std;
 
int n = 0 , m = 0 , k = 0;
string s , z;
int main()
{
	cin >> n >> s >> z;
	for (int i = 0; i < n; i++)
	{
		for (int a = 0; a < n; a++)
		{
			if (i + a == n)
			{
				break;      
			}
			if (z[a] != s[i+a])
			{
				break;
			}
			k++;
		}
		if (k > m)
		{
			m = k;
		}
		k = 0;
	}
	cout << 2 * n - m;
}


Measured memory_bytes: 256
import Data.Char

main=do
  [_,k]<-map read.words<$>getLine
  s<-getLine
  putStr$solve k 1 s

solve _ _ [] = []
solve k i (c:s)
  | k==i = toLower c:solve k (i+1)  s
  | otherwise = c:solve k (i+1) s

Measured memory_bytes: 508
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,C;
  cin >> N >> C;
  int D[C+1][C+1];
  for(int i=1;i<=C;i++){
    for(int j=1;j<=C;j++) cin >> D[i][j];
  }

  int cnt[3][C+1];
  fill(cnt[0], cnt[3], 0);
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      int k = (i + j) % 3;
      int c;
      cin >> c;
      cnt[k][c]++;
    }
  }

  /*for(int i=0;i<3;i++){
    for(int j=1;j<=C;j++){
      printf("cnt[%d][%d] = %d \n",i,j,cnt[i][j]);
    }
  }*/

  ll ans = 100000000000000LL;
  for(int i=1;i<=C;i++){
    for(int j=1;j<=C;j++){
      for(int k=1;k<=C;k++){
        if(i == j || j == k || k == i) continue;

        ll tmp = 0LL;
        for(int l=1;l<=C;l++) tmp += cnt[0][l] * D[l][i];
        for(int l=1;l<=C;l++) tmp += cnt[1][l] * D[l][j];
        for(int l=1;l<=C;l++) tmp += cnt[2][l] * D[l][k];

        ans = min(ans, tmp);
      }
    }
  }

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


Measured memory_bytes: 256
import java.util.*;

public class Main{

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt();
    int arr[] = new int[N+1];
    for(int i = 1; i<=M; i++){
      int n = sc.nextInt();
      arr[n] = 1;
    }
    int opt1 = 0; //cost of going from X to 0
    int opt2 = 0; //cost of going from X to N
    for(int i = X; i>=0; i--){
      opt1 += arr[i]; 
    }
    for(int i = X; i<=N; i++){
      opt2 += arr[i]; 
    }
    System.out.println(Math.min(opt1, opt2));
  }
}

/*

pre[i] = arr[1] + arr[2] + arr[3] + arr[4] + ... + arr[i]
The question for some l and r
arr[l] + arr[l+1] + arr[l+2] + ... + arr[r]
= 
pre[r] - pre[l-1]

pre[r]   = arr[1] + arr[2] + ... + arr[l-1] + arr[l] + arr[l+1] + ... + arr[r]
-
pre[l-1] = arr[1] + arr[2] + ... + arr[l-1]

*/


Measured memory_bytes: 27144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t=0,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        int s=max(x-t,0);
        t=x;
        ans+=s;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256