akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <utility>
#include <vector>

struct pair_hash {
	template<typename T1, typename T2>
	std::size_t operator()(const std::pair<T1, T2> &p) const {
		const auto h1 = std::hash<T1>{}(p.first);
		const auto h2 = std::hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};

std::unordered_map<std::pair<int, int>, int, pair_hash> map;

int solve(int, std::vector<std::pair<int, int>>);

int SOLVE(int W, std::vector<std::pair<int, int>> item) {
	if(map.find(std::make_pair(W, item.size())) != map.end()) {
		return map.at(std::make_pair(W, item.size()));
	} else {
		int a = solve(W, item);
		map[std::make_pair(W, item.size())] = a;
		return a;
	}
}

// 
int solve(int W, std::vector<std::pair<int, int>> item) {
	if(W == 0 || item.empty()) {
		return 0;
	} else {
		auto item2 = item;
		item2.erase(item2.begin());
		const int w = item.front().first;
		const int v = item.front().second;
		// 強度が足りる
		if(w <= W) {
			return std::max(SOLVE(W, item2), SOLVE(W - w, item2) + v);
		} else {
			return SOLVE(W, item2);
		}
	}
}

int main() {
	int N, W;
	std::cin >> N >> W;

	std::vector<std::pair<int, int>> item(N);
	for(int i = 0; i < N; i++) {
		int w, v;
		std::cin >> w >> v;
		item[i] = std::make_pair(w, v);
	}

	std::cout << solve(W, item) << std::endl;

	return 0;
}

Measured memory_bytes: 6308
n = int(input())
h = list(map(int,input().split()))
h[0] -= 1
for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1

    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 14396
antennas = []
for _ in range(5):
    x = int(input())
    antennas.append(x)
k = int(input())

import itertools

ans = True
for x, y in list(itertools.combinations(antennas,2)):
    dist = abs(x - y)
    if dist > k:
        ans = False
        break

if ans == True:
    print('Yay!')
else:
    print(':(')
    


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

int n, x, y, t1, t2, t3, t4;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;

    cin >> x >> y;

    t1 = x + y;
    t2 = x + y;
    t3 = x - y;
    t4 = x - y;

    for(int i = 2; i <= n; ++i)
    {
        cin >> x >> y;
        t1 = max(t1, x + y);
        t2 = min(t2, x + y);
        t3 = max(t3, x - y);
        t4 = min(t4, x - y);
    }

    cout << max(t1 - t2, t3 - t4);
    return 0;
}


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


int main(){
 cout<<fixed<<setprecision(12);
 double a,b,C;
 cin>>a>>b>>C;
 double PI=acos(-1.0);
 C=C/180.0*PI;
 cout<< a*b*sin(C)/2.0<<endl;
 //c*c=a*a+b*b-2*a*b*cosC
 double cc=a*a+b*b-2*a*b*cos(C);
 cout<<a+b+sqrt(cc)<<endl;
 cout<<b*sin(C)<<endl;
}


Measured memory_bytes: 3564
N,K = map(int,input().split())
note = [list(map(int,input().split())) for i in range(N)]
note = sorted(note,key=lambda x:(x[0],-x[1]))
cnt = 0
head = []
remain = []
for i in range(N):
    if note[i][0] > cnt:
        cnt = note[i][0]
        head.append(note[i][1])
    else:
        remain.append(note[i][1])
head = sorted(head,reverse = True)
remain = sorted(remain,reverse = True)
ans = 0
acc_head = [0]
acc_remain = [0]
tmp_head = 0
tmp_remain = 0
for i in range(len(head)):
    tmp_head += head[i]
    acc_head.append(tmp_head)
for i in range(len(remain)):
    tmp_remain += remain[i]
    acc_remain.append(tmp_remain)
for i in range(max(0,K-len(remain)),min(K,len(head))+1):
    deli = acc_head[i] + acc_remain[K-i]
    kind = i**2
    res = deli + kind
    if res > ans:
        ans = res
