akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<lint> b = a;
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    if (a.size() == b.size())
        cout << "YES"
             << "\n";
    else
        cout << "NO"
             << "\n";
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
typedef long long     ll;
#define fast          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define last          freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fr            first
#define sc            second
#define lcm(a,b)      (a*b)/__gcd(a,b)
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
#define endl          '\n'
using namespace std;
int main()
{
     int n,cnt=0;
     cin>>n;
     int a[n+1];
     dom(i,n)
     {
          cin>>a[i];
          if(i&1 && a[i]&1)
               cnt++;
     }
     cout << cnt << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    string S;
    cin>>S;
    map<string,int> num;
    num["SUN"]=7;
    num["MON"]=6;
    num["TUE"]=5;
    num["WED"]=4;
    num["THU"]=3;
    num["FRI"]=2;
    num["SAT"]=1;
    
   cout<<num[S]<<endl;
}




Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=1&&x<=n&&y>=1&&y<=m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  while(cin >> n >> m && m) {
    int x=1,y=1,k=1;
    string s;
    while(R s) {
      if(s=="STOP") break;
      else if(s=="RIGHT") k=(k+1)%4;
      else if(s=="LEFT") k=(k+3)%4;
      else {
        int d;
        R d;
        rep(i,d) {
          int xx=x,yy=y;
          if(s[0]=='F') xx+=dx[k],yy+=dy[k];
          else xx-=dx[k],yy-=dy[k];
          if(!check(n,m,xx,yy)) break;
          x=xx,y=yy;
        }
      }
    }
    pr(x,y);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 1220
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef pair< int , int > pi;
typedef set< int > se;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define Fn 1.618033987
int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin>>T;
    int a=0;int r=0;int t=0;int w=0;
    while(T-- >0)
    {
        string s;
        cin>>s;
        if(s.compare("AC")==0)
        {
            ++a;
        }
        if(s.compare("WA")==0)
        {
            ++w;
        }
        if(s.compare("RE")==0)
        {
            ++r;
        }
        if(s.compare("TLE")==0)
        {
            ++t;
        }
    }
    cout<<"AC x "<<a<<"\nWA x "<<w<<"\nTLE x "<<t<<"\nRE x "<<r<<"\n";
    return 0; 
}

Measured memory_bytes: 3604
n,m,x = map(int,input().split())
A = [[] for _ in range(n)]
for i in range(n):
    A[i] = list( map(int,input().split()) )
    
flag = 0
min_charge = 10**7

for i in range(2**n):
    which = format(i, '#020b')[-n:]
    
    #print(which,end = ':')
    
    charge = 0
    skill = [0 for _ in range(m)]
    for j in range(n):
        if which[j]=='1':
            charge += A[j][0]
            for k in range(m):
                skill[k]+=A[j][k+1]
    flag_skill = 1
    for l in range(m):
        if skill[l] < x:
            flag_skill = 0
    
    
    #print(skill,end=':')
    #print(charge,end=':')    
    
    if flag_skill ==1:
        min_charge = min(min_charge,charge)
    
    #print(flag_skill)

if min_charge == 10**7:
    print(-1)
else:
    print(min_charge)

Measured memory_bytes: 9248
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define INF 1050000000;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main() //input->compute->output
{
        int N, K;
        cin >> N >> K;
        vector<int> h(N);
        rep(i, N)
        {
                cin >> h[i];
        }

        int dp[100000 + 100];
        rep(i, 100100)
        {
                dp[i] = INF;
        }
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
                rep2(j, 1, K+1)
                {
                        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
                }
        }

        cout << dp[N - 1] << endl;
        return 0;
}

Measured memory_bytes: 1024
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $cnt = array_fill(0, 100000, 0);
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));  
  for ($i=0; $i<$n; $i++) {
    $cnt[$a[$i]]++;
  }

  $cntcnt = count($cnt);

  $ans = $cnt[0] + $cnt[1] + $cnt[2];
  $sum = $ans;
  for ($i=3; $i<$cntcnt; $i++) {
    $sum += $cnt[$i];
    $sum -= $cnt[$i-3];
    $ans = max($ans, $sum);
  }

  echo $ans;

Measured memory_bytes: 28832
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#define INF 1e8
using namespace std;
int w,h,s;
int sx,sy,gx,gy;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct data{
	int f,x,y,bit;
	data(){}
	data(int ff,int xx,int yy,int bbit){
		f=ff;
		x=xx;
		y=yy;
		bit=bbit;
	}
};

