akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.math.BigDecimal
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val n = sc.nextInt()
    val arr = Array(n){sc.next()}
    println(abc109b(n, arr))
}

fun abc109b(n: Int, arr: Array<String>): String {
    val cnt = arr.groupBy { it }.mapValues { it.value.count() }
    for((key, value) in cnt){
        if(value > 1) return "No"
    }
    for(i in 0 until n-1){
        if (arr[i].last() != arr[i+1].first()) return "No"
    }
    return "Yes"
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



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

vector<string> S(50);
vector<vector<int>> B(50,vector<int>(50,512411));
int H, W;
queue<pair<int,int>> Q;

void BFS(int i,int j) {
	if (i > 0 && S[i - 1][j] == '.') {
		if (B[i - 1][j] == 512411) {
			Q.push({ i - 1,j });
			B[i - 1][j] = B[i][j] + 1;
		}
	}
	if (i < H - 1 && S[i + 1][j] == '.') {
		if (B[i + 1][j] == 512411) {
			Q.push({ i + 1,j });
			B[i + 1][j] = B[i][j] + 1;
		}
	}
	if (j > 0 && S[i][j - 1] == '.') {
		if (B[i][j - 1] == 512411) {
			Q.push({ i,j - 1 });
			B[i][j - 1] = B[i][j] + 1;
		}
	}
	if (j < W - 1 && S[i][j + 1] == '.') {
		if (B[i][j + 1] == 512411) {
			Q.push({ i,j + 1 });
			B[i][j + 1] = B[i][j] + 1;
		}
	}
	return;
}

int main() {
	cin >> H >> W;
	for (int i = 0;i < H;i++) {
		cin >> S[i];
	}
	B[0][0] = 1;
	Q.push({ 0,0 });
	int s, t;
	while (!Q.empty()) {
		auto x = Q.front();
		Q.pop();
		s = x.first;
		t = x.second;
		BFS(s, t);
	}
	s = 0 - B[H - 1][W - 1];
	if (s == -512411) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			if (S[i][j] == '.') {
				s++;
			}
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()

ls = deque()
rev = False

for a in A:
  if rev:
    ls.appendleft(a)
  else:
    ls.append(a)
  rev = not rev

if rev:
  ls.reverse()

print(" ".join(str(x) for x in ls))


Measured memory_bytes: 123860
#include<stdio.h>
#include<string.h>
int main()
{
    char s[200001];
    char t[200001];
    scanf("%s ",s);
    scanf("%s",t);
    int x=strlen(s);
    int i,y=0;
    for(i=0;i<x;i++)
    {
        if(s[i]!=t[i]) y++;
    }
    printf("%d",y);
}



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

int main(){
    int n;
    cin >> n;
    int d[n],sum = 0;
    for(int i = 0; i < n; i++) cin >> d[i];
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            sum += d[i]*d[j];
        }
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

bool sortSecond(PLL &a, PLL &b) {
  return (a.second > b.second);
}

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

  vector<PLL> jobs(n);
  repl(i, n) {
    LL a, b;
    cin >> a >> b;
    jobs[i] = make_pair(a, b);
  }

  sort(jobs.begin(), jobs.end(), sortSecond);

  LL time_left = jobs[0].second;
  LL additional_time = 0;

  repl(i, n) {
    if (time_left > jobs[i].second) {
      additional_time = max(time_left - jobs[i].second, additional_time);
    }
    time_left -= jobs[i].first;

    if (time_left < 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  if (time_left - additional_time >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
ll NC2(ll n)
{
	return n*(n-1)/2;
}
void solve()
{
	int n;
	cin>>n;
	map<vector<int>, ll> mp;
	string s;
	ll cnt = 0;
	REP(i,n)
	{
		cin>>s;
		vector<int> v(26, 0);
		REP(j, s.length())
		{
			v[s[j]-'a']++;
		}
		mp[v]++;
	}
	for(auto m:mp)
	{
		if(m.second>1)
			cnt+=NC2(m.second);
	}
	cout<<cnt<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 22264
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;


int main() 
{

int a,b,c,d;
cin>>a>>b>>c>>d;
bool flag = true;
while(a>0 && c>0)
{
  if(flag)
  {
    c-=b;
  }
  else
  {
    a-=d;
  }
  flag = !flag;
  if(a<=0)
  {
    cout<<"No"<<endl;
    break;
  }
  if(c<=0)
  {
    cout<<"Yes"<<endl;
    break;
  }

}

}


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

int N, a[10009], sum, minx = 100000000, minid = 0;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) { cin >> a[i]; sum += a[i]; }
	for (int i = 0; i < N; i++) {
		int J = abs(a[i] * N - sum);
		if (minx > J) {
			minx = J; minid = i;
		}
	}
	cout << minid << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int H,W;
  cin>>H>>W;
  VS S(H);
  rep(i,H) cin>>S[i];
  vector<set<ll>> X(100000);
  VVI V(H,VI(W));
  rep(i,H) rep(j,W){
    if(S[i][j]=='#'){
      X[0].insert(i*10000+j);
      V[i][j]=1;
    }
  }
  int tmp=0;
  while(X[tmp].size()){
    auto itr=X[tmp].begin();
    rep(i,X[tmp].size()){
      ll Y=*itr;
      int A=Y/10000;
      int B=Y%10000;
      if(A){
        if(V[A-1][B]==0){
          V[A-1][B]=1;
          X[tmp+1].insert((A-1)*10000+B);
        }
      }
      if(H-1-A){
        if(V[A+1][B]==0){
          V[A+1][B]=1;
          X[tmp+1].insert((A+1)*10000+B);
        }
      }
      if(B){
        if(V[A][B-1]==0){
          V[A][B-1]=1;
          X[tmp+1].insert(A*10000+B-1);
        }
      }
      if(W-1-B){
        if(V[A][B+1]==0){
          V[A][B+1]=1;
          X[tmp+1].insert(A*10000+B+1);
        }
      }
      itr++;
    }
    tmp++;
  }
  cout<<tmp-1<<endl;
}

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

int main()
{

    ios_base::sync_with_stdio(false);

    string a, b;

    cin >> a >> b;

    if(a.size() > b.size())
    {
        cout << "GREATER\n";
        return 0;
    }
    else if(a.size() < b.size())
    {
        cout << "LESS\n";
        return 0;
    }
    else if(a == b)
    {
        cout << "EQUAL\n";
        return 0;
    }

    int i;
    for(i = 0; i < a.size(); i++)
        if(a[i] != b[i])
            break;

    if(a[i] > b[i])
        cout << "GREATER\n";
    else
        cout << "LESS\n";

    return 0;

}


Measured memory_bytes: 3660
#include <iostream>

const int MAX = 100005;

int A[MAX];

int main()
{
    std::ios_base::sync_with_stdio(0);
    int n;
    std::cin >> n;
    for (int i=1;i<=n;++i)
    {
        int a;
        std::cin >> a;
        A[a]=i;
    }
    for (int i=1;i<=n;++i) std::cout << (i > 1 ? " " : "") << A[i];
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    vector<ll> x(n);
    REP(i, n){
        cin >> x.at(i);
        x.at(i)--;
    }

    vector<bool> occupy(2019, false);
    for(ll xi : x){
        occupy.at(xi) = true;
    }

    ll m;
    cin >> m;
    REP(i, m){
        ll ai;
        cin >> ai;
        ai--;

        if(x.at(ai) >= 2019 - 1 || occupy.at(x.at(ai) + 1)){
            continue;
        }
        occupy.at(x.at(ai)) = false;
        x.at(ai)++;
        occupy.at(x.at(ai)) = true;
    }

    for(ll xi : x){
        cout << xi + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    set<int> st;
    ll ans = 0;
    rep(i,n) {
        bool ok = true;
        if (a[i] == a[i+1]) ok = false;
        for (int j = 1; j*j <= a[i]; j++) {
            if (a[i]%j == 0) {
                if (st.count(j) || st.count(a[i]/j)) ok = false;
            }
        }
        st.insert(a[i]);
        if (ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13464
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>mp,mp2;
int a[100005],b[100005];
long long arr[15];
main()
{
	int m,n,t;
    scanf("%d%d%d",&m,&n,&t);
    for(int i = 0;i < t;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        mp[make_pair(a[i],b[i])]=1;
    }
    for(int i = 0;i < t;i++)
    {
        for(int j = max(a[i]-1,2);j <= min(a[i]+1,m-1);j++)
        {
            for(int k = max(b[i]-1,2);k <= min(b[i]+1,n-1);k++)
            {
                if(mp2[make_pair(j,k)]==1)
                continue;
                int cs=0;
                for(int l = j-1;l <= j+1;l++)
                {
                    for(int mm = k-1;mm <= k+1;mm++)
                    {
                        if(mp.find(make_pair(l,mm))!=mp.end())
                        cs++;
                    }
                }
                arr[cs]++;
                mp2[make_pair(j,k)]=1;
            }
        }
    }
    long long cal=m-2;
    cal*=n-2;

    for(int i = 1;i <= 9;i++)
    cal-=arr[i];
    arr[0]=cal;
    for(int i = 0;i <= 9;i++)
    printf("%lld\n",arr[i]);
}


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

int main() {

  vector<int> A(3);
  for(int i=0;i<3;i++){
    cin>>A.at(i);
  }
  
  sort(A.begin(),A.end());
  cout<<A.at(2)-A.at(0)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

bool gragh[8][8];

int dfs(int v, int n, bool visited[8]) {
	bool all_visited = true;
	REP(i, n) {
		if (!visited[i]) all_visited = false;
	}
	if (all_visited) return 1;
	int ret = 0;
	REP(i, n) {
		if (!gragh[v][i]) continue;
		if (visited[i]) continue;
		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}

int main() {
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		gragh[a - 1][b - 1] = gragh[b - 1][a - 1] = true;
	}
	bool visited[8];
	REP(i, n) {
		visited[i] = false;
	}
	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=10001;
int ans[MAXN];
int main()
{
	int n;
	cin>>n;
	int tot=0;
	while(n!=0)
	{
		ans[tot++]=n%10;
		n/=10;
	}
	for(int i=tot-1;i>=0;i--)
	{
		if(ans[i]==1)
		cout<<9;
		else if(ans[i]==9)
		cout<<1;
		else
		cout<<ans[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
//ll a[N],sum[N];
ll x;
set<ll> st;

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

void init(){
    st.insert(1ll);
    for(int i=2;i<=50;i++){
        for(int j=2;j<=10;j++){
            st.insert(mypow(i,j));
        }
    }
}

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

    init();
    cin >>x ;
    cout << *prev(upper_bound(st.begin(),st.end(),x));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[0]*a[1]/2 << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> T(M);
  for (int i = 0; i < M; i++) {
    cin >> T.at(i);
  }
  
  vector<int> sum(N);
  for (int i = 0; i < N; i++) {
    string a = S.at(i);
    for (int j = 0; j < N; j++) {
      if (S.at(j) == a) {
        sum.at(i)++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (T.at(j) == a) {
        sum.at(i)--;
      }
    }
  }
  int max = 0;
  for (int i = 0; i < N; i++) {
    if (max < sum.at(i)) {
      max = sum.at(i);
    }
  }
  if (max > 0) {
    cout << max << endl;
  }
  else {
    cout << 0 << endl;
  }
}


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

using ll = long long;

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int n, dp[301][301], a[301][301];
bool used[301][301];

int main() {
    init();

    cin >> n;
    rep(i,n){
        rep(j,n) {
            cin >> a[i][j];
            dp[i][j] = a[i][j];
        }
    }


    rep(k,n) {
        rep(i,n) {
            rep(j,n) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    rep(i,n) {
        rep(j,n) {
            if (a[i][j] != dp[i][j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    ll sum = 0;
    bool flag;

    rep(i,n) {
        repi(j,i+1,n) {
            flag = false;

            rep(k,n) {
                if (i != k and j != k and dp[i][j] == dp[i][k] + dp[k][j]) {
                    flag = true;
                }
            }

            if (!flag) sum += dp[i][j];
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc128_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  multimap<string, vector<P>> sorted_map;
  rep(i, N) {
    string s;
    int p;
    cin >> s >> p;
    if (sorted_map.find(s) == sorted_map.end()){
      sorted_map.emplace(s, vector<P>(1, make_pair(p,i)));
    } else {
      sorted_map.find(s)->second.push_back(make_pair(p, i));
    }
  }

  for(auto kv : sorted_map) {
    sort(kv.second.begin(), kv.second.end(), greater<P>());
    for(auto v : kv.second) {
      cout << v.second + 1 << endl;
    }
  }

}

Measured memory_bytes: 256
def isCLKWISE(ph):
    a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]
    b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]
    crs = a[0]*b[1] - a[1]*b[0]
    if crs < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

Measured memory_bytes: 33464
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
p = p[:X]
q.sort(reverse=True)
q = q[:Y]

apples = []
for i in p:
    apples.append(i)
for j in q:
    apples.append(j)
for h in r:
    apples.append(h)

apples.sort(reverse=True)
apples = apples[:A+B]
print(sum(apples[:X+Y]))
"""
red = 0
green = 0
trans = 0
ans = 0
for i in range(A+B):
    num = apples[i][1]
    if num == 0 and red <= A:
        ans += apples[i][0]
        red += 1
    elif num == 1 and green <= B:
        ans += apples[i][0]
        green += 1
    elif num == 2 and trans <= C:
        ans += apples[i][0]
        if red < green:
            red += 1
        else:
            green += 1

print(ans)
"""    


Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int H, W;
char C[2010][2010];
int L[2010][2010]; //left to right
int R[2010][2010];
int U[2010][2010]; //up do down
int D[2010][2010];

void solve() {
	cin >> H >> W;
	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> C[i + 1][j + 1];
		}
	}
	rep(i, 1, H + 1) {
		L[i][0] = 0;
		rep(j, 1, W + 1) {
			if(C[i][j] == '#') L[i][j] = j;
			else L[i][j] = L[i][j - 1];
		}
	}
	rep(i, 1, H + 1) {
		R[i][W + 1] = W + 1;
		rer(j, W + 1, 1) {
			if(C[i][j] == '#') R[i][j] = j;
			else R[i][j] = R[i][j + 1];
		}
	}
	rep(j, 1, W + 1) {
		U[0][j] = 0;
		rep(i, 1, H + 1) {
			if(C[i][j] == '#') U[i][j] = i;
			else U[i][j] = U[i - 1][j];
		}
	}
	rep(j, 1, W + 1) {
		D[H + 1][j] = H + 1;
		rer(i, H + 1, 1) {
			if(C[i][j] == '#') D[i][j] = i;
			else D[i][j] = D[i + 1][j];
		}
	}
	int res = 0;
	rep(i, 1, H + 1) {
		rep(j, 1, W + 1) {
			if(C[i][j] == '.') {
				MAX(res, D[i][j] - U[i][j] + R[i][j] - L[i][j] - 3);
				// debug(i, j, D[i][j] - U[i][j] + R[i][j] - L[i][j] - 3);
			}
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 67328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
int main()
{
    int N, T, ans = 1e9;
    cin >> N >> T;
    rep(i, N)
    {
        int c, t;
        cin >> c >> t;
        if (t <= T)
            ans = min(ans, c);
    }
    if (ans == 1e9)
    {
        cout << "TLE" << endl;
        return 0;
    }

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


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

bool IsSquaredValue(int32_t n) {
  const int32_t a = static_cast<int32_t>(sqrt(n));
  return (a * a == n);
}

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

  int32_t N, D;
  cin >> N >> D;
  vector<vector<int32_t>> X(N, vector<int32_t>(D));
  for (int32_t i = 0; i < N; ++i) {
    for (int32_t j = 0; j < D; ++j) {
      cin >> X[i][j];
    }
  }

  int32_t count = 0;
  for (int32_t i = 0; i < N; ++i) {
    for (int32_t j = i + 1; j < N; ++j) {
      int32_t sq_sum = 0;
      for (int32_t k = 0; k < D; ++k) {
        const int32_t delta = X[i][k] - X[j][k];
        sq_sum += delta * delta;
      }
      if (IsSquaredValue(sq_sum)) {
        ++count;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define FAST_IO std::ios::sync_with_stdio(false)
using namespace std;
const int MAX = 1e5 + 5;
struct node {
	long long pos, num;//位置和居住人数 
} a[MAX];

long long n, s, ans = 0;

bool cmp(node x, node y) {
	return (x.pos < y.pos);
}

int main() {
	FAST_IO;
	cin >> n >> s;
	for (int i = 1; i <= n; i++)
		cin >> a[i].pos >> a[i].num;
	sort(a + 1, a + n + 1, cmp);//按照位置从小到大排序 
	ll left = 1, right = n;//定义左右边界 
	while (left <= right) {
		if (a[right].pos <= s) {//全部在最左边 
			ans += (s - a[left].pos);
			break;
		}
		if (a[left].pos >= s) {//全部在最右边 
			ans += (a[right].pos - s);
			break;
		}
		ans += (a[right].pos - a[left].pos);//最后一步的路程 
		
		/*最边上的人，人数更小的一边反而会投靠另一边，
		故而可以这样处理（例）：最右边的人数加上最左边
		的人数，ans += 两者间路径 */ 
		if (a[left].num >= a[right].num) { 
			while (left < right && a[left].num >= a[right].num)
				a[left].num += a[right--].num;
		} 
		else {
			while (left < right && a[right].num > a[left].num)
				a[right].num += a[left++].num;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	int n;
	cin>>n;
	cout<<24-n + 24<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,K,JK;
	JK=1;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		if(JK*2<=JK+K){
			JK=JK*2;
		}
		else{
			JK=JK+K;
		}
	}
	cout<<JK<<endl;
}

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

/*
3 - [6-8]
4 - [4-7]
3 - [3,5]
2 - [2,3]
 */

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    vector<int> arr(k);
    for(int i = 0; i < k; ++i) {
        cin >> arr[i];
    }
    pair<int, int> range = {2,2};
    for(int i = k-1; i >= 0; --i) {
        int smallestMult = (range.first+arr[i]-1)/arr[i]*arr[i];
        int largestMult = range.second/arr[i]*arr[i];
        if(largestMult < range.first) {
            cout << -1;
            return 0;
        }
        if(smallestMult > largestMult) {
            cout << -1;
            return 0;
        }
        range = {smallestMult, largestMult+arr[i]-1};
        //cout << "here, arr[i]: " << arr[i] << " range: " << range.first << ' ' << range.second << endl;
    }
    cout << range.first << ' ' << range.second << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n;
  cin>>n;
  int ans=(n+1)/2-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10005], b[10005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;

int main() {
	int n;
	cin >> n;
	vector<int>L(n);
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			int ij = L[j] + L[i];
			int r = lower_bound(L.begin(), L.end(), ij) - L.begin();
			int l = i + 1;
			ans += max(0, r - l);
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,M;
long a[50],b[50],c[50],d[50];
main()
{
    cin>>N>>M;
    for(int i=0;i<N;++i){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<M;++i){
        cin>>c[i]>>d[i];
    }
    for(int i=0;i<N;++i){
        int p=0;
        for(int j=0;j<M;++j){
            if(99*(abs(a[i]-c[j])+abs(b[i]-d[j]))+j<=99*(abs(a[i]-c[p])+abs(b[i]-d[p]))+p){
                p=j;
            }
        }
        cout<<p+1<<endl;
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
const int N=110000;
void sub(int x){if(x)puts("First");else puts("Second");exit(0);}
int gcd(int a,int b){
    if(!a||!b)return a+b;
    return gcd(b,a%b);
}
int n,a[N];
bool check(){
    int ji=0;
    int dj=0;
    int ans=0;
    rep(i,1,n){
        ans^=(!(a[i]&1));
        if(a[i]&1){++ji;dj=i;}
    }
    if((ji!=1)||(a[dj]==1))return ans;
    if(ans)return ans;
    a[dj]--;
    int c=0;
    rep(i,1,n)c=gcd(c,a[i]);
    rep(i,1,n)a[i]/=c;
    return !check();
}
int main(){
    scanf("%d",&n);
    rep(i,1,n)scanf("%d",&a[i]);
    if(n==1)sub(n%2==0);
    sub(check());
    return 0;
};





Measured memory_bytes: 640
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int a[] = new int[m];
		int b[] = new int[m];
		int c[] = new int[m];

		int dist[][] = new int[n][n];
		final int INF = 1001001001;
		for(int i=0; i<n; i++) {
			for(int j=0; j<n; j++) {
				if(i==j) {
					dist[i][j]=0;
				}else {
					dist[i][j]=INF;
				}
			}
		}

		for(int i=0; i<m; i++) {
			a[i]=sc.nextInt();a[i]--;
			b[i]=sc.nextInt();b[i]--;
			c[i]=sc.nextInt();
			dist[a[i]][b[i]]=c[i];
			dist[b[i]][a[i]]=c[i];
		}

		for(int k=0; k<n; k++) {
			for(int i=0; i<n; i++) {
				if(dist[i][k]==INF)continue;
				for(int j=0; j<n; j++) {
					if(dist[k][j]==INF)continue;
					dist[i][j] = Math.min(dist[i][j], dist[i][k]+dist[k][j]);
				}
			}
		}

		int cnt=m;
		for(int k=0; k<m; k++) {
			boolean shortest = false;
			for(int i=0; i<n; i++) {
				for(int j=0; j<n; j++) {
					if(dist[i][a[k]] + c[k] + dist[b[k]][j] == dist[i][j]) {
						shortest=true;
					}
				}
			}
			if(shortest) {
				cnt--;
			}
		}
		System.out.println(cnt);

		sc.close();
	}
}


Measured memory_bytes: 26044
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,k;cin>>n>>k;
  int a[101010],dp[101010];
  for(int i=0;i<n;i++) cin>>a[i];
  dp[0]=0;
  for(int i=1;i<min(n,k);i++){
    dp[i]=1e9+7;
  	for(int j=0;j<i;j++){
      dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
  }
  for(int i=k;i<n;i++){
    dp[i]=1e9+7;
  	for(int j=i-k;j<i;j++){
      dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
# global
in_list = []
# my_stack = []
register = []


if __name__ == "__main__":
    in_list = input().split(" ")
    for i in range(len(in_list)):
        if in_list[i].isdecimal():
            in_list[i] = int(in_list[i])

    for i in range(len(in_list)):
        if type(in_list[i]) is int:
            register.append(in_list[i])
        elif in_list[i] == "+":
            temp = register.pop() + register.pop()
            register.append(temp)
        elif in_list[i] == "-":
            temp = -register.pop() + register.pop()
            register.append(temp)
        elif in_list[i] == "*":
            temp = register.pop() * register.pop()
            register.append(temp)


    answer = register.pop()

    print(answer)


Measured memory_bytes: 5600
import java.util.*;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < S.length(); i++) {
            if (map.containsKey(S.substring(i,i+1))) {
                map.put(S.substring(i,i+1), map.get(S.substring(i,i+1)) + 1);
            } else {
                map.put(S.substring(i,i+1), 1);
            }
        }
        String result = "No";
        if (map.size() == 2) {
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                if (entry.getValue() != 2) {
                    break;
                }
                result = "Yes";
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int X;
int Y;
int Z;
int finalAns;

int main()
{
	scanf("%d %d %d", &X, &Y, &Z);
	finalAns = (X - Z) / (Y + Z);
	if(finalAns < 0)
	{
		printf("0");	
	}
	else
	{
		printf("%d", finalAns);
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main(){
	int sx, sy, tx, ty;
	int dx, dy;
	cin >> sx >> sy >> tx >> ty;
	dx = tx - sx;
	dy = ty - sy;
	cout << string(dy, 'U') << string(dx, 'R') << string(dy, 'D') << string(dx, 'L');
	cout << 'L';
	cout << string(dy + 1, 'U') << string(dx + 1, 'R');
	cout << 'D';
	cout << 'R';
	cout << string(dy + 1, 'D') << string(dx + 1, 'L');
	cout << 'U';
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,cc,n) for(int i=cc;i<(n);++i)
#define dreps(i,cc,n) for(int i=cc;i>(n);--i)
#define llreps(i,cc,n) for(long long i=cc;i<(n);++i)
#define ALL(v) begin(v),end(v)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

string MOJI(ll N) {
	--N;                        //「a-z：1-26」を「a-z：0-25」に変換
	string ans = "";
	while (N >= 0) {
		ans += (N % 26) + 'a';  //【'a'+[0-25]】の文字を末尾に追加
		N /= 26;                //
		--N;                    //「a-z：1-26」を「a-z：0-25」に変換
	}
	reverse(ALL(ans));
	return ans;
}

int main()
{
	ll n;
	cin >> n;
	cout << MOJI(n) << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec;
  vec = {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 a;
  cin >> a;
  cout << vec.at(a-1) << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
using namespace std;
int n,k,sum;
double ans,cnt;
int main() {
	cin>>n>>k;
	rep(i,1,n){
		cnt=1.0*1/n; sum=i;
		while(sum<k){
			cnt*=1.0*1/2;
			sum*=2;
		}
		ans+=cnt; 
	}
	cout<<setprecision(12)<<ans;
	re 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
v = list(map(int, input().split()))
t = min(n,k)
ans = 0
for i in range(t+1):
  for j in range(t-i+1):
    hnd = v[:i]+v[-j:]*(j!=0)
    hnd.sort(reverse=True)
    for _ in range(min(k-i-j,len(hnd))):
      if hnd[-1] < 0:
        hnd.pop()
      else:
        break
    cur = sum(hnd)
    if ans<cur:
      ans=cur
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

    int mn = min(x,y);
    res += mn*min(a+b, 2*c);
    res += (x-mn)*min(a, 2*c);
    res += (y-mn)*min(b, 2*c);

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

ll n;
vector<pi> ar;
ll dp[2010][2010];

ll func(ll i,ll j)
{
    if(i>j){return 0;}

    if(dp[i][j]==-1){
    ll idx=n-(j-i+1);
    dp[i][j]=max( ar[idx].first*abs(ar[idx].second-i)+func(i+1,j) , ar[idx].first*abs(ar[idx].second-j)+func(i,j-1) );
    }
    return dp[i][j];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n;
    ar.clear();
    ar.resize(n);
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n;++i){
        cin>>ar[i].first;
        ar[i].second=i;
    }
    sort(ar.begin(),ar.end());
    reverse(ar.begin(),ar.end());
    ll ans=func(0,n-1);
    cout<<ans;

    return (0);
}


Measured memory_bytes: 35372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a,b,c; cin>>a>>b>>c;
    if((a*100+b*10+c)%4==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define mod 998244353
#define INF 0x3f3f3f
#define fi first
#define se second
#define it iterator
#define ins insert
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false)
#define gcd __gcd
ll lgcd(ll a,ll b){return b == 0? a:lgcd(b, a % b);}

#define T int t;scanf("%d",&t);while(t--)
#define CE cout << endl
#define C(n) cout << n << endl
#define CY cout << "YES" << endl
#define CN cout << "NO" << endl
#define Cy cout << "Yes" << endl
#define Cn cout << "No" << endl

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
   String s1=sc.next();
   String s2=sc.next();
  int c=0;
  if(!(s1.equals(s2)))
  {
   for(int i=0;i<s1.length();i++) 
  {
       if(s1.charAt(i)!=s2.charAt(i))
	c++;
   }
  }
   System.out.println(c); 
  }
   
}

Measured memory_bytes: 41316
#include<stdio.h>

int main(void)
{
  int a,b,d,r;
  double f;

  scanf("%d %d",&a,&b);
  if(1<=a&&b<=10^9){
  d=a/b;
  r=a%b;
  f=(double)a/b;

  printf("%d %d %.8lf\n",d,r,f);
  }
  else
    {
      printf("\n");
    }
  return 0;

}
  
  



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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] num = Input.ScanIntArray();
          Console.WriteLine($"{(num[0]-1)*(num[1]-1)}");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13396
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	ll as=0, bs=0;
	ll cnt = 0;
	ll ans = 0;
	rep(i, m) {
		bs += b[i];
		if (bs <= k) ans = i+1;
	}

	rep(i, n) {
		as += a[i];
		if (as > k) break;
		cnt = i + 1;
		while (true) {
			if (m == 0) break;
			if (as + bs > k) {
				m--;
				bs -= b[m];
			}
			else break;
		}
		cnt += m;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6368
n, k = map(int, input().split())
X = list(map(int, input().split()))

ans = float('inf')
for i in range(n-k+1):
    l, r = X[i], X[i+k-1]
    if r <= 0:
        ans = min(abs(l), ans)
    elif 0 <= l:
        ans = min(abs(r), ans)
    else:
        dist = min(abs(l), abs(r))*2+max(abs(l), abs(r))
        ans = min(dist, ans)
print(ans)

Measured memory_bytes: 14536
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
using namespace std;

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



int main() {

	int k, t, a[100];
	int m = 0;

	cin >> k >> t;
	rep(i, 0, t) {
		cin >> a[i];
		m = max(m, a[i]);
	}
	cout << max(0, m - 1 - k + m) << endl;

	return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n1,n2) for(int i=n1;i<n2;i++)
using namespace std;
typedef long long ll;


int main() {
    ll n,n2;
    cin >> n;
    n2 =n;
    int a=0;
    while(n>0){
        a += n%10;
        n /= 10;
    }
    if(n2%a==0){
        cout << "Yes" << endl;;
    }else{
        cout << "No" << endl;
    }
    return 0;
}




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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	int m, d;
	cin >> m >> d;
	ll ans = 0;
	for (int i = 1; i <= d; ++i)
	{
		auto str = "0" + to_string(i);
		int sec = (str[str.length() - 1] - '0') * (str[str.length() - 2] - '0');
		if (sec <= m && (str[str.length() - 1] - '0') >= 2 && (str[str.length() - 2] - '0') >= 2)
			ans++;
	}
	cout << ans;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N;
  cin>>N;
  vector<ll> vec(N+1);
  for(ll i=0;i<=N;i++){
    cin>>vec.at(i);
  }
  if(N==0){
    if(vec.at(0)==1){cout<<1<<endl;}
    else{cout<<-1<<endl;}
  }
  else if(N>0){
    ll answer=1;
    ll dp[100020];
    dp[0]=1;
    vector<ll> sum(N+1);
    sum.at(N)=vec.at(N);
    for(ll i=N-1;i>=0;i--){
      sum.at(i)=sum.at(i+1)+vec.at(i);
    }
    for(ll i=1;i<=N;i++){
      dp[i]=min(2*(dp[i-1]-vec.at(i-1)),sum.at(i));
      if(dp[i]<=0){cout<<-1<<endl;return 0;}
      //cout<<i<<" "<<dp[i]<<endl;
      answer+=dp[i];
    }
    if(dp[N]!=vec.at(N)){cout<<-1<<endl;return 0;}
    cout<<answer<<endl;
  }
}

Measured memory_bytes: 5632
from collections import deque
K = int(input())
nums = deque([])
for i in range(1, 10):
  nums.appendleft(i)
count = 1
while count < K:
  num = nums.pop()
  last = int(str(num)[-1])
  for i in range(max(0, last-1), min(10, last+2)):
    nums.appendleft(int(str(num)+str(i)))
  count += 1
print(nums.pop())


Measured memory_bytes: 81064
N = int(input())
S_list = []
for _ in range(N):
    S_list.append(input())

S_dict = {}

for string in S_list:
    if not string in S_dict:
        S_dict[string] = 1
    else:
        S_dict[string] += 1

max_k = max(S_dict.values())
result = []
for k, v in S_dict.items():
    if v == max_k:
        result.append(k)

result = sorted(result)
for i in result:
    print(i)

Measured memory_bytes: 98896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back //FASTER THAN PUSH BACK!
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define what_is(x) cerr << #x << " is " << x <<"\n";
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


using namespace __gnu_pbds;
using namespace std;


int modp(int a,int n,int m)
{
    if(n==0) return 1;
    if(n==1) return a%m;
    int res=modp(a,n/2,m);
    if(n%2==0) return (res*res)%m;
    else return (a*res*res)%m;
}



signed main()
{
    int t,n,m,i,k,l,j,s,sum,flag=0,count=0;
    string S,T,U;
    // cin>>t;
    // while(t--)
    {
        cin>>n;
        int a[n];
        rep(i,0,n) cin>>a[i];
        int dp[n];
        dp[0]=0;
        dp[1]=abs(a[0]-a[1]);
        rep(i,2,n)
        {
            dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        }
        cout<<dp[n-1];
    } 
    return 0;
}


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

int main(){
    int n,a,b;
    cin >> n;
    cin >> a;
    cin >> b;
    if(n == 1){
        cout << "Hello World" << endl;
        return 0;
    }
    cout << a + b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 10000;

int main()
{
	int a, b, c;

	int array[3];
	cin >> array[0] >> array[1] >> array[2];

	sort(array, array + 3);

	rep(i, 3) {
		cout << array[i];

		if (i != 2){
			cout << " ";
		}
	}

	cout << endl;
 
	return 0;

}



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

int main(){
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    bool ok = false;
    if(a < b) {
        if(a + v*t >= b + w*t) ok = true;
    } else {
        if(a - v*t <= b - w*t) ok = true;
    }
    cout << ((ok)? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3624
X, Y, Z, K = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

D = []
for a in A:
    for b in B:
        D.append(a + b)
D.sort(reverse=True)

D = D[:K]
E = []
for c in C:
    for d in D:
        E.append(c + d)
E.sort(reverse=True)

E = E[:K]
for e in E:
    print(e)


Measured memory_bytes: 161104