print(ans)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  int res = 1 << 28;
  for (int b = 0; b < (1 << N); b++) {
    int cost = 0;
    vector<int> cnt(M, 0);
    for (int i = 0; i < N; i++) {
      if ((b >> i) & 1) {
        cost += C[i];
        for (int j = 0; j < M; j++) {
          cnt[j] += A[i][j];
        }
      }
    }
    bool flag = true;
    for (int i = 0; i < M; i++) {
      if (cnt[i] < X) flag = false;
    }
    if (flag) res = min(res, cost);
  }
  if (res == (1 << 28)) {
    cout << -1 << '\n';
  } else {
    cout << res << '\n';
  }
  return 0;
}


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

int N, M;
vector<int> pos(0);        //各地点の座標を格納
vector<int> diff(0);        //最低座標から順に、隣り合う座標の距離を格納

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

  if(N >= M){                         //駒が到達すべき地点より多い
    cout << 0 << endl;       //全地点に開始から駒を置けばよいので...
    return 0;
  }
  
  for(int i = 0; i < M; i++){
    int p;
    cin >> p;
    pos.push_back(p);
  }

  sort(pos.begin(), pos.end());                          //昇順
  int plen = pos.size();
  int count = pos[plen-1] - pos[0];      //全地域を含む最小領域幅を取得

  for(int i = 0; i < M-1; i++)
    diff.push_back(pos[i+1]-pos[i]);               //現地点に最も近いかつ大きい地点との座標差

  sort(diff.begin(), diff.end());                          //座標差のソート

  int dlen = diff.size();
  for(int i = 0; i < N-1; i++)                                //N個の駒は、N-1個の座標差を消すことと同じ
    count -= diff[dlen-1-i];                       //よって座標差の最大値から消していけばよい

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}
bool cmp(pair < int , string >   a , pair < int , string >   b){
  if(a.first < b.first ) return true;
  else return false;
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int32_t main(){  
 // fast;
  int a ; string b;
  cin >> a;
  cin  >> b;
  int x = (b[0]-'0');
  x = x*10 + (b[2]-'0');
  x = x * 10 + (b[3]-'0');
  //cout << x << " " << a << "++\n";
  int ans = a*x;
  ans= ans/100;
  cout <<  ans << "\n";
  return 0;
} 


/*

15 33


8.99 99
WB14D0028763
9990000000000000
9990000000000000
9990000000000000
9990000000000000

  4
3 5 7
1111
4 4 10
0110
4 3 4
1010
4 3 4
1100

111



3
3 5 4
101

2*k1 <=k2 
11111
8 10
11111 0 
5 5 05
111
k2 k2 k2 

10 12
126


3 

00001110000

000111000111
1111100
1110011

11101 10 01 00
0
k1 k1 k2 

*/
/*
1
[-5,3,-5],-3,1]

[-2,4,2,5,-5]
5
0 -1 2 -1 3
*/

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    cin >> N;
    vector<ll> v(N); REP(i,N) cin >> v[i];

    for(int i = N-2; i >= 0 ; --i){
        if(v[i + 1] >= v[i]) continue;
        else if(v[i+1]+ 1 == v[i]  ) --v[i];
        else{cout << "No"; return 0;}
    }
    cout << "Yes"; 
    return 0;
}

Measured memory_bytes: 1024
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    ll a; ld b; cin >> a >> b;
    print(ll(a * b));

    return 0;
}

