akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e5+5;
const long long INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve() {
    int n;
    cin >> n;
    int a[n];
    double len = 0;
    for(int i=0 ; i<n ; i++){
        cin >> a[i];
    }
    for(int i=0 ; i<n ;i++){
        if(a[i]!=0){
            len+=log10(a[i]);
        }
        else{
            cout << 0 << endl;
            return;
        }
    }
    int ans = len;
//    cout << ans << endl;
    if(ans > 18){
        cout << -1 << endl;
    }
    else{
        int mul = 1;
        for(int i=0 ; i<n ;i++){
            mul*=a[i];
        }
        if(mul > 1000000000000000000){
            cout << -1 << endl;
        }
        else{
            cout << mul << endl;
        }
    }

}

signed main(){
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/*Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

Measured memory_bytes: 4696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static ConsoleReader;

class Program
{
    static void Main(string[] args)
    {
        var n = Read<int>();
        var a = ReadArray<long>(n);
        var q = Read<int>();

        var s = a.Sum();
        var d = new Dictionary<long, long>();

        n.Times(i =>
        {
            if (d.ContainsKey(a[i])) d[a[i]] = d[a[i]] + 1;
            else d[a[i]] = 1;
        });

        q.Times(_ =>
        {
            var b = Read<long>();
            var c = Read<long>();
            if (d.ContainsKey(b))
            {
                var count = d[b];
                s += (c - b) * count;
                if (d.ContainsKey(c)) d[c] = d[c] + count;
                else d[c] = count;
                d.Remove(b);
            }
            Console.WriteLine(s);
        });
    }
}

public static class IntExtentions
{
    public static void Times(this int n, Action<int> action)
    {
        for (var i = 0; i < n; i++)
        {
            action(i);
        }
    }

    public static void Times(this (int n, int m) dimensions, Action<int, int> action)
    {
        var (n, m) = dimensions;
        n.Times(i => m.Times(j => action(i, j)));
    }
}

public static class ConsoleReader
{
    public static T Read<T>()
        where T : IConvertible
    {
        var inputBuffer = new StringBuilder();
        int currChar;

        while ((currChar = Console.Read()) != -1)
        {
            if (!char.IsWhiteSpace((char)currChar))
            {
                inputBuffer.Append((char)currChar);
            }
            else if (inputBuffer.Length != 0)
            {
                break;
            }
        }

        return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
    }

    public static T[] ReadArray<T>(int count)
        where T : IConvertible
    {
        if (count < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(count), $"'{nameof(count)}' must be >= 0");
        }

        var result = new T[count];

        for (var i = 0; i < count; i++)
        {
            result[i] = Read<T>();
        }

        return result;
    }
}

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

int main() {
  int x;
  cin >> x;
  int ans = 0;
  ans += (x / 500) * 1000;
  x %= 500;
  ans += (x / 5) * 5;

  cout << ans << endl;
}


Measured memory_bytes: 3112
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S, T;
    cin >> S >> T;

    if (S == T) {
        print("Yes");
        return 0;
    }

    unordered_map<char, char> m;

    REP(i, S.size()) {
        if (m.find(S[i]) == m.end()) {
            m[S[i]] = T[i];
        } else {
            if (m[S[i]] != T[i]) {
                print("No");
                return 0;
            }
        }
    }

    set<char> open;

    vector<bool> v(30, false);

    for(auto &p: m) {
        char start = p.fi;

        if (open.count(start) > 0) continue;

        char to = p.se;

        open.insert(start);

        while(true) {
            if (to == start) {
                break; // ok
            }

            if (open.count(to) > 0) {
                if (v[to - 'a']) {
                    // ok
                    v[start - 'a'] = true;
                    v[to - 'a'] = false;
                    break;
                }

                // ng
                print("No");
                return 0;
            }

            open.insert(to);

            if (m.find(to) == m.end()) {
                v[start - 'a'] = true;
                break; //ok
            }

            to = m[to];
        }
    }

    print("Yes");

}


Measured memory_bytes: 916
#include<cstdio>
#include<cctype>

int main(){
    char ch;
    while(1){
    scanf("%c",&ch);
    if(isalpha(ch)){
        if(islower(ch))printf("%c",toupper(ch));
        else printf("%c",tolower(ch));
       }else printf("%c",ch);
       
       if(ch=='\n')break;
        
    }
    return 0;
}


Measured memory_bytes: 2616
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int Ds[]=new int[5];
    int result=0;
    int sa=10;
    Ds[0]=sc.nextInt();
    Ds[1]=sc.nextInt();
    Ds[2]=sc.nextInt();
    Ds[3]=sc.nextInt();
    Ds[4]=sc.nextInt();




    for(int k=0;k<5;k++){
      if(Ds[k]%10<sa&&!(Ds[k]%10==0)){
        sa=Ds[k]%10;
      }
    }
    for(int j=0;j<5;j++){
      if(Ds[j]%10==0){
        result+=Ds[j];
      }else{
        while(!(Ds[j]%10==0)){
          Ds[j]++;
        }
        result+=Ds[j];
      }
    }
    System.out.println(result-10+sa);
  }
}


Measured memory_bytes: 20564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='1'||s[0]=='0'){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[n-2-i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    int to=n-1;
    for(int i=n-2;i>=0;i--){
        cout<<i+1<<" "<<to+1<<endl;
        if(s[i]=='1')to=i;
    }
}


Measured memory_bytes: 1664
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var x = ( arr[0] ) * arr[2] - arr[1]
print( x )
for var i = 0; i < 9; i+=1 {   
  x = ( arr[0]  ) * x - arr[1]
  print( x )
}
  

Measured memory_bytes: 4208
#include<iostream>

#define MAX_ROW 100
#define MAX_COLUMN 100

using namespace std;

int main(){

    unsigned int r, c;
    unsigned int i, j;
    unsigned int sum = 0;   // 一番右下用
    unsigned int sheet[MAX_ROW + 1][MAX_COLUMN + 1] = {0};

    cin >> r >> c;

    for( i = 0; i < r; i++ ){
        for( j = 0; j < c; j++ ){
            cin >> sheet[i][j];
        }
    }

    for( i = 0; i < r; i++){
        for( j = 0; j < c; j++){
            sheet[i][c] += sheet[i][j];
            sheet[r][j] += sheet[i][j];
            sum += sheet[i][j];
        }
    }

    sheet[i][j] = sum;

	for( i = 0;i < r+1;i++){
		for( j = 0; j < c+1; j++){
			if(j == c){
				cout << sheet[i][j];
			}else{
                cout << sheet[i][j] << " ";
            }
		}
		cout << endl;
	}    

    return 0;

}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void) {
  int a, b;

  cin >> a >> b;
  if (b == 1){
    cout << 0 << endl;
    return 0;
  }
  int s = a;
  int n = 1;
  while (s < b) {
    s += a - 1;
    n++;
  }
  cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string a, b;
	int flag_a = 0;
  	int flag_b = 0;
  
    cin >> a;

  	for (int i=0;i<3;i++){
     	if(a[i]=='A'){
          flag_a ++;
        }
      	if(a[i]=='B'){
          flag_b ++;
        }
    }
    if (flag_a >0 and flag_b >0){
     	printf("Yes") ;
    }else{
     	printf("No") ;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
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;
}
int main() {
  cout << fixed << setprecision(10);
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0; i<n; i++){
    cin >> a.at(i);
    if(a.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  for(ll i=0; i<n; i++){
    ll tmp = ans;
    ans*=a.at(i);
    if(tmp>1000000000000000000/a[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


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


int main(){
  int n,t;
  cin >> n >> t;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  long long int ans=0;
  for(int k=1;k<n;k++){
    ans += min(vec[k]-vec[k-1],t);
  }
  cout << ans+t << endl;
}

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

typedef long long ll;
using namespace std;

int main(){
	
	int a,b;
	cin >> a >> b;
	int s = 0;
	if(a> b) {
		s += a;
		a--;
	}else{
		s+=b;
		b--;
	}
	if(a> b) {
		s += a;
		a--;
	}else{
		s+=b;
		b--;
	}
	cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int m,n,ans;
int c[101][101];
bool check(void){
    REP(i,m)REP(j,n){
	if(c[i][j] != 0) return false;
    }
    return true;
}
bool ism(){
    REP(i,m)REP(j,n){
	if(c[i][0] == 1) return false;
    }
    return true;
}

int main(){
    ans = 0;
    cin >> m >> n;
    REP(i,m){
	REP(j,n){
	    cin >> c[i][j];
	    if(c[i][j] == 0) c[i][j] = -1;
	    //subete hanntenn
	    c[i][j] *= -1;
	}
    }
    //mosi itiretu nara
    if(n==1){
	int an = 0;
	c[0][0] *= -1;
	REP(i,m){
	    if(c[i][0] == 1){
		an++;
	    }
	}
	cout << an << endl;
	return 0;
	//end
    }

    /*
    // zyoudann ha hanntenn sinai
    FOR(i,1,n-1){
	c[0][i] *= -1;
    }
    */
    //ryouhasi ha hanntennsinai
    REP(i,m){
	c[i][0] *= -1;
	c[i][n-1] *= -1;
    }
    //mouiccho
    FOR(i,1,m){
	REP(j,n){
	    c[i][j] *= -1;
	}
    }

    /*
    REP(i,m){
	REP(j,n){
	    cout << c[i][j] << " ";
	}
	cout << endl;
    }
    */
    int ans = 0;
    REP(i,m){
	int sum = 0;
	int a = 0;
	//hidari hasi 
	if(c[i][0] == 1) sum++;
	//tyuukan
	FOR(k,1,n-1){
	    if(c[i][k] == 1){
		sum++;
	    }
	}
	//migi hasi
	if(c[i][n-1] == 1) sum++;

	//hidari ga sigo
	if(c[i][0] == 1){
	    a = max(a,sum-1);
	}else{
	    a = max(a,sum+1);
	}
	//dokoka ga saigo
	FOR(j,1,n-1){
	    int temp = 0;
	    if(c[i][j] == 1){
		temp = sum - 1;
	    }else if(c[i][j] == -1){
		temp = sum + 1;
	    }
	    a = max(a,temp);
	}
	//migi ga saigo
	if(c[i][n-1] == 1){
	    a = max(a,sum-1);
	}else{
	    a = max(a,sum+1);
	}
	ans += a;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1200
x = int(input())

if 400 <= x <= 599:
    ans = 8
elif 600 <= x <= 799:
    ans = 7
elif 800 <= x <= 999:
    ans = 6
elif 1000 <= x <= 1199:
    ans = 5
elif 1200 <= x <= 1399:
    ans = 4
elif 1400 <= x <= 1599:
    ans = 3
elif 1600 <= x <= 1799:
    ans = 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 9188
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

from collections import Counter

def c2s(c):
    s = ''
    for key, val in c:
        # print(key, val)
        # s = f'{s}{key}{val}'
        s = '{}{}{}'.format(s, key, val)
    # print(s)
    return s

def choose2(n):
    if n == 1:
        return 0
    return n * (n - 1) // 2

def solve():
    n = II()
    S = ["".join(sorted(input())) for _ in range(n)]
    # print(S)

    jisho = {}
    for s in S:
        # c = sorted(Counter(s).items(), key=lambda x: x[0])
        # print(c)
        # key = c2s(c)
        jisho[s] = jisho.setdefault(s, 0) + 1
    # print(jisho)
    ans = 0
    for val in jisho.values():
        ans = ans + choose2(val)

    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 19880
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;

int main(void) {
	i64 ans = 0;
	string s;
	vector<pair<char, i64>> q;
	cin >> s;
	q.push_back({s[0], 1});
	for (i64 i = 1; i < s.size(); i++) {
		if (s[i - 1] != s[i]) q.push_back({s[i], 1});
		else q.back().second++;
	}
	i64 pos = 0;
	while (true) {
		if (pos >= q.size() - 1) break;
		if (q[pos].second >= q[pos + 1].second) {
			ans += q[pos + 1].second * 2;
			q[pos].second -= q[pos + 1].second;
			if (pos + 2 >= q.size()) pos = q.size();
			else {
				q[pos + 2].second += q[pos].second;
				pos += 2;
			}
		}
		else {
			ans += q[pos].second * 2;
			q[pos + 1].second -= q[pos].second;
			pos += 1;
		}
		/*for (i64 i = pos; i < q.size(); i++) {
			for (i64 j = 0; j < q[i].second; j++) {
				cout << q[i].first;
			}
		}
		cout << endl;*/
	}
	cout << ans << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>a;
    int b;
    for(int i=0;i<N;i++){
        scanf("%d",&b);
        a.push_back(b);
    }
    map<int,int> m;
    int p=1;
    for(int i=0;i<N+2;i++){
        if(p==2){cout<<i<<endl;exit(0);}
        if(m[p]==1){cout<<"-1"<<endl;exit(0);}
        m[p]++;
        p=a[p-1];
    }
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007

using Graph = vector<vector<ll>>;
using pint = pair<ll,ll>;

Graph G;
ll s,t;
ll n,m;
ll solve(){
    vector<vector<ll>> dist(n,vector<ll>(3,-1));
    dist[s][0] = 0;
    queue<pint> que;
    que.push({s,0});
    while(!que.empty()){
        pint cur = que.front();que.pop();
        ll v = cur.first;
        ll parity = cur.second;
        for(auto nv : G[v]){
            ll np = (parity + 1) % 3;
            if(dist[nv][np] == -1){
                dist[nv][np] = dist[v][parity] + 1;
                que.push({nv,np});
            }
        }
    }
    if (dist[t][0] == -1) return -1;
    else return dist[t][0] / 3;

}
int main(){
    // ll n,m;
    cin>>n>>m;
    G.assign(n,vector<ll>());
    rep(i,m){
        ll u,v;
        cin>>u>>v;
        --u;--v;
        G[u].push_back(v);
    }
    cin>>s>>t;
    --s;--t;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 11136
use std::io::*;
use std::str::FromStr;

fn main(){
    let n = read::<i32>();
    let (d, x) = (read::<i32>(), read::<i32>());
    let mut r = 0;
    for _ in 0..n{
        r += 1 + (d - 1) / read::<i32>();
    }
    println!("{}", r + x )    
}

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

Measured memory_bytes: 4352
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
      
      for(int i = 0;i < W + 2; i++){
      	System.out .print("#");
      }System.out .println();
      
      
      for(int i = 0;i < H; i++){
        	System.out .print("#");
            String s = sc.next();
            System.out .print(s);
        	System.out .println("#");
            }
      
       for(int i = 0;i < W + 2; i++){
      	System.out .print("#");
      }System.out .println();
      
    }
}

Measured memory_bytes: 22356
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<vector<pair<ll, ll> > > dp(N, vector<pair<ll,ll>>(2));
  dp[0][0] = {0, 1000};
  dp[0][1] = {1000 / A[0], 1000 % A[0]};

  for (int i = 1; i < N; ++i) {
    pair<ll, ll> tmp, tmp2;

    // sell
    tmp = {0, dp[i - 1][1].first * A[i] + dp[i - 1][1].second};
    dp[i][0] = max(dp[i - 1][0], tmp);

    // buy
    tmp = {dp[i - 1][0].second / A[i], dp[i - 1][0].second % A[i]};
    tmp2 = {dp[i - 1][1].first + dp[i - 1][1].second / A[i], dp[i - 1][1].second % A[i]};
    dp[i][1] = max(tmp, tmp2);
  }

  cout << dp[N - 1][0].second << endl;
  return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*
5の数
2の数
mapでいれとく
{2,5,小数の数｝

7.5=0,3,1
2.4=3,0,1
3-2=1>0だからOK
全部9桁として
9+4=13桁として扱う
2と5が18桁あればOK


2

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll N; cin>>N;
  vector<vector<ll>> DP(20, vector<ll>(20,0));
  vector<pair<ll,ll>> Z(N,{0,0});
  rep(i,N){
    string S; cin>>S;
    ll n=0, j=0, d=100;
    while (S[j] && d-->0)
    {
      if (S[j] == '.'){
        d=9;
        j++;
        continue;
      }
      n = n * 10 + (S[j++] - '0');
    }
    d = min(d, 9LL);
    while (d-->0)
      n*=10;
    ll two=0, five=0;
    while (n%2==0)
    {
      two++;
      n/=2;
    }
    while (n%5==0)
    {
      five++;
      n/=5;
    }
    two = min(two,18LL);
    five = min(five,18LL);
    DP[two][five]++;
    Z[i] = {two,five};
  }
  ll ans=0;
  rep(i, N){
    ll t=Z[i].first;
    ll f=Z[i].second;
    for(ll j=18-t; j<=18; j++) for(ll k=18-f; k<=18; k++)
      ans += DP[j][k];
    if (t>=9 && f>=9)
      ans--;
  }
  ans /= 2;
  cout<<ans<<endl;
}

Measured memory_bytes: 6328
import fractions

N = int(input())
A = [int(i) for i in input().split()] 

L = [0]*(N+2)
R = [0]*(N+2)

gcd = fractions.gcd

for i in range(N):
    if i == 0:
        L[i+1] = A[i]
    else:
        L[i+1] = gcd(L[i],A[i])

    
for i in reversed(range(N)):
    if i == N-1:
        R[i+1] = A[i]
    else:
        R[i+1] = gcd(R[i+2],A[i])

#print(L,R)

M = []
for i in range(N):
    M.append(gcd(L[i],R[i+2]))

print(max(M))

Measured memory_bytes: 90208
#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef pair<int,Pii> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
class data{
public:
    int cnt;
    int power;
    int Exp;
    data(){}
    data(int _cnt,int _power,int _exp){
        cnt = _cnt;
        power = _power;
        Exp = _exp;
    }
};
int memo[101][10001];
int main(){
    int D,N;
    while(true){
        scanf("%d%d",&D,&N);
        if(D == 0 && N == 0)break;
        vector < P > s;
        memset(memo,0,sizeof(memo));
        rep(i,N){
            int a,e,r;
            scanf("%d%d%d",&a,&e,&r);
            s.PB(P(r,Pii(a,e)));
        }
        sort(s.begin(),s.end());
        int ans = -1;
        queue < data > Q;
        Q.push(data(0,D,0));
        memo[D][0] = 0;
        while(!Q.empty()){
            data d = Q.front();Q.pop();
            if(d.power == 0){
                ans = d.cnt;
                break;
            }
            rep(i,N){
                if(d.Exp < s[i].fi)break;
                int na = max(0,d.power-s[i].se.fi);
                int ne = d.Exp+s[i].se.se;
                if(memo[na][ne])continue;
                memo[na][ne] = d.cnt+1;
                Q.push(data(d.cnt+1,na,ne));
            }
        }
        if(ans == -1)puts("NA");
        else printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5292
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
ll a[111111];
ll b[111111];

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	n=read();
	FOR(i,0,n){
		a[i]=read();
		b[n-1]+=a[i];
		a[i]*=2;
		if(i%2==0)b[n-1]-=a[i];
	}
	b[n-1]+=a[n-1];
	for(int i=n-2;i>=0;--i){
		b[i]=a[i]-b[i+1];
	}
	FOR(i,0,n)printf("%d ",b[i]);
	
	
	
	
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#define int long long
using namespace std;

int a[12];
int sum = 1;

int llPow(int a,int b){
    int ans = 1;
    for(int i = 0; i < b; i ++){
        ans *= a;
    }
    return ans;
}

int bk(int n){
    int ans = 0;
    for(int i = 0; i < n; i ++){
        ans += llPow(26,i+1);
    }
    return ans;
}

int setIni(int n){
    if(n == 1) return 1;
    else{
        return 1 + bk(n-1);
    }
}


char numToLetter(int l){
    if(l == 0) return 'a';
    if(l == 1) return 'b';
    if(l == 2) return 'c';
    if(l == 3) return 'd';
    if(l == 4) return 'e';
    if(l == 5) return 'f';
    if(l == 6) return 'g';
    if(l == 7) return 'h';
    if(l == 8) return 'i';
    if(l == 9) return 'j';
    if(l == 10) return 'k';
    if(l == 11) return 'l';
    if(l == 12) return 'm';
    if(l == 13) return 'n';
    if(l == 14) return 'o';
    if(l == 15) return 'p';
    if(l == 16) return 'q';
    if(l == 17) return 'r';
    if(l == 18) return 's';
    if(l == 19) return 't';
    if(l == 20) return 'u';
    if(l == 21) return 'v';
    if(l == 22) return 'w';
    if(l == 23) return 'x';
    if(l == 24) return 'y';
    if(l == 25) return 'z';
    return 'null';
}


signed main() {

    int k;
    int d = 1;
    cin >> k;

    for(int i = 0; i < 12; i ++){
        a[i] = 0;
    }
   for(int i = 1; i < 12; i ++){
       //calulate digits
       if(k >= setIni(i) && k < setIni(i+1)){
           d = i;
           k -= setIni(i);
       }
   }


   for(int i = d-1; i >=0; i --){
       for(int j = 25; j >= 0; j --){
           if(k-llPow(26,i)*j >= 0){
               a[i] = j;
               k -= llPow(26,i)*j;

               break;
           }
       }
       if (k == 0) break;
   }

   for(int i = d-1; i >=0; i --){
       cout << numToLetter(a[i]);
   }

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    vector<char> te(n); //自分が出す手
    ll ans = 0;

    rep(i,n) {
        if (i+1<=k) {
            if (t[i]=='r') {
                ans += p;
                te[i] = 'p';
            }
            if (t[i]=='s') {
                ans += r;
                te[i] = 'r';
            }
            if (t[i]=='p') {
                ans += s;
                te[i] = 's';
            }
        } else {
                if (t[i]=='r') {
                    if (te[i-k]!='p') {
                        ans += p;
                        te[i] = 'p';
                    } else {
                        if (i+k>=n) continue;
                        if (t[i+k]=='r') te[i]='s';
                        if (t[i+k]=='s') te[i]='p';
                        if (t[i+k]=='p') te[i]='r';
                    }
                }
                if (t[i]=='s') {
                    if (te[i-k]!='r') {
                        ans += r;
                        te[i] = 'r';
                    } else {
                        if (i+k>=n) continue;
                        if (t[i+k]=='r') te[i]='s';
                        if (t[i+k]=='s') te[i]='s';
                        if (t[i+k]=='p') te[i]='p';
                    }
                }
                if (t[i]=='p') {
                    if (te[i-k]!='s') {
                        ans += s;
                        te[i] = 's';
                    } else {
                        if (i+k>=n) continue;
                        if (t[i+k]=='r') te[i]='r';
                        if (t[i+k]=='s') te[i]='p';
                        if (t[i+k]=='p') te[i]='r';
                    }
                }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 405;
const ll inf = 1e18L+5;
ll a[maxn], dp[maxn][maxn];
ll sum(ll l, ll r){
    ll sum=0;
    for(ll i=l;i<=r;i++)sum+=a[i];
    return sum;
}
int main()
{
    ll n;
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i];
    for(int l=n-1;l>=0;l--){
        for(int r=l;r<n;r++){
            if(l == r)dp[l][r] = 0;
            else{
                dp[l][r] = inf;
                ll s=sum(l,r);
                for(int i=l;i<=r-1;i++)dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+s);
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}



Measured memory_bytes: 1536
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();

            long max = 0;
            long sum = 0;

            foreach(var a in line)
            {
                if(max > a)
                {
                    sum += max - a;
                }
                else
                {
                    max = a;
                }
            }

            WriteLine(sum);
        }
    }
}

Measured memory_bytes: 47632
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1e9+7;
const int INF=1001001001;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  vector<int>dp(N,INF);
  dp[0]=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
    if(i<N-j){chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));}
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;  
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
string s;

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

	cin>>s;
	int n=s.size();
    if(s[0]!='1' || s[n-1]!='0')
    {
        cout<<-1;
        return 0;
    }

    int m=n-2;
    for(int i=1;i<=m/2;i++)
        if(s[i]!=s[m-i])
        {
            cout<<-1;
            return 0;
        }

    int posl=1;
    for(int i=2;i<=n;i++)
    {
        cout<<posl<<" "<<i<<endl;
        if(s[i-2]=='1')
            posl=i;
    }

	return 0;
}


Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int n, cnt = 0, k;
    cin >> n;
    string s;
    cin >> s;
    cin >> k;
    rep(i, n)
    {
        if (s[k - 1] != s[i])
        {
            s[i] = '*';
        }
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
s = list(s)
allli = {"w":s.count("W"),"e":s.count("E")}
leftli = {"w":0,"e":0}
rightli = allli
coli = []
for i in range(n):
    if i == 0:
        if s[i] == "W":
            rightli["w"] -= 1
        else:
            rightli["e"] -= 1
        coli.append(rightli["e"])
    else:
        if s[i - 1] == "W":
            leftli["w"] += 1
        else:
            leftli["e"] += 1
        if s[i] == "W":
            rightli["w"] -= 1
        else:
            rightli["e"] -= 1
        coli.append(rightli["e"] + leftli["w"])

print(min(coli))

Measured memory_bytes: 17740
IDENTIFICATION DIVISION.
       PROGRAM-ID. WHITE_CELLS.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 S PIC X(5).
       01 S1 PIC X(2).
       01 S2 PIC X(2).
       01 A PIC 9(2).
       01 B PIC 9(2).
       01 C PIC 9(2).
       01 D PIC 9(2).
       01 X PIC 9(3).
       PROCEDURE DIVISION.
       MAIN SECTION.
           ACCEPT S FROM SYSIN.
           UNSTRING S DELIMITED BY SPACE INTO S1, S2.
           MOVE S1 TO A.
           MOVE S2 TO B.
           ACCEPT S FROM SYSIN.
           UNSTRING S DELIMITED BY SPACE INTO S1, S2.
           MOVE S1 TO C.
           MOVE S2 TO D.
           COMPUTE X = (A - C) * (B - D).
           DISPLAY X(3 - FUNCTION INTEGER(FUNCTION LOG10(X)):)
           UPON SYSOUT.
       	   STOP RUN.

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    int n,a=100000000,x,b,c;
    cin>>n;
    c=n;
    while(a!=1){
        x=n/a;
        n=n%a;
        b=b+x;
        a=a/10;
    }
    x=n%10;
    b=b+x;
    if(c%b==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int N(1e5), M(105);
int64_t dp[N + 5], res;
int n, g, w[M], v[M], newsum;
int main() {
    DAU
    cin >> n >> g;
    for (int i = 1; i <= n; ++i)
        cin >> w[i] >> v[i];
    dp[0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int sum = g; sum >= 0; --sum)
            if (dp[sum] && sum + w[i] <= g) {
                newsum = sum + w[i];
                dp[newsum] = max(dp[newsum], dp[sum] + v[i]);
                res = max(res, dp[newsum]);
            }
    cout << res - 1;
    PLEC
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long ans = 0;
    for(long i = 1; i <= n; i++) {
      if(((i % 3) != 0) && ((i % 5) != 0)) ans += i;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35636
import java.util.*;

public class Main {
  public static String[][] maze;
  public static int[][] kyori;
  public static int[][] seen;
  public static int h;
  public static int w;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    h = sc.nextInt();
    w = sc.nextInt();
    maze = new String[h][w];
    for(int i = 0; i < h; i++) {
      String s = sc.next();
      for(int j = 0; j < w; j++) {
        maze[i][j] = String.valueOf(s.charAt(j));
      }
    }
    kyori = new int[h][w];
    seen = new int[h][w];
    int ans = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        int[] s = new int[2];
        s[0] = i;
        s[1] = j;
        if(maze[i][j].equals(".")) ans = Math.max(ans, bfs(s));
      }
    }
    System.out.println(ans);
  }
  public static int bfs(int[] st) {
    Queue<int[]> que = new LinkedList<int[]>();
    que.add(st);
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        kyori[i][j] = 1000;
      }
    }
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        seen[i][j] = 0;
      }
    }
    kyori[st[0]][st[1]] = 0;
    seen[st[0]][st[1]] = 1;
    while(!que.isEmpty()) {
      int[] a = que.poll();
      for(int i = -1; i <= 1; i++) {
        for(int j = -1; j <= 1; j++) {
          int x = a[0] + i;
          int y = a[1] + j;
          int d = kyori[a[0]][a[1]];
          int[] b = new int[2];
          b[0] = x;
          b[1] = y;
          if((x >= 0) && (x < h) && (y >= 0) && (y < w) && (seen[x][y] == 0) && (maze[x][y].equals("."))) {
            if(i == -1) {
              if(j == 0) {
                seen[x][y] = 1;
                kyori[x][y] = d + 1;
                que.add(b);
              }
            } else if(i == 0) {
              if(j != 0) {
                seen[x][y] = 1;
                kyori[x][y] = d + 1;
                que.add(b);
              }
            } else {
              if(j == 0) {
                seen[x][y] = 1;
                kyori[x][y] = d + 1;
                que.add(b);
              }
            } 
          }
        }
      }
    }
    int ret = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        if(maze[i][j].equals(".")) ret = Math.max(ret, kyori[i][j]);
      }
    }
    return ret;
  }
}

