akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {
	int N;
	long[] A;
	long result = 0;

	long gcd(long large, long small) {
		if (large < small) {
			return gcd(small, large);
		}
		if (large == small) {
			return large;
		}
		if (large % small == 0) {
			return small;
		}
		return gcd(small, large % small);
	}

	void calc() {
		List<Long> gcds = new ArrayList<>();
		gcds.add(gcd(A[A.length - 1], A[A.length - 2]));
		int index = A.length - 2;
		for (int i = A.length - 3; i >= 0; --i) {
			long last = gcds.get(gcds.size() - 1);
			long g = gcd(last, A[i]);
			gcds.add(g);
			if (g < last) {
				index = i;
			}
		}

		if (index <= A.length - 3) {
			// その数を置き換える
			long r = A[A.length - 1];
			for (int i = A.length - 2; i >= 0; --i) {
				if (i == index) {
					continue;
				}
				r = gcd(r, A[i]);
			}
			this.result = r;
		} else {
			long r0 = A[A.length - 1];
			for (int i = A.length - 3; i >= 0; --i) {
				r0 = gcd(r0, A[i]);
			}
			long r1 = A[A.length - 2];
			for (int i = A.length - 3; i >= 0; --i) {
				r1 = gcd(r1, A[i]);
			}
			this.result = Math.max(r0, r1);
		}
	}

	Main() throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		N = Integer.parseInt(in.readLine());
		A = new long[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		in.close();
		Arrays.sort(A);
		calc();
	}

	public static void main(String[] args) throws IOException {
		Main ins = new Main();
		System.out.println(ins.result);
	}

}

Measured memory_bytes: 50524
#include<iostream>
using namespace std;
int main(){
  int n;
  int array[100005];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>array[i];
  }
  
  int cnt=0;
  int index=1;
  while(index<n){
    if(array[index]==index){
      if(array[index+1]==index+1){
	index++;
      }
      cnt++;
    }
    index++;
  }
  if(array[index]==index){
    cnt++;
  }
  cout<<cnt<<endl;
  return(0);
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

piipii c[405];
piipii rotate(piipii x){
    return mp(mp(x.se.se, x.fi.fi), mp(x.fi.se, x.se.fi));
}

unordered_map<ll, int> dp;
ll get_idx(piipii x){
    return x.fi.fi*1ll*1000*1000*1000 + x.fi.se*1ll*1000*1000 + x.se.fi*1ll*1000 + x.se.se;
}
void add(piipii p){
    for(int k=0;k<4;k++){
        dp[get_idx(p)]++;
        p = rotate(p);
    }   
}
void del(piipii p){
    for(int k=0;k<4;k++){
        dp[get_idx(p)]--;
        p = rotate(p);
    }
}


int main(){
    int n;
    scanf("%d", &n);   
    for(int i=1;i<=n;i++){
        scanf("%d%d%d%d", &c[i].fi.fi, &c[i].fi.se, &c[i].se.fi, &c[i].se.se);
        add(c[i]);
    }
    double ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i == j) continue;
            piipii p1 = c[i];
            for(int k=0;k<4;k++){
                del(p1);
                piipii p2 = c[j];
                for(int l=0;l<4;l++){
                    del(p2);

                    double res = 1;
                    piipii tmp1 = mp(mp(p1.fi.se, p1.fi.fi), mp(p2.fi.se, p2.fi.fi));
                    piipii tmp2 = mp(mp(p1.fi.se, p2.fi.fi), mp(p2.se.se, p1.se.fi));
                    piipii tmp3 = mp(mp(p1.se.se, p1.se.fi), mp(p2.se.se, p2.se.fi));
                    piipii tmp4 = mp(mp(p2.fi.se, p1.fi.fi), mp(p1.se.se, p2.se.fi));
                    if(dp.count(get_idx(tmp1))){
                        res *= dp[get_idx(tmp1)];
                        del(tmp1);
                    }
                    else res = 0;
                    if(dp.count(get_idx(tmp2))){
                        res *= dp[get_idx(tmp2)];
                        del(tmp2);
                    }
                    else res = 0;
                    if(dp.count(get_idx(tmp3))){
                        res *= dp[get_idx(tmp3)];
                        del(tmp3);
                    }
                    else res = 0;
                    if(dp.count(get_idx(tmp4))){
                        res *= dp[get_idx(tmp4)];
                        del(tmp4);
                    }
                    else res = 0;

                    ans += res;

                    if(dp.count(get_idx(tmp1))){
                        add(tmp1);
                    }
                    if(dp.count(get_idx(tmp2))){
                        add(tmp2);
                    }
                    if(dp.count(get_idx(tmp3))){
                        add(tmp3);
                    }
                    if(dp.count(get_idx(tmp4))){
                        add(tmp4);
                    }
                    
                    add(p2);
                    p2 = rotate(p2);
                }

                add(p1);
                p1 = rotate(p1);
            }
        }
    }
    printf("%.0lf\n", ans/24);
}

