akhauriyash/Code-Regression huggingface dataset:
// atcoder/abc167/D/main2.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

namespace doubling {
  constexpr int N = 2 * 1e5 + 5;
  constexpr int DEPTH = 61;

  int T[N][DEPTH];
  function<int(int)> fn;

  void build(const int size, function<int(int)> fn_)
  {
    fn = fn_;

    fill(&T[0][0], &T[N - 1][DEPTH], -1);
    for (int i = 0; i < size; ++i) {
      T[i][0] = fn(i);
    }

    for (int i = 1; i < DEPTH; ++i) {
      for (int j = 0; j < size; ++j) {
        T[j][i] = T[T[j][i - 1]][i - 1];
      }
    }

    return ;
  }

  int query(int x, lli ntimes)
  {
    for (int i = DEPTH; 0 <= i; --i) {
      if (ntimes & (1LL << i)) {
        x = T[x][i];
      }
    }
    return x;
  }
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  lli k;
  while (cin >> n >> k) {
    vec<int> a(n);
    cin >> a;
    each (i, a) --i;

    doubling::build(n, [&] (int x) { return a[x]; });
    cout << doubling::query(0, k) + 1 << endl;
  }

  return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    int N,A;
    cin >> N >> A;
    string ans;
    ans = (N%500<=A) ? "Yes":"No";
    cout << ans << endl;

    return 0;


}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class Dice
  attr_accessor:node,:top,:s,:e,:num
  def initialize(arr)
    @node=Array.new(6){|i| i+1}
    @num=arr
    @top=1
    @s=2
    @e=3
  end

  def reverse_num(x)
    return 7-x
  end

  def S()
    top=@top
    s=@s
    e=@e
    @top=reverse_num(s)
    @s=top
  end

  def E()
    top=@top
    s=@s
    e=@e
    @top=reverse_num(e)
    @e=top
  end

  def W()
    top=@top
    s=@s
    e=@e
    @top=e
    @e=reverse_num(top)
  end

  def N()
    top=@top
    s=@s
    e=@e
    @top=s
    @s=reverse_num(top)
  end
end

a=get_i
move=get_nsp
dice=Dice.new(a)
move.each do|q|
  case q
  when "S" then
    dice.S
  when "E" then
    dice.E
  when "W" then
    dice.W
  when "N" then
    dice.N
  end
end
puts dice.num[dice.top-1]


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
int i,n,k,j,ans;
int a[10001];
int main(){
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<n;i++)
		if(a[i]%2==1)
			if(i%2==0)ans++;
	cout<<ans;		
	return 0;
}


Measured memory_bytes: 3644
from _collections import deque


def bfs(field, field_info, starting_y, starting_x, goal_y, goal_x):
    queue = deque([[starting_y, starting_x]])
    field_info[starting_y][starting_x] = 1

    while queue:
        y, x = queue.popleft()
        for dy, dx in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y + dy, x + dx
            if 0 <= new_y <= goal_y and 0 <= new_x <= goal_x and field[new_y][new_x] == "." and field_info[new_y][new_x] == -1:
                field_info[new_y][new_x] = field_info[y][x] + 1
                queue.append([new_y, new_x])


def solve():
    number_of_rows, number_of_columns = list(map(int, input().split()))  # Row, Column数
    field = [input() for _ in range(number_of_rows)]
    field_info = [[-1] * number_of_columns for _ in range(number_of_rows)]
    starting_y, starting_x = 0, 0
    goal_y, goal_x = number_of_rows - 1, number_of_columns - 1
    bfs(field, field_info, starting_y, starting_x, goal_y, goal_x)

    # # BFSの結果をチェック
    # for field_info_line in field_info:
    #     print(field_info_line)

    if field_info[goal_y][goal_x] == -1:
        print(-1)
        return
    else:   # 到達できる場合
        number_of_black_cell = 0
        for row_i in range(number_of_rows):
            for column_i in range(number_of_columns):
                if field[row_i][column_i] == "#":
                    number_of_black_cell += 1
        point = number_of_columns * number_of_rows - field_info[goal_y][goal_x] - number_of_black_cell
        print(point)

solve()