Measured memory_bytes: 39716
#include<iostream>
int main() {
	int num[4];
	int sum=0;
	for (int i = 0; i < 4; ++i) {
		std::cin >> num[i]; sum += num[i];
	}
	std::cout << sum / 60 << std::endl;
	std::cout << sum % 60 << std::endl;
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    long long int sum=0;
    int d[n];
    for (int i=0; i<n; i++) cin >> d[i];

    for (int i=0; i<n-1; i++){
        for (int j=i+1; j<n; j++){
            sum += d[i]*d[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main(){
  int a=0;
  int b=0;
  int o=0;
  int ab=0;
  int count;
  char brood[3];
  while(scanf("%d,%s",&count,&brood)!=EOF){
    if(strcmp("AB",brood)==0){
      ab++;
    }
    else if(strcmp("A",brood)==0){
      a++;
    }
    else if(strcmp("O",brood)==0){
      o++;
    }
    else if(strcmp("B",brood)==0){
      b++;
    }
  }
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}
  

Measured memory_bytes: 596
N = int(input())
A = list(map(int,input().split()))

A2 = 0
A35 = 0
for i in range(N):
	if A[i]%2 == 0:
		A2 += 1
		if A[i] % 3 == 0 or A[i] % 5 == 0:
			A35 += 1

if A2 == A35:
	print("APPROVED")
else:
	print("DENIED")



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

using namespace std;

int main() {
	string s;
	cin >> s;
	int i, n=s.size(), m = 0;
	
	for (i=0; i < n; i++) {
		if (s[i] == 'x')
			m++;
	}
	if (m<=7)
		cout <<"YES\n";
	else 
		cout << "NO\n";

	return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

ll mod = 1000000007;

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n & 1)res=res*a%mod;
    a =a*a%mod;
    n>>=1;
  }
  return res;
}

int main(){
  double X,A,B;
  cin >> X >> A >> B;
  if(A>=B) cout << "delicious";
  else if(A+X>=B ) cout << "safe";
  else if(B>A+X) cout << "dangerous";
}

Measured memory_bytes: 256
# A - One out of Three

# A B C は整数
# 上記2つは同じ整数で　1つだけ異なる整数
# ex) A = 5,B = 7,C = 5  ...  A ⇔ C Bは異なる値
# 3つの整数のうち 1つのことなる整数を出力させる

# A B C を標準入力
A, B, C = map(int, input().split(maxsplit=3))
# print(A, B, C)

# 以下で条件を分けて代入。
# 1. A ⇔ B の時 C を代入。
# 2. A ⇔ C の時 B を代入。
# 3. B ⇔ C の時 A を代入。

if A == B:
    answer = C
elif A == C:
    answer = B
else:
    answer = A

# 結果を出力
print(answer)


Measured memory_bytes: 9080
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,n){e.exports=function(e){for(var n=e[0],t=n.length,r=0;r<t;r++)if((r+1)%2==0){if("R"==n[r])return void console.log("No")}else if("L"==n[r])return void console.log("No");console.log("Yes")}},function(e,n){e.exports=require("fs")}]);