Measured memory_bytes: 3824
while(n,p=gets.split.map(&:to_i))!=[0,0]
	a=Array.new(n,0)
	i=0
	c=p
	while (a[i]!=p)
		c.zero? ? (c+=a[i];a[i]=0) : (a[i]+=1;c-=1) 
		i=(i+1)%n
	end
	puts i
end

Measured memory_bytes: 6096
#include <iostream>

using namespace std;
const int N = 20;
int n,m,x;
int a[N][N],c[N],sum[N];
int main()
{
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++){
        cin >> c[i];
        for (int j = 1; j <= m; j++) cin >> a[i][j];
    }
    long long ans = 1e18;
    for (int i = 1; i <= (1 << n) - 1; i++){
        fill(sum + 1,sum + 1 + n,0);
        long long coin = 0;
        for (int temp = 0; temp < n; temp++)
            if ((i >> temp) & 1 == 1){
                coin = coin + c[temp + 1];
                for (int j = 1 ; j <= m; j++) sum[j] += a[temp + 1][j];
            }
        bool check = true;
        for (int j = 1; j <= m; j++)
            if (sum[j] < x) check = false;
        if (check) ans = min(ans , coin);
    }
    cout << ((ans == 1e18) ? -1 : ans);
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>

int main() {
    int n, m, l, r;
    char s[101] = {};
    scanf("%d %d",&n, &m);
    for(int i=0;i<m;i++){
        scanf("%d %d",&r, &l);
        s[r]=(char)((int)s[r] + 1);
        s[l]=(char)((int)s[l] + 1);
    }
    for(int i=0;i<n;i++){
        printf("%d\n",s[i+1]);
    }
    return 0;
}

Measured memory_bytes: 128
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = 0
    tail = A[N]
    idx = N-1
    while B:
        brave = B.pop()
        if brave >= tail + A[idx]:
            ans += tail + A[idx]
            tail = 0
        else:
            ans += brave
            if brave < tail:
                tail = A[idx]
            else:
                tail = A[idx] - (brave-tail)
        idx -= 1
    print(ans)



    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 23952
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		long max,min,sum = 0;
		int n = s.nextInt();
		long[] data = new long[n];
		
		for(int i = 0;i < n;i++){
			data[i] = s.nextInt();
		}
		
		max = data[0];
		min = data[0];
		for(int i = 0;i < n;i++){
			if(data[i] >= max)
				max = data[i];
			if(data[i] <= min)
				min = data[i];
			sum += data[i];
		}
		
		System.out.println(min +" "+max+" "+sum);
		
	}
}

Measured memory_bytes: 31756
#include <math.h>
#include <iostream>
using namespace std;

#define PI 3.14159265

int main()
{
	long double a, b, C;
	long double S, L, h;
	cin >> a >> b >> C;
	cout << fixed << a*b*sin(C*(PI/180)) / 2 << endl;
	cout << fixed << a + b + sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C*(PI / 180))) << endl;
	cout << fixed << b * sin(C*(PI / 180)) << endl;
	return 0;
}