Measured memory_bytes: 3744
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        mp[x]++;
        mp[x - 1]++;
        mp[x + 1]++;
    }
    int ans = 0;
    for(auto x : mp){
        ans = max(ans, x.S);
    }
    cout << ans;
    return 0;
}
/*
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 4736
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

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

    multiprecision::cpp_dec_float_100 a,b,c;
    cin >> a >> b >> c;

    if(multiprecision::sqrt(a) + multiprecision::sqrt(b) < multiprecision::sqrt(c)) cout << "Yes\n";
    else cout << "No\n";


    return 0;
}


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

int main(){
    string s;
    int q;
    bool revers = false;
    
    cin >> s;
    cin >> q;

    deque <char> str;

    for (auto c : s) str.push_back(c);

    for (int i = 0; i < q; i ++){
        int q_1;
        cin >> q_1;
        if (q_1 == 1){
            revers = !revers;
        }
        else{
            int q_2;
            char q_3;
            cin >> q_2 >> q_3;
            if (!revers){
                if (q_2 == 1) str.push_front(q_3);
                else str.push_back(q_3);
            }
            else{
                if (q_2 == 1) str.push_back(q_3);
                else str.push_front(q_3);
            }
        } 
    }

    //if (revers) reverse(s.begin(), s.end());

    if (revers){
        for (int i = str.size() - 1; i >= 0; i --){
            cout << str[i];
        }
        cout << endl;
    }
    else{
        for (int i = 0; i < str.size(); i ++){
            cout << str[i];
        }
        cout << endl; 
    }
}

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

int n;
int d[202][202];

void WarshallFroyd(){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                d[k][j] = min(d[k][j], d[i][k] + d[j][i]);
            }
        }
    }
}

int main()
{
    cin >> n;
    char s[202][202];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> s[i][j];
            d[i][j] = s[i][j] - '0';
        }
    }
    bool f = true;
    int col[202] {0};
    col[0] = 1;
    queue<int> que;
    que.push(0);
    while(que.size()){
        int now = que.front();
        que.pop();
        for(int i = 0; i < n; i++){
            if(d[now][i] == 1){
                if(col[i] == 0){
                    col[i] = 3 - col[now];
                    que.push(i);
                }
                if(col[i] == col[now]){
                    f = false;
                    break;
                }
            }
        }
    }
    if(!f) cout << -1 << endl;
    else{
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(d[i][j] == 0 && i != j) d[i][j] = 10000;
            }
        }
        WarshallFroyd();
        int lar = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                lar = max(lar, d[i][j]);
            }
        }
        cout << lar + 1 << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;
#define MOD 1000000007

int N;
string s;
long long dp[3003][3003];

int main(){
    cin >> N >> s;
    dp[N][N] = 1;
    s = '<' + s;
    for(int i=N; i>0; i--){
        if(s[N-i] == '<'){
            for(int j=i-1; j>=0; j--)
                dp[i-1][j] = (dp[i-1][j+1] + dp[i][j+1])%MOD;
        }else{
            dp[i-1][0] = dp[i][0];
            for(int j=1; j<=i-1; j++)
                dp[i-1][j] = (dp[i-1][j-1] + dp[i][j])%MOD;
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 68992
import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import java.math.BigInteger;

@SuppressWarnings("unchecked")
public class Main {

	static boolean fileIO = false;
	static boolean DEBUG = false;



	final static int INF = 0x7FFFFFFF;
	final static int MOD = (int)(1 << 30);
	final static int EPS = (int)1e6;

	final static String input = "input.txt";
	final static String output = "output.txt";

	public static void main(String args[]) throws IOException {
		InputStream is = null;
		OutputStream os = null;
		if (fileIO) {
			is = new FileInputStream(input);
			os = new FileOutputStream(output);
		} else {
			is = System.in;
			os = System.out;
		}
		InputReader in = new InputReader(is);
		PrintWriter out = new PrintWriter(os);
		new Task_B().solve(in, out);
		out.close();
	}


	static class Task_A {

		public void solve(InputReader in, PrintWriter out) {
			int a[][] = new int[2][3];
			char row1[] = in.nextString().toCharArray();
			char row2[] = in.nextString().toCharArray();
			for (int j = 0; j < 3; ++j) {
				a[0][j] = row1[j];
				a[1][j] = row2[j];
			}
			int b[][] = new int[2][3];
			b[1][1] = a[0][1];
			b[0][1] = a[1][1];
			b[1][2] = a[0][0];
			b[0][0] = a[1][2];
			b[1][0] = a[0][2];
			b[0][2] = a[1][0];
			boolean ans = true;
			for (int i = 0; i < 2; ++i) {
				for (int j = 0; j < 3; ++j) {
					if (a[i][j] != b[i][j]) {
						ans = false;
					}
				}
			}
			out.println(ans ? "YES" : "NO");
		}
	}

	static class Task_B {

		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int ans = 1;
			for (int i = 1; i * i <= n; ++i) {
				ans = i * i;
			}
			out.println(ans);
		}
	}




	static class InputReader {

		private StringTokenizer tokenizer;
		private BufferedReader reader;

		public InputReader(InputStream is) {
			tokenizer = null;
			reader = new BufferedReader(new InputStreamReader(is), 32768);

		}

		public String nextString() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					if (line == null) return null;
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public String nextLine() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					if (line == null) return null;
					tokenizer = new StringTokenizer(line, "\n");
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public Integer nextInt() { return Integer.parseInt(nextString()); }
		public Integer[] nextIntArray(int n) {
			Integer ret[] = new Integer[n];
			int i = 0;
			while (n-- > 0) ret[i++] = nextInt();
			return ret;
		}
		public Long nextLong() { return Long.parseLong(nextString()); }
		public Long[] nextLongArray(int n) {
			Long ret[] = new Long[n];
			int i = 0;
			while (n-- > 0) ret[i++] = nextLong();
			return ret;
		}
	}
}

Measured memory_bytes: 23380
import math


length_hour, length_min, hour, minute = map(int, input().split(' '))
total_min = hour * 60 + minute

hx = math.sin((total_min / (12 * 60)) * (2 * math.pi)) * length_hour
hy = math.cos((total_min / (12 * 60)) * (2 * math.pi)) * length_hour
mx = math.sin((minute / 60) * (2 * math.pi)) * length_min
my = math.cos((minute / 60) * (2 * math.pi)) * length_min

distance = math.sqrt((hx - mx) ** 2 + (hy - my) ** 2)

print(f"{distance}")


Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
#define N 	100*1000+5

int bal, ans;
void solve(){
	int n; cin>>n;
	string s;
	cin>>s;
	rep(i,0,sz(s)){
		if(s[i]=='I')bal++;
		else bal--;
		ans = max(ans, bal);
	}
	cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc047/tasks/abc047_b

import numpy as np

W, H, N = map(int, input().split())

x_list = []
y_list = []
a_list = []

field = np.ones((H, W), dtype=np.int)

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for i in range(x):
            for j in range(H):
                field[j, i] = 0
    elif a == 2:
        for i in range(x, W):
            for j in range(H):
                field[j, i] = 0
    elif a == 3:
        for i in range(y):
            for j in range(W):
                field[i, j] = 0
    elif a == 4:
        for i in range(y, H):
            for j in range(W):
                field[i, j] = 0

print(np.count_nonzero(field == 1))
    





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

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

  string t;
  cin >> t;

  for (auto &c : t) if (c == '?') c = 'D';
  cout << t << '\n';

  return (0);
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
ll n, k;
ll v[214514];
//-------------------関数----------------------//
int main() {
  cin >> n >> k;
  REP(i, n) {
    ll a;
    cin >> a;
    v[a]++;
  }
  sort(v, v + n + 1);
  ll cnt = 0;
  REP(i, n - k + 1) { cnt += v[i]; }
  cout << cnt << endl;
}


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

int main(){
	ll n; cin >> n;
	vector<pair<ll,ll>> w(n); rep(i,n)cin >> w[i].second >> w[i].first;
	bool r = true;
	ll time = 0;
	sort(w.begin(), w.end());
	rep(i,n){
		time += w[i].second;
		if(time > w[i].first){
			r = false;
			break;
		}
	}
	if(r)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n+m; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    ll result = K;
    REP(i, N) {
        if (i != N-1) result *= K-1;
    }
    cout << result << endl;
    return 0;
}


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

int a[101];
int cnt[100];

int main()
{
	int n,N;
	scanf("%d",&n);
	N=n;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),cnt[a[i]]++;
	int D = *max_element(a+1,a+1+n);
	int B;
    for(int i=0,j=D;i<=j;i++,j--)
    {
		int P = D-min(i,j);
		if(i==j) cnt[P]--;
		else cnt[P]-=2;

		if(i==j || i==j-1)
		{
			B=P;
		}
    }
	for(int i=1;i<=N-1;i++)
		if(cnt[i]<0)
		{
			puts("Impossible");
			return 0;
		}

    for(int i=B+1;i<=N;i++)
		cnt[i]=0;
	for(int i=1;i<=N-1;i++)
		if(cnt[i])
		{
			puts("Impossible");
			return 0;
		}
	puts("Possible");
	return 0;
}


Measured memory_bytes: 384
MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def comb(n, r):
    global MOD, modFacts, invs
    return (modFacts[n] * invs[n - r] * invs[r]) % MOD


def perm(n, r):
    global MOD, modFacts, invs
    return (modFacts[n] * invs[n - r]) % MOD


S = int(input())
modFacts, invs = prepare(10 * S)
ans = 0
for k in range(1, S // 3 + 1):
    s = S - 3 * k
    cnt = comb(k - 1 + s, s)
    ans += cnt
    ans %= MOD
print(ans)


Measured memory_bytes: 64652
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}
 
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t;
	cin>>n>>x>>t;
	ll ans=(x+n-1)/x*t;
	cout<<ans<<"\n";
}

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

int main() {
    char str[256];
    int len, i;
    scanf("%s", str);
    len = strlen(str);
    for (i=len-2; i>0; i-=2)
        if (strncmp(str, str+i/2, i/2) == 0) {
            printf("%d\n", i);
            break;
        }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args){
	Scanner scn = new Scanner(System.in);
	int hp = scn.nextInt();
      int n = scn.nextInt();
      int[] a = new int[n];
      int att = 0;
      for(int i=0; i<a.length; ++i){
        a[i] = scn.nextInt();
      }
      for(int i=0; i<a.length; ++i){
        att = att + a[i];
      }
      if(att >= hp){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
	}
}

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

#define AS(arr)  (sizeof(arr)/sizeof(arr[0]))
#define ALL(c) (c).begin(),(c).end() 
#define SIZE(a) int((a).size())
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl

#define pb push_back
#define mp make_pair

typedef vector<int> VI;
typedef vector<string> VS;
typedef long long LL;

const double EPS = 1e-11;
#define EQ(a,b) (abs(a-b)<EPS)
#define EQ0(x) (abs(x)<EPS)

int main(void){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    cout << ( min(K, N) * X + max(0, N-K) * Y ) << endl;
    
}


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


  /* 配列の要素を交換する */