Measured memory_bytes: 11468
h,w = map(int,input().split())
s = [input() for _ in range(h)]
cnt = [[-3]*w for _ in range(h)]

for i in range(h):
    c = 1
    for j in range(w):
        if s[i][j] == "#": c = 1
        else:
            cnt[i][j] += c
            c += 1
    c = 1
    for j in range(w)[::-1]:
        if s[i][j] == "#": c = 1
        else:
            cnt[i][j] += c
            c += 1

for j in range(w):
    c = 1
    for i in range(h):
        if s[i][j] == "#": c = 1
        else:
            cnt[i][j] += c
            c += 1
    c = 1
    for i in range(h)[::-1]:
        if s[i][j] == "#": c = 1
        else:
            cnt[i][j] += c
            c += 1

print(max(max(i) for i in cnt))

Measured memory_bytes: 96088
#include <stdio.h>
#include <string.h>
int main()
{
    char str[100];
    scanf("%s", str);
    int l = strlen(str);
    for(int i=0; i<l; i++)
    {
        if(i%2==0)
        {
            if(str[i]=='L')
            {
                printf("No\n");
                return 0;
            }
        }
        else
        {
           if(str[i]=='R')
            {
                printf("No\n");
                return 0;
            } 
        }        
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;

typedef long double ld;

vector <ll> vec[20005];

ll dis[2005][2005];
ll temp[2005][2005];

void solve(ll i,ll j,ll n)
{
	
	set <pair<ll,ll>> pq;
	for(ll it=1;it<=n;it++)
	{
		if(it==i)
		{
			pq.insert({0,i});
		}
		else{
			pq.insert({1e18,it});
			dis[i][it] = 1e18;
		}
	}
	
	while(pq.size()>0)
	{
		auto it = *pq.begin();
		pq.erase(it);
		temp[i][it.second]++;
		for(auto itr:vec[it.second])
		{
			if(temp[i][itr]==-1)
			{
				if(dis[i][itr]>dis[i][it.second]+1)
				{
					pq.erase({dis[i][itr],itr});
					dis[i][itr] = dis[i][it.second]+1;
					pq.insert({dis[i][itr],itr});
				}
			}
		}
		
	}
	
}
	

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
	ll n,x,y;
	cin>>n>>x>>y;
	memset(dis,0,sizeof(dis));
	for(ll i=1;i<=n-1;i++)
	{
		vec[i].push_back(i+1);
		vec[i+1].push_back(i);
	}
	
	vec[x].push_back(y);
	vec[y].push_back(x);
	memset(temp,-1,sizeof(temp));
	memset(dis,-1,sizeof(dis));
	
	for(ll i=1;i<=n;i++)
	{
		dis[i][i] = 0;
		solve(i,i,n);
	}
	
	map <ll,ll> mp;
	
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			//cout<<i<<" "<<j<<" "<<dis[i][j]<<endl;
			mp[min(dis[i][j],dis[j][i])]++;
		}
	}
	
	for(ll i=1;i<n;i++)
	{
		cout<<mp[i]<<endl;
	}
	
}


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

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

    int mi = 1 << 30, ma = 0, a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        mi = min(mi, a);
        ma = max(ma, a);
    }

    cout << abs(mi - ma) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(){

int n;

std::cin>>n;
std::cin.get();
int x,min,max;
long sum=0;
for(int i=0;i<n;i++){
std::cin>>x;
if(i==0){
min=x;
max=x;}
else if(x<min){
min=x;}
else if(x>max){
max=x;}
sum+=x;
}
std::cout<<min<<" "<<max<<" "<<sum<<"\n";


return 0;

}

Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(void){
    int n;
    int dp[31];
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    for(int i = 3; i < 31; i++){
        dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    }
    while(1){
        cin >> n;
        if(n == 0)  break;
        int x;
        x = dp[n] / 3650;
        if(dp[n]%3650 != 0) x++;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
n, m = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)
ans =0
sum = 0
l = []
if n>=m
  ans =0
else
  x = x.sort  
  path = x[m-1] - x[0]
  
  (0 .. m-2).each do |i|
    l << x[i+1] - x[i]
  end
  l = l.sort
  
  (0 .. n-2).each do |i|
    sum += l[l.length-1-i]
  end
  ans = path - sum
end


puts ans

Measured memory_bytes: 11896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int m,n;
    if(a%d==0)
    m=a/d;
    else
    m=a/d+1;
    if(c%b==0)
    n=c/b;
    else
    n=c/b+1;
    if(m>=n)//(a!=d&&b!=c)||b==c)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& v,T w){if(v<w){v=w;return 1;} return 0;}
template<class T> inline bool chmin(T& v,T w){if(v>w){v=w;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int dp[1010][10010];

int main(){
  int W,N;
  cin >> N >> W;
  vector<int> v(N);
  vector<int> w(N);
  rep(i,N) cin >> v[i] >> w[i];
  rep(i,N){
    for(int j=0;j<=W;j++){
      chmax(dp[i+1][j],dp[i][j]);
      if(j+w[i]<=W) chmax(dp[i][j+w[i]],dp[i][j]+v[i]);
    }
  }
  cout << dp[N-1][W] << endl;
}


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

int main()
{
    int n, k=2;
    cin >> n ;
    int a[n + 1];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int start;
    int dp[n];
    for (int i = 0; i < n; i++)
        dp[i] = INT_MAX;
    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        start = i - k;
        if (start < 0)
            start = 0;
        for (int j = start; j < i; j++)
        {
            dp[i] = min(dp[j] + abs(a[i] - a[j]), dp[i]);
        }
    }

    cout << dp[n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;




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

	vector<double> list(N, 0.0);

	int p;
	int cnt;
	double sum = 0;
	for (int ni = 1; ni <= N; ni++) {
		p = ni;
		cnt = 0;
		while (p < K) {
			p *= 2;
			cnt++;
		}
		list[ni-1] = 1.0 / N / pow(2, cnt);
		sum += list[ni-1];
	}

	printf("%.9f", sum);


	return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
int main(void){
    uint_fast8_t a,b;
    scanf("%" SCNuFAST8 " %"SCNuFAST8 "",&a,&b);
    printf("%" PRIuFAST16 "\n",(uint_fast16_t)a*b);
    exit(0);
}

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

int main() {
  string s;
  int k;
  cin >> s >> k;
  if(s.at(0) == '1'){
    for(int i=0;i<k;i++){
      if(s.at(i) != '1'){
        cout << s.at(i);
        break;
      }
      else if(i == k-1)
        cout << 1;
    }
  }
  else
    cout << s.at(0);
}

Measured memory_bytes: 256