Measured memory_bytes: 3432
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a[26]={};
	for(int i=0;i<s.size();i++){
		a[s[i]-'a']=1;
	}
	for(int i=0;i<26;i++){
		if(a[i]==0){
			char b=i+'a';
			cout<<b<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
}


Measured memory_bytes: 512
fn main() {
    let (a, mut b, mut c): (i64, i64, i64) = (read::<i64>(), read::<i64>(), read::<i64>());
    let mut k: i64 = read();
    let mut ans = min(a, k);
    k -= a;
    while k > 0 && b > 0 {
        b -= 1;
        k -= 1;
    }
    while k > 0 && c > 0 {
        c -= 1;
        ans -= 1;
        k -= 1;
    }
    println!("{}", ans);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

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

// =========


Measured memory_bytes: 2088
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    edges = []
    for i in range(M):
        A,B = map(int, input().split())
        edges += (A,B),
    
    good = [True]*N
    for A,B in edges:
        if H[A-1] > H[B-1]:
            good[B-1] = False
        elif H[A-1] < H[B-1]:
            good[A-1] = False
        else:
            good[A-1] = False
            good[B-1] = False
    print(len(list(filter(lambda b: b, good))))

main()


Measured memory_bytes: 27692
H,W,K = map(int, input().split())

mod = 10**9+7
dp = [["0"]*(W+2) for _ in range(H+1)]
for h in range(H+1):
    dp[h][0] = 0
    dp[h][W+1] = 0
for w in range(W+2):
    dp[0][w] = 0
dp[0][1] = 1

cmb = [1, 2, 3, 5, 8, 13, 21, 34]
def f(h, w):
    if dp[h][w] != "0":
        return dp[h][w]
    dp[h][w] = 0
    dp[h][w] += f(h-1, w-1)*cmb[max(0, w-3)]*cmb[max(0, W-w-1)]
    dp[h][w] += f(h-1, w)*cmb[max(0, w-2)]*cmb[max(0, W-w-1)]
    dp[h][w] += f(h-1, w+1)*cmb[max(0, w-2)]*cmb[max(0, W-w-2)]
    dp[h][w] %= mod
    return dp[h][w]

print(f(H, K))

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int main()
{
	long long a, b, n, m;
	int k;
	long long i;
	scanf("%lld %lld %d", &a, &b, &k);
	n = a;
	m = b;
	if(b - a + 1 > 2 * k) {
		int k1 = k;
		while(k--) {
			printf("%lld\n", n);
			n++;
		}
		m = m - k1 + 1;
		for(i = m; i <= b; i++) 
			printf("%lld\n", i);
	}
	else {
		for(i = a;i <= b; i++) {
			printf("%lld\n", i);
		}
	}
}

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

#define fi first 
#define se second

const int maxn = 1e5+1;

vector<int> g[maxn];
int ans[maxn] = {0};
int cmp = 0;
void dfs(int cur,int par){
    if(ans[cur]) return ;
    ans[cur] = 1;
    for(auto it:g[cur]){
        if(it==par) continue;
        dfs(it,cur);
    }
}

int main(){

    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif

    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y,z;
        cin>>x>>y>>z;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        if(ans[i]==0){
            cmp++;
            dfs(i,i);
        }
    }
    cout<<cmp;
    return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>

int gcd(int x,int y)
{
	int r;
	if(y>x){
		r=x;
		x=y;
		y=r;
	}
	while(y>0){
		r=x%y;
		x=y;
		y=r;
	}
	return x;
}

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

int main(void)
{
	int n,a[10],i;
	scanf("%d",&n);
	for(i=0;i<n;++i)scanf("%d",&a[i]);
	for(i=1;i<n;++i)a[i]=lcm(a[i-1],a[i]);
	printf("%d\n",a[i-1]);
	return 0;
}


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

int main(){
    int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin>>x>>y;
    if(a[x]==a[y])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

string s;
int main() {
   cin>>s;
   if(s[1]=='B') puts("ARC");
   else puts("ABC");
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define F 105
#define zero(n) memset(n,0,sizeof(n))
typedef struct dir
{
	int ch_num;
	char child_name[50][F],name[F];
	struct dir *child[100],*parent;
}dir;

dir *useP[500];
int used;
char stack[F][105];

dir* init(char *name,dir *pa)
{
	dir* p=(dir*)malloc(sizeof(dir));
	useP[used++]=p;
	strcpy(p->name,name);
	p->parent=pa;
	p->ch_num=0;
	return p;
}

void input()
{
	int i;char s[F],*p,d[150]="root";
	zero(stack);
	gets(s);
	strcat(d,s);
	if(d[strlen(d)-1]=='/')strcat(d,"?");
	for(i=0,p=strtok(d,"/");p;p=strtok(NULL,"/"),i++)strcpy(stack[i],p);
}

void push(int sp,dir *np)
{
	int i;
	if(!stack[sp][0])return;
	for(i=0;i<np->ch_num;i++)
		if(!strcmp(stack[sp],np->child_name[i]))
		{
			push(sp+1,np->child[i]);
			return;
		}
	strcpy(np->child_name[i],stack[sp]);
	np->child[i]=init(stack[sp],np);
	np->ch_num++;
	push(sp+1,np->child[i]);
	return;
}

dir *access(int sp,dir *np)
{
	int i;
	if(!stack[sp+1][0])//end of url
	{
		if(np->ch_num==0&&(!strcmp(stack[sp],np->name)||!strcmp("index.html",np->name)))
			return np;//np is file and dist name
		for(i=0;i<np->ch_num;i++)
			if(!strcmp("index.html",np->child_name[i])&&np->child[i]->ch_num==0)
				return np->child[i];
		return 0;
	}
	if(!strcmp(stack[sp+1],"."))
		return access(sp+1,np);
	if(!strcmp(stack[sp+1],".."))
		return (np->ch_num==0||!strcmp("root",np->name))?0:access(sp+1,np->parent);
	if(!strcmp(stack[sp+1],"?"))
	{
		for(i=0;i<np->ch_num;i++)
			if(!strcmp("index.html",np->child_name[i])&&np->child[i]->ch_num==0)
				return np->child[i];
	}
	for(i=0;i<np->ch_num;i++)
		if(!strcmp(stack[sp+1],np->child_name[i]))
			return access(sp+1,np->child[i]);
	return 0;
}

int main()
{
	int N,M,i;
		dir dbg;
	for(;scanf("%d%d\n",&N,&M),N;)
	{
		zero(useP);
		used=0;
		dir* root=init("root",0);
		for(i=0;i<N;i++)
		{
			input();
			push(1,root);
		}
		for(i=0;i<M;i++)
		{
			dir *r1,*r2;
			input();
			r1=access(0,root);
			input();
			r2=access(0,root);
			if(r1==0||r2==0)puts("not found");
			else if(r1==r2) puts("yes");
			else puts("no");
		}
		for(i=0;i<used;i++)free(useP[i]);
	}
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<ll>c(n);
    vector<ll>rikaido(m);
    ll a[n][m];
    ll cost;
    ll answer = INT64_MAX;
    bool flag;
    REP(i,n){
        cin >> c[i];
        REP(j,m){
            cin>> a[i][j];
        }
    }
    for (int bit = 0; bit < (1<<n); ++bit) {
        flag = true;
        cost = 0;
        REP(j,m){
            rikaido[j] = 0;
        }
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                cost += c[i];
                REP(j,m){
                    rikaido[j]+=a[i][j];
                }
            }
        }
        REP(j,m){
            if(rikaido[j] < x)flag = false;
        }
        if(flag){
            answer = min(answer,cost);
        }
    }
    if(answer == INT64_MAX){
        cout << -1 << endl;
    }else{
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <vector>
using namespace std;

typedef double D;
const D EPS = 1e-8;

struct P {
  D x, y;
  P() { }
  P(D x_, D y_) : x(x_), y(y_) { }
};

struct L {
  P a, b;
  L() { }
  L(P a_, P b_) : a(a_), b(b_) { }
};

P operator +(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
P operator *(P a, D b) { return P(a.x * b, a.y * b); }
P operator /(P a, D b) { return P(a.x / b, a.y / b); }

int sig(D a, D b) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}

D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }
D norm(P p) { return inp(p, p); }
D abs(P p) { return sqrt(norm(p)); }
P rot90(P p) { return P(-p.y, p.x); }

P vec(P from, P to) { return to - from; }

int ccw(P a, P b, P c) { // 重なっている点があるとうまく動かないと思われる
  b = vec(a, b); c = vec(a, c);

  // a - b - c が折れ曲がるとき
  if(sig(outp(b, c),0.0) > 0) return +1; // 反時計回り
  if(sig(outp(b, c),0.0) < 0) return -1; // 時計回り

  // a - b - c が直線上に並ぶとき
  // sigを使わない実装が主流っぽい？
  if(sig(inp(b, c),0.0) < 0)   return +2; // c - a - b
  if(sig(norm(b),norm(c)) < 0) return -2; // a - b - c
  return 0;                               // a - c - b
}

bool operator <(P a, P b) {
  if(sig(a.x, b.x) != 0) return a.x < b.x;
  return a.y < b.y;
}

vector<P> convex_hull(vector<P> ps) {
  int N = ps.size();
  int k = 0; // 凸包を構成する点の数
  sort(ps.begin(), ps.end());
  vector<P> res(N * 2);
  for(int i = 0; i < N; i++) {
    // 時計回りの折れ曲がりがあったら、折れ点を削除
    while(k >= 2 && ccw(res[k - 2], res[k - 1], ps[i]) <= 0) k--;
    res[k++] = ps[i];
  }
  int t = k + 1;
  // 右端は取らない (重複するから)
  // 左端は取る (重複するけど、あとから取り除いたほうが楽)
  for(int i = N - 2; i >= 0; i--) {
    while(k >= t && ccw(res[k - 2], res[k - 1], ps[i]) <= 0) k--;
    res[k++] = ps[i];
  }
  res.resize(k - 1);
  return res;
}

int main() {
  for(int N; cin >> N, N; ) {
    vector<P> ps(N);
    for(int i = 0; i < N; ++i) {
      string S; cin >> S;
      for(int j = 0; j < (int)S.size(); ++j)
        if(S[j] == ',') S[j] = ' ';
      istringstream iss(S);
      iss >> ps[i].x >> ps[i].y;
    }
    vector<P> qs = convex_hull(ps);
    cout << ps.size() - qs.size() << endl;
  }
}

Measured memory_bytes: 1272
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N;
  string S;
  S.size() == N;
  int K;
  cin >> N;
  cin >> S;
  cin >> K;

  int i;
  for (i = 0; i < N; i++) {
    if (S.at(i) != S.at(K - 1)) {
      char c = '*';
      S.at(i) = c;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int gcd(int a, int b) {
    if(a == 0) return b;
    if(a > b) {
        int t = a;
        a = b;
        b = t;
    }
    return gcd(b % a, a);
}

int main() {
    int a, b, k, c=0;
    cin >> a >> b >> k;

    int g = gcd(a, b);

    for(int i=g; i>=1; i--) {
        if(g % i == 0) {
            c++;
            if(c == k) {
                cout << i << endl;
                break;
            }
        }
    }
    // int m = min(a, b);
    // for(int i=m; i>=1; i--) {
    //     if(b % i == 0 && a % i == 0) {
    //         c++;
    //         if(c == k) {
    //             cout << i << endl;
    //             break;
    //         }
    //     }
    // }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

	int N;

	string S;

	cin >> N >> S;

	vector<int> num(10);
	vector<int> max(10);
	vector<int> sec(10);

	int count = 0;

	for(int i = S.length() - 1; i >= 0; i--) {
		int x = 0;
		for(int i = 0; i < 10; i++) {
			x += sec[i];
		}
		max[int(S[i]) - 48] = x;
		x = 0;
		for(int i = 0; i < 10; i++) {
			if(num[i] > 0) {
				x++;
			}
		}
		sec[int(S[i]) - 48] = x;
	//	cout << max[int(S[i]) - 48] << endl;
		if(num[int(S[i]) - 48] != 3) {
			num[int(S[i]) - 48]++;
			//count++;
		}
	}

	int ans = 0;

	for(int i = 0; i < 10; i++) {
		ans += max[i];
	}
/*
	for(int i = 0; i < 10; i++) {
		int x = 1;
		cout << max[i] << endl;
		for(int j = max[i]; j > 0; j--) {
			x *= j;
		}
		for(int j = 2; j > 0; j--) {
			x /= j;
		}
		for(int j = max[i] - 2; j > 0; j--) {
			x /= j;
		}
		ans += x;
	}
*/
	cout << ans << endl;
			
}


Measured memory_bytes: 384
use proconio::{input, fastout};

fn main() {
    input!(
        x: usize,
        y: usize,
    );
    let n = x*2;
    if y >= n && y & 1 == 0 && y <= 2*n {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    string S;cin>>S;
    reverse(S.begin(),S.end());
    bool ok=true;
    while(S!=""){
        if(S.substr(0,5)=="maerd"){
            S=S.substr(5,S.size()-5);
            continue;
        }
        if(S.substr(0,7)=="remaerd"){
            S=S.substr(7,S.size()-7);
            continue;
        }
        if(S.substr(0,5)=="esare"){
            S=S.substr(5,S.size()-5);
            continue;
        }
        if(S.substr(0,6)=="resare"){
            S=S.substr(6,S.size()-6);
            continue;
        }
        ok=false;
        break;
    }
    cout<<(ok?"YES":"NO")<<endl;
}

Measured memory_bytes: 512
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var x = inputs[0];
            var y = inputs[1];

            var result = 0;
            while (true)
            {
                if (x < y)
                {
                    var temp = x;
                    x = y;
                    y = temp;
                }
                else if(x==y)
                {
                    result = x;
                    break;
                }
                x = x % y;
                if (x % y == 0)
                {
                    result = y;
                    break;
                }
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 19900
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
	{
		static void Main(string[] args)
		{
			int n=int.Parse(Console.ReadLine());

			List<test> list幸福度 = new List<test>();

			for(int i=0;i<n;i++)
			{
				string[] input = Console.ReadLine().Split(' ');
				long A = long.Parse(input[0]);
				long B = long.Parse(input[1]);

				long kouhuku=A+B;

				test 幸福度	= new test
					(
					kouhuku,
					A,
					B
					);
				list幸福度.Add(幸福度);

				
			}

			list幸福度	= new List<test>( list幸福度.OrderByDescending( x => x.幸福度));
			long 高橋 = 0;
			long 青木 = 0;
			for(int i=0;i<list幸福度.Count;i++)
			{
				if(i% 2 == 1)
				{
					青木	+= list幸福度[i].B;
				}
				else
				{
					高橋	+= list幸福度[i].A;
				}

			}
			Console.WriteLine(高橋 - 青木);
			
		}
	}
	class test
	{
		public long 幸福度	{get;set;}
		public long A		{get;set;}
		public long B		{get;set;}

		public test
			(
			long	幸福度,
			long A,
			long B
			)
		{
			this.幸福度 = 幸福度;
			this.A		= A;
			this.B		= B;
		}
	}

Measured memory_bytes: 28860
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	for (int i = 0; i < n; i++)d[i] = INFTY;
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front();
		q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0)continue;
			if (d[v] != INFTY)continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}

int main() {
	int u, k, v;

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)M[i][j] = 0;
	}

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0);

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << setprecision(10) << sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) << endl;
}



Measured memory_bytes: 3268
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 16+7;
const int MSK = (1<<16)+7;

int n;
ll a[N][N];
ll dp[MSK];
ll score[MSK];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    cin >> n;
    REP(i,0,n-1) REP(j,0,n-1) cin >> a[i][j];

    REP(msk,0,(1<<n)-1)
    {
        REP(i,0,n-1) REP(j,i+1,n-1) if (msk&(1<<i) && msk&(1<<j)) score[msk] += a[i][j];

    }

    // dp[msk] = the best score of we already grouped the msk rabbits
    dp[0] = 0;

    REP(msk,1,(1<<n)-1)
    {
        vector<int> nt;
        REP(i,0,n-1)
        {
            if (msk&(1<<i)) nt.PB(i);
        }
        int m = nt.size();
        REP(msk2,0,(1<<m)-1)
        {
            int x = 0;
            REP(i,0,m-1) if (msk2&(1<<i)) x += (1<<nt[i]);
            dp[msk] = max(dp[msk],score[x]+dp[msk^x]);
        }
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}


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

int main() {
	int count = 0;
	string str, strtmp;

	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		if (i == 0 ||  i == str.length() - 1)strtmp += str[i];
		if (i == str.length() - 2)strtmp += to_string(count);
		count++;
	}
	cout << strtmp << endl;
}

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

