akhauriyash/Code-Regression huggingface dataset:
N = int(input())
h = list(map(int,input().split()))
i = N-1

for j in range(N-1):
  if h[i-1] - h[i] > 1:
    print("No")
    exit()
  elif h[i-1] - h[i] == 1:
    h[i-1] -= 1
  i -= 1 
print("Yes")

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

typedef long long ll;
ll merge(int A[], int left, int mid, int right);
ll mergeSort(int A[], int left, int right);
# define MM 2000000000
int main()
{
  using namespace std;
  int n;
  cin >> n;
  int *A = new int[n];
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &A[i]);
  }
  cout << mergeSort(A, 0, n - 1) << endl;
  delete[] A;
  return 0;
}

ll merge(int A[], int left, int mid, int right)
{
  ll count = 0;
  int len1 = mid - left + 1;
  int len2 = right - mid;
  int *L = new int[len1 + 1];
  int *R = new int[len2 + 1];
  for (int i = 0; i < len1; i++)
  {
    L[i] = A[i + left];
  }
  for (int i = 0; i < len2; i++)
  {
    R[i] = A[i + mid + 1];
  }

  int i = 0, j = 0, k = left;
  while (i < len1 && j < len2)
  {
    if (L[i] <= R[j])
    {
      A[k++] = L[i++];
    }
    else
    {
      A[k++] = R[j++];
      count += len1 - i;
    }
  }
  while (i < len1)
  {
    A[k++] = L[i++];
  }
  while (j < len2)
  {
    A[k++] = R[j++];
  }
  delete[] L;
  delete[] R;
  return count;
}

ll mergeSort(int A[], int left, int right)
{
  ll r1, r2, r3;
  if (left < right)
  {
    int mid = (left + right) / 2;
    r1 = mergeSort(A, left, mid);
    r2 = mergeSort(A, mid + 1, right);
    r3 = merge(A, left, mid, right);
    return r1 + r2 + r3;
  }
  else
  {
    return 0;
  }
}



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

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans1 = a * x + b * y;
    ll ans2, ans3;
    if (x >= y) ans2 = c * 2 * y + a * (x - y), ans3 = c * 2 * x;
    else if (x < y) ans2 = c * 2 * x + b * (y - x), ans3 = c * 2 * y;

    cout << min({ans1, ans2, ans3}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int N,A,B;
  cin >> N;
  if(N==1) {cout << "Hello World" << endl; return 0;}
  else {
    cin >>A >>B;
    cout <<A+B<<endl;
  }
  
}


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

int main()
{
    int a, b;
    cin>>a>>b;
    if(a>b)
    {
        for (int i=0;i<a; i++ )
        {
            std::cout << b;
        }
    }
    else
    {
        for (int i=0;i<b; i++ )
        {
            std::cout << a;
        }
    }
    return 0;
}

Measured memory_bytes: 256
keys = ('W', 'H', 'x', 'y', 'r')
attr = {k:v for k, v in zip(keys, map(int, input().split()))}
border = {'from':(attr['r'], attr['r']),
         'to':(attr['W'] - attr['r'], attr['H'] - attr['r'])}