void Swap(long long int x[ ], int y[ ], int i, int j)
{
    long long int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
  	temp = y[i];
    y[i] = y[j];
    y[j] = temp;
}


void QSort(long long int x[ ], int y[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, y, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, y, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, y, j + 1, right);    /* 右の配列を Q ソートする */
}

int main(void)
{
  int n, m, i;
  long long int a[10000000];
  int b[10000000];
  long long int ans = 0;
  long long int sum = 0;

  scanf("%d %d", &n, &m);
  
  for (i = 0; i < n; i++){
    scanf("%lld %d", &a[i], &b[i]);
  }
  
  QSort(a, b, 0 , n-1);
  
  i = 0;
  
  while (sum != m){
    if (sum + b[i] <= m){
      ans += a[i] * b[i];
      sum += b[i];
    } else {
      ans += a[i] * (m - sum);
      sum += (m - sum);
    }
    i++;
    
  }
  
  printf("%lld", ans);
  
  return 0;
}

Measured memory_bytes: 6656
import itertools


def solve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    matrix = [[] for _ in range(N)]
    for i in range(N):
        matrix[i].append(A[i] - 1)
        matrix[i].append(A[i])
        matrix[i].append(A[i] + 1)

    cnt = 0
    for element in list(itertools.product(*matrix)):
        for i in range(N):
            if element[i] % 2 == 0:
                cnt += 1
                break

    print(cnt)