using namespace std;

int n, u, v, a, b, disu[100005], disv[100005], ans;
vector <int> G[100005];
queue <int> q;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> u >> v;
	for (int i=1; i<n; i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	q.push(u);
	while (!q.empty()) {
		int k = q.front();
		q.pop();
		for (int m : G[k]) {
			if (disu[m]) continue;
			disu[m] = disu[k] + 1;
			q.push(m);
		}
	}
	disu[u] = 0;
	q.push(v);
	while (!q.empty()) {
		int k = q.front();
		q.pop();
		for (int m : G[k]) {
			if (disv[m]) continue;
			disv[m] = disv[k] + 1;
			q.push(m);
		}
	}
	disv[v] = 0;
	for (int i=1; i<=n; i++) {
		if (disv[i] > disu[i]) ans = max(ans, disv[i]);
	}
	ans--;
	cout << ans << endl;
}

Measured memory_bytes: 6656
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

A,B=gets.chomp.split(' ').map{|n| n.to_i}

if(A + B <= 16 && A <= 8 && B <= 8)
	puts "Yay!"
else
	puts ":("
end

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
//#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  bitset<64> bs(0);
  int q;
  cin >> q;
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 0)
    {
      int i;
      cin >> i;
      cout << bs[i] << endl;
    }
    else if (type == 1)
    {
      int i;
      cin >> i;
      bs[i] = 1;
    }
    else if (type == 2)
    {
      int i;
      cin >> i;
      bs[i] = 0;
    }
    else if (type == 3)
    {
      int i;
      cin >> i;
      bs.flip(i);
    }
    else if (type == 4)
    {
      cout << bs.all() << endl;
    }
    else if (type == 5)
    {
      cout << bs.any() << endl;
    }
    else if (type == 6)
    {
      cout << bs.none() << endl;
    }
    else if (type == 7)
    {
      cout << bs.count() << endl;
    }
    else if (type == 8)
    {
      cout << bs.to_ullong() << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3220
S = input()
T = input()
ans = len(T)
n1 = len(S)-len(T)+1
for i in range(n1):
    ans2 = 0
    for k in range(len(T)):
        # print(S[k+i],T[k])
        if S[k+i] != T[k]:
            ans2 += 1
    
    ans = min([ans,ans2])
    # print(ans)
print(ans)

Measured memory_bytes: 9112
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+1;

int main(){
    string s;
    cin >> s;
    ll n=s.length();
    ll ans=0;
    rep(i,n){
        if(s[i]=='1') ans++;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define I64 "%I64d"
#define RAN(v)v.begin(),v.end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
template<class T>
inline void upd1(T&a,T b){a>b?a=b:0;}
template<class T>
inline void upd2(T&a,T b){a<b?a=b:0;}
struct ano{
	operator ll(){
		ll x=0,y=0,c=getchar();
		while(c<48)
			y=c==45,c=getchar();
		while(c>47)
			x=x*10+c-48,c=getchar();
		return y?-x:x;
	}
}buf;
const int N=5e5+5;
char a[N];
int c[N],f[N][3];
int sol(int l,int r){
	int k=0,m=0;
	for(int i=l;i<=r;++i)
		if(a[i]=='1'){
			++k;
			if(i==r||a[i+1]=='0')
				c[++m]=k,k=0;
		}
	f[0][1]=-1e9;
	for(int i=1;i<=m;++i){
		f[i][0]=max(f[i-1][2]+c[i],f[i-1][0]+c[i]-1);
		f[i][1]=max(f[i-1][2],f[i-1][1]+c[i]-1);
		f[i][2]=max(f[i-1][2],max(f[i-1][0],f[i-1][1]+c[i]));
		if(c[i]!=1)
			upd2(f[i][1],f[i-1][0]);
	}
	return f[m][2];
}
int main(){
	int l=0,s=0;
	~buf,scanf("%s",a+2);
	for(int i=2;a[i];++i)
		if(a[i]=='1'){
			if(a[i-1]!='1'&&a[i-2]!='1')l=i;
			if(a[i+1]!='1'&&a[i+2]!='1')s+=sol(l,i);
		}
	printf("%d\n",s);
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    int n,m,q;
    cin >> n >> m >> q;
    vector<vector<int>>a(n,vector<int>(n));
    rep(i,m) {
        int l,r;
        cin >> l >> r;
        l--;r--;
        a[l][r]++;
    }
    vector<vector<int>>as(n+1,vector<int>(n+1));
    rep(i,n) {
        rep(j,n) {
            as[i+1][j+1] = as[i][j+1] + as[i+1][j] - as[i][j] + a[i][j];
        }
    }
    rep(i,q) {
        int l,r;
        cin >> l >> r;
        l--;
        int ans = as[r][r] - as[l][r] - as[r][l] + as[l][l];
        cout << ans << endl;
    }
}

Measured memory_bytes: 5576
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++){
			A[i]  = sc.nextInt();
		}
		
		int temp1 = A[0];
		int temp2 = 0;
		int count = 1;
		for(int i=1; i<N; i++){
			if(temp2==-1){
				if(temp1<A[i]){
					temp2=0;
					temp1=A[i];
					count++;
				}else{
					temp1=A[i];
				}
				
			}else if(temp2==1){
				if(temp1>A[i]){
					temp2=0;
					temp1=A[i];
					count++;
				}else{
					temp1=A[i];
				}
			}else{
				if(temp1>A[i]){
					temp2=-1;
					temp1=A[i];
				}else if(temp1<A[i]){
					temp2=1;
					temp1=A[i];
				}else{
					temp1=A[i];
				}
			}
		}
		
		System.out.println(count);

	}

}