Measured memory_bytes: 40048
#include<stdio.h>
int main(){
    char b[11];
    int cnt,max;
    max=cnt=0;
    scanf("%s",b);
    for(int i=0;i<10;i++){
        if(b[i]=='A'||b[i]=='C'||b[i]=='G'||b[i]=='T'){
            cnt++;
            if(max<cnt)max=cnt;
        }
        else{
            
            cnt=0;
        }
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c; cin >> a >> b >> c;
  cout << (char)(a.at(0) + ('A' - 'a')) << (char)(b.at(0) + ('A' - 'a')) << (char)(c.at(0) + ('A' - 'a')) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
ll a[123456];
map<ll, int>mp;

// Returns value of Binomial Coefficient C(n, k)
ll binomialCoeff(int n, int k)
{
	ll res = 1;
        if(n < k) return 0;
	// Since C(n, k) = C(n, n-k)
	if ( k > n - k )
		k = n - k;
 
	// Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
	for (int i = 0; i < k; ++i)
	{
		res *= ll(n - i);
		res /= ll(i + 1);
	}
 
	return res;
}

class DCandyDistribution {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m;
		in >> n >> m;
		mp.clear();
		memset(a, 0, sizeof(a));
		ll sum = 0;
		for (int i = 1; i <= n; ++i) {
			in >> a[i];
			if(i != 0)a[i] += a[i-1];
			a[i] %= m;
			mp[a[i]]++;
		}

		for (auto it = mp.begin(); it != mp.end(); ++it) {
			if(it->second >= 2 && it->first != 0)sum += binomialCoeff(it->second, 2);
			else if(it->first == 0)sum += binomialCoeff(it->second, 2) + it->second;
		}
		out << sum << endl;
	}
};
 
int main() {
	DCandyDistribution solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5248
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;


fn main() {
    input! {
        N: usize,
        As: [i128; N],
    }

    let MOD: i128 = 1000_000_007;

    // 累積和
    let mut Sum = vec![0i128; N + 1];
    // Sum[n+1] = As[0] + As[1] + ... As[n] = Sum[n] + As[n]
    // As[t] + As[t+1] .... + As[s] = Sum[s+1] - Sum[t]

    // Sum[0] = 0;
    for i in 0..N {
        Sum[i + 1] = (Sum[i] + As[i]) % MOD;
    }

    let mut ans: i128 = 0;

    for i in 0..N - 1 {
        let sum = (Sum[N] + (MOD - Sum[i + 1])) % MOD;
        let add = (As[i] * sum) % MOD;
        ans = (ans + add) % MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 10288
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template <typename __VA_ARGS__> inline
#define USE2(T, ...) USE1(T, typename __VA_ARGS__)
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
using ll = long long;
template<typename T> using vec = std::vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=std::pair<T,int>)vec<U>enume(const vec<T>&x,int s=0){int N=x.size();auto v=reserved<U>(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

struct Record {
  int t, pc, student, login;
  Record(int t, int pc, int student, int login) : t(t), pc(pc), student(student), login(login) {}
};

signed main() {
  int N, M;
  while (N = in(), M = in(), N || M) {
    int r = in();
    auto record = reserved<Record>(r);
    rep(i, r) {
      int t = in(), n = in(), m = in(), s = in();
      record.pb(t, n, m, s);
    }
    int q = in();
    rep(i, q) {
      int ts = in(), te = in(), m = in();
      vec<int> imos(2048, 0);
      for (auto&& rec : record) {
        if (rec.student != m) continue;
        if (rec.login) {
          imos[rec.t] += 1;
        } else {
          imos[rec.t] -= 1;
        }
      }
      int ans = 0, act = 0;
      rep(t, 1300) {
        act += imos[t];
        if (ts <= t && t < te) {
          if (act) ans++;
        }
      }
      pr(ans);
    }
  }
  return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

struct UF{
 int N;
 vector<int> V;
 void init(int n){
  N=n; V.resize(N);
  rep(i,N) V[i]=i;
 }
 int root(int a){
  if(V[a]==a) return a;
  return V[a]=root(V[a]);
 }
 void unite(int r,int s){
  V[root(s)] = root(r);
 }
};

int N,Q;
UF G;

int main(){
 scanf("%d%d",&N,&Q);
 G.init(N);
 rep(q,Q){
  int c; scanf("%d",&c);
  if(c==0){
   int u,v; scanf("%d%d",&u,&v);
   G.unite(u,v);
  }
  if(c==1){
   int u,v; scanf("%d%d",&u,&v);
   if(G.root(u)==G.root(v)) printf("1\n");
   else printf("0\n");
  }
 }
 
 return 0;
}


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

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    rep(i,2){
        if (s[i] != s[i+1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
main(){
   int r, g, b ;
   cin >> r >> g >> b ;

   int ans = (r *100 + g * 10 + b );

   if (ans % 4 == 0 ){
      cout << "YES" << endl;
      }
      else
      {
      cout << "NO" << endl;
      }
 }

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(0);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

const ll N = 3*MAX5;
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll  m, y, k, z, l;
string s, t, d, c;

// <------------- Implement Functions Here ----------> //

ll n,x;

/*void bs(ld n)  {
	ll l = 0,r = 10000000;

}
*/


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n ;
	m = 7;
	for(ll i=1;i<=1000000;i++) {
		if(m%n == 0) {
			cout<<i;
			return;
		}
		m = (m*10 %n + 7%n)%n;
	}
	cout<<-1;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3580
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;
    int m = n;
    String[] s = new String[n];


    s = sc.next().split("");

    for(int i=0; i<n-1; i++){
      if(s[i].equals("R")&&(s[i+1].equals("L"))){
        count += 1;
      }

    }
    if(s[0].equals("L")){
      count += 1;
      m += 1;
    }
    if(s[n-1].equals("R")){
      count += 1;
      m += 1;
    }
    int ans = Math.min(n-1,m-2*count+2*k);
    System.out.println(ans);

  }
}

Measured memory_bytes: 32672
#include<bits/stdc++.h>
using namespace std;
int main(){
string abc;
  abc="abcdefghijklmnopqrstuvwxyz";
  char cba;
  cin>>cba;
  for(int i=0;i<25;i++){
    if(cba==abc.at(i)){
      cout<<abc.at(i+1)<<endl;
      break;
    }
  }
}

Measured memory_bytes: 384
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);

    foreach (i ; 0 .. n) {
        int yi, mi, di;
        scan(yi, mi, di);
        writeln(mill(yi, mi, di));
    }
}

int mill(int y, int m, int d) {
    int res;

    if (y % 3 == 0) {
        res += 10 * 20 - ((m - 1) * 20 + d) + 1;
    }
    else {
        res += 5*19 + 5*20 - ((m - 1) / 2 * 39 + ((m-1)&1)*20 + d) + 1;
    }

    foreach (yy ; y + 1 .. 1000) {
        if (yy % 3 == 0) res += 10*20;
        else res += 5*39;
    }

    return res;
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2472
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def abc():
    s = int(input().rstrip())

    pre = 0
    ns = []
    for i in range(1, 1000001):
        if i == 1:
            a = s
        else:
            a = f(pre)
        if a in ns:
            print(i)
            return
        ns.append(a)
        pre = a


abc()


Measured memory_bytes: 3060
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())

    a = input().strip()

    if re.match('[A-Z]', a):
        print('A')
    else:
        print('a')



if __name__ == '__main__':
    main()


Measured memory_bytes: 9812
// https://atcoder.jp/contests/abc171/tasks/abc171_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  ll xor_sum = 0;
  rep(i, N) xor_sum ^= as[i];

  VL res(N);

  rep(i, N) { res[i] = xor_sum ^ as[i]; }

  rep(i, res.size()) {
    if (i > 0) cout << " ";
    cout << res[i];
  }
  cout << "\n";
}


Measured memory_bytes: 6240
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    long long N,M;
    cin >> N >> M;
    if (N == M){
        unsigned long long ans = 1;
        unsigned long long tmp = M;
        for(long long i = N;i > 0;i--){
            ans = (i * tmp * ans) % (1000000000 + 7);
            tmp--;
        }
        ans *= 2;
        ans = ans % (1000000000 + 7);
        cout << ans << endl;
    }else if(N - 1 == M || M - 1 == N){
        if(M - 1 == N){
            swap(N,M);
        }
        long long ans = 1;
        long long tmp = N;
        for(long long i = M;i > 0;i--){
            ans = ((i * tmp)% (1000000000 + 7) * (ans % (1000000000 + 7)) % (1000000000 + 7));
            tmp--;
        }
        cout << ans % (1000000000 + 7) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

int dp[3005][3005];

// O(nm)

int main()
{
    string s,t;
    cin >> s >> t;


    for(int i=1; i<=s.size(); i++)
    {
        for(int j = 1;j<=t.size();j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = max( max( dp[i-1][j-1] + 1, dp[i-1][j]), dp[i][j-1]);
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    string ans = "";

    int i=s.size();
    int j=t.size();

    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1] && dp[i][j] == dp[i-1][j-1]+1)
        {
            ans += s[i-1];
            i--;
            j--;
        }
        else if( dp[i][j] == dp[i][j-1])
        {
            j--;
        }
        else
            i--;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;

int main(){
    string s;
    cin >> s;
    vector<int> ans(int(s.size()),0);
    int r_count = 0;
    for(int i = 0; i < s.size()-1;i++){
        if(s.at(i) == 'R') r_count++;
        if(s.at(i) == 'R' && s.at(i+1) == 'L'){
            ans.at(i) += (r_count+1)/2;
            ans.at(i+1) += (r_count)/2;
            r_count = 0;
        }
    }
    int l_count = 0;
    for(int i = s.size()-1;i >= 1;i--){
        if(s.at(i) == 'L') l_count++;
        if(s.at(i) == 'L' && s.at(i-1) == 'R'){
            ans.at(i) += (l_count+1)/2;
            ans.at(i-1) += (l_count)/2;
            l_count =0;
        }
    }
    for(int i = 0;i <s.size();i++) cout << ans.at(i) << " ";
    cout << endl;
}

Measured memory_bytes: 3832
from sys import stdin

N = int(stdin.readline().rstrip())


def dfs(x):
    ret = 0
    if int(x) > N:
        return ret
    if '7' in x and '5' in x and '3' in x:
        ret += 1
    for k in '753':
        ret += dfs(x + k)
    return ret


print(dfs('0'))

Measured memory_bytes: 49628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int M = 1'000'001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> cnt(M);
  for (int x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < M; i += x) cnt[i]++;
  }

  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }

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

Measured memory_bytes: 7884
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>
#include<math.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nBuf,int N){
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}
#define MAX(a,b) ( ((a)>(b)) ? (a):(b) )

int main(){
    int N,L,taste,tmp;

    scanf("%d %d%*c",&N,&L);

    taste = (L + (L+N-1))*N/2;      //元のパイの味

    if(L>0){
        tmp= L;
        taste -= L;
    }
    else if(L<=0 && (L+N-1)>0){
        tmp=0;
        taste -= 0;
    }
    else{
        tmp=(L+N-1);
        taste -= (L+N-1);
    }

    printf("%d\n",taste);
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

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

    unordered_set<string> st;

    st.insert(vs[0]);
    char e = vs[0].back();
    bool ok = true;
    for (int i = 1; i < N; i++) {
        if (vs[i].front() != e) {
            ok = false;
        }
        if (st.find(vs[i]) != st.end()) {
            ok = false;
        }
        if (!ok) {
            break;
        }
        e = vs[i].back();
        st.insert(vs[i]);
    }

    cout << (ok ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

ll result[200005] = {0};
void fact(ll n) {
   if (n >= 0) {
      result[0] = 1;
      for (ll i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
   }
}

void dfs(ll n, ll m, ll i, vector<ll> &v){
  if(i == n){
  }else{
    for(int k = 1; k <= m; k++){
      v.push_back(k);
      dfs(n, m, i+1, v);
      v.pop_back();
    }
  
  }
}

void solution(){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ans += min(k, a);
  k -= min(k, a);

  if(k > 0){
    k -= min(k, b);
  }

  if(k > 0){
    ans -= min(k, c);
  }

  cout << ans << endl;
}     



Measured memory_bytes: 3184
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	double a, b, c, d, e, f;
	while (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF) {
		double y = (c * d - a * f) / (b * d - a * e);
		double x = (c - b * y) / a;
		printf ("%.3lf %.3lf\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#define N 5005
using namespace std;

typedef long long ll;
ll M = -2e18;
ll n, m, di, tc, a1[N], a2[N], w[N], d[N];
bool v[N];
vector<ll> b[N];
void g(ll p) {
	ll i;
	if (v[p]) return;
	v[p] =1 ;
	for (i = 0; i < b[p].size(); i++) {
		g(b[p][i]);
	}
}

int main()
{
	ll i, j, t1, t2;
	cin >> n >> m >> di;
	for (i = 0; i < m; i++) {
		scanf ("%lld %lld %lld", &a1[i], &a2[i], &w[i]);
		b[a2[i]].push_back(a1[i]);
		w[i] -= di;
	}
	g(n);
	d[1] = 0;
	for (i = 2; i <= n; i++) {
		d[i] = M;
	}
	bool up;
    for (tc = 1; tc <= n; tc++) {
		up = 0;
		for (i =0; i < m; i++) {
			t1 = a1[i];
			t2 = a2[i];
			if (d[t1] == M) continue;
			if (d[t2] < d[t1] + w[i]) {
				d[t2] = d[t1] + w[i];
				if (v[t2]) up = 1;
			}
		}
		if (!up) break;
    }
    if (tc <= n) cout << max(d[n], 0ll) << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 640
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main() {
	int n,m;
	string s, t;
	cin >> n >> m;
	cin >> s;
	cin >> t;

	int g = gcd(s.length(), t.length());
	ll ans = s.length()*t.length() / g;
	int sidx = 0, tidx = 0;
	string ansstr = "";

	int ss = n / g;
	int ts = m / g;

	for (int i = 0; i < g; i++) {
		if (s[sidx] != t[tidx]) {
			ans = -1;
		}
		sidx += ss;
		tidx += ts;
	}

	cout << ans << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
import collections


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]", D: "List[int]"):
    par = list(range(N))
    rank = [0] * N

    def find(x):
        if par[x] == x:
            return x
        par[x] = find(par[x])
        return par[x]

    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return

        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

    def same(x, y):
        return find(x) == find(y)

    friend = collections.defaultdict(set)
    for i in range(M):
        a = A[i] - 1
        b = B[i] - 1
        unite(a, b)
        friend[a].add(b)
        friend[b].add(a)

    block = collections.defaultdict(set)
    for i in range(K):
        c = C[i] - 1
        d = D[i] - 1
        block[c].add(d)
        block[d].add(c)

    tomodatinowa = [0] * N
    for i in range(N):
        tomodatinowa[find(i)] += 1

    res = [0] * N
    for i in range(N):
        res[i] = tomodatinowa[par[i]] - 1
        for bl in block[i]:
            if same(i, bl):
                res[i] -= 1
        for fr in friend[i]:
            if same(i, fr):
                res[i] -= 1

    print(" ".join(str(a) for a in res))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    C = [int()] * (K)  # type: "List[int]"
    D = [int()] * (K)  # type: "List[int]"
    for i in range(K):
        C[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(N, M, K, A, B, C, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 115592
#include <cstdio>

using namespace std;

bool is_prime(int x) {
  int counter = 0;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) counter++;
  }
  return counter == 1 ? true : false;
}

int main() {
  int n;
  scanf("%d", &n);
  int counter = 0;
  for (int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    if (num != 1 && is_prime(num)) counter++;
  }
  printf("%d\n", counter);
}

Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    string s;cin>>s;

    int n = s.size() - 1;

    ll sum = 0;
    for(int i = 0;i < (1<<n);i++){
        int l = 0;//左端
        ll tmp = 0;

        int r= 0;
        for( r = 0;r<n;r++){  //右端
            if(i & (1<<r)){
                string t = s.substr(l,r-l+1);
                ll num = stoll(t);
                tmp += num;
                l = r+1;
            }
        } 

        string t = s.substr(l,r-l+1);
        ll num = stoll(t);
        tmp+=num;
        sum+=tmp;
    }

    cout<<sum<<endl;



}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    string s;
    cin >> s;
    if(s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int cnt = 0;
    for(int i = 2; i < s.size()-1; i++) {
        if(s[i] == 'C') cnt++;
    }
    if(cnt != 1) {
        cout << "WA" << endl;
        return 0;
    }

    for(int i = 1; i < s.size(); i++) {
        bool flag = false;
        if(i >= 2 && i <= s.size()-2) {
            if(s[i] == 'C') continue;
        }
        for(char j ='a'; j <= 'z'; j++) {
            if(s[i] == j) flag = true;
        }
                if(!flag) {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string S,T;
  cin >>S>>T;
  int a,b;
  cin >>a>>b;
  string U;
  cin >>U;
  if(U == S){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

class Main{
    private static int[] d;
    private static int[][] g;
    private static int t = 0;
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        d = new int[n+1];
        for(int i = 0; i<=n; i++)
            d[i] = -1;
        g = new int[n+1][n+1];
        for(int i = 0; i<n; i++){
            final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            final int u = Integer.parseInt(st.nextToken());
            final int k = Integer.parseInt(st.nextToken());
            g[u][0] = k;
            for(int j = 1; j<=k; j++){
                g[u][j] = Integer.parseInt(st.nextToken());
            }
        }
        bfs(1);
        final StringBuilder sb = new StringBuilder();
        for(int i = 1; i<=n; i++){
            sb.append(i).append(' ').append(d[i]).append('\n');
        }
        System.out.print(sb);
    }
    private static void bfs(int e){
        final Deque<state> q = new ArrayDeque<state>();
        q.add(new state(e, 0));
        while(!q.isEmpty()){
            final state s = q.remove();
            final int id = s.id;
            int t = s.d;
            if(d[id]!=-1) continue;
            d[id] = t++;
            for(int i = 1, n = g[s.id][0]; i<=n; i++)
                q.add(new state(g[id][i], t));
        }
    }
}
class state{
    final int id;
    final int d;
    state(int id, int d){
        this.id = id;
        this.d = d;
    }
}

Measured memory_bytes: 24364
from sys import exit

s = input()
l = ['dream', 'dreamer', 'erase', 'eraser']

pos = len(s) - 1
while pos >= 0:
    flag = False

    for string in l:
        length = len(string)
        if pos >= length - 1 and s[pos-length+1:pos+1] == string:
            pos -= length
            flag = True

    if not flag:
        print('NO')
        exit()

print('YES')

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NL = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var list = new List<string>();
            for(int i = 0; i < NL[0]; i++)
            {
                list.Add(Console.ReadLine());
            }
            list = list.OrderBy(s => s).ToList();

            string ans = string.Empty;
            for(int i = 0; i < NL[0]; i++)
            {
                ans += list[i];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 12512
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

#define T0(T) T
#define V0(v, T, n, ...) v
#define T1(T) vector<T0(T)>
#define V1(v, T, n, ...) T1(T)(n, V0(v, T, __VA_ARGS__))
#define T2(T) vector<T1(T)>
#define V2(v, T, n, ...) T2(T)(n, V1(v, T, __VA_ARGS__))

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	inc(i, h) { cin >> s[i]; }
	
	int ans = 0, INF = 1e6;
	inc(i, h) {
	inc(j, w) {
		if(s[i][j] == '#') { continue; }
		auto d = V2(INF, int, h, w);
		
		queue<array<int, 3>> q;
		d[i][j] = 0;
		q.push({ d[i][j], i, j });
		until(q.empty()) {
			auto p = q.front(); q.pop();
			if(p[0] != d[p[1]][p[2]]) { continue; }
			setmax(ans, p[0]);
			inc(k, 4) {
				int di[9] = { +1,  0, -1,  0, +1, +1, -1, -1,  0 };
				int dj[9] = {  0, +1,  0, -1, +1, -1, +1, -1,  0 };
				int ii = p[1] + di[k];
				int jj = p[2] + dj[k];
				if(! (inID(ii, 0, h) && inID(jj, 0, w))) { continue; }
				if(s[ii][jj] == '#') { continue; }
				if(setmin(d[ii][jj], p[0] + 1)) { q.push({ d[ii][jj], ii, jj }); }
			}
		}
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll a,b,c=0;
    cin>>a>>b;
    ll d=b;
    while(d>0)
    {
      c++;
      d/=10;
    }
    //cerr<<a<<" "<<b<<" "<<c<<endl;
    ll temp=(a*pow(10,c))+b;
    //cerr<<temp<<endl;
    ll sq=sqrt(temp);
    if(sq*sq==temp)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

std::vector<int> prime_list(int N) {
  std::vector<bool> bools(N, true);
  bools[0] = false, bools[1] = false;
  for (int i = 2; i < sqrt(N); i++) {
    if (!bools[i]) continue;
    for (int j = i * i; j < N; j+=i) {
      bools[j] = false;
    }
  }

  std::vector<int> primes;
  for (int i = 2; i < N; ++i) {
    if (bools[i]) primes.push_back(i);
  }
  return primes;
}


int main() {
  std::vector<int> list = prime_list(1000000);

  int X; std::cin >> X;
  int i = 0;
  while (X > list[i]) ++i;
  std::cout << list[i] << std::endl;;
}


Measured memory_bytes: 1020
a,b,x = gets.chomp.split(" ").map(&:to_i)

pi = Math::PI

y = (2*x)/(a*b).to_f

if y <= a
  t = Math.atan(b/y)*180/pi
  p t
else
  t = Math.atan((2*b)/(a.to_f)-((2*x)/(a*a*a).to_f))*180/pi
  p t
end

Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		cin>>a[i];
		a[i] *= -1;
	}
	vector<int> dp(n,1);
	for (int i = 0; i < n; i++){
		*upper_bound(all(dp),a[i]) = a[i];
	}
	int ans = -1;
	for (int i = 0; i < n; i++){
		if(dp[i]<=0) ans = i+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024