akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.BigInteger;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    while(sc.hasNextBigInteger()){
      BigInteger N = sc.nextBigInteger();
      BigInteger T = sc.nextBigInteger();
      char[] t = sc.next().toCharArray();

      BigInteger calc = N.pow(t[2] - '0');

      for(int i = 6; i < t.length; i += 4){
        calc = calc.add(N.pow(t[i] - '0'));
      }

      calc = calc.multiply(T);

      if(calc.compareTo(new BigInteger("1000000000")) <= 0){
        System.out.println(calc);
      }
      else{
        System.out.println("TLE");
      }
    }
  }
}

Measured memory_bytes: 17412
#ABC065B
N = int(input())
ai = [int(input()) for _ in range(N)]

lightning = 1
count = 1
ok = False
for _ in range(N):
    lightning = ai[lightning-1]
    if lightning == 2:
        print(count)
        ok = True
        break
    else:
        count += 1

if not ok:
    print(-1)


Measured memory_bytes: 7084
#include <iostream>
#include <vector>

using namespace std;
int main(int argc, const char * argv[]) {
    long long int n,m;
    cin >> n >> m;
    long long int ans = 0;
    if(n*2>m){
        ans = m/2;
    }else{
           ans += n;
           long long tempM = m - 2*n;
        ans += tempM/4;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
let arr_of_str s = Array.init (String.length s) (fun i -> s.[i])
let () =
  Scanf.scanf "%d %s" (fun _ s -> arr_of_str s)
  |> Array.fold_left (fun (a,c) o -> if o = 'I' then (max a (c+1), c+1) else (a, c-1)) (0, 0)
  |> fst |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
	int n,count=0;
	string s;
	cin >> n>>s;
	for (int i = 0; i < n-2; i++) {
		if (s[i] == 'A'&&s[i+1]=='B'&&s[i+2]=='C') {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())
X = abs(X)

n_to_move = X // D
  
if K >= n_to_move:
  pre_pos = X % D
  n_move = X // D
    
  n_nokori_move = K - n_move
    
  if n_nokori_move % 2 == 0:
    last_pos = pre_pos
      
  else:
    last_pos = min(abs(pre_pos + D), abs(pre_pos - D))
	
else:
  if X >= 0:
    last_pos = X - K * D
    

print(last_pos)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c;
	for(int i=1;;i=i*10){
		if(b/i==0){
			c=i;
			break;
		}
	}
	int d=a*c+b;
	d=sqrt(d)*1000;
	
	if(d%1000==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  vector<char> a(4);
  rep(i,4){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  if(a.at(0) == a.at(1) && a.at(2) == a.at(3) && a.at(0) != a.at(2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  }


Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    bsum = 0
    ma = a[0]
    if ma < 0:
        ma = -ma
    count = 0
    for aa in a:
        if aa < 0:
            count += 1
            aa = -aa
        bsum += aa
        if aa < ma:
            ma = aa
    if count % 2 == 0:
        print(bsum)
    else:
        print(bsum-2*ma)

Measured memory_bytes: 14412
#include<bits/stdc++.h>
#define int long long
using namespace std;
int mod=1000000007;
int qp(int b,int p)
{
	int ans=1;
	while(p)
	{
		if(p&1) ans=ans*b%mod;
		p>>=1;
		b=b*b%mod;
	}
	return ans%mod;
}
signed main()
{
	int n;
	scanf("%lld",&n);
	printf("%lld",((qp(10,n)-2*qp(9,n)+qp(8,n))%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

int main() {
    int L, R;
    cin >> L >> R;
    if(R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 2020;
    for(ll i = L; i < R; i++) {
        for(ll j = i + 1; j <= R; j++) {
            ans = min((i * j) % 2019, ans);
            if(ans == 0) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  bool student[31];
  int n;
  
  for(int i = 0; i< 31; i++){
    student[i] = 0;
  }

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

  for(int i = 1; i< 31; i++){
    if(student[i] == 0) cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int ruiJ[1002][1002],ruiO[1002][1002],ruiI[1002][1002];
int ruiruiJ[1002][1002],ruiruiO[1002][1002],ruiruiI[1002][1002];
int main(){
    int H,W,N;
    cin>>H>>W>>N;
    string fie[1002];
    for(int i=0;i<H;i++)cin>>fie[i];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(j!=0){
                ruiJ[i][j]+=ruiJ[i][j-1];
                ruiO[i][j]+=ruiO[i][j-1];
                ruiI[i][j]+=ruiI[i][j-1];
            }
            if(fie[i][j]=='J')ruiJ[i][j]++;
            if(fie[i][j]=='O')ruiO[i][j]++;
            if(fie[i][j]=='I')ruiI[i][j]++;
        }
    }
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            if(j!=0){
                ruiruiJ[j][i]+=ruiruiJ[j-1][i];
                ruiruiO[j][i]+=ruiruiO[j-1][i];
                ruiruiI[j][i]+=ruiruiI[j-1][i];
            }
            ruiruiJ[j][i]+=ruiJ[j][i];
            ruiruiO[j][i]+=ruiO[j][i];
            ruiruiI[j][i]+=ruiI[j][i];
        }
    }
    for(int i=0;i<N;i++){
        int a,b,c,d,ansJ=0,ansO=0,ansI=0;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        a--,b--,c--,d--;
        ansJ+=ruiruiJ[c][d];
        ansO+=ruiruiO[c][d];
        ansI+=ruiruiI[c][d];
        if(a!=0){
            ansJ-=ruiruiJ[a-1][d];
            ansO-=ruiruiO[a-1][d];
            ansI-=ruiruiI[a-1][d];
        }
        if(b!=0){
            ansJ-=ruiruiJ[c][b-1];
            ansO-=ruiruiO[c][b-1];
            ansI-=ruiruiI[c][b-1];
        }
        if(a!=0&&b!=0){
            ansJ+=ruiruiJ[a-1][b-1];
            ansO+=ruiruiO[a-1][b-1];
            ansI+=ruiruiI[a-1][b-1];
        }
        printf("%d %d %d\n",ansJ,ansO,ansI);
    }
    return 0;
}

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


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N, Y;
    cin >> N >> Y;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            ll ans = 10000 * i + 5000 * j + 1000 * (N - i -j);
            if(ans == Y && N - i - j >= 0){
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e5 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int N, X, arr[maxn];
signed main()
{
    N = read(), X = read();
    for (ri i = 1; i <= N; ++i) {
        arr[i] = read();
    }
    int sum = 0;
    if (arr[1] > X) {
        sum += arr[1] - X;
        arr[1] = X;
    }
    for (ri i = 2; i <= N; ++i) {
        int tmp = arr[i - 1] + arr[i];
        if (tmp > X) {
            sum += (tmp - X);
            arr[i] -= (tmp - X);
        }
    }
    writeln(sum);
    return 0;
}

Measured memory_bytes: 1024
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <string>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int inf = 1e9;
const ll mod = 1e9 + 7;

int ans = 0;
vector<int> d;

int sumx(int x, int num) {
	for (int i = num; i < d.size(); ++i) {
		ans += x * d[i];
	 }
	if (num + 1 >= d.size()) {

		return 0;
	}

	return sumx(d[num],num+1);
}

int main() {
	int n;
	
	cin >> n;
	rep(i, n) {
		int tako;
		cin >> tako;
		d.push_back(tako);
	}
	int y;
	y = sumx(d[0], 1);

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

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
struct FordFulkerson {
    struct edge {
        int to;
        int cap;
        int rev;
    };

    int V;
    vector<vector<edge>> table;
    vector<bool> visited;

    int dfs(int s, int t, int mn) {
        if (s == t) return mn;
        visited[s] = true;

        for (int i = 0; i < table[s].size(); i++) {
            edge &e = table[s][i];
            if (visited[e.to] || e.cap == 0) continue;
            int diff = dfs(e.to, t, min(mn, e.cap));
            if (diff > 0) {
                e.cap -= diff;
                table[e.to][e.rev].cap += diff;
                return diff;
            }
        }

        return 0;
    }

public:
    FordFulkerson(int v) {
        V = v;
        table.resize(V);
        visited.resize(V);
    }

    void add_edge(int from, int to, int cap) {
        table[from].emplace_back((edge) {to, cap, (int) table[to].size()});
        table[to].emplace_back((edge) {from, 0, (int) table[from].size() - 1});
    }

    int calc(int from, int to) {
        int flow = 0;

        while (true) {
            fill(visited.begin(), visited.end(), false);
            int f = dfs(from, to, INF);
            if (f == 0) break;
            flow += f;
        }

        return flow;
    }
};

signed main() {
    int N;
    cin >> N;

    vector<P> p1(N);
    vector<P> p2(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        p1[i] = P(x, y);
    }
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        p2[i] = P(x, y);
    }

    FordFulkerson ff = FordFulkerson(2 * N + 2);

    for (int i = 1; i <= N; i++) ff.add_edge(0, i, 1);
    for (int i = N + 1; i <= 2 * N; i++) ff.add_edge(i, 2 * N + 1, 1);

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (p1[i].first < p2[j].first && p1[i].second < p2[j].second) ff.add_edge(i + 1, 1 + N + j, 1);
        }
    }

    cout << ff.calc(0, 2 * N + 1) << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stdlib.h>
using namespace std;
typedef long long LL;
LL x[300006],s[300006],u[300006];
LL dp[300006];
int main(void)
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
      for(int i = 0;i < n;i++)
      scanf("%lld %lld",&x[i],&s[i]);
      u[0] = s[0];
      LL maxx = u[0];
      dp[0] = u[0];
      for(int i = 1;i < n;i++)
      {
         dp[i] = max(dp[i-1] + s[i] - x[i] + x[i-1],s[i]);
         maxx = max(dp[i],maxx);
      }
      printf("%lld\n",maxx);
    }
    return 0;
}


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

int main() {
  string s;
  cin>>s;
  if(s=="SUN")cout<<7<<endl;
  else if(s=="MON")cout<<6<<endl;
  else if(s=="TUE")cout<<5<<endl;
  else if(s=="WED")cout<<4<<endl;
  else if(s=="THU")cout<<3<<endl;
  else if(s=="FRI")cout<<2<<endl;
  else if(s=="SAT")cout<<1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define llint long long

using namespace std;

llint a, b;
llint gcd(llint a, llint b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b;
	cout << a*b/gcd(a, b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N, nxt[(int)2e5 + 7][30], opt[(int)2e5 + 7];
string in;

int main(){
  FAST_IO
  cin >> in;
  N = SZ(in);
  for(int c = 0; c < 26; ++c) nxt[N][c] = N;

  for(int idx = N - 1; idx >= 0; --idx){
    for(int c = 0; c < 26; ++c){
      if(in[idx] == char(c + 'a')) nxt[idx][c] = idx;
      else nxt[idx][c] = nxt[idx + 1][c];
    }
  }

  for(int idx = N; idx >= 0; --idx){
    opt[idx] = INF;
    for(int c = 0, match; c < 26; ++c){
      match = nxt[idx][c];
      min_self(opt[idx], opt[match + 1] + 1);
    }
  }
      
  int itr = 0, c;
  while(itr < N + 1){
    for(c = 0; c < 26; ++c){
      int match = nxt[itr][c];
      if(opt[itr] == opt[match + 1] + 1){
        itr = match + 1;
        break;
      }
    }

    assert(c >= 0 && c < 26);
    cout << char('a' + c);
  }

  return 0;
}


Measured memory_bytes: 27976
#include<stdio.h>
int main(){
  int m,f,r;
  while(scanf("%d %d %d",&m,&f,&r)){
    if(m==-1 && f==-1 && r==-1)break;
    if(m==-1 || f==-1)printf("F\n");
    else if(m+f>=80)printf("A\n");
    else if(m+f>=65)printf("B\n");
    else if(m+f>=50)printf("C\n");
    else if(m+f>=30){
      if(r>=50)printf("C\n");
      else printf("D\n");
    }
    else printf("F\n");
  }
  return(0);
}

Measured memory_bytes: 584
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    string s = to_string(N);
    if(s.find("9") != string::npos) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a,b; cin >> a >> b;
  if(a<=b){
    for(int i=0;i<b;i++){
      cout << a;
    }
  }else{
    for(int i=0;i<a;i++){
      cout << b;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AAirConditioner {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int X;
        cin >> X;
        cout << (X >= 30 ? "Yes" : "No") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AAirConditioner solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3580
def main():
    ans = 0
    n, k = map(int, input().split())
    for i in range(k, n + 2):
        mi = i * (i - 1) // 2 #和
        ma = n * (n + 1) // 2 - (n - i) * (n - i + 1) // 2
        ans += ma - mi + 1
    print(ans % (10 ** 9 + 7))
if __name__ == '__main__':
    main()
        


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

int main() {
    int k, a[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                  1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 764
let cnt = ref 0
let (g : int list ref) = ref []

let insertion_sort (a : int array) n g =
  for i = g to n - 1 do
    let v = a.(i) in
    let j = ref (i - g) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+g) <- a.(!j);
      j := !j - g;
      incr cnt;
    done;
    a.(!j+g) <- v;
  done

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc) in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  g := generate_g n;
  List.iter (fun g -> insertion_sort a n g) !g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) !g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)

int main() {
    int N; cin >> N;
    vector<int> A(N);    
    rep(i, N) cin >> A[i];
    
    vector<vector<int>> AA;
    rep(i, N) {
        vector<int> a;
        while(i < N and A[i]) {
            a.push_back(A[i]);
            i++;
        }
        if(a.size()) AA.push_back(a);
    }

    ll ans = 0;
    rep(i, AA.size()) {
        vector<int> a = AA[i];
        vector<int> b = AA[i];
        reverse(b.begin(), b.end());
        auto f = [](vector<int> &a) -> ll {
            ll ret = 0;
            for(int j = 0; j < a.size();) {
                if(a[j] >= 2) {
                    ret += a[j] / 2;                    
                    a[j] = a[j] % 2;
                } else if(a[j] and j + 1 < a.size() and a[j + 1]) {
                    a[j]--;
                    a[j+1]--;
                    ret++;
                } else j++;                
            }
            return ret;
        };
        ans += max(f(a), f(b));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3380
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    fr(i,3) cout<<s[i];
    cout<<endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


const LL mod = 1e9 + 7;
int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  int n = 0;
  scanf("%d", &n);
  LL a = 1, b = 1, c = 1;
  for (int i = 0; i < n; i++) {
    a *= 10;
    b *= 9;
    c *= 8;
    a %= mod;
    b %= mod;
    c %= mod;
  }
  LL ans = a - 2 * b + c;
  ans = (ans % mod + mod) % mod;
  cout << ans << endl;
  
#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) * 1.0 / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3684
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a % 2 == 0 || b % 2 == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<cmath>
#define MAX 100000
using namespace std;
int n,m,k;
int M[MAX];
 
void dfs(int a,int b,int cost)//a->n , b->m
{
  if(a >= n)
    {
      M[max(cost-k,1)]++;
      return;
    }
 
    for(int i=1;i<=m;i++)dfs(a+1,b+i,cost+i);
}
 
int main()
{
  while(cin >> n >> m >> k,n|m|k)
    {    
      for(int i=0;i<MAX;i++)M[i] = 0;     
      dfs(0,0,0);
      long double total = 0;
      for(int i=0;i<MAX;i++)total += i*M[i];
      cout << setiosflags(ios::fixed) << setprecision(8) << total/pow((double)m,(double)n) << endl;
    }
  return 0;
}

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

using namespace std;

int main() {
    int n, k;
    int length[110]; 
    int ans = 0;
    for (int i = 0; i < 110; i++){
        length[i] = 0;
    }

    cin >> n >>  k;
    for (int i = 0; i < n; i++){
        cin >> length[i];
    }
    sort(length, length + n, greater<int>());
    
    for (int i = 0; i < k; i++){
        ans += length[i];
    }

    cout << ans << "\n";
    
    return 0;
}

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

using namespace std;

class Edge {
public:
	int to, weight;
	Edge(int t, int w) : to(t), weight(w) {}
};

int memo[100001] = {0};

inline int height(const vector< vector<Edge> > &Graph, const int root) {
	if (memo[root]) return memo[root];
	int ret = 0;
	for (int i=0; i<(int)Graph[root].size(); ++i) {
		ret = max(ret, Graph[root][i].weight + height(Graph, Graph[root][i].to));
	}
	return memo[root] = ret;
}

inline int diameter(const vector< vector<Edge> > &Graph, const int root) {
	int ret = 0;
	int h1 = 0, h2 = 0;
	for (int i=0; i<(int)Graph[root].size(); ++i) {
		int h = Graph[root][i].weight + height(Graph, Graph[root][i].to);
		if (h1 < h) {
			h2 = h1;
			h1 = h;
		} else if (h2 < h) {
			h2 = h;
		}
		ret = max(ret, diameter(Graph, Graph[root][i].to));
	}
	ret = max(ret, h1 + h2);
	return ret;
}

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

	int n, s, t, w;
	cin >> n;
	vector< vector<Edge> > Graph(n + 1);
	for (int i=1; i<=n-1; ++i) {
		cin >> s >> t >> w;
		Graph[s].push_back(Edge(t, w));
	}
	cout << diameter(Graph, 0) << endl;

	return 0;
}

Measured memory_bytes: 11960
N, x = map(int, input().split())
a = [int(i) for i in input().split()]
ans = 0
for i in range(N-1):
    t = a[i] + a[i+1] - x
    if t <= 0: continue
    ans += t
    if a[i+1] >= t:
        a[i+1] -= t
    else:
        a[i+1] = 0
        a[i] -= (t - a[i+1])
print(ans)

Measured memory_bytes: 14052
#!/usr/bin/env python

import sys
import argparse
import logging
#import math

logging.basicConfig(filename='logger.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


def f(n: int, d: int, xy_list: list) -> int:
    '''
    >>> f(1, 1, [(1,1)])
    0
    >>> f(1, 2, [(1,1)])
    1
    >>> f(4, 5, [(0,5),(-2,4),(3,4),(4,-4)])
    3
    >>> f(1, 2, [(200000,200000)])
    0
    '''
    points = 0
    for x, y in xy_list:
        #if math.sqrt(x * x + y * y) <= d:
        #    points += 1
        if x * x + y * y <= d * d:
            points += 1
    return points


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument(
            '--doctest', action='store_true', default=False)
    args = parser.parse_args()
    if args.doctest:
        import doctest
        doctest.testmod(verbose=True)
        sys.exit()

    n, d = map(lambda x: int(x), sys.stdin.readline().rstrip().split())
    xy_list = list()
    for i in range(0, n):
        x, y = map(lambda x: int(x), sys.stdin.readline().rstrip().split())
        xy_list.append((x, y,))
    print(f(n, d, xy_list))

Measured memory_bytes: 38916
n = int(input())
a = [int(i) for i in input().split(' ')]
result = 0
max_height = 0

for i in range(n):
  an = a[i]
  if i == 0:
    max_height = an
    continue

  if an >= max_height:
    max_height = an
    continue

  result += (max_height - an)

print(result)

Measured memory_bytes: 32188
use proconio::input;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }
    let x = x / 50;

    let mut dp = vec![0; x + 1];
    dp[0] = 1;

    for (s, t) in [(a, 10), (b, 2), (c, 1)].iter() {
        for i in (0..=x).rev() {
            for j in 1..=*s {
                if j * t <= i {
                    dp[i] += dp[i - j * t]
                }
            }
        }
    }

    println!("{}", dp[x])
}


Measured memory_bytes: 2184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    string s;
    int K;
    cin >> s >> K;
    vector<int> v;
    int curr = 0;
    for (int i = 0; i < s.size(); i++) {
        curr++;
        if (i == s.size()-1 || s[i] != s[i+1]) {
            v.push_back(curr);
            curr = 0;
        }
    }
    if (v.size() == 1) {
        ll ans = (1LL*s.size()*K)/2;
        cout << ans << '\n';
        return 0;
    }
    ll sum = 0;
    for (int i: v) {
        sum += i/2;
    }
    if (s[0] != s.back()) {
        cout << sum*K << '\n';
    }
    else {
        vector<int> u = v;
        u[0] += u.back();
        u.pop_back();
        ll ans = 0;
        for (int i: u) {
            ans += i/2;
        }
        ans *= (K-1);
        ans += sum;
        cout << ans << '\n';
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4184
import math

while True:
    try:
        m, n = map(int, raw_input().split())

        f2 = int(math.log(n, 2))
        f3 = int(math.log(n, 3))
        f5 = int(math.log(n, 5))

        count = 0
        for i in range(f2 + 1):
            for j in range(f3 + 1):
                for k in range(f5 + 1):
                    if m <= (2 ** i) * (3 ** j) * (5 ** k) <= n:
                        count += 1
        print count

    except ValueError:
        break

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

int main(){
  long long t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  long long v1 = a1 - b1;
  long long v2 = a2 - b2;
  long long x1 = v1 * t1;
  long long x2 = v2 * t2;
  long long T = x1 + x2;
  if(T == 0) cout << "infinity" << endl;
  else if((x1>0 && T>0) || (x1<0 && T<0)) cout << 0 << endl;
  else{
    if (x1 < 0) x1 *= -1;
    else T *= -1;
    
    long long n = x1 / T;
    if (x1 % T != 0){
      cout << 2*n+1 << endl;
    }
    else{
      cout << 2*n << endl;
    }
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const double pi = 3.141592653589793;

#define INF 1000000000000


signed main(){
  int n=1,x=1;

  while(true){
    cin>>n>>x;
    if(n==0&&x==0){exit(0);}
    int ans=0;
    for(int i=1;i<=n-2;i++){
      for(int j=i+1;j<=n-1;j++){
        if(x-i-j>j&&x-i-j<=n){
          ans++;
        }
      }
    }
    cout<<ans<<endl;
  }
}



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

int main()
{
	int a, b;
	int c;
	int sum = 0;
	cin >> a >> b;
	c = a;
	for (int i= 0; i < b-a+1; i++)
	{
		if (c/10000 == c-(c/10)*10 && c/1000 - (c/10000)*10 == c/10 - (c/100)*10 )
		{	
		sum += 1;
		c++;
		continue;
		}
		
		else
		{
			c++;
			continue;
		}
		 
	}
	cout << sum << endl;
}

Measured memory_bytes: 3524
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, root, a[100100], x, y;
vector<int> e[100100];
bool ng;

int rec(int v, int p) {
	if (e[v].size()==1 && e[v][0]==p) return a[v];
	int sum = 0, mx = 0;
	each(i,e[v]) if (i!=p) {
		int t = rec(i,v);
		sum += t, chmax(mx, t);
	}
	int in = sum - a[v], out = a[v]*2 - sum;
	if (in<0 || min(sum-mx, sum/2)<in) ng = 1;
	return out;
}

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	if (n==2) return cout << (a[0]==a[1] ? "YES" : "NO") << endl, 0;
	rep(i,n-1) {
		cin >> x >> y;
		x--, y--;
		e[x].push_back(y), e[y].push_back(x);
	}
	rep(i,n) if (e[i].size()>=2) root = i;
	cout << (rec(root,-1) || ng ? "NO" : "YES") << endl;
}

Measured memory_bytes: 12160
#include <stdio.h>

int main(void){
	int height,width;
	while(1){
		int h,i,j,k;
		scanf("%d %d",&height,&width);
		if(!height&&!width) break;

		for(h=0;h<width;h++) printf("#");
		printf("\n");

		for(i=0;i<height-2;i++){
			printf("#");
			for(j=0;j<width-2;j++) printf(".");
			printf("#\n");
		}
		
		for(h=0;h<width;h++) printf("#");
		printf("\n\n");
	}
	return 0;
}

Measured memory_bytes: 588
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, k = 0;
	cin >> n >> k;
	vector<lli> a(n);
	for (auto &i : a)
		cin >> i;
	for (int i = k; i < n; ++i)
	{
		if (a[i - k] < a[i])
			cout << "Yes";
		else
			cout << "No";
		cout << endl;
	}
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll b1 = 0, b2 = 0, b4 = 0;
    rep(i, N)
    {
        cin >> a[i];
        if (a[i] % 4 == 0) {
            b4++;
        } else if (a[i] % 2 == 0) {
            b2++;
        } else {
            b1++;
        }
    }
    if (b2 == 0) {
        if (b1 <= b4 + 1) {
            puts("Yes");
            return 0;
        }
    } else {
        if (b1 <= b4) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 1024
#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.at(i);
    sort(A.begin(),A.end());
    cout<<A.at(n-1)-A.at(0)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
int panjang,buka=0;
string input,output;
int main()
{
	output="";
	cin>>panjang>>input;
	int total=0;
	for(int i=0;i<panjang;i++)
	{
		if(input[i]=='(')
		{
			total++;
		}
		else
		{
			if(total==0)
				buka++;
			else
				total--;
		}
	}
	while(buka--)
		output+='(';
	output+=input;
	while(total--)
		output+=')';
	cout<<output<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

double q[2222222];
ll l[2222222];

ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    return (a%b==0?b:gcd(b,a%b));
}

ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    a/=g;
    if((double)a>1e18/b)return (ll)1e18+1;
    else return a*b;
}
int main(){
    ll n,x;
    cin>>n>>x;
    ll a[n];
    rep(i,n)cin>>a[i];
    int m=1<<n;
    rep(i,m){
        ll g=1;
        ll cnt=0;
        rep(j,n)if((1<<j)&i)g=lcm(g,a[j]),cnt++;
        l[i]=x/g;
        if(cnt%2)l[i]*=-1;
    }
    l[0]=0;
    rep(j,n)rep(i,m)if((1<<j)&i)l[i]+=l[i^(1<<j)];
    
    double p[n];
    rep(i,n){
        cin>>p[i];
        p[i]/=100;
    }
    rep(i,m)q[i]=1;
    rep(i,m)rep(j,n){
        if((1<<j)&i)q[i]*=p[j];
        else q[i]*=1.0-p[j];
    }
    double ans=0;
    rep(i,m)ans+=q[i]*l[i];
    cout<<fixed<<setprecision(10);
    cout<<-ans<<endl;
    return 0;
}


Measured memory_bytes: 19672
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

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

type point struct {
	y, x, d int
}

func main() {
	sc.Split(bufio.ScanWords)
	dy := [4]int{-1, 0, 1, 0}
	dx := [4]int{0, -1, 0, 1}

	h, w := scanInt(), scanInt()
	board := make([]string, h)
	for i := 0; i < h; i++ {
		board[i] = scanText()
	}

	queue := make([]point, 0)
	dd := make([][]int, h)
	for i := 0; i < h; i++ {
		dd[i] = make([]int, w)
		for j := 0; j < w; j++ {
			if board[i][j] == '#' {
				queue = append(queue, point{y: i, x: j, d: 0})
			}
		}
	}

	max := 0
	for len(queue) > 0 {
		now := queue[0]
		queue = queue[1:]

		max = now.d

		for i := 0; i < 4; i++ {
			nextY, nextX := now.y+dy[i], now.x+dx[i]

			if nextY < 0 || nextY >= h || nextX < 0 || nextX >= w || dd[nextY][nextX] != 0 || board[nextY][nextX] == '#' {
				continue
			}

			dd[nextY][nextX] = now.d + 1
			queue = append(queue, point{y: nextY, x: nextX, d: now.d + 1})
		}
	}

	fmt.Println(max)
}


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

int main(){
	
	int n, m, taro = 0, hanako = 0;
	int i, j;
	string st, sh;
	
	cin >> n;
	
	for(i = 0; i < n; ++i){
		cin >> st >> sh;
		
		if(st.size() > sh.size()) m = st.size();
		else m = sh.size();
		
		for(j = 0; j < m; ++j){
			
			if(st[j] < sh[j]){
				hanako += 3;
				break;
			}
			else if(st[j] > sh[j]){
				taro += 3;
				break;
			}
			
			if(j == m-1){
				if(st.size() > sh.size()) taro += 3;
				else if(st.size() < sh.size()) hanako += 3;
				else{
					++taro;
					++hanako;
				}
			}
		}
	}
	
	cout << taro << " " << hanako << endl;
	
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int H1,M1,H2,M2,K; cin >>H1 >>M1 >>H2 >>M2 >>K;
  int okiru=H1*60+M1;
  int neru=H2*60+M2;
  cout <<neru-okiru-K <<endl;
  return 0;
}


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

int main()
{

        std::string S;
        cin >> S;

        int len = S.length();
        int l = len / 2;
        for (int i = 0; i < l; ++i) {

                if (S[i] != S[len-1-i]) {

                        cout << "No" << endl;
                        return 0;
                }
        }
        std::string str = S.substr(0, l);
        int lent = str.length();
        int lt = lent / 2;
        for (int i = 0; i < lt; ++i) {
                if (str[i] != str[lent-1-i]) {
                        cout << "No" << endl;
                        return 0;
                }
        }
        str = S.substr(l+1, l);
        lent = str.length();
        lt = lent / 2;
        for (int i = 0; i < lt; ++i) {
                if (str[i] != str[lent-1-i]) {
                        cout << "No" << endl;
                        return 0;
                }
        }
        cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
int main() {
    Int N; cin >> N;
    vector<Int> r(2), m(2);
    Int ans = LLONG_MAX;
    for (Int a = 1; a * a <= 2*N; a += 1) {
        if (2*N % a != 0) continue;
        Int b = 2*N / a;
        if (gcd(a, b) != 1) continue;
        for (int t = 0; t < 2; t++) {
            r[0] = 0, m[0] = a;
            r[1] = -1, m[1] = b;
            auto [y, z] = atcoder::crt(r, m);
            if (0 < y && y < ans) ans = y;
            swap(a, b);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
# 入力値の取得
n = gets.chomp.to_i
nums = gets.chomp.split(" ").map(&:to_i)

sum = 0
min = 1000000
max = -1000000
nums.each do |num|
    sum += num
    
    if num < min
        min = num
    end
    if max < num
        max = num
    end
end

puts "#{min} #{max} #{sum}"


Measured memory_bytes: 7248
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    
    int res = 0;
    for (int n = 0; n < N; ++n) {
        set<char> Set;
        Set.insert(A[n]);
        Set.insert(B[n]);
        Set.insert(C[n]);
        res += (Set.size() - 1);
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int k; cin>>k;
    string ans;
    string s="ACL";
    for(int i=0; i<k; i++) ans+=s;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3620
def takeFirst(elem):
    return elem[0]

N, T = map(int, input().split())
cts = []
for n in range(N):
	c, t = map(int, input().split())
	cts.append((c,t))

cts.sort(key=takeFirst)

# print(ct)
for ct in cts:
	if ct[1] <= T: 
		print(ct[0])
		exit()

print('TLE')

Measured memory_bytes: 3064
N = int(input())
S = input()

a = [chr(i) for i in range(ord('A'),ord('Z')+1)]

res = ""
for x in S:
    for y in range(len(a)):
        if x == a[y]:
            index = y
            break
    res += a[(y+N)%26]
print(res)


Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn solve(a: i64, b: i64, c: i64) -> &'static str {
    if b -a == c - b {
        "YES"
    } else {
        "NO"
    }
}

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
    };
    println!("{}", solve(a, b, c));
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
  val H = readInt()
  val W = readInt()
  val N = readInt()
  println(((N + Math.max(H, W) - 1) / Math.max(H, W)))
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 31800
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	
	map<int, int> mp;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (3200 < a) a = 3200;
		mp[a / 400]++;
	}

	int ans = 0;
	for (int i = 0; i < 8; ++i) {
		if (mp[i] != 0) {
			++ans;
		}
	}
	int minAns = 0;
	int maxAns = 0;
	minAns = max(1, ans);
	maxAns = ans + mp[8];

	cout << minAns << " " << maxAns << endl;
	return 0;
}

Measured memory_bytes: 3616