int dp[2][51][51][1<<10];
int fie[51][51];
int change[11][51][51];
int where[1<<10][51][51];
int bfs(){
	for(int i=0;i<2;i++){
		for(int j=0;j<=50;j++){
			for(int k=0;k<=50;k++){
				for(int l=0;l<(1<<s);l++){
					dp[i][j][k][l]=INF;
				}
			}
		}
	}
	queue<data> que;
	que.push(data(0,sx,sy,0));
	dp[0][sx][sy][0]=0;
	while(que.size()){
		data q=que.front();
		que.pop();
		if(q.x==gx && q.y==gy)return dp[q.f][q.x][q.y][q.bit];
		for(int i=0;i<4;i++){
			int nx=q.x+dx[i],ny=q.y+dy[i];
			if(nx>=0 && nx<w && ny>=0 && ny<h){
				if(fie[nx][ny]==-1)continue;
				if(where[q.bit][nx][ny]!=q.f && fie[nx][ny]!=-2)continue;
				if(dp[q.f][nx][ny][q.bit]==INF){
					dp[q.f][nx][ny][q.bit]=dp[q.f][q.x][q.y][q.bit]+1;
					que.push(data(q.f,nx,ny,q.bit));
				}
			}
		}
		if(fie[q.x][q.y]==-2){
			if(dp[1-q.f][q.x][q.y][q.bit]==INF){
				dp[1-q.f][q.x][q.y][q.bit]=dp[q.f][q.x][q.y][q.bit]+1;
				que.push(data(1-q.f,q.x,q.y,q.bit));
			}
		}
		if(fie[q.x][q.y]>=0 && fie[q.x][q.y]<=19){
			int nbit=q.bit^(1<<(fie[q.x][q.y]%10));
			if(dp[where[nbit][q.x][q.y]][q.x][q.y][nbit]==INF){
				dp[where[nbit][q.x][q.y]][q.x][q.y][nbit]=dp[q.f][q.x][q.y][q.bit]+1;
				que.push(data(where[nbit][q.x][q.y],q.x,q.y,nbit));
			}
		}
	}
	return -1;
}

int main(void){
	scanf("%d %d",&w,&h);
	for(int i=0;i<h;i++){
		string str;
		cin >> str;
		for(int j=0;j<w;j++){
			if(str[j]=='#')fie[j][i]=-1;
			if(str[j]=='|')fie[j][i]=-2;
			if(str[j]=='%'){
				sx=j,sy=i;
				fie[j][i]=-3;
			}
			if(str[j]=='&'){
				gx=j,gy=i;
				fie[j][i]=-4;
			}
			if(str[j]>='a' && str[j]<='j'){
				fie[j][i]=str[j]-'a';
			}
			if(str[j]>='A' && str[j]<='J'){
				fie[j][i]=str[j]-'A'+10;
			}
			if(str[j]=='_')fie[j][i]=-5;
			if(str[j]=='^')fie[j][i]=-6;
		}
	}
	scanf("%d",&s);
	for(int i=0;i<s;i++){
		for(int j=0;j<h;j++){
			string str;
			cin >> str;
			for(int k=0;k<w;k++){
				if(str[k]=='#')change[i][k][j]=-1;
				if(str[k]=='|')change[i][k][j]=-2;
				if(str[k]=='*')change[i][k][j]=1;
				if(str[k]=='.')change[i][k][j]=0;
			}
		}
	}
	for(int i=0;i<(1<<s);i++){
		for(int j=0;j<h;j++){
			for(int k=0;k<w;k++){
				if(fie[k][j]>=10 || fie[k][j]==-6)where[i][k][j]=1;
				else where[i][k][j]=0;
			}
		}
		for(int j=0;j<s;j++){
			if(!(i>>j & 1))continue;
			for(int k=0;k<h;k++){
				for(int l=0;l<w;l++){
					if(change[j][l][k]==1)where[i][l][k]=1-where[i][l][k];
				}
			}
		}
	}
	printf("%d\n",bfs());
	return 0;
}

Measured memory_bytes: 33156
s = input()
ss = s[0:len(s)-1]

#print (ss)
for i in range(len(ss)):
    chrnum = int(len(ss))- i
    #print (chrnum)
    if chrnum % 2 == 0:
        #print (ss[0:int(chrnum/2)], end=' ')
        #print (ss[int(chrnum/2) : chrnum])
        if ss[0:int(chrnum/2)] == ss[int(chrnum/2) : chrnum]:
            print (chrnum)
            exit()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    static int n;
    static int W;
    static long[][] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        W = sc.nextInt();
        dp = new long[n + 1][1000 * n + 1];
        for (int i = 0; i < n+1; i++) {
            for (int j = 1; j < dp[i].length; j++) {
                dp[i][j] = Integer.MAX_VALUE;
            }
        }
        for (int i = 0; i < n; i++) {
            int w = sc.nextInt();
            int v = sc.nextInt();
            for (int j = 0; j < v; j++) {
                dp[i + 1][j] = dp[i][j];
            }
            for (int j = v; j < dp[0].length; j++) {
                dp[i + 1][j] = Math.min(dp[i][j], dp[i][j - v] + w);
            }


        }
        int max = 0;
        for (int i = 0; i < dp[n].length; i++) {
            if (dp[n][i] <= W) max = i;
        }
        System.out.println(max);
    }

}


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