Measured memory_bytes: 50172
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;


int main() {
	int h, r; cin >> h >> r;
	int ans;
	if (h + r == 0)ans = 0;
	else if (h + r > 0)ans = 1;
	else ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		int trainFee = Math.min(a, b);
		int busFee = Math.min(c, d);

		System.out.println(trainFee + busFee);

	}

}


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

int main() {

  int n, a, min = 1000001, max = -1000000;
  long sum = 0;
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    if(a < min) min = a;
    if(a > max) max = a;
    sum += a;
  }

  cout << min << " " << max << " " << sum << endl;

   return 0;
}      

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
#define sz(x)                 (int)(x.size())
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.141592653589793238462643383279;

//#define int                   long long

typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; scanf("%d", &_x); return _x; }
long long lin() {long long _x; scanf("%lld", &_x); return _x; };

void f(int d) {
        if (d == 0) cout << "No" << endl;
        else cout << "Yes" << endl;
        exit(0);
}

signed main() { 
        int a, b;
        cin >> a >> b;
        if (a == 2) f(0);
        else if (a == 4 or a == 6 or a == 9 or a == 11) {
                if (b == 6 or b == 9 or b == 11) f(1);
                else f(0);
        } else {
                if (b == 1 or b == 3 or b == 5 or b == 7 or b == 8 or b == 10 or b == 12) f(1);
                else f(0);
        }
}               



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))


