akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
struct any{
    string s;
    any(string s):s(s){}
    operator lint()const{return stoll(s);}
    operator double()const{return stod(s);}
    operator string()const{return s;}
};
any in(void){
    return any(*istream_iterator<string>(cin));
}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
inline lint mex(vector<lint> s){
    lint res=0;
    sort(all(s));
    while(binary_search(all(s),res))res++;
    return res;
}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    complex<double>a{in(),in()},b{in(),in()},c,ans;
    lint n;
    cin>>n;
    rep(i,n){
        c={in(),in()};
        ans=a+((b-a)*conj(c-a)).real()/conj(b-a);
        cout<<ans.real()<<" "<<ans.imag()<<endl;
    }
}


Measured memory_bytes: 3312
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int A[] = new int[100];

        for(int i=0;i<n;i++){
            A[i] = scan.nextInt();
        }

        for(int i=1;i<n;i++){
            printArray(A, n);
            int v = A[i];
            int j = i - 1;
            // 挿入先が見つかるまでループ
            // 挿入するため、見ていった要素を一個ずつ後方へズラす。
            while(j >=0 && A[j] > v){
                A[j+1] = A[j];
                j--;
            }
            // 見つけた挿入場所へ挿入。
            A[j+1] = v;
        }
        printArray(A, n);
    }

    // スペース区切りで表示
    public static void printArray(int A[], int n){
        int i;
        for(i=0;i<n-1;i++){
            System.out.print(A[i] + " ");
        }
        System.out.println(A[i]);
    }
}

Measured memory_bytes: 22496
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = 0
s = [[0], [0]]
for i in range(2):
    for j in range(n):
        s[i].append(s[i][-1] + a[i][j])
for i in range(n):
    ans = max(ans, s[0][i + 1] + s[1][-1] - s[1][i])
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>

using namespace std;