if border['from'][0] <= attr['x'] <= border['to'][0] and border['from'][1] <= attr['y'] <= border['to'][1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        int a = 9;
        int b = 900;
        int c = 90000;
        if (str.length() == 2) {
            System.out.println(a);
        } else if (str.length() == 4) {
            System.out.println(a + b);
        } else if (str.length() == 6) {
            System.out.println(a + b + c);
        } else if (str.length() == 1) {
            System.out.println(str);
        } else if (str.length() == 3) {
            int d = Integer.parseInt(str) - 99;
            System.out.println(a + d);
        } else if (str.length() == 5) {
            int d = Integer.parseInt(str) - 9999;
            System.out.println(a + b + d);
        }
    }
}

Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
  Scanner sc;

  void run() {
    for ( ;; ) {
      int N = ni();
      int Q = ni();

      if ( ( N | Q ) == 0 ) {
        break;
      }

      int[][] list = new int[N][];
      Map<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( int i = 1; i < 100; ++i ) {
        map.put( i, 0 );
      }
      for ( int i = 0; i < N; ++i ) {
        int M = ni();
        list[ i ] = new int[M];
        for ( int j = 0; j < M; ++j ) {
          int d = ni();
          list[ i ][ j ] = d;
//          debug(d);
//          debug(map.keySet());
          map.put( d, map.get( d ) + 1 );
        }
      }

      int max = 0;
      int idx = 0;
      for ( Integer key : map.keySet() ) {
        int n = map.get( key );
        if( n >= Q ) {
          if( max < n ) {
            idx = key;
            max = n;
          }
        }
      }
      
      System.out.println(idx);
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 64680
#include<stdio.h>
#include <cstdlib>

int main ()
{
	int a,b,c;
	scanf("%d %d",&a,&b);

	int temp=-1005;
	if(a*b>temp)
		temp=a*b;
	if(a+b>temp)
		temp=a+b;
	if(a-b>temp)
		temp=a-b;
	
	printf("%d\n",temp);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
ll n,a[maxn],b[maxn];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],a[i]*=2;

    ll sum=0;
    for(int i=1;i<=n;i++)
        if(i%2)sum+=a[i];
        else sum-=a[i];

    b[1]=sum/2;
    printf("%lld",b[1]);

    for(int i=2;i<=n;i++){
        b[i]=a[i-1]-b[i-1];
        printf(" %lld",b[i]);
    }
    printf("\n");

    return 0;
}



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

c = input()

if c == "a":
    print("vowel")
elif c == "e":
    print("vowel")
elif c == "i":
    print("vowel")
elif c == "o":
    print("vowel")
elif c == "u":
    print("vowel")
else:
    print("consonant")

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<long long> table(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		table[a[i]]++;
	}
	long long sum = 0, ans;

	for (int i = 0; i < n; i++) {
		if (table[i] > 1) {
			long long x = table[i];
			sum += x*(x-1)/2;
		}
	}

	for (int i = 0; i < n; i++) {
		ans = sum - (table[a[i]]-1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5592
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class AKthTerm {
public:
	void solve(std::istream& in, std::ostream& out) {
	    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	    int k;
	    in >> k;
	    out << a[k-1] << endl;
	}
};


int main() {
	AKthTerm solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
if K.odd?
  puts (N/K)**3
else
  k=K/2
  cnt=0
  while k<=N
    cnt+=1
    k+=K 
  end
  puts (N/K)**3+cnt**3
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<pll,ll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define piii pair<pii, int>
#define pb push_back
const ll llinf = 2e18 + 7;
const int inf = 2e9 + 7;
const ll mod = 1e9 + 7;
const ll N = 2e2 + 7;
const ld pi = 3.14159265358979; 

void solve() {
    int x,n;
    cin>>x>>n;
    vector<int> a(N);
    for(int i=0;i<n;i++) {
        int f;
        cin>>f;
        a[f]++;
    }
    int minn = inf;
    int ele = -1;
    for(int i=0;i<110;i++) {
        if(a[i]) continue;
        if(minn > abs(x-i)) {
            minn = abs(x-i);
            ele = i;
        }
    }
    cout<<ele;
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<"\n";
    }
    return 0; 

}


Measured memory_bytes: 3624
import sys
import math
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd


def inv(x, mod):
    return pow(x, mod-2, mod)


def lcm(arr, mod = 10 ** 9 + 7):
    ret = 1
    for a in arr:
        ret = ret * a // gcd(ret, a)
    return ret

mod = 10 ** 9 + 7

N = int(input())
A = [int(x) for x in input().split()]
a = lcm(A)
print(sum(a * inv(x, mod) for x in A) % mod)


Measured memory_bytes: 6140
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
  int X;
  cin >> X;
  if(X==3||X==5||X==7){
  cout << "YES" << endl;
  }
  else{
  cout << "NO" << endl;
  } 
  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

void solve(){
	int N;
	cin>>N;
	vint A(N);
	rep(i,N)cin>>A[i];

	string S;cin>>S;

	vint T(60);
	for(int i=N-1;i>=0;i--){
		int e=A[i];
		for(int j=59;j>=0;j--){
			if(T[j]==0)continue;
			if((e&T[j])==0)continue;
			if(topbit(e&T[j])==topbit(T[j]))e^=T[j];
		}
		if(S[i]=='1'){
			if(e){
				cout<<1<<endl;
				return;
			}
		}
		else{
			if(e){
				rep(j,60){
					if(T[j]==0)continue;
					if((e&T[j])==0)continue;
					if(topbit(e&T[j])==topbit(e))T[j]^=e;
				}
				T[topbit(e)]=e;
			}
		}
	}
	cout<<0<<endl;
}

signed main(){
	int T;cin>>T;
	while(T--)solve();
	return 0;
}

Measured memory_bytes: 3524
#include <cstdio>
#include <algorithm>
#include <cstring>
typedef long long ll;

const ll MOD = 1e9 + 7;
const int maxn = 2e5 + 5;
using namespace std;

ll a[maxn], n, sum[maxn], ans;

int main() {
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", a + i);
        sum[i] = (a[i] + sum[i - 1]) % MOD;
    }

    for (int i = 2; i <= n; i++) {
        ans = (ans + a[i] * sum[i - 1] % MOD) % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

int main()
{
   int a, b;
   cin >> a >> b;
   for(int i=1;i<=1e4;i++)
   {
       int ansA =i*8/100, ansB=i*10/100;
       if(a==ansA&&b==ansB)
       {
           cout << i;
           exit(0);
       }
   }
   cout << "-1";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<queue>

int main() {
	int A, B, C, K;
	std::cin >> A >> B >> C >> K;

	int answer;

	if (A >= K)	answer = K;
	else if (A + B >= K) answer = A;
	else answer = A - (K - A - B);

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

Measured memory_bytes: 3548
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;


int main(){
	ll a,b,res=INF;
	cin>>a>>b;
	if(a<=b)res=min(res,b-a);
	if(-1*a<=b)res=min(res,b+a+1);
	if(a<=-1*b)res=min(res,-b-a+1);
	if(-1*a<=-1*b)res=min(res,-b+a+2);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    bool dpw[f+1];
    bool dps[f+1];
    dpw[0]=true;
    dps[0]=true;
    for(ll i=1;i<=f;i++){
        dpw[i]=false;
        dps[i]=false;
    }
    for(ll i=0;i<f;i++){
        if(dpw[i]==true){
            if(i+100*a<=f){
                dpw[i+100*a]=true;
            }
            if(i+100*b<=f){
                dpw[i+100*b]=true;
            }
        }
        if(dps[i]==true){
            if(i+c<=f){
                dps[i+c]=true;
            }
            if(i+d<=f){
                dps[i+d]=true;
            }
        }
    }
    ll maxi=-1;
    ll mw=-1,ms=-1;
    for(ll i=1;i<=f;i++){
        if(dpw[i]==true){
            for(ll j=f;j>=0;j--){
                if(dps[j]==true){
                    if(j<=f-i && 100*j<=e*i){
                        if(maxi<10000000*j/(i/100)){
                            maxi=10000000*j/(i/100);
                            mw=i;
                            ms=j;
                        }
                        j=-1;
                    }
                }
            }
        }
    }
    cout<<(mw+ms)<<' '<<ms<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  vec.push_back(0);
  N++;
  sort(ALL(vec));
  for (int i = 0; i < N; i++)
  {
    if(i%2 == 1)
    {
      vec[i] = 24 - vec[i];
    }
  }
  sort(ALL(vec));
  int ANS = INF;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if(i != j)
      {
        chmin(ANS,abs(min(vec[i] - vec[j],24 - vec[i] + vec[j])));
      }
    }
    
  }
  if(ANS == 24) ANS = 0;
  cout<<ANS<<endl;
  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    mod = 2019
    input = stdin.buffer.readline
    s = list(map(int, list(input()[:-1].decode())))
    n = len(s)
    s.reverse()

    tmp_p10 = 1
    p10 = [tmp_p10]
    for _ in range(1, n + 1):
        tmp_p10 *= 10
        tmp_p10 %= mod
        p10.append(tmp_p10)

    tmp_mod = s[0] % mod
    mods = [0, tmp_mod]
    for i in range(1, n):
        tmp_mod = (s[i] * p10[i] + tmp_mod) % mod
        mods.append(tmp_mod)
    m2019 = [0] * 2019
    for mi in mods:
        m2019[mi] += 1
    ans = 0
    for mi in m2019:
        ans += mi * (mi - 1) // 2

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 113452
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    X = int(input())
    if X < 600:
        print(8)
    elif X < 800:
        print(7)
    elif X < 1000:
        print(6)
    elif X < 1200:
        print(5)
    elif X < 1400:
        print(4)
    elif X < 1600:
        print(3)
    elif X < 1800:
        print(2)
    else:
        print(1)
    


if __name__ == '__main__':
    main()

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

using namespace std;

int main() {
    string A, B, C, D, E;
    cin >> A >> B;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    reverse(B.begin(),B.end());
    

    if(A<B) {
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }
    

    return 0;
}

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

int main(){
 	int s,ans;
  	vector<int> a(1000000,0);
  	cin >> s;
  	for(int i = 1 ; ; i ++){
      	if(a[s - 1] == 1){
          	cout << i << endl;
          	break;
        } else {
          	a[s - 1] ++;
        }
      	if(s % 2 == 0) s /= 2; else s = 3 * s + 1;
    }
}

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

template<typename T>
inline T pow(T a, long long n) {
    T ret = 1; while (n) { if (n & 1) ret *= a; n >>= 1; a *= a; }
    return ret;
}

int main() {
    int d, n; cin >> d >> n;
    n += n == 100;
    cout << n * pow(100, d) << endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop


def calcSpace():
    H = []
    hpush = lambda x: heappush(H, -x)
    hpop = lambda: -heappop(H)
    for x in X:
        hpush(x)
    
    E = [0] * 60
    while H:
        x = hpop()
        b = x.bit_length() - 1
        if E[b]:
            x ^= E[b]
            if x: hpush(x)
        else:
            E[b] = x
    
    return E
    
def chk(y):
    y0 = y
    for i in range(60)[::-1]:
        if y >> i & 1:
            if V[i]:
                y ^= V[i]
                # print("chk", y0, "OK", V)
                if y == 0: return 1
            else:
                return 0

def chk_all():
    for y in Y:
        if chk(y) == 0:
            return 1
            break
    else:
        return 0
    
T = int(input())
for _ in range(T):
    N = int(input())
    A = [int(a) for a in input().split()]
    S = [int(a) for a in input()]
    
    if 0:
        print("N =", N)
        print("A =", A)
        print("S =", S)
    
    X = []
    Y = []
    i = N - 1
    ans = 0
    while i >= 0:
        while i >= 0:
            if S[i]: break
            X.append(A[i])
            i -= 1
        while i >= 0:
            if S[i] == 0: break
            Y.append(A[i])
            i -= 1

            V = calcSpace()
            # print("X =", X)
            # print("Y =", Y)
            # print("V =", V)
            if chk_all():
                ans = 1
                i = -1
    print(ans)

Measured memory_bytes: 78364
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll MOD;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[5000001], invf[5000001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
//ll dp[6060][2020];
int main()
{
	int n;
    cin>>n>>MOD;
    fac(3*n);
    ll ans=0;
    for(int i=0; i<=n; i++){
        for(int j=2*i; j<=3*i; j++){
            (ans+=comb(j, 3*(j-2*i))*f[3*(j-2*i)]%MOD*inv(powmod(3, j-2*i))%MOD*invf[j-2*i]%MOD*f[2*(3*i-j)]%MOD*inv(powmod(2, 3*i-j))%MOD*invf[3*i-j]%MOD*comb(3*n, j))%=MOD;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2304
a,b,m = gets.split().map(&:to_i)
A = gets.split().map(&:to_i)
B = gets.split().map(&:to_i)
M = []
m.times do
  x = gets.split().map(&:to_i)
  x = A[x[0]-1] + B[x[1]-1] - x[2]
  M << x
end
A_min = A.min
B_min = B.min
C = A_min + B_min
M = M.min
if C > M
  puts M
else
  puts C
end

Measured memory_bytes: 20072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;

int N, M;
int A[200005], B[200005];

vector<int> Adj[100005];
queue<int> Q;

int ans[200005];

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

	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		Adj[A[i]].push_back(B[i]);
		Adj[B[i]].push_back(A[i]);
	}

	Q.push(1);

	while (Q.size()) {
		int u = Q.front(); Q.pop();

		for (auto v : Adj[u]) {
			if (ans[v] == 0) { ans[v] = u; Q.push(v); }
		}
	}

	cout << "Yes" << endl;
	for (int i = 2; i <= N; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 12004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int B, A;
  cin >> A >> B;
//  cout << A << B << endl;
  int n = 0;
 
  for(int j = A; j <= B; ++j){
//    cout << j << endl;
    int i = j;
    int x5, x4, x3, x2, x1;
    x5 = i / 10000;
    i = i - x5 * 10000;
	x4 = i / 1000;
    i = i - x4 * 1000;
    x3 = i / 100;
    i = i - x3 * 100;
	x2 = i / 10;
    i = i - x2 * 10;
	x1 = i / 1;

//    cout << x5 << endl;
//    cout << x4 << endl;
//    cout << x3 << endl;
//    cout << x2 << endl;
//    cout << x1 << endl;

    if(x5 == x1 && x4 == x2){
      ++n;      
    }   
  }
  cout << n << endl;
  
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int main()
{
	int n, m;
	cin>>n>>m;
	vector<ll> v;
	rep(i, 0, n)
	{
		ll x;
		cin>>x;
		v.pb(x);
	}
	sort(all(v));
	ll ans = LONG_MAX;
	repn(i, 0, n-m)
	{
		chmin(ans, v[i+m-1] - v[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int ws(long long x)
{
	int sum=0;
	while(x)
	  sum+=x%10,x/=10;
	return sum;
}
unsigned long long sum;
long long n,a,b,l;
int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		l=ws(i);
		if(l>=a&&l<=b)sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    for(int i=0;i<=N;i++) {
        for(int j=0;j<=N;j++) {
            ll a = N - R*i - G*j;
            if(a%B == 0 && a >= 0) ans++; 
        }
    }
    cout << ans << endl;
}

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

int main() {
    int X;
    cin >> X;
    rep(i,X+1) {
        if (X <= i * (i + 1) / 2) {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 3580
#include <cmath>
#include <iostream>
#include <vector>
#include <iomanip>

int get_factorial(int num) {
  int factrial = 1;
  for (int i = num; i > 1; --i) {
    factrial *= i;
  }
  return factrial;
}

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

  std::vector<std::vector<int>> vec(8, std::vector<int>(2));
  for (int i = 0; i < n; ++i) {
    std::cin >> vec.at(i).at(0) >> vec.at(i).at(1);
  }
  double sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      int aaa = std::pow(vec.at(i).at(0) - vec.at(j).at(0), 2) + std::pow(vec.at(i).at(1) - vec.at(j).at(1), 2);
      sum += sqrt(aaa);
    }
  }
  std::cout << std::fixed;
  std::cout << std::setprecision(10) << sum / n << std::endl; 
}


Measured memory_bytes: 256
var k: Int = 0
var foundCount: Int = 0
var lastFound: Long = 0

fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    k = line.toInt()

    var keta = 0

    while(true) {
        keta += 1

        for (i in (1..9)) {
            recur(keta, listOf(i))

            if (foundCount == k) {
                break
            }
        }

        if (foundCount == k) {
            break
        }
    }

    println(lastFound)
}

fun recur(keta: Int, nos: List<Int>) {
    if (keta == 1) {
        foundCount += 1
        lastFound = nos.map {it.toString()}.joinToString("") {it}.toLong()
        return
    }

    val nums = (Math.max(nos.last() - 1, 0)..Math.min(nos.last() + 1, 9))
    for (i in nums) {
        recur(keta - 1, nos.plus(i))
        if (foundCount == k) {
            break
        }
    }
}

Measured memory_bytes: 66420
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int n,sz[maxn],fa[maxn],d[maxn];
ll b[maxn],D;
vector<int> G[maxn];
struct Node{ll x;int id;}a[maxn];
inline bool operator <(Node x,Node y){return x.x<y.x;}
void dfs(int u,int fa){
    for(int v:G[u]) if(v!=fa) d[v]=d[u]+1,dfs(v,u);
}
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%lld",&a[i].x),a[i].id=i,b[i]=a[i].x;
    sort(a+1,a+n+1);sort(b+1,b+n+1);
    rep(i,1,n) sz[i]=1;
    per(i,n,2){
        int u=a[i].id;
        if(n%2==0&&sz[u]==n/2) return puts("-1"),0;
        int x=lower_bound(b+1,b+n+1,a[i].x-(n-2*sz[u]))-b;
        if(b[x]!=a[i].x-(n-sz[u])+sz[u]) return puts("-1"),0;
        x=a[x].id;fa[u]=x;sz[x]+=sz[u];
    }
    rep(i,1,n) G[i].push_back(fa[i]),G[fa[i]].push_back(i);
    dfs(a[1].id,0);
    rep(i,1,n) D+=d[i];if(D!=a[1].x) return puts("-1"),0; 
    rep(i,1,n) if(fa[i]) printf("%d %d\n",i,fa[i]);
    return 0;
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 1010

using namespace std;
int n, q;
ll ci[N]; ll ans = 0;

ll read() {
	ll s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

int main() {
	n = read();
	for (int i = 1, x; i <= n; i++) {
		x = read(); ans += x;
		ci[x]++;
	}
	q = read();
	for (int i = 1, b, c; i <= q; i++) {
		b = read(), c = read();
		ans += ci[b] * (c - b);
		ci[c] += ci[b], ci[b] = 0;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4464
package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a , b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var s string
	fmt.Fscan(r, &s)

	counting := true
	cnt := 0
	ans := 0
	for _, v := range s {
		if counting {
			if v == 'R' {
				cnt += 1
			} else {
				counting = false
				ans = max(ans, cnt)
			}
		} else {
			if v == 'R' {
				cnt = 1
				counting = true
			}
		}
	}
	ans = max(ans, cnt)
	fmt.Fprintln(w, ans)
}


Measured memory_bytes: 1844
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).expect("err");
    s.trim().to_string()
}

fn main() {
    let s = read_line();
    let t = read_line();

    let mut n = 0;
    for (_s, _n) in s.chars().zip(t.chars()) {
        if _s != _n { n += 1; }
    }

    println!("{}", n);
}


Measured memory_bytes: 2524
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;
int X;
int main(){
    cin >> X;
    int ans = 0;
    for(int i = 2; i<=9; ++i){
        int n = 1, j = 1;
        while(pow(j,i) <= X){
            n = pow(j,i);
            j++;
        }
        ans = max(n,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  i64 a[maxn], b[maxn];
  i64 n, k;
  void solve() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    i64 l = 0, r = 1e12;
    while (l < r) {
      i64 mid = l + r >> 1;
      if (ok(mid)) {
        r = mid;
      } else {
        l = mid + 1;
      }
    }
    cout << l;
  }
  bool ok(i64 Max) {
    i64 K = k;
    for (int i = n - 1; i >= 0; --i) {
      if (a[i] * b[n - 1 - i] <= Max) {
        continue;
      }
      i64 nwa = Max / b[n - 1 - i];
      if (K < a[i] - nwa) {
        return false;
      }
      K -= a[i] - nwa;
    }
    return true;
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 3328
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int h[100001];

int32_t main(){
   boost;
   memset(h,0,sizeof(h));
   int N; cin>>N;
   int s=0;
   int t[N];
   for(int i=0; i<N; i++){
      cin>>t[i];
      s+=t[i];
      h[t[i]]++;
   }
   int Q; cin>>Q;
   while(Q--){
      int b,c; cin>>b>>c;
      s-=h[b]*b; s+=c*h[b];
      h[c]+=h[b]; h[b]=0;
      cout << s << endl;
      //cout << endl;
   }



   return 0;
}



Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const ll INF = 1e15;

using namespace std;

int F[110][20];
ll P[110][20];

main()
{
    fast;
    int n,i,j,k;
    cin>>n;
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=10;j++)
            cin>>F[i][j];
    }
    for (i=1;i<=n;i++)
    {
        for (j=0;j<=10;j++)
            cin>>P[i][j];
    }
    int p,ctr;
    ll ans=-INF;
    for (k=1;k<(1<<10);k++)
    {
        p=k;
        ctr=10;
        int mark[11]={0};
        while (ctr>0)
        {
            if (p&1)
                mark[ctr]=1;
            else
                mark[ctr]=0;
            ctr--;
            p>>=1;
        }
        ll tp=0;
        for (i=1;i<=n;i++)
        {
            int cnt=0;
            for (j=1;j<=10;j++)
            {
                if (F[i][j]==1 && mark[j]==1)
                    cnt++;
            }
            tp+=P[i][cnt];
        }
        ans=max(tp,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
  int i,N;
  char ch[6];

  scanf("%s",ch);

  N=strlen(ch);

  for(i=0;i+1<N;i++){
    if(ch[i]=='A' && ch[i+1]=='C'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int h,w; cin >> h >> w;
    vector<vector<int> > data(h, vector<int>(w));
    vector<int> low(h,0);
    vector<int> col(w,0);

    rep(i,h) {
        string tmp;
        cin >> tmp;
        low[i] = i;
        rep(j,tmp.size()) {
            col[j] = j;
            if(tmp[j] == '#') { data[i][j] = 1; };
        }
    }
#if 0
    rep(i,h){ 
        rep(j,w) {
            cout << data[i][j] << ",";
        }
        cout << endl;
    }
#endif
    while(1) { 
        bool all_low = true;
        rep(i,low.size()) {

            int low_check = 0;
            rep(j,col.size()) {
                if(data[low[i]][col[j]]) { low_check++; }
            }    
            if(low_check == 0) { 
                low.erase(low.begin()+i); 
                all_low = false;
            }
            
        }

        bool all_col = true;
        rep(j,col.size()) {

            int col_check = 0;
            rep(i,low.size()) {
                if(data[low[i]][col[j]]) { col_check++; }
            }    
            if(col_check == 0) { 
                col.erase(col.begin()+j); 
                all_col = false;
            }
        }
        if(all_col & all_low) { break; }
    }

    rep(i,low.size()){ 
        rep(j,col.size()) {
            if(data[low[i]][col[j]]) { cout << '#'; }
            else                     { cout << '.'; }
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 2005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

char grid[maxn][maxn];
int L[maxn][maxn];
int R[maxn][maxn];
int U[maxn][maxn];
int D[maxn][maxn];
int n,m;

void left()
{
	for(int i = 1; i <= n; i++){
    	for(int j = 1; j <= m; j++){
    		if(grid[i][j] == '.'){
    			if(j == 1) L[i][j] = 1;
    			else L[i][j] = L[i][j - 1] + 1;
    		}
    	}
    }
}

void right()
{
	for(int i = n; i >= 1; i--){
    	for(int j = m; j >= 1; j--){
    		if(grid[i][j] == '.'){
    			if(j == m) R[i][j] = 1;
    			else R[i][j] = R[i][j + 1] + 1;
    		}
    	}
    }
}

void up()
{
	for(int i = 1; i <= n; i++){
    	for(int j = 1; j <= m; j++){
    		if(grid[i][j] == '.'){
    			if(i == 1) U[i][j] = 1;
    			else U[i][j] = U[i - 1][j] + 1;
    		}
    	}
    }
}

void down()
{
	for(int i = n; i >= 1; i--){
    	for(int j = m; j >= 1; j--){
    		if(grid[i][j] == '.'){
    			if(i == n) D[i][j] = 1;
    			else D[i][j] = D[i+1][j] + 1;
    		}
    	}
    }
}

void solve()
{
	int ans = 0;
	for(int i = 1; i <= n; i++){
    	for(int j = 1; j <= m; j++){
    		ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
    	}
    }
    cout << ans << endl;
}

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
    	for(int j = 1; j <= m; j++){
    		cin >> grid[i][j];
    	}
    }
    left();
    right();
    up();
    down();
    solve();

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}


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

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

	int N;
	int i,j;
	int tmp;
	int max=0;
	int answer;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> N;

	for(i=0;i<N;i++){
		cin >> tmp;
		given.push_back(tmp);
	}

	for(i=0;i<N-1;i++){
		if(given[i]>=given[i+1]){
			counter++;
		}else{
			if(max<counter) max=counter;
			counter=0;
		}
	}

	if(max<counter) max=counter;

	answer=max;
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<vector<int> > v(10, vector<int>(10));
    for(int i=1;i<=n;i++){
        string s = to_string(i);
        int k = s.size();
        int a = (s[0]-'0');
        int b = (s[k-1]-'0');
        v[a][b]++;
    }

    /*rep(i, 9){
        rep(j, 9) cout<<v[i][j]<<" ";
        cout<<endl;
    }*/

    int ans = 0;
    rep(i, 10){
        rep(j, 10){
            ans += v[i][j]*v[j][i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    string a, b, c;
    cin>>a>>b>>c;
    ll ans = 0;
    for(ll i=0;i<n;++i){
        ll flag = 0;
        if(a[i] != b[i]){
            flag++;
        }
        if(b[i] != c[i]){
            flag++;
        }
        if(a[i] != c[i]){
            flag++;
        }
        if(flag == 3){
            ans += 2;
        }else if(flag == 2){
            ans += 1;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Basic Data Structures - Queue
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_2_B&lang=jp

"""
from collections import deque

n, q = map(int, input().split())
queues = [deque() for _ in range(n)]
for _ in range(q):
    op, t, x = (input() + ' 1').split()[:3]
    if op == '0':
        queues[int(t)].append(x)
    elif op == '1':
        if queues[int(t)]:
            print(queues[int(t)][0])
    else:
        if queues[int(t)]:
            queues[int(t)].popleft()



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

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    loop {
        let s: String = sc.next();
        let mut sum: u32 = 0;
        for x in s.as_bytes() {
            sum += (x - b'0') as u32;
        }

        if sum > 0 {
            println!("{}", sum);
        } else {
            break;
        }
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }

    fn char(&mut self) -> char {
        self.chars()[0]
    }
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  string s,t;cin >> s >> t;
  int i = 0;
  for(i = 0; i < N; ++i){
    bool f = true;
    for(int j = 0; j < N - i; ++j){
      if(s[i + j] != t[j])f = false;
    }
    if(f)break;
  }
  cout << N + i << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
w=list(map(int,input().split()))
ans=0
if len(set(w))==1:
    print(len(w)//2)
else:
    a=[]
    a1=[]
    for i in range(n):
        if i%2==0:
            a.append(w[i])
        else:
            a1.append(w[i])
    a.sort()
    a1.sort()
    ans=0
    t=a[0]
    cnt1=[]
    cnt=[]
    b=[]
    b1=[]
    for j in range(len(a)):
        if a[j]==t:
            ans+=1
        else:
            cnt.append([ans,t])
            t=a[j]
            ans=1
        if j==len(a)-1:
            cnt.append([ans,t])
    s=a1[0]
    ans=0
    for j in range(len(a)):
        if a1[j]==s:
            ans+=1
        else:
            cnt1.append([ans,s])
            s=a1[j]
            ans=1
        if j==len(a1)-1:
            cnt1.append([ans,s])
    cnt.sort(reverse=True)
    cnt1.sort(reverse=True)
    """
    print(a)
    print(a1)
    print(cnt)
    print(cnt1)
    """
    if cnt[0][1]!=cnt1[0][1]:
        print(n-cnt[0][0]-cnt1[0][0])
    else:
        if cnt[0][0]>cnt1[0][0]:
            print(n-cnt[0][0]-cnt1[1][0])
        elif cnt[0][0]<cnt1[0][0]:
            print(n-cnt1[0][0]-cnt[1][0])
        else:
            t=0
            s=0
            for i in range(1,min(len(cnt),len(cnt1))):
                if cnt[i][0]!=cnt1[i][0]:
                    if cnt[i][0]==max(cnt[i][0],cnt1[i][0]):
                        t=cnt[i][0]
                        s=cnt1[0][0]
                        break
                if cnt[i][0]!=cnt1[i][0]:
                    if cnt1[i][0]==max(cnt[i][0],cnt1[i][0]):
                        t=cnt1[i][0]
                        s=cnt[0][0]
                        break
                if i==-1+min(len(cnt),len(cnt1)):
                    t=cnt[0][0]
                    s=cnt1[1][0]
            print(n-t-s)

Measured memory_bytes: 18012
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    char n[200];
    while(~scanf("%s",n))
    {
        int l=strlen(n);
        printf("%c%d%c\n",n[0],l-2,n[l-1]);
    }
}


Measured memory_bytes: 256