def main():
    n,m = LI()
    a = [[c!='.' for c in l] for l in sys.stdin.readlines()] + [[True] * m]
    b = [[None] * n for _ in range(m)]
    for i in range(n):
        j = 0
        ai = a[i] + [True]
        while j < m:
            if ai[j]:
                j += 1
            else:
                k = j+1
                while not ai[k]:
                    k += 1
                s = k - j
                b[j][i] = s
                if k < m:
                    b[k][i] = 0
                j = k

    r = 0
    c = [0] * n
    for j in range(m):
        bj = b[j]
        for i in range(n):
            if bj[i] is None:
                continue
            c[i] = bj[i]
        i = 0
        while i < n:
            if a[i][j]:
                i += 1
            else:
                k = i+1
                while not a[k][j]:
                    k += 1
                t = max(c[i:k]) + k - i
                if r < t:
                    r = t
                i = k

    return r - 1


print(main())



Measured memory_bytes: 69076
#include<iostream>
#include<cstring>
#include<cctype>
using namespace std;

int main(){
    char swap;
    string str;
    int length,i;

    getline(cin,str);
    length = str.size();
    for(i=0;i<length;i++){
        if(isalpha(str[i])){
            if(islower(str[i])){
                swap = str[i];
                str[i] = toupper(swap);
            }else if(isupper(str[i])){
                swap = str[i];
                str[i] = tolower(swap);
            }
        }
    }
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 3172
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
pair<int,int> s[100005];
int main(void){
    int n;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
		scanf("%d",&s[i].F);
		s[i].S=i;
	}
	sort(s,s+n);
	int tot=0;
	for(i=0;i<n;i++){
		if(abs(s[i].S-i)%2) tot++;
	}
	printf("%d\n",tot/2);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;

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

int N; 
VS S(2);
cin>> N >> S[0] >> S[1];

i64 cnt;
bool tateyoko; //縦ドミノ1つならfalse，横ドミノ2つならture を記録．
int s; // 左端の縦横をチェックして次の添え字 s から始める．
if (S[0][0] == S[1][0]){
    tateyoko = false;
    cnt = 3;
    s = 1;
} 
else {
    tateyoko = true;
    cnt = 6;
    s = 2;
}

rep(i, s, N)
    if (S[0][i] == S[1][i]){
        if (!tateyoko) (cnt *= 2) %= MOD;
        tateyoko = false;
    }
    else {
        if (tateyoko) (cnt *= 3) %= MOD;
        else (cnt *= 2) %= MOD;
        tateyoko = true;
        ++i;
    }


cout << cnt  << endl;

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> num(26, 0);
  for (auto& c : s) {
    num[c - 'a']++;
  }

  mint ans(1);

  for (auto& v : num) {
    ans *= (v + 1);
  }

  cout << ans.x - 1<< endl;

  return 0;
}


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

template<typename C>
inline void out_vector(const C& v){
  bool isFirst = true;
  for(const auto& e : v){
    if(isFirst) { isFirst = false; }
    else { cout << " "; }
    
    cout << e;
  }
  cout << endl;
}

int main() {
  int64_t a;
  string s;
  cin >> a >> s;
  
  if(a >= 3200) { cout << s << endl; }
  else { cout << "red" << endl; }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>

using namespace std;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    for(int i=0; i<=999; i++){
        ostringstream sout;
        sout << setfill('0') << setw(3) << i;
        string s = sout.str();
        int ind = 0;
        for(int j=0; j<3; j++){
            ind = (int)S.find(s[j], ind);
            if(ind == -1) break;
            ind++;
        }
        if(ind != -1) ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    string a,b; cin >> a >> b;
    string s = a+b;
    int t = atoi(s.c_str());
    for(int i=1;i<=1000;++i){
        if(i*i==t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256