int main(){

    int N, K, count = 0;
    cin >> N >> K;

    for (int i = 0; i < N; i++){
        int h;
        cin >> h;
        if (h >= K) count++;
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	set<int> st;
	for (int i = 0; i < N; ++i) {
		int temp;
		cin >> temp;
		st.insert(temp);
	}
	cout << st.size() << endl;

	return 0;
}



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

class Cmondai
{
    static void Main()
    {
        var nm = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var list = new List<long[]>();
        for (int i=0;i<nm[0];++i)
        {
            var ab = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            list.Add(new long[2] { ab[0],ab[1]});
        }
        list=list.OrderBy(x => x[0]).ThenByDescending(x => x[1]).ToList();
        var ans = 0L;
        for (int i = 0; i < nm[0]; ++i)
        {
            if (list[i][1] < nm[1]) {
                nm[1] -= list[i][1];
                ans += list[i][1] * list[i][0];
            }
            else
            {
                ans += list[i][0] * nm[1];
                nm[1] = 0;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 26688
import java.util.*;
import java.util.stream.*;

class Main {
	Scanner sc;
	int N, M;
	String S;
	Deque<Integer> d;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		S = sc.next();
		d = new ArrayDeque<>();
		
		int p = N;
		while (p > 0) {
			int dice = Math.min(M, p);
			while (true) {
				if (dice == 0 || p-dice < 0) {
					dice = -1;
					break;
				}
				if (S.charAt(p-dice) == '0') break;
				dice--;
			}
			if (dice == -1) break;
			p -= dice;
			d.addFirst(dice);
		}
		if (p > 0) System.out.println(-1);
		else {
			System.out.println(d.stream().map(n -> String.valueOf(n)).collect(Collectors.joining(" ")));
		}
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 34108
N = int(input())
odd_count = 0
mo4_count = 0 # multiple of 4
for i in map(int, input().split()):
  if i % 2 == 1:
    odd_count += 1
  elif i % 4 == 0:
    mo4_count += 1
if odd_count - N % 2 <= mo4_count:
  print('Yes')
else:
  print('No')


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

int main(){

  int n;

  while(cin >> n && n){

    int cnt = 0;
    int xmax = INT_MIN, ymax = INT_MIN;
    int value;
    int direction;
    int xcopy, ycopy;
    int block[402][402];

    for(int i = 0; i < 402; i++){
      for(int j = 0; j < 402; j++){
	block[i][j] = 300;
      }
    }
    
    // vector<int> block[200];
    int judge = 0;
    block[200][200] = 0;

    for(int i = 1; i < n; i++){
      cin >> value >> direction;
      if(direction == 0){
	for(int s = 0; s < 402; s++){
	  for(int l = 0; l < 402; l++){
	    if(value == block[s][l]){
	      block[s][l-1] = i;
	      judge = 1;
	      break;
	    }
	  }
	  if(judge == 1){
	    judge = 0;
	    break;
	  }
	}
      }else if(direction == 2){
	for(int s = 0; s < 402; s++){
	  for(int l = 0; l < 402; l++){
	    if(value == block[s][l]){
	      block[s][l+1] = i;
	      judge = 1;
	      break;
	    }
	  }
	  if(judge == 1){
	    judge = 0;
	    break;
	  }  
	}
      }else if(direction == 3){
	for(int s = 0; s < 402; s++){
	  for(int l = 0; l < 402; l++){
	    if(value == block[s][l]){
	      block[s-1][l] = i;
	      judge = 1;
	      break;
	    }
	  }
	  if(judge == 1){
	    judge = 0;
	    break;
	  }  
	}
      }else if(direction == 1){
	for(int s = 0; s < 402; s++){
	  for(int l = 0; l < 402; l++){
	    if(value == block[s][l]){
	      block[s+1][l] = i;
	      judge = 1;
	      break;
	    }
	  }
	  if(judge == 1){
	    judge = 0;
	    break;
	  }  
	}
      }
    }
    int xmin = INT_MAX, ymin = INT_MAX;
    int max = INT_MIN, min = INT_MAX;
    for(int s = 0; s < 402; s++){
      for(int l = 0; l < 402; l++){
	if(block[s][l] != 300){
	  if(xmax < l) xmax = l;
	  if(xmin > l) xmin = l;
	  if(ymax < s) ymax = s;
	  if(ymin > s) ymin = s;
	}
      }
    }
    /*  for(int s = 0; s < 402; s++){
      for(int l = 0; l < 402; l++){
	cout << block[s][l] << " ";
      }
      cout << endl;
    }
*/
    cout << xmax - xmin + 1 << " " << ymax - ymin + 1 << endl;
  }



return 0;
}

Measured memory_bytes: 1788
# # coding: utf-8
# data = list(input())
# removed_block = 0
# i = 1
# log = data[0]
# while i < (len(data) + 1):
#     try:
#         if data[i] != log:
#             data.pop(i)
#             data.pop(i - 1)
#             removed_block += 2
#             i = 1
#             log = data[0]
#         else:
#             i += 1
#     except:
#         break
# print(removed_block)

# coding: utf-8
n = input()
print(min(n.count('0'), n.count('1')) * 2)


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

using namespace std;
typedef long long Int;

const int MAX_Q = 210000;

Int a_bit[MAX_Q + 1], b_bit[MAX_Q + 1];
Int qt[MAX_Q + 1], qa[MAX_Q + 1], qb[MAX_Q + 1];

void add(Int *bit, int p, Int val)
{
  for (p += 1; p <= MAX_Q; p += p & -p) {
    bit[p] += val;
  }
}

Int _val(Int *bit, int p)
{
  Int res = 0;
  for (p += 1; p; p -= p & -p) {
    res += bit[p];
  }
  return res;
}

Int val(int p, Int xp)
{
  Int ret = _val(a_bit, p) * xp;
  ret += _val(b_bit, p);
  return ret;
}

int main()
{
  int q;
  
  scanf("%d", &q);
  
  vector<Int> xs;
  
  for (int i = 0; i < q; i++) {
    scanf("%lld", qt + i);
    if (qt[i] == 1) {
      scanf("%lld %lld", qa + i, qb + i);
      xs.push_back(qa[i]);
    }
  }
  
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  
  for (int i = 0; i < q; i++) {
    if (qt[i] == 1) {
      int pos = lower_bound(xs.begin(), xs.end(), qa[i]) - xs.begin();
      add(a_bit, 0, -1);
      add(a_bit, pos, 2);
      add(b_bit, 0, qa[i] + qb[i]); 
      add(b_bit, pos, -2 * qa[i]);
    }
    else {
      int l = 0, r = (int)xs.size() - 1;
      while (l != r) {
        int m = (l + r) / 2;
        if (val(m, xs[m]) <= val(m + 1, xs[m + 1])) r = m;
        else l = m + 1;
      }
      printf("%d %lld\n", xs[l], val(l, xs[l]));
    }
  }
  
  return 0;
}

Measured memory_bytes: 11892
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	ll n, k; cin >> n >> k;
	vector<ll> x(n), y(n), xx, yy;
	rep(i, n) cin >> x[i] >> y[i];
	xx = x; yy = y;
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	ll ans = 1LL * (x[n - 1] - x[0])*(y[n - 1] - y[0]);
	rep(a, n) {
		for (int b = a + 1; b < n; b++) {
			rep(c, n) {
				for (int d = c + 1; d < n; d++) {
					int cnt = 0;
					rep(i, n) {
						if (x[a] <= xx[i] && xx[i] <= x[b] && y[c] <= yy[i] && yy[i] <= y[d])
							cnt++;
					}if (cnt >= k)ans = min(ans, 1LL * (x[b] - x[a])*(y[d] - y[c]));
				}
			}
		}
	}cout << ans << endl;
}

Measured memory_bytes: 3612
using System;
using System.Linq;

public class MainClass {
    public static void Main(string[] args) {
        Console.ReadLine();
        string[] input = Console.ReadLine().Split(' ');
        int[] ms = input.Select(i => int.Parse(i)).ToArray();
        int ans = 1;
        int max = ms[0];
        for (int i=1; i<ms.Length; i++) {
            if (ms[i] >= max) {
                max = ms[i];
                ans += 1;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }
  int sum = 0;
  rep(i, N)
  {
    sum += 1 + abs((D - 1) / A[i]);
  }
  cout << X + sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
		#include <iostream>
		#include <numeric>
        using namespace std;
	    typedef long long int ll; 
		
		ll my_gcd(ll a, ll b){
          if (a<b){
            ll c=a;
            a=b; 
            b=c;
          }
          while(b!=0){
            ll c=b; 
            b = a%b;
            a=c;
          }
          return a; 
        }
		
		ll count(ll a, ll b, ll p){ // a以上b以下のpの倍数の数
          return b/p - (a-1)/p; 
        }


        int main() {
          ll A,B,C,D;
          cin>> A>> B >> C >>D;
          ll G = my_gcd(C,D);
          ll M = C*D/G;
          ll X= count(A,B,C) + count(A,B,D) - count(A,B,M);
          ll answer = B-A+1-X; 
          cout << answer << endl;
        }

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
EPS = 1e-9
def solve():
    xa, ya, ra, xb, yb, rb = map(float, readline().split())
    d = ((xa - xb)**2 + (ya - yb)**2)**.5
    if d < rb - ra:
        write("-2\n")
    elif d < ra - rb:
        write("2\n")
    elif d > ra + rb:
        write("0\n")
    else:
        write("1\n")
T = int(readline())
for i in range(T):
    solve()



Measured memory_bytes: 5656
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define ET cout << "\n"
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef bbq
#define debug(...) {\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}
#define DB(a,s,e) {for(int _i=s;_i<e;++_i) cerr << a[_i] << " ";cerr << "\n";}
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T,typename ...S> void _do(T &&x,S &&...t){cerr<<x<<", ";_do(t...);}
template<typename a,typename b> ostream& operator << (ostream &s,const pair<a,b> &p){return s<<"("<<p.X<<","<<p.Y<<")";}
#else
#define debug(...)
#define DB(a,s,e)
#endif

vector<int> G[2005];
int dis[2005],k;

void dfs(int u,int f=0,int d=0)
{
    dis[u]=d;
    if(d==k>>1) return;
    for(int i:G[u])
        if(i!=f)
            dfs(i,u,d+1);
}

bool dfs2(int u,int f=0,int d=0)
{
    dis[u]=d;
    if(d>k) return 0;
    for(int i:G[u])
        if(i!=f&&~dis[i])
            if(!dfs2(i,u,d+1))
                return 0;
    return 1;
}

int main()
{
    IOS();
    int n,a,b,ans=0;
    cin >> n >> k;
    for(int i=1;i<n;++i)
        cin >> a >> b,G[a].pb(b),G[b].pb(a);
    if(k&1^1)
        for(int i=1;i<=n;++i)
        {
            FILL(dis,-1);
            dfs(i);
            if(dfs2(max_element(dis+1,dis+n+1)-dis))
            {
                int tmp=0;
                for(int j=1;j<=n;++j)
                    if(~dis[j])
                        ++tmp;
                ans=max(ans,tmp);
            }
        }
    else
        for(int i=1;i<=n;++i)
            for(int j:G[i])
                if(i<j)
                {
                    FILL(dis,-1);
                    dfs(i,j),dfs(j,i);
                    if(dfs2(max_element(dis+1,dis+n+1)-dis))
                    {
                        int tmp=0;
                        for(int r=1;r<=n;++r)
                            if(~dis[r])
                                ++tmp;
                        ans=max(ans,tmp);
                    }
                }
    cout << n-ans << "\n";
}

Measured memory_bytes: 512
A,B,C,X,Y=map(int,input().split())

ans = A*X + B*Y
tmp = A*X + B*Y
x = X
y = Y
z = 0

while x >= 0 or y >= 0:
    tmp = A*max(0,x) + B*max(0,y) + C*z
    ans = min(ans,tmp)
    x=x-1
    y=y-1
    z=z+2

print(ans)

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int sx, sy, tx, ty;
	cin >>sx >>sy >>tx >>ty;
	string s;
	rep(i, ty-sy) s+="U";
	rep(i, tx+1-sx) s+="R";
	rep(i, ty+1-sy) s+="D";
	rep(i, tx+1-sx) s+="L";
	s+="UL";
	rep(i, ty+1-sy) s+="U";
	rep(i, tx+1-sx) s+="R";
	rep(i, ty+1-sy) s+="D";
	rep(i, tx-sx)   s+="L";
	
	cout << s <<"\n";
	return 0;
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    map<int, int> map;
    vector<int> sum(n + 1);
    for(int i = 0; i < n; i++)
    {
        sum.at(i + 1) = (sum.at(i) + a.at(i)) % m;
    }
    long long ans = 0;
    for(int i = 0; i < n + 1; i++)
    {
        ans += map[sum.at(i)];
        map[sum.at(i)]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,x,y,n,ans;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	c*=2;
	n=max(x,y);
	ans=x*a+y*b;
	for(int i=1;i<=n;i++)
		ans=min(ans,max(x-i,0)*a+max(y-i,0)*b+i*c);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/09.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int N;
    string S, T;
    
    cin>>N>>S>>T;

    for (int i = 0; i < N; ++i) {
        cout<<S[i]<<T[i];
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
S = input().split()
words = []
for i in range(len(S)):
    words.append(S[i])
    words.sort()

cnt = 0
maxcnt = 0
ans1 = ""
ans2 = words[0]
for i in range(1, len(words)):
    if words[i] == words[i-1]:
        cnt += 1
    else:
        cnt = 0
    if maxcnt < cnt:
        ans1 = words[i]
        maxcnt = cnt
    if len(ans2) < len(words[i]):
        ans2 = words[i]

print(ans1,ans2)


Measured memory_bytes: 5560
#include<stdio.h>

int main()
{
  int a;
  int b;
  int r;
  int tmp;

  scanf("%d%d", &a, &b);
  if(b > a) 
    {
      tmp = a;
      a = b;
      b = tmp;
    }

  while(b != 0)
    {
      tmp = a % b;
      a = b;
      b = tmp;
    }

  printf("%d\n", a);

  return 0;
}

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

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

int n, m, f[maxn][maxn], cur;
char a[maxn][maxn];

void dfs(int x, int y)
{
	queue<pair<int,int> > Q;
	Q.push(make_pair(x,y));
	while(!Q.empty())
	{
	x = Q.front().first;
	y = Q.front().second;
	Q.pop();
	cur = max(cur, f[x][y]);
	
	for(int k = 0; k <= 3; ++ k)
	{
		int nx = x + dx[k], ny = y + dy[k];
		if(nx < 1 || ny < 1 || nx > n || ny > m) continue;
		if(a[nx][ny] == '#') continue;
		if(f[nx][ny] != -1) continue;
		f[nx][ny] = f[x][y] + 1;
		Q.push(make_pair(nx,ny));
	}
	}
}

int main()
{
	#ifdef MPS
		freopen("a.in","r",stdin);
		freopen("a.out","w",stdout);
	#endif
	scanf("%d%d",&n,&m);
	int ans = 0;
	for(int i = 1; i <= n; ++ i) scanf("%s",a[i]+1);
	for(int sx = 1; sx <= n; sx ++)
		for(int sy = 1; sy <= m; sy ++) if(a[sx][sy] != '#')
		{ 
			memset(f,-1,sizeof(f));
			cur = 0;
			f[sx][sy] = 0;
			dfs(sx, sy);
			ans = max(ans, cur);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    let S = lines[0]
    let T = lines[1]
    let ans = 1000000

    for(let i = 0; i<= S.length - T.length; i++) {
        let tmp = 0
        for(let j = 0; j < T.length; j++) {
            if(S[i+j] != T[j]) tmp++
        }
        ans = Math.min(tmp, ans)
    }

    console.log(ans)
});

Measured memory_bytes: 33228
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
re1=0
re2=0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      re1+=1
a+=a
for i in range(2*n-1):
  for j in range(i+1,2*n):
    if a[i]>a[j]:
#      print("i j",i,j)
      re2+=1
#print(re2)
re2-=2*re1
ans=(k*re1+re2*(k-1)*k//2)%(10**9+7)
while ans>=10**9+7:
  ans%=10**9+7
print(ans)      


Measured memory_bytes: 3316
using System;
using System.Linq;

namespace FSound
{
    class Program
    {
        static void Main(string[] args)
        {
            //A円(単価)　B円(所持金)　C回聞きたいんだ―
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = input[1] / input[0] >= input[2] ? input[2] : input[1] / input[0];
            Console.Write(ans);

        }
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>

const int MAXN = 40;
const int MAXS = 150000;
const int MOD = 1000000007;

inline int Add(int x, const int &y) {
	x += y; if (x >= MOD) x -= MOD; return x;
}

const int P = 23;
const int HASH_MOD = 100003;

int N, X, Y, Z, S;
int Dp[MAXN + 5][MAXS +5][2];

void Debug(const std::vector<int> &T) {
	puts("");
	for (int i = 0; i < int(T.size()); i++)
		printf("%d ", T[i]);
	puts("");
}

std::vector<std::pair<std::vector<int>, int> > Hash[HASH_MOD + 5];

int Key(const std::vector<int> &T) {
	int ret = 0;
	for (int i = 0; i < int(T.size()); i++)
		ret = (ret * P + T[i]) % HASH_MOD;
	return ret;
}

int Find(const std::vector<int> &T) {
	int pos = Key(T);
	for (int i = 0; i < int(Hash[pos].size()); i++)
		if (Hash[pos][i].first == T)
			return Hash[pos][i].second;
	return 0;
}

int Tot;
bool Good[MAXS + 5];
int Next[MAXS + 5][12];
std::vector<int> cur, State[MAXS +5];

void Dfs(int num, int sum) {
	if (num > N || sum > X + Y + Z)
		return;
	State[++Tot] = cur;
	Hash[Key(cur)].push_back(std::make_pair(cur, Tot));
	if (sum == X + Y + Z) {
		int cnt = 0, tmp = 0;
		for (int i = 0; i < int(cur.size()); i++) {
			tmp += cur[i];
			if ((1 << tmp) & S)
				cnt++;
		}
		Good[Tot] = cnt == 3;
		return;
	}
	for (int i = 1; i <= 10; i++) {
		cur.push_back(i);
		Dfs(num + 1, sum + i);
		cur.pop_back();
	}
}

int main() {
	scanf("%d%d%d%d", &N, &X, &Y, &Z);
	S = (1 << X) | (1 << (X + Y)) | (1 << (X + Y + Z));
	Dfs(0, 0);
//	for (int i = 1; i <= Tot; i++)
//		printf("[%d]", i), Debug(State[i]);
	for (int i = 1; i <= Tot; i++) {
		for (int j = 1; j <= 10; j++) {
			cur = State[i];
			cur.push_back(j);
			int sum = 0, k = cur.size() - 1;
			while (k >= 0 && sum + cur[k] <= X + Y + Z)
				sum += cur[k--];
			for (int t = 0; t <= k; t++)
				cur.erase(cur.begin());
			Next[i][j] = Find(cur);
		}
	}
//	for (int i = 1; i <= Tot; i++, puts(""))
//		for (int j = 1; j <= 10; j++)
//			printf("%d ", Next[i][j]);
	Dp[0][1][0] = 1;
	for (int i = 0; i < N; i++)
		for (int j = 1; j <= Tot; j++)
			if (Dp[i][j][0] || Dp[i][j][1]) {
//				printf("-- %d, %d --", i, j), Debug(State[j]);
				for (int k = 1; k <= 10; k++) {
					int s = Next[j][k];
//					printf("(%d)-> [%d]", k, s), Debug(State[s]);
					Dp[i + 1][s][1] = Add(Dp[i + 1][s][1], Dp[i][j][1]);
					if (Good[s])
						Dp[i + 1][s][1] = Add(Dp[i + 1][s][1], Dp[i][j][0]);
					else
						Dp[i + 1][s][0] = Add(Dp[i + 1][s][0], Dp[i][j][0]);
				}
			}
	int Ans = 0;
//	for (int i = 0; i <= N; i++)
//		for (int j = 1; j <= Tot; j++)
//			if (Dp[i][j][0] || Dp[i][j][1])
//				printf("[%d][%d] %d %d\n", i, j, Dp[i][j][0], Dp[i][j][1]);
	for (int i = 1; i <= Tot; i++) {
//		if (Dp[N][i][1]) {
//			printf("\n[%d]", i);
//			Debug(State[i]);
//			printf("Dp = %d\n", Dp[N][i][1]);
//		}
		Ans = Add(Ans, Dp[N][i][1]);
	}
//	puts("");
	printf("%d", Ans);
	return 0;
}



Measured memory_bytes: 71128
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int a,b;
    cin>>a>>b;

    cout<<max(a+b,max(a-b,a*b))<<endl;

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

struct str {
	vi s;
};

int main() {
	ll N;
	cin >> N;
	vector<string> vs(N);

	for (ll i = 0; i < N; i++) {
		char c[10];
		for (ll j = 0; j < 10; j++) {
			cin >> c[j];
		}
		sort(c, c+10);
		string s = c;
		vs[i] = s;
	}
	sort(vs.begin(), vs.end());

	/*
	for (auto s : vs) {
		cout << s <<endl;
	}
	// */

	ll count = 0;
	ll tmp = 0;

	for (int i = 1; i < N; i++) {
		if (vs[i-1] == vs[i]) {
			tmp++;
		}
		else {
			count += tmp * (tmp + 1) / 2;
			tmp = 0;
		}
	}
	count += tmp * (tmp + 1) / 2;

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  ll a, p;
  cin >> a >> p;
  pt((a*3+p)/2);
  
  
}












Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int x;
  cin >> x;
  if(x<600)cout << 8 << endl;
  else if(x<800)cout << 7 << endl;
  else if(x<1000)cout << 6 << endl;
  else if(x<1200)cout << 5 << endl;
  else if(x<1400)cout << 4 << endl;
  else if(x<1600)cout << 3 << endl;
  else if(x<1800)cout << 2 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	int dif=n/500;
	n-=dif*500;
	int dif2=n/5;
	int ans=dif*1000+dif2*5;
	printf("%d\n", ans); return 0;
}

Measured memory_bytes: 256
n,m,d = map(int,input().split())

"""
#kuso code
start = time.time()
a = [random.randrange(n) for i in range(m)]
a = np.array(a)
b = np.abs(a[1:]-a[:-1])
cnt = np.sum(b == d)
ave = cnt

i = 0
while(time.time() - start < 10):
    a = [random.randrange(n) for i in range(m)]
    a = np.array(a)
    b = np.abs(a[1:]-a[:-1])
    cnt = np.sum(b == d)
    ave = ((i+1)*ave + cnt)/(i+2)
    i += 1
print(ave)
"""

oks_times_n = 2*(n-d)
ave = oks_times_n/n/n*(m-1)
if (d == 0):
    ave /= 2
print(ave)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class51
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int r = I[0];
            int g = I[1];
            int b = I[2];
            int N = I[3];
            int count = 0;
            int sum;
            for(int i = 0; i*r<= N; i++)
            {
                for(int j = 0; r*i + g*j<=N; j++)
                {
                    if ((N - r * i - g * j) % b == 0)
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cerr << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    ll n;
    cin >> n;
    
    vll a(n);
    ll sum = 0;
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i];
    	sum ^= a[i];
    }
    
    for(int i = 0 ; i < n ; i++){
    	cout << (sum ^ a[i]) << " ";
    }
    return 0;
}

Measured memory_bytes: 4752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();
            var L = cin.nextInt();

            var ringo = Enumerable.Range(1, N).ToArray();
            int[] aji = new int[N];
            for(int i = 0; i < N; i++)
            {
                aji[i] = L + i;
            }

            int t = int.MaxValue;
            foreach(var i in aji)
            {
                if(t >= i && i >= 0)
                {
                    t = i;
                }
            }

            if(t == int.MaxValue)
            {
                t = aji.Max();
            }

            Console.WriteLine( aji.Sum() - t);
        }

        

        public static long Sum(int left, int right, long[] a)
        {
            return a[right] - a[left];
        }
    }

    class Point
    {
        public int x { get; set; }
        public int y { get; set; }
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
 
#define Endl endl
 
 
/*--------------------template--------------------*/
 
int main()
{
	cin >> s;
	n = s.size();
	sort(ALL(s));
	ans = 1;
	vi v;
	sum = 1;
	REP(i, s.size()-1)
	{
		if (s[i] == s[i+1]) {
			sum++;
		} else {
			v.push_back(sum);
			sum = 1;
		}
	}

	REP(i,v.size())
	{
		n -= v[i];
		ans += v[i] * n;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long n,k,i,j;
    cin>>n>>k;
    long long *arr=new long long[n+1];
    for(i=1;i<=n;i++) cin>>arr[i];
    long long *dp=new long long[n+1]; //whether the person who starts it wins it or not
    dp[n]=0;
    //dp[n-2]=abs(arr[n-1]-arr[n-2]);
    for(i=n-1;i>0;i--)
    {
        dp[i]=abs(arr[i]-arr[i+1])+dp[i+1];
        for(j=2;j<=k;j++)
            if(i+j<=n) dp[i]=min(dp[i],(long long)(abs(arr[i]-arr[i+j])+dp[i+j]));
    }
    cout<<dp[1];
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
// #include <bits/stdc++.h> 
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

int32_t main(){
    fast
	int D, T, S;
	cin >> D >> T >> S;
	if(S*T >= D){
		cout << "Yes";
	} else {
		cout << "No";
	}
    return 0;
}





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

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((c - b) % 2 == 0) cout << "Alice" << endl;
    else cout << "Borys" << endl;
}


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

int n;
bool a[100005];

int main(){
  string str;
  cin>>str;
  n=str.size();
  for(int i=0;i<n;i++){
    if(str[i]=='0')a[i+1]=false;
    else a[i+1]=true;
  }
  if(!a[1] || a[n]){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    int j=n-i;
    if( a[i]!=a[j] ){
      cout<<-1<<endl;
      return 0;
    }
  }


  set<int> st;
  for(int i=1;i<=n/2;i++){
    if(a[i])
      st.insert(i);
  }

  cout<<1<<' '<<2<<endl;
  int last=2;
  int index=3;
  
  for(int x:st){
    if(x==1)continue;
    cout<<last<<' '<<index<<endl;
    int tmp=index;
    
    index++;
    
    for(int i=0;i<x-tmp+1;i++){
      cout<<last<<' '<<index<<endl;
      index++;
    }
    
    last=tmp;
  }
  
  while(index<=n){
    cout<<last<<' '<<index<<endl;
    index++;
  }
  return 0;
}


Measured memory_bytes: 3968
import sys
input = lambda: sys.stdin.readline().rstrip()
d={} ; a=[]
from collections import Counter
for _ in range(int(input())):
    s=input()
    a.append(s)
d=Counter(a)
maxx=max(d.values())
ans=[]
for i in d:
    if d[i]==maxx:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)
    

Measured memory_bytes: 90568
# coding:utf-8

import sys
import heapq
from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, a, b = LI()
X = LI()
C = []
for i in range(n - 1):
    C.append(X[i + 1] - X[i])

ans = 0
for i in range(n - 1):
    ans += min(a * C[i], b)

print(ans)


Measured memory_bytes: 15380
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

	int sum = 0;
	int is_all_tens=1;
	VI v(n);
	int min_no_zero=100;
	REP(i, n) {
		cin >> v[i];
		sum += v[i];
		if (v[i] % 10 != 0) {
			is_all_tens = 0;
			min_no_zero = min(v[i], min_no_zero);
		}
	}

	if (is_all_tens == 1) {
		ANS(0);
		return 0;
	}

	if (sum % 10 == 0) {
		ANS(sum - min_no_zero);
	}
	else {
		ANS(sum);
	}



	return 0;
}



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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < c && c < b)
        cout << "Yes" << endl;
    else if (b < c && c < a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int> a(5);
for(int i = 0; i< 5;i++){
  cin >> a.at(i);
}
vector<int>P = {0,1,2,3,4};
int final_answer = 1000;
do{
  int ans = 0;
  for(int i = 0; i<5; i++){
    while(ans%10 != 0) ans++;//10の倍数の時間になるまで注文できない事を再現
    ans+= a.at(P[i]);
  }
  final_answer = min(final_answer,ans);
}while(next_permutation(P.begin(),P.end()));
cout << final_answer << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let a = read!([i64]);
	for i in 0..a.len() {
		if a[i]==0 {
			println!("{}",i+1);
			return;
		}
	}
}

fn run() {
    solve();
}


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

int main()
{
	int N;
	char S[101];
	scanf("%d", &N);
	scanf("%s", S);
	
	int i, count = 0, max = 0;
	for (i = 0; S[i] != 0; i++) {
		if (S[i] == '(') count--;
		else count++;
		if (count > max) max = count;
	}
	
	for (i = 0; i < max; i++) printf("(");
	printf(S);
	for (i = 0; i < max - count; i++) printf(")");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = -1;

ll n, m, d;

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%lld %lld %lld", &n, &m, &d) >= 1){
        ll t = (d ? (n-d)*2 : n); //db(t);
        ld ans = ((ld)t*(m-1)) /n /n;
        printf("%.20Lf\n", ans);
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

vector<bool> seen, finished;

int pos = -1;
stack<int> hist, ans;

void determine(const Graph &G) {
  set<int> cycle;
  while (!hist.empty()) {
    int t = hist.top();
    ans.push(t);
    cycle.insert(t);
    hist.pop();
    if (t == pos) break;
  }
  for (auto v : cycle) {
    int count = 0;
    for (auto nv : cycle) {
      if (binary_search(all(G[v]), nv)) ++count;
    }
    if (count > 1) {
      pos = -1;
      while (!ans.empty()) {
        int t = ans.top();
        hist.push(t);
        ans.pop();
      }
      return;
    }
  }
}

void dfs(const Graph &G, int v) {
  seen[v] = true;
  hist.push(v);

  for (auto nv : G[v]) {
    if (finished[nv]) continue;

    if (seen[nv] && !finished[nv]) {
      pos = nv;
      determine(G);
      if (pos != -1) return;
      else continue;
    }

    dfs(G, nv);

    if (pos != -1) return;
  }

  hist.pop();
  finished[v] = true;
}

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

  Graph G(N);
  int a, b;
  for (int i=0; i<M; ++i) {
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
  }

  rep(i,N) sort(all(G[i]));

  seen.assign(N, false), finished.assign(N, false);
  pos = -1;

  rep(i,N) {
    if (seen[i]) continue;
    dfs(G, i);
    if (pos != -1) break;
  }

  if (pos == -1) {
    cout << -1 << endl;
    return 0;
  }

  cout << ans.size() << endl;
  while (!ans.empty()) {
    cout << ans.top() + 1 << endl;
    ans.pop();
  }
  return 0;
}


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

using namespace std;

#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

int main(void) {
    li N[3];
    cin >> N[0] >> N[1] >> N[2];

    sort(N, N + 3);

    cout << N[2] * 10 + N[1] + N[0];

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
m = max(l)

ans = 0
for i in range(m):
  ans += (l[0] > i)
  for j in range(1,n):
    if l[j-1] <= i:
      ans += (l[j] > i)
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	d := scanInts(n)

	sort.Ints(d)
	ans := d[len(d)/2] - d[len(d)/2-1]
	fmt.Println(ans)
}


Measured memory_bytes: 2048
s=input()
n=int(input())
front=""
back=s
reverse=False

for i in range(n):
  t=input().split()
  if t[0]=="1":
    reverse=not reverse
  else:
    if (t[1]=="1")^reverse:
      front=front+t[2]
    else:
      back=back+t[2]
if reverse:
  print(back[::-1]+front)
else:
  print(front[::-1]+back)


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

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

typedef unsigned int uint;
typedef long long ll;
typedef pair<int,int> pii;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

bool can[10];
bool ok(int n){
	while(n>0){
		if(can[n%10])
			return false;
		n/=10;
	}
	return true;
}

int main(){
	int n=read(),k=read();
	REP(i,k)
		can[read()]=true;
	while(!ok(n))n++;
	cout<<n<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long L, R, ans; cin >> L >> R; ans = 2018;
    for(long long i=L; i<=R; i++){
        for(long long j=i+1; j<=R; j++){
            ans = min(ans, (i*j)%2019);
            if(ans == 0) break;
        }
        if(ans == 0) break;
    }
    cout << ans;
}


Measured memory_bytes: 256