using namespace std;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int n_of_1 = 0, n_of_2 = 0, n_of_3 = 0;
  int p;
  while (cin >> p) {
    if (p <= A)
      ++n_of_1;
    else if (A + 1 <= p && p <= B)
      ++n_of_2;
    else if (B + 1 <= p)
      ++n_of_3;
  }
  int res = 100;
  res = min(res, n_of_1);
  res = min(res, n_of_2);
  res = min(res, n_of_3);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u128, u128) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u128> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, k) = input_tuple();
    let mut half_count = 0u128;
    let mut zero_count = 0u128;
    for i in 1..(n+1) {
        if i % k == 0 {
            zero_count += 1;
        }
        if k % 2 == 0 && (i % k) == (k / 2) {
            half_count += 1;
        }
    }
    // println!("{} {}", zero_count, half_count);
    println!("{}", zero_count * zero_count * zero_count + half_count * half_count * half_count);
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
char a[15];
char b[25];
char c[15];
int main()
{
    scanf("%s %s %s",a,b,c);
    int x,y,z;
    x=strlen(a);
    y=strlen(b);
    z=strlen(c);
    if(a[x-1]==b[0]&&b[y-1]==c[0])
        printf("YES\n");
    else
        printf("NO\n");
}


Measured memory_bytes: 256
from collections import defaultdict

N, K = map(int, input().split())
MOD = 10**9 + 7

def partition_num(n, k, mod):
    partition = {i: defaultdict(int) for i in range(n + 1)}
    for j in range(1, k+1):
        partition[0][j] = 1
    for i in range(1, n+1):
        partition[i][1] = 1
        for j in range(2, k+1):
            if i - j >= 0:
                partition[i][j] = (partition[i][j - 1] + partition[i - j][j]) % mod
            else:
                partition[i][j] = partition[i][j - 1] % mod
    return partition
if N-K >= 0:
    p = partition_num(N-K, K, MOD)
    ans = p[N-K][K]
else:
    ans = 0
print(ans)


Measured memory_bytes: 20948
# Aizu Problem ITP_1_6_C: Official House
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


building = {b: [[0] * 10, [0] * 10, [0] * 10] for b in range(1, 5)}

N = int(input())
for k in range(N):
    b, f, r, v = [int(_) for _ in input().split()]
    building[b][f-1][r-1] += v

for b in range(1, 5):
    for level in building[b]:
        print(' ' + ' '.join([str(l) for l in level]))
    if b < 4:
        print('#' * 20)

Measured memory_bytes: 7804
#include <bits/stdc++.h>
using namespace std;
int main(){
  int R,G,B,N; cin>>R>>G>>B>>N;
  int ans=0;
  for(int i=0;;i++){
    int count=N;
    if(count<R*i)break;
    count-=R*i;
    for(int j=0;;j++){
      int coun=count;
      if(count<G*j)break;
      coun-=G*j;
      if(coun%B==0)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}

/*		START		*/
$S=getq(1);
if($S[0]<=$S[2]&&$S[0]+$S[1]>=$S[2]){
	echo "YES\n";
}else{
	echo "NO\n";
}
?>

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void) {
  bool prime[60000];
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (int i = 2; i * i <= 50100; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j <= 50100; j += i) {
        prime[j] = false;
      }
    }
  }

  int n;
  while (cin >> n) {
    for (int i = n - 1; i >= 2; --i)
      if (prime[i]) {
        cout << i << " ";
        break;
      }
    FOR(i, n + 1, 51000) if (prime[i]) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3120
package main

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

type Vector struct {
	v []int
}

func NewVector() Vector {
	return Vector{make([]int, 0)}
}

func (v *Vector) PushBack(x int) {
	v.v = append(v.v, x)
}

func (v *Vector) Dump(w *bufio.Writer) {
	w.WriteString(v.String())
	w.WriteString("\n")
}

func (v *Vector) Clear() {
	v.v = v.v[:0]
}

func (v Vector) String() string {
	var b bytes.Buffer
	lenv := len(v.v)
	for i := 0; i < lenv; i++ {
		b.WriteString(fmt.Sprintf("%d", v.v[i]))
		if i < lenv-1 {
			b.WriteString(" ")
		}
	}
	return b.String()
}

func NextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)

	n, _ := NextInt(sc)
	v := make([]Vector, n)
	for i := 0; i < n; i++ {
		v[i] = NewVector()
	}

	q, _ := NextInt(sc)
	for i := 0; i < q; i++ {
		cmd, _ := NextInt(sc)
		t, _ := NextInt(sc)
		switch cmd {
		case 0:
			x, _ := NextInt(sc)
			v[t].PushBack(x)
		case 1:
			v[t].Dump(w)
		case 2:
			v[t].Clear()
		}
	}

	w.Flush()
}