solve()

Measured memory_bytes: 11252
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner in = new MyScanner();
		int n = in.nextInt();
		int[] p = in.nextIntArray(n);
		Arrays.sort(p);
		int sum = 0;
		for (int i = 0; i < p.length; i++) {
			if (i==p.length-1) {
				sum += p[i]/2;
			} else {
				sum += p[i];
			}
		}
		System.out.println(sum);
		
	}
	
	private static class MyScanner {
		static Scanner sc = new Scanner(System.in);
		
		String next() {
			return sc.next();
		}
		
		String nextLine() {
			return sc.nextLine();
		}
		
		int nextInt() {
			return Integer.parseInt(sc.next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextInt();
			}
			return array;
		}
		
		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextDouble();
			}
			return array;
		}
		
		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}
			return array;
		}
		
	}
}

Measured memory_bytes: 23888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x[100001],y,z,h,w,k,sum,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;


int main(void){
    cin>>n>>k;
    rep(i,n)cin>>x[i];
    //右を全部使う場合から左を全部使う場合まで全探索
    //端の位置がわかればO(1)で最小距離が求まる
    rep(i,n)if(x[i]>=0){itr=i;break;}
    if(x[n-1]<0)itr=n;
    if(itr+k-1<=n-1)mi=min(mi,x[itr+k-1]);
    if(itr-k>=0)mi=min(mi,-1*x[itr-k]);
    rep(i,k-1){
        if(itr+k-i-2>n-1)continue;
        if(itr-i-1<0)continue;
        d(i)d(itr+k-i-2)d(itr-i)
        d(min(x[itr+k-i-2]*2-x[itr-i-1],x[itr+k-i-2]-2*x[itr-i-1]));
        mi=min(mi,min(x[itr+k-i-2]*2-x[itr-i-1],x[itr+k-i-2]-2*x[itr-i-1]));
    }
    p(mi);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;



int main() {
	int a, b, c,count=0;
	while (cin >> a && cin >> b) {
		c = a + b;

		while (c > 0) {
			c /= 10;
			count++;
		}

		cout << count << endl;
		count = 0;
	    
	}
	return 0;
}

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

int main()
{
string s ;
cin >> s ;
if(s[2]!=s[3])ans="No";
if(s[4]!=s[5])ans="No";
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		// standard input
		int numProblems = sc.nextInt();

		// solve
		long sum = 0;
		int max = 0;
		for (int i = 1; i <= numProblems; i++) {
			sum += i;
			if (sum >= numProblems) {
				max = i;
				break;
			}
		}

		// standard output
		for (int i = max; i > 0; i--) {
			if (i <= numProblems) {
				System.out.println(i);
				numProblems -= i;
			}

			if (numProblems <= 0) {
				break;
			}
		}
	}
}


