akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>

#define N 1000000L
bool num[N];

void furui(void){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0L] = false;
  num[1L] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = (long int) divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0;(c = getchar()) != EOF ;i++){

      if(c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    if(c == EOF) break;
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == true) count++;
    }
    std::cout << count << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2108
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int n = sc.nextInt();
		long dam = 0;
		for (int i = 0; i < n; i++)
			dam += sc.nextLong();
		if (dam >= h)
			out.print("Yes");
		else
			out.print("No");

		
	}
}

Measured memory_bytes: 48516
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC106_1 solver = new ABC106_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC106_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int ans = (in.nextInt() - 1) * (in.nextInt() - 1);
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
void read(T&);
template<class T>
void write(const T&);

typedef long long ll;
typedef unsigned long long ull;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
const int N = 200005;

int a[N];
int n;
int ans;

int main () {
  read(n);
  int now = iinf;
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
    if (a[i] > now) {
      ++ans;
    } else {
      now = a[i];
    }
  }
  write(n - ans), EL;
  return 0;
}

template<class T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template<class T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int h[101];
    cin>>n;
    for(int i=0;i<n;i++) cin>>h[i];
    int mn=h[0];
    int sum=1;
    for(int i=1;i<n;i++){
        if(mn>h[i]) continue;
        sum++;
        mn=max(mn,h[i]);
    }
    cout<<sum<<endl;
    return 0;
}



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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  const int n = 13;
  vector<ll> dp(n);
  dp[0] = 1;

  ll mul = 1;
  for (int i = int(s.size()) - 1; i >= 0; i--) {
    vector<ll> next_dp(n);
    auto c = s[i];
    if(c == '?'){
      for (int k = 0; k < 10; k++) {
        for (int j = 0; j < n; j++) {
          next_dp[(k * mul + j) % n] += dp[j];
          next_dp[(k * mul + j) % n] %= MOD;
        }
      }
    }else{
      int k = int(s[i] - '0');
      for (int j = 0; j < n; j++) {
        next_dp[(k * mul + j) % n] += dp[j];
        next_dp[(k * mul + j) % n] %= MOD;
      }
    }
    mul *= 10;
    mul %= n;
    dp = next_dp;
  }
  cout << dp[5] << endl;

}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    agc007a()
}

private var roots: List<BooleanArray>? = null
private var h: Int? = null
private var w: Int? = null


fun agc007a() {
    readLine()!!.split(" ").map { it.toInt() }.let {
        h = it[0]
        w = it[1]
    }
    roots = (1..h!!).map { readLine()!!.map { it == '#' }.toBooleanArray() }

    dfs(0, 0)
    val answer = roots!!.all { booleans -> booleans.all { !it } }
        .let { if (it) "Possible" else "Impossible" }

    println(answer)
}

private fun dfs(x: Int, y: Int): Boolean {
    if (x >= w!! || y >= h!!) return false

    return if (roots!![y][x]) {
        return if (x == w!! - 1 && y == h!! - 1) {
            roots!![y][x] = false
            true
        } else {
            if (dfs(x + 1, y) || dfs(x, y + 1)) {
                roots!![y][x] = false
                true
            } else false
        }
    } else false
}


Measured memory_bytes: 38244
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)