Measured memory_bytes: 24024
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;

const int MAXN = 100010;
int n, a[MAXN], L;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x * f;
}

int main() {
	int i, j;
	n = read(), L = read();
	for(i = 1; i <= n; i++) a[i] = read();
	for(i = 1; i < n; i++) 
		if(a[i]+a[i+1] >= L) break;
	if(i == n) {
		printf("Impossible\n");
		return 0;
	}
	printf("Possible\n");
	for(j = 1; j < i; j++) printf("%d\n", j);
	for(j = n-1; j > i; j--) printf("%d\n", j);
	printf("%d\n", i);
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){

	int cnt, N, W, value, weight, v[1001][1001], w[1001][1001];

	cnt = 0;

	while(1){
		cin >> W;
		if(W == 0) break;
		
		cnt++;
		cin >> N;

		for(int i=0; i<=N; i++){
			v[0][i] = 0;
			w[0][i] = 0;
		}
		
		for(int i=1; i<=N; i++){
			scanf("%d, %d", &value, &weight);
			for(int j=0; j<=W; j++){
				if(weight > j){
					v[i][j] = v[i-1][j];
					w[i][j] = w[i-1][j];
				}
				else {
					if(v[i-1][j] < v[i-1][j-weight] + value || (v[i-1][j] == v[i-1][j-weight] + value && v[i-1][j] > w[i-1][j-weight] + weight)){
						v[i][j] = v[i-1][j-weight] + value;
						w[i][j] = w[i-1][j-weight] + weight;
					}
					else {
						v[i][j] = v[i-1][j];
						w[i][j] = w[i-1][j];
					}
				}
			}
		}

		cout << "Case " << cnt << ":" << endl;
		cout << v[N][W] << endl;
		cout << w[N][W] << endl; 
		
	}

	return 0;

}

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

namespace ABC152B
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if (a <= b)
            {
                for (int i=1;i<=b;i++){ Console.Write(a); }
            }
            else
            {
                for (int i = 1; i <= a; i++) { Console.Write(b); }
            }

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
from collections import deque
if __name__ == "__main__":
    h, w = map(int, input().split())
    grid = []
    for _ in range(h):
        grid.append(input())
    
    white = 0
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                white += 1
    
    qu = deque()
    qu.append(((0, 0), 0))
    
    visited = [[False] * w for _ in range(h)]
    visited[0][0] = True
    ans = -1

    while qu:
        now, dis = qu.pop()
        if now[0] == h-1 and now[1] == w-1:
            ans = white - dis - 1
            break

        if now[0] + 1 < h and grid[now[0] + 1][now[1]] != "#" and not visited[now[0] + 1][now[1]]:
            visited[now[0] + 1][now[1]] = True
            qu.appendleft(((now[0] + 1, now[1]), dis + 1))
        
        if now[0] - 1 >= 0 and grid[now[0] - 1][now[1]] != "#" and not visited[now[0] - 1][now[1]]:
            visited[now[0] - 1][now[1]] = True
            qu.appendleft(((now[0] - 1, now[1]), dis + 1))

        if now[1] + 1 < w and grid[now[0]][now[1] + 1] != "#" and not visited[now[0]][now[1] + 1]:
            visited[now[0]][now[1] + 1] = True
            qu.appendleft(((now[0], now[1] + 1), dis + 1))
        
        if now[1] - 1 >= 0 and grid[now[0]][now[1] - 1] != "#" and not visited[now[0]][now[1] - 1]:
            visited[now[0]][now[1] - 1] = True
            qu.appendleft(((now[0], now[1] - 1), dis + 1))
    print(ans)

Measured memory_bytes: 3316
K,N=map(int,input().split())
A=list(map(int,input().split()))
a=[]
for i in range(N):
    if i==0:
        a.append(A[i]+K-A[N-1])
    else:
        a.append(A[i]-A[i-1])

print(K-max(a))

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

long long n;

int main(){
    cin >> n;

    cout << 50 << endl;

    for(int i=0;i<50;i++){
        if(i)   cout << ' ';
        cout << 49-i+(n+49-i)/50;
    }

    return 0;
}


Measured memory_bytes: 256
n,a,b,c = map(int,input().split())
li = []
ans=10000000000

for i in range(n):
    li.append(int(input()))