Measured memory_bytes: 11704
#include <bits/stdc++.h>
#define fly ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define ll long long
const ll mod = 1e9 + 7;

using namespace std;
ll dp[100010][101] = {0};
int main(int argc, char const *argv[]) {
  fly;
  ll n,w;
  cin >> n >> w;
  vector<ll>weigth(n+1);
  vector<ll>cst(n+1);
  for(int i = 1;i<=n;i++){
    cin >> weigth[i] >> cst[i];
  }
  for(ll i = 0;i<=w;i++){
    for(ll j = 0;j<=n;j++){
      dp[i][j] = 0;
      if(i == 0 || j == 0)
        continue;
      dp[i][j] = max(dp[i][j], dp[i][j-1]);
      if(i>=weigth[j]){
        dp[i][j] = max(dp[i][j], dp[i-weigth[j]][j-1] + cst[j]);
      }
    }
  }
  ll ans = 0;
  for(ll i = 0;i<=w;i++){
    ans = max(ans, dp[i][n]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 82544
using System;
using System.Collections.Generic;
class Program
{
	//static long[,] dp;
	//static	Dictionary<string, long> dp;
	//static int[] weight, value;
    //static List<string> str = new List<string>();
	static void Main(string[] args)
	{
			// 入力フェーズ
			//int N = Int32.Parse(Console.ReadLine());
			//string[] input = Console.ReadLine().Split(' ');
			string input = Console.ReadLine(); // R...L
			int N =input.Length;

			// 長さNのListを初期値1で作る
			List<int> kids = new List<int>();
			for(int i=0; i<N; i++)
			{
				kids.Add(1);
			}

			// 左から初めて、Rの子を順次移動させる
			for(int i=0; i<N-1; i++)
			{
				if(input[i] == 'R')
				{
					if(input[i+1] == 'L')
					{
						// 移動しない
					}
					else
					{
						// 2マス移動させる（右端は必ずLなのでindex out of Rangeしない）
						int numOfkids = kids[i];
						kids[i] = 0;
						kids[i+2] = kids[i+2] + numOfkids;
					}
				}
			}

			// 右から始めて、Lの子を順次移動させる
			for(int i=N-1; i>0; i--)
			{
				if(input[i] == 'L')
				{
					if(input[i-1] == 'R')
					{
						// 移動しない
					}
					else
					{

						// 2マス移動させる（左端は必ずRなのでindex out of Rangeしない）
						int numOfkids = kids[i];
						kids[i] = 0;
						kids[i-2] = kids[i-2] + numOfkids;
					}
				}
			}

	// 10^100 = 偶数なので、偶数回振動した後は同じ位置に戻る
			Console.Write(kids[0] + "");
			for(int i=1; i<N; i++)
			{
				Console.Write(" " + kids[i]);
			}

    }
}


Measured memory_bytes: 17436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
  cin>>s;
if(s[0] != s[1] && s[1] != s[2] && s[0] != s[2]){
  cout<<"Yes"<<endl;
}
  else{
    cout<<"No"<<endl;
  }
 
}

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

int n,m,k;

deque<pair<int,int> >q;

int dx[]= {-1,0,1,0};
int dy[]= {0,1,0,-1};
int dd[]= {-2,-1,0,1,2};

bool isValid(int x,int y)
{

    if(x<1 || x>n || y<1 || y>m)
        return false;

    return true;

}

int main()
{

    cin>>n>>m;
    int x1,x2,y1,y2;
    cin>>x1>>y1;
    cin>>x2>>y2;
    char a[n+5][m+5];
    int dis[n+5][m+5];

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

    q.push_front({x1,y1});
    dis[x1][y1]=0;
    while(!q.empty())
    {
        int currX=q.front().first;
        int currY=q.front().second;
        q.pop_front();
        for(int i=0; i<4; i++)
        {
            int newX=currX+dx[i];
            int newY=currY+dy[i];
            if(isValid(newX,newY) && a[newX][newY]!='#' && dis[newX][newY]> dis[currX][currY])
            {
                dis[newX][newY]=dis[currX][currY];
                q.push_front({newX,newY});

            }
        }

        for(int i=0; i<5; i++)
        {
            for(int j=0; j<5; j++)
            {
                int newX=currX+dd[i];
                int newY=currY+dd[j];
                if(isValid(newX,newY) && a[newX][newY]!='#' && dis[newX][newY]>1+dis[currX][currY])
                {
                    dis[newX][newY] = dis[currX][currY]+1;
                    q.push_back({newX,newY});

                }

            }
        }
    }


    int ans=dis[x2][y2];
    if(ans==INT_MAX)
        cout<<-1<<endl;
    else
        cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8556
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int Tpoint = 0;
    int Hpoint = 0;
    int T[] = new int[100];
    int H[] = new int[100];
    
 
    for(int i = 0; i < n; i++){
      for(int x = 0; x < 100; x++){
        T[x] = 0;
        H[x] = 0;
      }
      String strT = sc.next();
      int Tnum = strT.length();
      for(int x = 0; x < Tnum; x++){
        char c = strT.charAt(x);
        T[x] += Character.getNumericValue(c);
      }
      String strH = sc.next();
      int Hnum = strH.length();
      for(int x = 0; x < Hnum; x++){
        char c = strH.charAt(x);
        H[x] += Character.getNumericValue(c);
      }
      
      for(int x = 0; x < 100; x++){
        if(T[x] > H[x]){
          Tpoint += 3;
          break;
        }else if(T[x] < H[x]){
          Hpoint += 3;
          break;
        }else if(T[x] == 0 && H[x] == 0){
          Tpoint += 1;
          Hpoint += 1;
          break;
        }
      }
    }
    System.out.println(Tpoint+" "+Hpoint);
  }
}


Measured memory_bytes: 30100
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#define lson i<<1
#define rson i<<1|1
#define up(i,x,y) for(i=x;i<=y;i++)
#define down(i,x,y) for(i=x;i>=y;i--)
#define mem(a,x) memset(a,x,sizeof(a))
#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d%d",&x,&y)
#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld%lld",&x,&y)
#define gc(x) scanf("%c",&x)
#define gc2(x,y) scanf("%c%c",&x,&y)
using namespace std;
const double eps=1e-8; 
typedef long long ll;
const double PI = acos(-1.0); 
const int MAXN=100005;
const ll mod=1e7+9;
const ll llinf = (ll)(1e18) + 500;
const int inf=0x3f3f3f3f;
int a[MAXN];
int main(){
	
	
	ll n,m;
	gll2(n,m);
	n%=m;
	cout<<min(n,m-n)<<endl;
	
	
	return 0;
}



















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string o,e;cin >> o >> e;
	rep(i,e.size()){
		cout << o.at(i) << e.at(i);
	}
	if(o.size() != e.size()) cout << o.at(o.size() - 1);
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

constexpr int mod = int(998244353);

int add(int a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	return a;
}

int mul(int a, int b) {
	return int(a * LL(b) % mod);
}

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

	int n;
	cin >> n;
	vector<pair<int, int>> in(n);
	for(auto &p : in)
		cin >> p.first >> p.second;
	sort(in.begin(), in.end());
	vector<int> x(n), d(n);
	REP(i, n)
		tie(x[i], d[i]) = in[i];
	debug(x, d);

	/*constexpr int inf = int(2e9 + 1);
	vector<int> range(n, -inf);
	for(int i = n - 1; i >= 0; --i) {
		if(i != n - 1 and x[i] + d[i] > x[i + 1])
			range[i] = range[i + 1];
		range[i] = max(range[i], x[i] + d[i]);
	}
	debug(range);

	vector<int> until(n, -1);
	for(int i = n - 1; i >= 0; --i) {
		auto last = lower_bound(x.begin(), x.end(), range[i]);
		until[i] = int(prev(last) - x.begin());
	}
	debug(until);*/

	vector<int> until(n);
	for(int i = n - 1; i >= 0; --i) {
		until[i] = i;
		while(until[i] + 1 < n and x[i] + d[i] > x[until[i] + 1])
			until[i] = until[until[i] + 1];
	}
	debug(until);

	vector<int> dp(n + 1);
	dp[n] = 1;
	dp[n - 1] = 2;
	for(int i = n - 2; i >= 0; --i) {
		// not taking
		dp[i] = dp[i + 1];
		// taking
		dp[i] = add(dp[i], dp[until[i] + 1]);
	}
	debug(dp);
	cout << dp[0] << '\n';
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int r;
    cin >> r;
    cout << 3*r*r << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
const long long INF = 123456789987654321;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int v, e;
	cin >> v >> e;
	vector<vector<long long>> g(v, vector<long long>(v, INF));
	for(int i = 0; i < v; i++) g[i][i] = 0;
	for(int i = 0; i < e; i++) {
		int s, t, d;
		cin >> s >> t >> d;
		g[s][t] = d;
	}
	for(int i = 0; i < v; i++) {
		for(int j = 0; j < v; j++) {
			for(int k = 0; k < v; k++) {
				if(g[j][i] == INF || g[i][k] == INF) continue;
				g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
			}
		}
	}
	for(int i = 0; i < v; i++) {
		if(g[i][i] < 0) {
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	for(int i = 0; i < v; i++) {
		for(int j = 0; j < v; j++) {
			if(g[i][j] == INF) {
				cout << "INF";
			}
			else {
				cout << g[i][j];
			}
			if(j == v - 1) {
				cout << '\n';
			}
			else {
				cout << " ";
			}
		}
	}
		
	return 0;	
}



Measured memory_bytes: 3312