int compint(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int p[1002];
  rep(i,n){
    scanf("%d",&p[i]);
  }
  qsort(p,n,sizeof(int),compint);
  int sum=0;
  rep(j,k){
    sum+=p[j];
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1744
function main(lines) {
  const N = n();
  const S = s();

  let ans = i = 0;
  while (i < N) {
    if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
      ans++;
      i += 2;
    }
    i++;
  }
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

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

const int MAX = 100;

double abs(double n) {
	return n >= 0 ? n : -n;
}
int main() {
	int N, a[MAX];
	cin >> N;
	int sum = 0;
	for (int i = 0;i < N;++ i) {
		cin >> a[i];
		sum += a[i];
		a[i] *= N;
	}
	int diff = abs(sum - a[0]);
	int ans = 0;
	for (int i = 0;i < N;++ i) {
		if (diff > abs(sum - a[i])) {
			ans = i;
			diff = abs(sum - a[i]);
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

平均値求めて、差が最小になるの選んでいくだけ
誤差が怖いので全てをN倍しておくことで、誤差が消滅するよ
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
bool f(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b){
    return a.second.second<b.second.second;
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,pair<int,int>>> vc(m);
    rep(i,0,m){
        cin>>vc[i].first;
        cin>>vc[i].second.first;//ここの値を変更
        vc[i].second.second=i;//出力の順番
    }
    sort(vc.begin(),vc.end());
    int num=vc[0].first,c=1;
    rep(i,0,m){
        if(vc[i].first==num){
            vc[i].second.first=c;
            c++;
        }else{
            num=vc[i].first;
            c=2;
            vc[i].second.first=1;
        }
    }
    sort(vc.begin(),vc.end(),f);
    rep(i,0,m){
        cout<<setfill('0')<<right<<setw(6)<<vc[i].first;
        cout<<setfill('0')<<right<<setw(6)<<vc[i].second.first<<endl;
    }
}

Measured memory_bytes: 2688
a = input().rstrip()
b = input().rstrip()
c = 0

array1 = []
array2 = []

for i in range(len(a)):
    array1.append(a[i])


for j in range(len(b)):
    array2.append(b[j])


for z in range(len(a)):
    if a[z] == b[z]:
        c = c
    else:
        c = c +1

print(c)

Measured memory_bytes: 12540
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#define int long long
#define uint unsigned long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

signed main()
{
	int N;
	cin >> N;
	vector<int> A;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		A.push_back(a);
	}
	SORT(A);

	int ans = 0;
	int sum = 0;
	for (int i = 0; i < N - 1; i++)
	{
		sum += A[i];
		if (sum * 2 >= A[i + 1])
		{
			ans++;
		}
		else
		{
			ans = 0;
		}
	}
	ans++;
	cout << ans << endl;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main(void){
    
    int A, B, C;
    int max_flag;
    
    cin >> A >> B >> C;
    
    if(A >= B && A >= C){
        
        max_flag = 1;
        
    }
    else if(B >= A && B >= C){
        
        max_flag = 2;
        
    }
    else{
        
        max_flag = 3;
        
    }
    
    if(max_flag == 1) cout << 10 * A + B + C << endl;
    else if(max_flag == 2) cout << 10 * B + A + C << endl;
    else cout << 10 * C + A + B << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define timeKyaHorhaH 1.0 * clock() / CLOCKS_PER_SEC

#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define MEM(a,val) memset(a,val,sizeof(a));
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
//DEBUGGER------------------------------------------------------------------------
// #define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
// #define DEBUGON
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point

vector<string> vec_splitter(string s) {
	for(char& c: s) c = c == ',' ?  ' ': c;
	stringstream ss; ss << s;
	vector<string> res;
	for(string z; ss >> z; res.push_back(z));
	return res;
}

void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
	void debug_out(vector<string> args, int idx, Head H, Tail... T) {
		if(idx > 0) cerr << ", ";
		stringstream ss; ss << H;
		cerr << args[idx] << " = " << ss.str();
		debug_out(args, idx + 1, T...);
	}

#ifdef DEBUGON
	#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);
	#define DEBUG(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);	
#else
	#define debug(...) 320;
	#define DEBUG(...) 320;
#endif

lld power(lld b, lld e)
{
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) 
		n*=-1;
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

#define endl '\n'
#define mod 1000000007

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

void swagWaalaFunction()
{
	lld s,w;
	cin>>s>>w;
	cout<<((w>=s)?"unsafe":"safe");
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	while(t--)
 		swagWaalaFunction();
	
	// cerr<<"\n"<<timeKyaHorhaH; 	
 	return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
LL n,m,k;
char s[10][10];
int main()
{
	n=read();
	m=read();
	k=read();
	for(int i=0;i<n;++i)
		scanf("%s",s[i]);
	int ans=0;
	for(int i=0;i<(1<<n);++i){
		for(int j=0;j<(1<<m);++j){
//			printf("%d %d\n",i,j);
			int conn=0;
			for(int k=0;k<n;++k){
				if((i>>k)&1)
					continue;
				for(int l=0;l<m;++l){
					if((j>>l)&1)
						continue;
//					printf("%d %d\n",k,l);
					if(s[k][l]=='#')
						++conn;
				}
			}
			if(conn==k)
				++ans;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3760
#include<cstdio> 
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
#include<vector>
#include<string>
#define ms(i, j) memset(i, j, sizeof i)
#define LL long long
#define db double
#define fir first
#define sec second
#define mp make_pair
using namespace std;

namespace flyinthesky {
	
	LL A, B;

	LL get(LL x) {
		if (x % 4ll == 0ll) return x;
		if (x % 4ll == 1ll) return 1ll;
		if (x % 4ll == 2ll) return x + 1ll;
		if (x % 4ll == 3ll) return 0ll;
	}

    void clean() {
    }
    int solve() {
		
    	clean();
    	cin >> A >> B;
    	if (A == 0) cout << get(B); else
    	cout << (get(A - 1ll) ^ get(B));
    	
        return 0;
    } 
}
int main() {
	flyinthesky::solve();
    return 0;
}
//16:05-
/*
*/

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"
#define Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything 42

signed main(){
	cout<<fixed<<setprecision(7);
	
	int x, y;
	cin>>x>>y;
	
	cout<<(x+y+1)/2<<endl;
	
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int su=0;
  vector<int>t(n);
  for(int i=0;i<n;i++){
    cin >> t.at(i);
    su+=t.at(i);
  }
  int m,a,b;
  cin >> m;
  vector<int>yaku(m);
  for(int i=0;i<m;i++){
    cin >> a >> b;
    yaku.at(i)=t.at(a-1)-b;
  }
  for(int i=0;i<m;i++)
    cout << su-yaku.at(i) << endl;
  exit(0);
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll mod = 1e9 + 7;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

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

  mint all(1);
  rep(i, n) all *= 10;

  mint ng(1);
  rep(i, n) ng *= 8;

  mint one(1);
  rep(i, n) one *= 9;
  one = all - one;

  mint wa = all - ng;

  mint ans = (one * 2 - wa);
  cout << ans << endl;
}


Measured memory_bytes: 3628
while True:
  n = int(input())
  if n==0:
    break
  if n==1:
    print(int(input()))
    continue

  op = "+*"
  f = [input() for i in range(n)]
  f = f[::-1]
  stack = []

  for i in range(n):
    if f[i][-1] not in op:
      stack.append(f[i])
    else:
      nest = f[i].count(".")
      if f[i][-1]=="*":
        cur = 1
        while len(stack):
          if stack[-1].count(".")!=nest+1:
            break
          else:
            t = stack.pop().strip(".")
            cur *= int(t)
        stack.append("."*(nest)+str(cur))
      else:
        cur = 0
        while len(stack):
          if stack[-1].count(".")!=nest+1:
            break
          else:
            t = stack.pop().strip(".")
            cur += int(t)
        stack.append("."*(nest)+str(cur))
  print(stack[0])


Measured memory_bytes: 5608
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		x: usize,
	}

	println!("{}", 8 - ((x - 400) / 200));


	// if x < 600 {
	// 	println!("8");
	// 	return;
	// } 
	// if x < 800 {
	// 	println!("7");
	// 	return;
	// } 
	// if x < 1000 {
	// 	println!("6");
	// 	return;
	// } 
	// if x < 1200 {
	// 	println!("5");
	// 	return;
	// } 
	// if x < 1400 {
	// 	println!("4");
	// 	return;
	// } 
	// if x < 1600 {
	// 	println!("3");
	// 	return;
	// } 
	// if x < 1800 {
	// 	println!("2");
	// 	return;
	// } 
	// println!("1");
}



Measured memory_bytes: 2148
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = a+b, right = c+d;
    if(left > right){
        cout << "Left";
    }
    else if(left < right){
        cout << "Right";
    }
    else
    {
        cout << "Balanced";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
s = input()
# ans = 0
# DNA = ['A', 'C', 'G', 'T']
# count = 0
# for i in range(len(s)):
#     c = s[i]
#     if c in DNA:
#         count += 1
#     else:
#         ans = max(ans, count)
#         count = 0
#     if i == len(s) - 1:
#         ans = max(ans, count)
# print(ans)

N = len(s)
ans = 0
for i in range(N):
    for j in range(i, N):
        # if all(c in ['A', 'G', 'C', 'T'] for c in s[i : j + 1]):
        if all('ACGT'.count(c) for c in s[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

ll abc(ll a, ll b) {
    ll tmp;
    ll ans = a * b;
    if(a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    
    ll r = a % b;
    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    
    return ans / b;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ll wide = b - a + 1;
    ll tmp = abc(c, d);
    
    ll small = b / c - ((a % c == 0) ? (a / c) : (a / c) + 1) + 1;
    ll large = b / d - ((a % d == 0) ? (a / d) : (a / d) + 1) + 1;
    ll mix = b / tmp - ((a % tmp == 0) ? (a / tmp) : (a / tmp) + 1) + 1;
    
    cout << wide - (small + large - mix) << endl;
    
    return 0;
}



Measured memory_bytes: 256
while True:
    H, W = [int(i) for i in input().split()]
    if H == 0 and W == 0:
        break

    for i in range(H):
        for j in range(W):
            if i == 0 or j == 0 or i == H - 1 or j == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print('')
    print('')

Measured memory_bytes: 9140
import java.util.Scanner;

public class Main {
	
	public static void main( String[]args ){
		
		Scanner sc = new Scanner( System.in );
		
		int n = sc.nextInt();
		int l = sc.nextInt();
		 
		int p_number = 0;//ロープのほどく可能ナンバー
		int b = 0;//一個前のロープの長さ
		boolean l_flag = false; // ここがfalseだったらほどけないということ
		for( int i = 0;i < n;i++ ){
			
			int a = sc.nextInt();
			if( i == 0 && !l_flag ){
				if( a == l ){
					l_flag = true;
					p_number = i;
					break;
				}
			}else if( !l_flag ){
				
				if( l > a + b )
					l_flag = false;
				else{
					l_flag = true;
					p_number = i;
					break;
				}
			}
			b = a;
		}
		
		if( l_flag ){
			System.out.println("Possible");
			
				for( int i = n - 1;i > p_number;i-- )
					System.out.println(i);
				for( int i = 1;i <= p_number;i++ )
					System.out.println(i);
		
		}else{
			System.out.println("Impossible");
		}
		
	}

}

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

int main() {
  int n,m;
  cin >> n >> m;
  map<string,int> ma;
  for(int i=0; i<n; i++) {
    string s;
    cin >> s;
    ma[s]++;
  }
  set<string> se;
  vector<string> ans;
  string z="";
  for(map<string,int>::iterator it=ma.begin(); it!=ma.end(); it++) {
    string s=it->first;
    if(se.count(s)) continue;
    string t=s;
    reverse(t.begin(),t.end());
    if(s==t) {
      if(ma[s]%2&&z=="") z=s;
      for(int i=0; i<ma[s]/2; i++) ans.push_back(s);
    } else for(int i=0; i<min(ma[s],ma[t]); i++) ans.push_back(s);
    se.insert(t);
  }
  for(int i=0; i<ans.size(); i++) cout << ans[i];
  cout << z;
  for(int i=ans.size()-1; i>=0; i--) {
    reverse(ans[i].begin(),ans[i].end());
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3516
#include <iostream>
#include <string>
#include <vector>
#include <stack>

using namespace std;

int main(int argc, char **argv) {
    int N, M, K;
    cin >> N >> M >> K;

    //  vector<pair<int, int>> friendships, blockships;

    vector<vector<int>> blocks(N + 1);
    vector<vector<int>> friends(N + 1);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        //      friendships.push_back({a, b});
        friends[a].push_back(b);
        friends[b].push_back(a);
    }
    for (int i = 0; i < K; i++) {
        int c, d;
        cin >> c >> d;
        //     blockships.push_back({c, d});
        blocks[c].push_back(d);
        blocks[d].push_back(c);
    }


    vector<int> groupLookup; // who is in which group
    vector<int> groupSizes;
    stack<int> stack; // DFS search
    groupLookup.push_back(0); // dummy element to start with 1 indexing
    groupSizes.push_back(0); // dummy element to start with 1 indexing

    for (int i = 1; i <= N; i++) {
        groupLookup.push_back(0); // no assigned group yet
        stack.push(i); // every user unassigned
    }

    int nextGroup = 1;
    while (!stack.empty()) {
        auto s = stack.top();
        stack.pop();
        int currGroup = groupLookup[s];
        if (currGroup == 0) {
            // new group!
            currGroup = nextGroup++;
            groupLookup[s] = currGroup;
            groupSizes.push_back(1);
        }

        for (auto f : friends[s]) {
            if (groupLookup[f] != 0) // already grouped
                continue;
            groupLookup[f] = currGroup;
            groupSizes[currGroup]++;
            stack.push(f);
        }
    }

    for (int i = 1; i <= N; i++) {
        int group = groupLookup[i];
        int size = groupSizes[group];
        for (auto f : friends[i]) {
            if (groupLookup[f] == group)
                size--;
        }
        for (auto b : blocks[i]) {
            if (groupLookup[b] == group)
                size--;
        }
        size--; // don't count self
        cout << size;
        if (i != N) cout << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 13048
import scala.io.StdIn.{readLine,readInt}
 
object Main extends App {
  val seq1 = for(i<-1 to 9) yield List(i,i,i)
  val seq2 = for(i<-1 to 7) yield List(i,i+1,i+2)
 
  def check(m:List[Int], count:Int,u:Int,v:Int):Boolean =  {
    if(m.length != count) false
    else if(count==2) {
      val List(x,y) = m
      if(x==y) true else false
    } else {
      if((u to 8).exists( i=> check(m diff seq1(i),count-3,i+1,v))) {
        true
      } else {
        (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i) )
      }
    }
  }
 
  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toList
    val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14,0,0) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N * 3);
    for (int i = 0; i < N * 3; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    long long ans = 0;
    for (int i = 0; i < N * 2; i += 2) {
        ans += A[i + 1];
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n, g, I;
    cin >> n;
    long long S[n], M=5000000000, p, k, L=0, R=200002, t;
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    while (R - L > 1)
    {
        t = (L + R) / 2;
        g = 1;
        set <long long> Se;
        set <long long> :: iterator it;
        unordered_map <long long, long long> Ma;
        for (int i = 1; i < n; i++)
        {
            it = Se.lower_bound(M-2000000000);
            while (it != Se.end() && M-(*it) >= S[i])
            {
                Ma[M-*it] = 0;
                Se.erase(it);
                it = Se.lower_bound(M-200000000);
            }
            if (S[i] <= S[i-1])
            {
                if (t == 1)
                {
                    g = 0;
                    break;
                }
                I = S[i]-1;
                while (I >= 0 && Ma[I] == t-1)
                {
                    Se.erase(Se.find(M-I));
                    Ma[I] = 0;
                    I--;
                }
                if (I < 0)
                {
                    g = 0;
                    break;
                }
                if (Ma[I] == 0)
                {
                    Se.insert(M-I);
                }
                Ma[I]++;
            }
        }
        if (g == 1)
        {
            R = t;
        }
        else
        {
            L = t;
        }
    }
    cout << R;
    return 0;
}


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

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;

  swap(A, B);
  swap(A, C);

  cout << A << " " << B << " " << C << "\n";

  return 0;
}


Measured memory_bytes: 256
def levenshtein(str1, str2):
    prev_dp = list(range(len(str2) + 1))

    for i1, c1 in enumerate(str1):
        current_dp = [i1 + 1]
        current_dp.extend(min(prev_dp[i2 + 1] + 1, current_dp[i2] + 1, prev_dp[i2] + int(c1 != c2))
                          for i2, c2 in enumerate(str2))
        prev_dp = current_dp

    return prev_dp[-1]


print(levenshtein(input(), input()))

Measured memory_bytes: 7552
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+12
#define PI acos(-1)
using ll = long long;
using ull = unsigned long long;

vector<int> v;
vector<int> c;

int main(){
    double r;
    cin >> r;

    double ans = PI * 2 * r;
    printf("%.12lf", ans);
}


Measured memory_bytes: 3784
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int *stack,int *top,int num){
	(*top)++;
	stack[*top]=num;
}

int pop(int *stack,int *top){
	(*top)--;
	return stack[*top+1];
}

int main(){
	char input[1024],*p;
	int stack[101],top=0,num_1,num_2;
	
	fgets(input,sizeof input,stdin);
	p=strtok(input," ");
	push(stack,&top,atoi(p));
	
	while(1){
		p=strtok(NULL," ");
		
		if(p==NULL){
			break;
		}
		
		switch(*p){
		case '+':
			num_2=pop(stack,&top);
			num_1=pop(stack,&top);
			push(stack,&top,num_1+num_2);
		break;
		
		case '-':
			num_2=pop(stack,&top);
			num_1=pop(stack,&top);
			push(stack,&top,num_1-num_2);
		break;
			
		case '*':
			num_2=pop(stack,&top);
			num_1=pop(stack,&top);
			push(stack,&top,num_1*num_2);
		break;
			
		case '/':
			num_2=pop(stack,&top);
			num_1=pop(stack,&top);
			push(stack,&top,num_1/num_2);
		break;
			
		default:
			push(stack,&top,atoi(p));
		break;
		}
		
	}
	
	printf("%d\n",stack[1]);
	
	return 0;
}

Measured memory_bytes: 528
N,M=map(int,input().split())
MAP=[[] for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    MAP[a].append(b)
    MAP[b].append(a)

import itertools
T=[i+2 for i in range(N-1)]
PMT=list(itertools.permutations(T))
#print(MAP)
#print(PMT)

ans=0
for i in range(len(PMT)):
    t=[1]+list(PMT[i])
    flag=True
    for j in range(N-1):
        if t[j+1] not in MAP[t[j]]:
            flag=False
            break
    if flag:
        #print(t)
        ans+=1

print(ans)

Measured memory_bytes: 3572
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}

void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}

#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

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

void solve() {
    cini(n);
    vvi adj(n);
    for(int i=1; i<n; i++) {
        cini(aux);
        aux--;
        adj[aux].push_back(i);
        adj[i].push_back(aux);
    }

    cout<<adj[0].size()<<endl;
    for(int i=1; i<n; i++)  {
        cout<<adj[i].size()-1<<endl;
    }
}

signed main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
}



Measured memory_bytes: 16284
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

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

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

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

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

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

    let r: usize = sc.input();
    println!("{}", 2. * 3.141569 * r as f64);
}


Measured memory_bytes: 2108
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;


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

	vector<int> l(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> l[i];
	}

	sort(l.begin(), l.end());

	int max = 0;

	for (int i = 0; i < M; ++i)
	{
		max += l[N - i - 1];
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int tail[1000];
int cnt;
int nxt[501010];
int val[501010];
 
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++)tail[i]=i,nxt[i]=-1;
	cnt=n;
	while(q--){
		int t;
		scanf("%d",&t);
		if(t==0){
			int k,x;
			scanf("%d%d",&k,&x);
			val[cnt]=x;
			nxt[tail[k]]=cnt;
			tail[k]=cnt;
			nxt[tail[k]]=-1;
			cnt++;
		}else if(t==1){
			int k;
			scanf("%d",&k);
			int idx=nxt[k];
			if(idx==-1)puts("");
			else{
				while(idx!=-1){
					printf("%d%c",val[idx],nxt[idx]==-1?10:32);
					idx=nxt[idx];
				}
			}
		}else{
			int k,kk;
			scanf("%d%d",&k,&kk);
			nxt[tail[kk]]=nxt[k];
			tail[kk]=tail[k];
			tail[k]=k;
			nxt[k]=-1;
		}
	}
}


Measured memory_bytes: 5720
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=100005;
int main(){
   // freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    LL i,j,n;
    scanf("%lld",&n);
    for (i=1;i<=3500;i++)
        for (j=i;j<=3500;j++){
            LL x=n*i*j,y=(4ll*i*j-n*(i+j));
            if (y<=0||x%y) continue;
            LL c=x/y;
            printf("%lld %lld %lld\n",i,j,c);
            return 0;
        }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	ll gc = 0, rc = 0, bc = 0, ans = 0;
	for (int i = 0;i < N;i++) {
		if (S[i] == 'G')gc++;
		if (S[i] == 'R')rc++;
		if (S[i] == 'B')bc++;
	}
	ans = gc * rc * bc;
	for (int i = 0;i < N;i++) {
		for (int j = i + 1;j < N;j++) {
			int k = j + (j - i);
			if (k >= N)continue;
			if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) {
				ans--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
A = input()
B = input()

import sys
if len(A)>len(B):
    print('GREATER')
    sys.exit()
elif len(A)<len(B):
    print('LESS')
    sys.exit()
else:
    for a,b in zip(A,B):
        if int(a)>int(b):
            print('GREATER')
            sys.exit()
        elif int(a)<int(b):
            print('LESS')
            sys.exit()
print('EQUAL')

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

const int MAXN = 200000+100;
char str[MAXN];
typedef long long ll;
	ll cnt[MAXN];
int main()
{
	scanf("%s",str);
	int Len=strlen(str);
	for(int i=0;i<Len;++i)
	{
		cnt[str[i]-'a']++;
	}
	ll l=Len;
	ll sum=(l-1)*l/2;
	for(int i=0;i<26;i++)	sum-=(cnt[i]*(cnt[i]-1)/2);
	printf("%lld\n",sum+1);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
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;
}
//以上テンプレ
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    ll N,M;
    cin>>N>>M;
    vl yaku=divisor(M);
    reverse(all(yaku));
    rep(i,999999){
        if(yaku.at(i)<=M/N){
            cout<<yaku.at(i)<<endl;
            break;
        }
    }
    }


Measured memory_bytes: 256
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  string s,t;cin>>s>>t;
  cout << t<<s<<endl;
  return 0;
}


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

int main () {
	int n, d, x;
	cin >> n >> d >> x;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}


	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j+=a[i]) {
			sum++;
		}
	}
	sum += x;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

const int N = 2007;

int up[N][N], dwn[N][N], lef[N][N], rig[N][N];
bool f[N][N];

void solve() {
    int n, m;
    cin >> n >> m;
    loop1(i, n) {
        loop1(j, m) {
            char c; cin >> c;
            f[i][j] = c == '#';
            lef[i][j] = (c == '#' ? 0 : lef[i][j - 1] + 1);
            up[i][j] = (c == '#' ? 0 : up[i - 1][j] + 1);
        }
    }
    int ans = 0;
    for (int i = n; i > 0; --i) {
        for (int j = m; j > 0; --j) {
            rig[i][j] = (f[i][j] ? 0 : rig[i][j + 1] + 1);
            dwn[i][j] = (f[i][j] ? 0 : dwn[i + 1][j] + 1);
            ans = max(ans, rig[i][j] + lef[i][j] + up[i][j] + dwn[i][j] - 3);
        }
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 133008
#include<stdio.h>
int main(void){
	int i, x, y, n;
	n = 0;
	for(i=1;i++;){
		scanf("%d %d", &x, &y);
		if(x==0&&y==0){
			break;
		}
		if(x>y){
			n=x;
			x=y;
			y=n;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}


Measured memory_bytes: 2048
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int n = Integer.parseInt(line1[0]);
        int k = Integer.parseInt(line1[1]);
        String line2 = sc.nextLine();
        String[] line3 = line2.split(" ");
        int[] ary = new int[n];
        for(int i = 0; i < n; i++)  ary[i] = Integer.parseInt(line3[i]);
        int count = 0;
        for(int i = 0; i < n; i++){
            if(k <= ary[i]) count++;
        }
        System.out.println(count);
    }
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

class SegmentTree
{
    int N;
    vector<int> ns;

public:
    SegmentTree(const std::string& s) : N(s.size()), ns(2*N, 0)
    {
        for (int i = 0; i < N; ++i)
            ns[N + i] = 1 << (s[i] - 'a');

        for (int i = N - 1; i > 0; --i)
            ns[i] = ns[2*i] | ns[2*i + 1];
    }

    int RSQ(int i, int j)
    {
        // As folhas estão na segunda metade de ns
        int a = i + N, b = j + N;
        int s = 0;

        while (a <= b)
        {
            if (a & 1)                  
                s |= ns[a++];

            if (not (b & 1))
                s |= ns[b--];

            a /= 2;
            b /= 2;
        }

        int bits = 0;

        while (s)
        {
            ++bits;
            s &= (s - 1);
        }

        return bits;
    }

    void update(int i, char c)
    {
        int a = i + N;

        ns[a] = 1 << (c - 'a');

        // Atualiza todos os pais de a
        while (a >>= 1)
            ns[a] = ns[2*a] | ns[2*a + 1];
    }
};

vector<int> solve(const string& S, int Q)
{
    SegmentTree tree(S);
    vector<int> ans;

    for (int i = 0; i < Q; ++i)
    {
        int cmd, a, b;
        string c;

        cin >> cmd;

        switch (cmd) {
        case 1:
            cin >> a >> c;
            tree.update(a - 1, c.front());
            break;

        default:
            cin >> a >> b;
            ans.push_back(tree.RSQ(a - 1, b - 1));
        }
    }
 
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    string S;
    cin >> N >> S;

    int Q;
    cin >> Q;

    auto ans = solve(S, Q);

    for (auto x : ans)
        cout << x << '\n';

    return 0;
}


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

int N, K;


int main(){
	cin >> N >> K;
	int ans =1;
	int count = N;
	while(ans<K && count > 0){
		ans*=2;
		count--;
	}
	while(count > 0){
		ans+=K;
		count--;
	}
	cout << ans << endl;
	return 0;
}


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

#define M 1000003/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;/* your task */ }
int h2(int key){ return 1+key%(M-1);/* your task */ }

int find(char str[]){
    /* your task */
  long long int key,h,i;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i*h2(key))%M;  
  if(strcmp(str,H[h])==0) return 1;
  if(H[h][0]=='\0') return 0;
  }
}
int insert(char str[]){
 long long int key,h,i;
    /* your task */
  key = getKey(str);
 
  for(i=0;;i++){
  h = (h1(key) + i*h2(key))%M;
  if(H[h][0]=='\0'){
    strcpy(H[h],str);
    break;
  } 
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i = 0;i < M;i++){
        H[i][0] = '\0';
    }
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	}
    }
    }
    return 0;
}


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

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < int , int > pp;

const int mod = 1e9 + 7;
const int N   = 1e5 + 5;

ll n,x,y,t,mn=mod;

int main(){
	cin >> n;
	for(;n--;){
		cin >> x >> y;
		if(x > y) mn = min(mn , y);
		t += x;
	}

	cout << (mn == mod ? 0 : t - mn);
	return 0;
}	

Measured memory_bytes: 256