def search(depth,ho):
    if(depth == n):
        
        global ans
        acn=0
        bcn=0
        ccn=0
        alo=0
        blo=0
        clo=0
        for i in range(n):
            if(ho[i] == 1):
                acn += 1
                alo += li[i]
            elif(ho[i] == 2):
                bcn += 1
                blo += li[i]
            elif(ho[i] == 3):
                ccn += 1
                clo += li[i]
        if(acn==0 or bcn==0 or ccn==0):
            return
        ans = min(ans,abs(a-alo)+(acn-1)*10+abs(b-blo)+(bcn-1)*10+abs(c-clo)+(ccn-1)*10)
        return
    ho.append(0)
    search(depth+1,ho)
    ho.pop(len(ho)-1)
    ho.append(1)
    search(depth+1,ho)
    ho.pop(len(ho)-1)
    ho.append(2)
    search(depth+1,ho)
    ho.pop(len(ho)-1)
    ho.append(3)
    search(depth+1,ho)
    ho.pop(len(ho)-1)
search(0,[])
print(ans)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
    int n;
    double m;
    int a[10000];
    scanf("%d %lf",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    double sum = 0;
    for(int k=0;k<n;k++){
        sum += a[k];
    }
    double kijun = sum/(4*m);
    int flg = 0;
    for(int j=0;j<n;j++){
        if(a[j] >= kijun){
            flg += 1;
        }
    }
    if(flg>=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a);
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef double db;
const db EPS = 1e-9;
using namespace std;

void dbg() {cout << "\n";}
template<typename T, typename... A> void dbg(T a, A... x) {cout << a << ' '; dbg(x...);}
#define logs(x...) {cout << #x << " -> "; dbg(x);}

int T;

int solve(int n,int x){
	int ans = n;
	int h1 = x, h2 = n-x;
	while(1){
		if(h1 == h2) {ans += h1; break;}
		if(h1 < h2){
			ans += 2*h1;
			h2 -= h1;
		}
		else{
			ans += 2*h2;
			h1 -= h2;
		}
	}
	T = h1;
	return ans;
}

ll gcd(ll x,ll y){
	return y == 0 ? x:gcd(y,x%y);
}

ll n,x;

int main()
{
	scanf("%lld%lld",&n,&x);
	ll ans = (n-1ll)*3ll;
	ll thp = gcd(n,x);
	ans -= (thp-1ll)*3ll;
	printf("%lld\n",ans);
	// rep(n,2,100){
	// 	printf("\n");
	// 	rep(x,1,n-1){
	// 		printf("n:%d, x:%d, gcd:%d, ans:%d\n",n,x,gcd(n,x),solve(n,x));
	// 	}
	// }
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {
    vector<string> v;
    int n;
    int l;

    cin >> n >> l;

    for (int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    for (string str:v) {
        cout << str;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define console
using namespace std;
#ifndef console
ifstream fin("data.in");
ofstream fout("data.out");
#else
#define fin cin
#define fout cout
#endif
#define usain_bolt() (ios_base::sync_with_stdio(false), \
fin.tie(NULL), fout.tie(NULL))
typedef long long ll;
int main()
{
    usain_bolt();
    ll x;
    fin >> x;
    ll p = 100, rez = 0;
    while (p < x)
    {
          p += p / 100;
          ++rez;
    }
    fout << rez;
#ifndef console
    fin.close(), fout.close();
#endif
    return 0;
}


Measured memory_bytes: 3656
a = Array.new 4
a.map!{|b|
	b = Array.new 3
	b.map!{|c|
		c = Array.new 10,0
	}
}

gets.to_i.times{
	d = gets.split.map{|e|e.to_i}
	a[d[0]-1][d[1]-1][d[2]-1] += d[3]
}

a.each_with_index{|b,i|
	b.each{|c| 
		c.each{|d|
			print " "+d.to_s
		}
		puts ""
	} 
	puts "####################" if i != 3
} 

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

int main() {
   int N ;
   cin >> N;
  vector<int> a(N);
  for(int i = 0;i<N;i++) cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  for(int i =0;i<N-1;i++){
    sum += a[i];
  }
  if(a[N-1]>=sum){
    cout << "No" <<endl;
  }else{
    cout << "Yes" <<endl;
  }
       
   
  
 
}
   

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

int main(void)
{
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int u=ty-sy;
    int r=tx-sx;
    string x;
    for(int i=1;i<=u;i++)
    {
        x+='U';
    }
    for(int i=1;i<=r;i++)
    {
        x+='R';
    }
    for(int i=1;i<=u;i++)
    {
        x+='D';
    }
    for(int i=1;i<=r;i++)
    {
        x+='L';
    }
    x+="LU";
     for(int i=1;i<=u;i++)
    {
        x+='U';
    }
    for(int i=1;i<=r;i++)
    {
        x+='R';
    }
    x+="RD";
    x+="RD";
    for(int i=1;i<=u;i++)
    {
        x+='D';
    }
    for(int i=1;i<=r;i++)
    {
        x+='L';
    }
    x+="LU";
    cout <<x<<endl;
   // cout <<x.length()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll N,T,A,t=1,a=1,q;
  cin >> N;
  FOR(i,0,N){
    cin >> T >> A;
    q = max((T+t-1)/T,(A+a-1)/A);
    t = q*T;
    a = q*A;
    cerr << t << " " << a << endl;
  }
  cout << t+a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll h,w;
    cin >> h >> w;
    vector<ll> sp(4,1e5+1);

    sp[0] = (h%3 == 0)?0:w;
    sp[1] = (w % 3 == 0)?0:h;
    FOR(i,1,h){
        vector<ll> stmp;
        stmp.push_back(w*i);
        stmp.push_back((h-i)*(w/2+w%2));
        stmp.push_back((h-i)*(w/2));
        ll smax = *max_element(all(stmp));
        ll smin= *min_element(all(stmp));
        if(smax - smin < sp[2]){
            sp[2] = smax - smin;
        }        
    }

    FOR(i,1,w){
        vector<ll> stmp;
        stmp.push_back(h*i);
        stmp.push_back((w-i)*(h/2+h%2));
        stmp.push_back((w-i)*(h/2));
        ll smax = *max_element(all(stmp));
        ll smin= *min_element(all(stmp));
        if(smax - smin < sp[3]){
            sp[3] = smax - smin;
        }        
    }

    cout << *min_element(all(sp)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;
const ll MOD = 998244353;
int main(int argc, char const *argv[])
{
	fast;
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ll t;cin>>t;ll T=t;
	//while(t--)
	{
		//cout<<"Case #"<<T-t<<": ";
		string s;cin>>s;ll cnt=0;ll ans=0;
		for(auto u:s)
		{
			if(u=='R')cnt++;
			else cnt=0;
			ans=max(ans,cnt);
		}
		cout<<ans;
	}
}

Measured memory_bytes: 3664
# -*- coding: utf-8 -*-
n = int(input())
a = tuple(map(int,input().split()))
#山1に降った雨の量を求める
m1 = 0
for i,v in enumerate(a):
    m1+= v*((-1)**(i%2))
ret = [m1]*n
for i in range(1,len(ret)):
    ret[i]=a[i-1]*2-ret[i-1]
ret = tuple(map(str,ret))
print(" ".join(ret))


Measured memory_bytes: 18456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const ll MOD=998244353;

int N;
string S;
vi vr, vg, vb;
void input(){
	cin>>N;
	cin>>S;
	rep(i,3*N){
		if(S[i]=='R') vr.pb(i);
		if(S[i]=='G') vg.pb(i);
		if(S[i]=='B') vb.pb(i);
	}
}

int ct[3*MAX];
ll ans;
void solve(){
	rep(i,N){
		int x[3];
		x[0]=vr[i];
		x[1]=vg[i];
		x[2]=vb[i];
		int mx=max(vr[i], max(vg[i], vb[i]));
		int mn=min(vr[i], min(vg[i], vb[i]));
		rep(k,3){
			if(x[k]==mx)ct[x[k]]=2;
			else if(x[k]==mn)ct[x[k]]=0;
			else ct[x[k]]=1;
		}
	}
	ans=1;
	rep1(i,N)ans=(ans*i)%MOD;
  	
	ll t1=0, t2=0;
	rep(i,3*N){
		if(ct[i]==0)t1++;
		else if(ct[i]==1){
			ans=(ans*t1)%MOD;
			t1--;
			t2++;
		}
		else{
			ans=(ans*t2)%MOD;
			t2--;
		}
	}
}

void output(){
	cout<<ans<<endl;
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 3324
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    #divisors.sort()
    return divisors

ans = float('inf')
div = make_divisors(N)
for d in div:
    temp = d+N//d-2
    if temp<ans:
        ans = temp
print(ans)

Measured memory_bytes: 39408
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {
	int i, ans = 100, sum, cnt;
	string s;
	cin >> s;
	for (char c = 'a'; c <= 'z'; c++) {
		sum = 0;
		cnt = 0;
		for (i = 0; i < s.size(); i++) {
			if (s[i] == c)
				cnt = 0;
			else {
				cnt++;
				sum = max(sum, cnt);
			}
		}
		ans = min(ans, sum);
	}
	cout << ans << "\n";
	return 0;
}

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

const int N=1e7;

ll v[N+10];

ll a[N+10];


bool compare(string  &a, string &b)
{
     string f=a+b,c=b+a;

     return f<c;
}

int main()
{
    ll a,b;

    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
        else if(a>5)cout<<b/2<<endl;
    else cout<<0<<endl;

}








Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<ll> cnt(n + 1, 0);
  FOR(i, 1, n + 1) {
    if (i >= 1 && s[i - 1] == 'C' && s[i - 2] == 'A') {
      cnt[i] = cnt[i - 1] + 1;
    } else {
      cnt[i] = cnt[i - 1];
    }
  }
  while (q--) {
    ll l, r;
    cin >> l >> r;
    ll ans = cnt[r] - cnt[l - 1];
    if (l >= 2 && s[l - 2] == 'A' && s[l - 1] == 'C') {
      ans--;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001



int main(){
	
	string A;
	cin>>A;
	
	vector<vector<int>> next(A.size()+1,vector<int>(26,A.size()+1));
	{
		vector<int> temp(26,A.size()+1);
		for(int i=A.size()-1;i>=0;i--){
			next[i+1] = temp;
			temp[A[i]-'a'] = i+1;
		}
		next[0] = temp;
	}
	
	vector<int> dis(A.size()+2,Inf);
	dis[0] = 0;
	for(int i=0;i<next.size();i++){
		for(int j=0;j<26;j++){
			int to = next[i][j];
			dis[to] = min(dis[to],dis[i]+1);
		}
	}
	
	vector<vector<bool>> valid_edge(A.size()+1,vector<bool>(26,false));
	vector<bool> valid_vertex(A.size()+2,false);
	valid_vertex.back() = true;
	for(int i=valid_edge.size()-1;i>=0;i--){
		for(int j=0;j<26;j++){
			int to = next[i][j];
			if(!valid_vertex[to])continue;
			if(dis[i]+1==dis[to]){
				valid_vertex[i]=true;
				valid_edge[i][j] = true;
			}
		}
	}
	
	string ans = "";
	int now = 0;
	while(now!=A.size()+1){
		for(int i=0;i<26;i++){
			if(valid_edge[now][i]){
				ans += 'a'+i;
				now = next[now][i];
				break;
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 41860
S = input()
ans = 0
acgt = "AGCT"
for i in range(len(S)):
    count = 0
    if S[i] not in acgt:
        continue
    else:
        count += 1
    for j in range(i + 1, len(S)):
        if S[j] in acgt:
            count += 1
        else:
            break
    ans = max(ans, count)
print(ans)

Measured memory_bytes: 38384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Read, Write, BufWriter};
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

/// http://hama-du-competitive.hatenablog.com/entry/2017/04/22/185540 wo mimashita
fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    let n = get();
    let m: usize = get();
    let q: usize = get();
    let mut pool = Vec::new();
    for i in 0 .. m + q {
        let l: usize = get::<usize>() - 1;
        let r: usize = get::<usize>() - 1;
        pool.push((r, i, l));
    }
    pool.sort();
    let mut ans = vec![0; q];
    let mut seg = vec![0; n];
    for (r, id, l) in pool {
        if id < m {
            seg[l] += 1;
        } else {
            let idx = id - m;
            ans[idx] += seg[l..r+1].iter().sum::<i32>();
        }
    }
    for v in ans { puts!("{}\n", v); }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main(){
  int H,W;
  cin>>H>>W;
  std::vector<string> s(H);
  for(int i=0;i<H;i++)cin>>s[i];
  std::vector<int> v(26,0);
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)v[s[i][j]-97]++;
  int a=0;//奇数
  int b=0;//2mod4
  for(int i=0;i<26;i++){
    if(v[i]%4==2)b++;
    if(v[i]%2)a++;
  }
  int out=0;
  if(H%2&&W%2){
    if(a!=1)out++;
    if(b>(H-1)/2+(W-1)/2)out++;
  }
  else if(a)out++;
  if(H%2==0&&W%2==0)if(b)out++;
  if(H%2&&W%2==0)if(b>W/2)out++;
  if(W%2&&H%2==0)if(b>H/2)out++;
  if(out)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  //cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
from collections import deque
from copy import deepcopy
 
def bfs(pos,map):
      while pos:
        x,y,depth=pos.popleft()
        if map[x][y]=="#":
            continue
        map[x][y]="#"
        if map[x-1][y]!="#":
          pos.append([x-1,y,depth+1])
        if map[x+1][y]!="#":
          pos.append([x+1,y,depth+1])
        if map[x][y+1]!="#":
          pos.append([x,y+1,depth+1])
        if map[x][y-1]!="#":
          pos.append([x,y-1,depth+1])
      return depth
H,W=map(int,input().split())
ans=0
fence=["#"]*(W+2)
field=[fence]
for _ in range(H):
  L=list(input())
  field.append(["#"]+L+["#"])
field.append(fence)
for i in range(1,H+1):
  for j in range(1,W+1):
    if field[i][j]==".": 
      pos=deque([[i,j,0]])
      depth=bfs(pos,deepcopy(field))
      if ans<depth:
        ans=depth
print(ans)

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

typedef long long ll;


int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
    int n;
    ll a[200005],sum;
    ll mod = 1e9+7;

    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        ans = (ans+a[i]*sum)%mod;
        sum += a[i];
        sum %= mod;
    }
    cout << ans;
}


Measured memory_bytes: 5136
#include <iostream>
using namespace std;
int main(void){
    int b1,b2,b3;
    cin>>b1>>b2>>b3;
    if (b1==1&&b2==0&&b3==0){
        cout<<"Close"<<endl;
    }else if(b1==0&&b2==1&&b3==0){
        cout<<"Close"<<endl;
    }else if (b1==1&&b2==1&&b3==0){
        cout<<"Open"<<endl;
    }else if (b1==0&&b2==0&&b3==1){
        cout<<"Open"<<endl;
    }else if (b1==0&&b2==0&&b3==0){
        cout<<"Close"<<endl;
    }
    }
    


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, 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; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll p(n);
  rep(i,n) cin>>p[i], p[i]--;
  vll a(n), b(n);
  rep(i,n){
    a[i]=20000*(i+1);
    b[i]=20000*(i+1);
  }
  reverse(all(b));
  rep(i,n){
    b[p[i]]+=i;
  }
  rep(i,n){
    if(i) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  rep(i,n){
    if(i) cout<<" ";
    cout<<b[i];
  }
  cout<<endl;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 100100
using namespace std;

int main()
{
	int n;
	char s[110], t[110];
	scanf("%d%s%s",&n, s, t);
	for (int i = 0; i < n; i++) {
		printf("%c%c", s[i], t[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	int n,count=1;
	int a;
	int point = 1;
	cin >> n;
	vector<pair<int, int>> pairs(n);
	for (int i = 0;i < n;i++)
	{
		cin >> a;
		pairs[i] = make_pair(a, point);
		point++;
	}
	sort(pairs.begin(), pairs.end());
	for (int i = 0;i < n;i++)
	{
		cout << pairs[i].second<<" ";
	}
	return 0;
}

Measured memory_bytes: 1536
/*
 ALLAH is Almighty....
*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 1000000007
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
#define fans(x) \
    if ( x  ) coul("YES"); \
    else coul("NO")
#define mset(x, y) memset(x, y, sizeof(x))
#define fileshow  freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
 //for sieve function
//void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
//void segPre(ll l, ll h, ll in) {  ll segTree[3*mx];   if ( l == h ){  segTree[ in ] = arr[ l ];   return;  }   ll m = (l + h) / 2; pre(l, m, 2*in);  pre(m+1, h, 2*in+1);    segTree[ in ] = segTree[ in*2 ] | segTree[ in*2+1 ];   segTree[ in ] = segTree[ in*2 ] ^ segTree[ in*2+1 ];    }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1
// Don't use ceil and pow function


ll h1, m1, h2, m2, ne;
string s1, s2;
ll ans, an;
ll ax[ 1050 ];
ll ay[ 1050 ];


start;

    cin5( h1, m1, h2, m2, ne );

    h1++;

    ans = ( h2 - h1 ) * 60 + 60 - m1 + m2 - ne;

    coul( ans );

finish


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            
            var line = Input.Line();
            Console.WriteLine(Sum(line, 1));
        }

        static long Sum(String line, int id) {
            if (id == line.Length) {
                return line.Split('+').Select(long.Parse).Sum();
            }

            return Sum(line.Insert(id, "+"), id + 2) + Sum(line, id + 1);
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define float long double
typedef vector<int> vi;
#define pb push_back

int mod(int a,int b){
    return (a-b)>0?(a-b):(b-a);
}


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int *arr = new int [n];
	for(int i =0 ; i < n ; i++) cin >> arr[i];
	if(n == 1 ) cout << 0;
	else if(n == 2) cout << mod(arr[1],arr[0]);
	else{
        int *temp = new int [n];
        temp[1] = mod(arr[1],arr[0]);
        temp[0] = 0;
        for(int i  = 2 ; i < n ; i++) temp[i] = min(temp[i-1] + mod(arr[i],arr[i-1]),temp[i-2] + mod(arr[i],arr[i-2]));
        cout << temp[n-1] << endl;
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char a;
    int b[30];
  for(int i=0;i<30;i++){
    b[i]=0;
  }
    while(cin>>a){
        if(islower(a)){
            b[a-'a']++;
        }
        if(isupper(a))b[a-'A']++;
    }
    for(char i='a';i<='z';i++){
     cout<<i<<" : "<<b[i-'a']<<endl;
    }
}


Measured memory_bytes: 3084