akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 11;
struct ddd{
    int x, y, id, tp;
    bool operator < (const ddd &a) const{
        if(tp != a.tp)return tp < a.tp;
        else{
            if(tp == 1)return y < a.y;
            else if(tp == 2)return x < a.x;
            else if(tp == 3)return y > a.y;
            else if(tp == 4)return x > a.x;
        }
    }
};
vector<ddd> nd;
int n, r, c;
int zh[N], tp;
bool mark[N];
bool check(int x, int y){
    if(x > 0 && x < r && y > 0 && y < c)return 0;
    return 1;
}
void get(int x, int y, int id){
    ddd now;
    now = (ddd){x, y, id, 0};
    if(x == 0 && y < c)now.tp = 1;
    else if(x < r && y == c)now.tp = 2;
    else if(x == r && y > 0)now.tp = 3;
    else now.tp = 4;
    nd.push_back(now);
}
int main(){
    //freopen("arc076e.in", "r", stdin);
    cin>>r>>c>>n;
    int x1, x2, y1, y2;
    for(int i = 1;i <= n; i++){
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        if(check(x1, y1) && check(x2, y2)){
            get(x1, y1, i); get(x2, y2, i);
        }
    }
    sort(nd.begin(), nd.end());
    int s = nd.size();
    for(int i = 0;i < s; i++){
        if(tp == 0){
            zh[++tp] = nd[i].id;
            mark[nd[i].id] = 1;
        }
        else{
            if(mark[nd[i].id]){
                if(zh[tp] == nd[i].id)tp--;
                else {
                    puts("NO");
                    return 0;
                }
            }
            if(!mark[nd[i].id]){
                mark[nd[i].id] = 1;
                zh[++tp] = nd[i].id;
            }
        }
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 6128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{ 
    static void Main(string[] args)
    {
        var num = Input.num;
        var ar = Input.ar;Array.Sort(ar);
        var last = 0;
        long sum = ar[0];
        for (var i = 1; i < num; i++)
            if (2 * sum < ar[i])
            {
                sum += ar[i];
                last = i;
            }
            else sum += ar[i];
        WriteLine(num - last);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 25052
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    sc.close();

    String ans = N <= M ? "Yes" : "No";
    System.out.println(ans);
  }
}

Measured memory_bytes: 25172
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int X, Y; 
  cin >> X >> Y;

  REP(i, 500) REP(j, 500){
    if(i+j == X && i*2+j*4 == Y){
      Yes;
      return 0;
    }
  }

  No;

  return 0;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define LL long long

int main() {
	LL N, M, Mnew, ans = 0;
	cin >> N >> M;
	if(M >= 2*N) {
		ans += N;
		Mnew = M - 2*N;
	}
	else {
		ans += M/2;
		Mnew = M - 2*ans;
	}
	ans += Mnew/4;
	if(M < 2) ans = 0;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
const int MOD = 1000000007;
/*
dp[i][j]
(1,1)から(i,j)までの経路数

--遷移--
dp[i][j] = dp[i-1][j] + dp[j-1][i]
ただし、a[i][j] == '#' のとき dp[i][j] = 0
dp[0][j] = dp[i][0] = 0
(1-index)
*/

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

    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];

    vector<vector<int>> dp( h+1, vector<int>(w+1) );
    dp[1][1] = 1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if( !(i==1&&j==1) ){
                if(a[i-1][j-1] == '#') dp[i][j] = 0;
                else dp[i][j] = (dp[i-1][j]+dp[i][j-1])%MOD;
            }
        }
    }

    int ans = dp[h][w];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String args[]) throws IOException {
    InputStreamReader br = new InputStreamReader(System.in);	
    BufferedReader is = new BufferedReader(br);
    String str = is.readLine();
    int x = Integer.parseInt(str);
    int h,m,s;
    h=x/3600;
    x=x%3600;
    m=x/60;
    s=x%60;
    System.out.println(h + ":" +  m + ":" + s);
    }
}

Measured memory_bytes: 24188
#include<stdio.h>

const int MAXN = 10000;
int n, v[MAXN], la2[MAXN];

int main ()
{
	int sum = 0;

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
		int cp = v[i];
		while((cp & 1) == 0) {
			cp = (cp >> 1);
			la2[i]++;
		}
		sum += la2[i];
	}

	printf("%d\n", sum);

	return 0;
}


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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;
typedef pair <LL, int> pli;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 1e5 + 100, Maxm = 2e5 + 100;
const LL inf = 1e18;
const int Mod = 1e9 + 7;

int N, M;
int S, T;
int e, Begin[Maxn], To[Maxm << 1], Next[Maxm << 1], W[Maxm << 1];

inline void add_edge (int x, int y, int z) { To[++e] = y; Next[e] = Begin[x]; Begin[x] = e; W[e] = z; }

inline void Add (int &a, int b) { if ((a += b) >= Mod) a-= Mod; }

struct Graph
{
	LL Dis[Maxn];
	int Num[Maxn], Vis[Maxn];
	priority_queue <pli, vector <pli>, greater <pli> > Q;

	inline void dij (int s)
	{
		for (int i = 1; i <= N; ++i) Dis[i] = inf, Num[i] = 0;

		Q.push (mp (0, s));
		Dis[s] = 0, Num[s] = 1;

		while (!Q.empty())
		{
			int x = Q.top().y; Q.pop();
			if (Vis[x]) continue;
			Vis[x] = 1;
			for (int i = Begin[x]; i; i = Next[i])
			{
				int y = To[i];
				if (Chkmin (Dis[y], Dis[x] + W[i])) Num[y] = Num[x], Q.push (mp (Dis[y], y));
				else if (Dis[y] == Dis[x] + W[i]) Add (Num[y], Num[x]);
			}
		}
	}
} G[2];

inline int sqr (int x) { return (LL) x * x % Mod; }

inline void Solve ()
{
	G[0].dij (S), G[1].dij (T);

	LL dist = G[0].Dis[T];
	int ans = sqr (G[0].Num[T]);

	for (int i = 1; i <= N; ++i)
	{
		LL d0 = G[0].Dis[i], d1 = G[1].Dis[i];
		int g0 = G[0].Num[i], g1 = G[1].Num[i];

		if ((d0 == d1) && (d0 + d1 == dist)) 
			Add (ans, Mod - sqr ((LL) g0 * g1 % Mod));
	}

	for (int x = 1; x <= N; ++x)
		for (int i = Begin[x]; i; i = Next[i])
		{
			int y = To[i];
			LL d0 = G[0].Dis[x], d1 = G[1].Dis[y], d = W[i];
			int g0 = G[0].Num[x], g1 = G[1].Num[y];

			if ((d0 + d + d1 == dist) && (d0 + d > d1) && (d1 + d > d0))
				Add (ans, Mod - sqr ((LL) g0 * g1 % Mod));
		}

	cout << ans << endl;
}

inline void Input ()
{
	N = read<int>(), M = read<int>();
	S = read<int>(), T = read<int>();
	for (int i = 1; i <= M; ++i)
	{
		int x = read<int>(), y = read<int>(), z = read<int>();
		add_edge (x, y, z);
		add_edge (y, x, z);
	}
}

int main()
{

#ifdef hk_cnyali
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}


Measured memory_bytes: 13040
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;

int main() {

	int a,b; 
	cin >> a >> b;
	
	if((a*b)%2 == 1) cout << "Odd" << endl;
	else cout << "Even" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W;
	int i, j;

	scanf("%d %d", &H, &W);
	
	while (!(H == 0 && W == 0)) {
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if ((i % 2) == (j % 2))
					putchar('#');
				else
					putchar('.');
			}
			putchar('\n');
		}
		putchar('\n');

		scanf("%d %d", &H, &W);
	}

	return 0;
}

Measured memory_bytes: 572
import java.io.*;
import java.util.*;
import java.util.Map.Entry;


public class  Main{
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		HashSet<Integer>hs=new HashSet<Integer>();
		hs.add(sc.nextInt());
		hs.add(sc.nextInt());
		hs.add(sc.nextInt());
		if(hs.size()==2) {
			pw.println("Yes");
			
		}
		else {
			pw.println("No");
		}
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 22612
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main()
{
    //system("chcp 65001");

    int N;
    cin >> N;

    int i,j;

    bool ans = false;

    for(i = 1;i <= 9;i++)
    {
        for(j = 1;j <= 9;j++)
        {
            if(N == i*j)
            {
                cout << "Yes";
                ans = true;
            }
        }
        if(ans == true) break;
    }

    if(ans == false)
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.IOException;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        String[] a = new String[1000];
        int i = 0;
        a[i] = sc.next();
            try{
                while(a[i] != null){
                    boolean b = isNumber(a[i]);
                if(b){
                    list.add(Integer.parseInt(a[i]));
                }else{
                    if(a[i].equals("+")){
                        list.set(list.size()- 2, list.get(list.size()- 1) + list.get(list.size()- 2));
                        list.remove(list.size()-1);
                    }else if(a[i].equals("-")){
                        list.set(list.size()- 2, list.get(list.size()- 2) - list.get(list.size()- 1));
                        list.remove(list.size()- 1);
                    }else{
                        list.set(list.size()- 2, list.get(list.size()- 1) * list.get(list.size()- 2));
                        list.remove(list.size()- 1);
                    }
                }
                i++;
                a[i] = sc.next();
            }
                
        }catch(Exception e){
            
        }
            
        System.out.println(list.get(0));
    }
    public static boolean isNumber(String num) {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
}
}




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

int main(){
 int N,K;
 cin>>N>>K;
 int a[60];
 for(int i=0;i<N;i++)cin>>a[i];

 sort(a,a+N,greater<int>());
 int nagasa;
 for(int i=0;i<K;i++){
  nagasa += a[i];
 }

 cout<<nagasa<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using iii = pair<int, ii>;

using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvvi = vector<vi>;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	vi v(n); for (int i = 0; i < n; ++i) cin >> v[i];

	bool pos = true;
	--v[0];
	for (int i = 1; i < n; ++i) {
		if (v[i] == v[i - 1]) {}
		else if (v[i] > v[i - 1]) { --v[i]; }
		else if (v[i - 1] > v[i]) {
			pos = false;
			break;
		}
	}

	if (pos) cout << "Yes\n";
	else cout << "No\n";

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>

using namespace std;



int main(){
	int A, B, C, X;
	int clear = 0;
	cin >> A >> B >> C >> X;
	
	for (int a = 0; a <= A; a++){
		for (int b = 0; b <= B; b++){
			for (int c = 0; c <= C; c++){
				int total = 500 * a + 100 * b + 50 * c;
				if (total == X){
					clear++;
				}
			}
		}
	}
	cout << clear << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pr pair<int,int>
using namespace std;

typedef bitset<2005>bt;
int n,m;
vector<int>vo[2005];
bt G[2005];
bt onpath[2005][2005];
vector<pr>edg;
void dfs(int rt,int x,int ba=-1) {
	onpath[rt][x][x] = 1;
	for(auto y:vo[x]) {
		if(y==ba) continue;
		onpath[rt][y] = onpath[rt][x];
	}
	for(auto y:vo[x]) {
		if(y==ba) continue;
		dfs(rt,y,x);
		onpath[rt][x]  |= onpath[rt][y];
	}
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++) {
		int x,y; scanf("%d%d",&x,&y);
		vo[x].push_back(y); vo[y].push_back(x);
	}
	for(int i=1;i<=n;i++) dfs(i,i),G[i][i] = 1;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) onpath[i][j] |= onpath[j][i];
	}
	for(int i=1;i<=m;i++) {
		int x,y; scanf("%d%d",&x,&y);
		edg.push_back(pr(x,y));
		G[x][y] = G[y][x] = 1;
	}
	for(int j=0;j!=edg.size();j++) {
		auto p = edg[j];
		int x = p.first; int y = p.second;
		if(!G[x][y]) {
			cerr<<"WTF";
			exit(0);
		}
		bt tmp = ((G[x]^G[y]) & (onpath[x][y]) );
		for(auto i = tmp._Find_first();i!=tmp.size();i=tmp._Find_next(i)) {
			if(!G[x][i]) {
				G[x][i] = G[i][x] = 1;
				edg.push_back(pr(i,x));
			} else if(!G[y][i]) {
				G[y][i] = G[i][y] = 1;
				edg.push_back(pr(i,y));
			}
		}
	}
	printf("%d",(int)edg.size());
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

struct Pos{
    int x,y;
    Pos(int x,int y):x(x),y(y){}
};

int H,W;
int Ch,Cw;
int Dh,Dw;
string field[1005];
int s[1005][1005];
int d[1000005];
bool visited[1005][1005];
int id;
set<int> E[1000005];


void init(){
    id=0;
    for(int i=0;i<1000003;++i)d[i]=INF;
    for(int i=0;i<1003;++i){
        for(int j=0;j<1003;++j){
            s[i][j]=-1;
            visited[i][j]=false;
        }
    }
}

void bfs1(int sx,int sy){
    queue<Pos> que;
    que.push(Pos(sx,sy));
    s[sy][sx]=id;
    visited[sy][sx]=true;
    while(que.size()){
        Pos p=que.front();
        que.pop();
        for(int i=0;i<4;++i){
            int nx=p.x+dx[i],ny=p.y+dy[i];
            if(nx<0||nx>=W||ny<0||ny>=H)continue;
            if(visited[ny][nx])continue;
            if(s[ny][nx]!=-1)continue;
            if(field[ny][nx]=='#')continue;
            que.push(Pos(nx,ny));
            s[ny][nx]=id;
            visited[ny][nx]=true;
        }
    }
    id++;
}

void bfs2(int s){
    queue<int> que;
    que.push(s);
    d[s]=0;
    while(que.size()){
        int p=que.front();
        que.pop();
        for(auto u:E[p]){
            if(d[u]!=INF)continue;
            que.push(u);
            d[u]=d[p]+1;
        }
    }
}

signed main(){
    init();
    cin>>H>>W;
    cin>>Ch>>Cw;
    cin>>Dh>>Dw;
    Ch--,Cw--;
    Dh--,Dw--;
    for(int i=0;i<H;++i)cin>>field[i];
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            if(field[y][x]=='#')continue;
            if(s[y][x]!=-1)continue;
            bfs1(x,y);
        }
    }
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            if(field[y][x]=='#')continue;
            for(int i=-2;i<=2;++i){
                for(int j=-2;j<=2;++j){
                    int nx=x+i,ny=y+j;
                    if(nx<0||nx>=W||ny<0||ny>=H)continue;
                    if(s[ny][nx]==s[y][x])continue;
                    if(field[ny][nx]=='#')continue;
                    E[s[y][x]].insert(s[ny][nx]);
                    E[s[ny][nx]].insert(s[y][x]);
                }
            }
        }
    }
    bfs2(s[Ch][Cw]);
    if(d[s[Dh][Dw]]==INF)cout<<-1<<endl;
    else cout<<d[s[Dh][Dw]]<<endl;
}

Measured memory_bytes: 87476
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> x(n), y(n);
	for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);
	
	double ans = 0;
	std::vector<int> vec(n, -1);
	auto solve = [&](auto && solve, int cnt) -> void {
		if(cnt == n) {
			std::vector<int> ord(n, 0);
			for(int i = 0; i < n; i++) ord[vec[i]] = i;

			for(int i = 0; i < n - 1; i++) {
				int A = ord[i], B = ord[i + 1];
				
				ans += sqrt(
							(x[A] - x[B]) * (x[A] - x[B]) +
							(y[A] - y[B]) * (y[A] - y[B])
							);
			}
			return;
		}
		
		for(int i = 0; i < n; i++) {
			if(vec[i] != -1) continue;
			vec[i] = cnt;
			solve(solve, cnt + 1);
			vec[i] = -1;
		}
	};
	solve(solve, 0);

	for(int i = 1; i <= n; i++) ans /= (double)i;
	printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i <= 0; i--)
#define w(t) int t; cin >> t; while (t--)


typedef unsigned long long ull;
typedef vector<long long> vi;
#define ull unsigned long long
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int sum=0;
    f(s.size())
    {
        sum+=s[i]-'0';
    }
    //cout<<sum<<endl;
    if(sum%9==0)
    {
        yes;
    }
    else
    {
        no;
    }

    

    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n;
	ios::sync_with_stdio(0);
	cin>>m>>n;
	if(m<1||m>9||n<1||n>9) cout<<-1<<"\n";
	else cout<<m*n<<"\n";
	return 0; 
}

Measured memory_bytes: 256
n = int(input())
r = n
left = n//100
n = n%100
pay = 0
chance = 0
for i in range(5, 0,-1):
	pay+=(n//i)
	chance+=(n%i)
	n=n%i
if pay<=left:
	print(1)
else:
	print(0)

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

int main() {
    int N;
    cin >> N;
    long long res=1;
    int U = pow(10,9)+7;
    for (int i=1; i<=N; i++) {
        res *= i;
        if (res>=U) res%=U;
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
local s = io.read()
local t = io.read()
local ret = 1000000007
for i = 1, #s - #t + 1 do
  local z = 0
  for j = i, i + #t - 1 do
    if s:byte(j) ~= t:byte(j - i + 1) then
      z = z + 1
    end
  end
  if z < ret then ret = z end
end
print(ret)


Measured memory_bytes: 2692
#include <stdio.h>
int N[300],dist[300][300],dice[6];
main(){
	int M,s,g,i,j,k;
	//input
	scanf("%d",&M);
	for(i=0;i<6;i++)scanf("%d",dice+i);
	scanf("%d%d",&s,&g);s--,g--;
	for(i=0;i<M;i++)scanf("%d",N+i);
	//setup
	memset(dist,11,sizeof(dist));
	for(i=0;i<M;i++){
		dist[i][i]=0;
		for(j=0;j<6;j++){
			k=i+dice[j];
			if(k<M&&i!=k+N[k])dist[i][k+N[k]]=1;
			k=i-dice[j];
			if(k>=0&&i!=k+N[k])dist[i][k+N[k]]=1;
		}
	}
	//warshall-floyd
	for(k=0;k<M;k++)for(i=0;i<M;i++)for(j=0;j<M;j++)
		if(dist[i][j]>dist[i][k]+dist[k][j])dist[i][j]=dist[i][k]+dist[k][j];
	//interaction started
	int test,coor[3],cost[3];
	for(test=0;test<3000;test++){
		scanf("%d",&k);k=dice[k-1];
		coor[0]=s-k,coor[1]=s,coor[2]=s+k;
		cost[0]=coor[0]>=0?dist[coor[0]+=N[coor[0]]][g]:999;
		cost[1]=dist[coor[1]][g];
		cost[2]=coor[2]<M?dist[coor[2]+=N[coor[2]]][g]:999;
		for(k=0,j=1;j<3;j++)if(cost[k]>cost[j])k=j;
		printf("%d\n",k-1),fflush(stdout),s=coor[k];
		if(s==g)break;
	}
	if(test==3000)return 1;
}

Measured memory_bytes: 1308
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println(Math.min(a,b) + Math.min(c,d));
  }
}

Measured memory_bytes: 22100
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 2001;
const LL INF = 1e15;

int n,z,w;
LL dp[N][2];
int A[N];
LL solve(int idx, int p) {
  if(idx == n + 1) {
    assert(p == 0);
    return 0;
  }

  LL &res = dp[idx][p];
  if(res != -1) {
    return res;
  }
  if(!p) {
    res = 0;
    rep(i,idx,n+1) {
      if(i < n) {
        res = max(res, solve(i + 1, p ^ 1));
      } else {
        res = max(res, 1LL * abs(A[n] - A[idx-1]));
      }
    }
  } else {
    res = INF;
    rep(i,idx,n+1) {
      res = min(res, solve(i + 1, p ^ 1) + ((i == n) ? abs(A[i] - A[idx - 1]) : 0));
    }
  }
  return res;
}

int main() {
  scanf("%d%d%d",&n,&z,&w);
  rep(i,1,n+1) S(A[i]);
  A[0] = w;
  memset(dp, -1, sizeof(dp));
  printf("%lld\n",solve(1,0));
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

//ofstream out("debug.txt");

const int MxN = 1e5, md = 1e9 + 7;

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

    int n, x, t;
    cin >> n >> x >> t;
    cout << (n / x) * t + t * (n % x > 0) << '\n';
}

Measured memory_bytes: 3648
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
row = 0
column = 0
flg = True
while True:
    flg = True
    if N < M+column:
        break
    row = 0
    while True:
        flg = True
        if N < M+row:
            break
        for i in range(M):
            for k in range(M):
                if B[i][k] != A[i+column][k+row]:
                    flg = False
                    break
        if flg:
            print('Yes')
            exit()
        row += 1
    column += 1
print('No')

Measured memory_bytes: 3064
#include<stdio.h>
  
#define M 2000001
#define INFTY (1<<30)
  
int H, A[M];

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s", com);
    if(com[0]=='e' && com[1]=='n'){
      break;
    }
    if(com[0]=='i'){
      scanf("%d", &key);
      insert(key);
    }
    else printf("%d\n", extract());
  }
     
  return 0;
}

void maxHeapify(int i){
  int l, r, biggest, tmp;
     
  l = 2 * i;
  r = 2 * i + 1;
 
  if(l <= H && A[l] > A[i]) biggest=l;
  else biggest=i;
     
  if(r <= H && A[r] > A[biggest]) biggest=r;
  if(biggest != i){
    tmp = A[i];
    A[i] = A[biggest];
    A[biggest] = tmp;
    maxHeapify(biggest);
  }
}
  
int extract(){
  int maxv;
  if(H < 1)return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}
  
void increKey(int i, int key){
  int tmp;
  if(key < A[i]) return;
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i/2;
  }
}
  
void insert(int key){
  H++;
  A[H] = -INFTY;
  increKey(H,key);
}

Measured memory_bytes: 4696
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String s = sc.next();
        int mojisuu = n/2;
        List<String> moji = new ArrayList<>();
        for (int i=0;i<mojisuu;++i)
        {
            moji.add(s.substring(i,i+1));
        }
        List<String> moji2 = new ArrayList<>();
        for (int i=mojisuu;i<s.length();++i)
        {
            moji2.add(s.substring(i,i+1));
        }

        if (moji.size()!=moji2.size())
        {
            System.out.println("No");
        }else
        {
            int j = 0;
            String answer = "Yes";
            for (int i=0;i<mojisuu;++i)
            {
                if (!moji.get(i).equals(moji2.get(i)))
                {
                    answer = "No";
                    break;
                }
            }
            System.out.println(answer);
        }
        sc.close();
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>

using namespace std;

long long sum(long long nb)
{
  if (nb <= 0)
    return 0;
  else
    return nb + sum(nb-1);
}

int main()
{
  string s;
  cin >> s;
  int i = 0;
  long long total = 0;
  while (i < s.size())
  {
    long long inc = 0, dec = 0;
    while (i < s.size() && s[i] == '<')
    {
      ++inc;
      ++i;
    }
    while (i < s.size() && s[i] == '>')
    {
      ++dec;
      ++i;
    }
    //cout << sum(inc - 1) << ' ' << sum(dec - 1) << '\n';
    total += sum(max(0ULL, inc - 1ULL)) + sum(max(0ULL, dec - 1ULL)) + max(inc, dec);
    //cout << inc << ' ' << dec << ' ' << total << '\n';
  }
  cout << total << '\n';
}


Measured memory_bytes: 900
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(),(a).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i,a,b) for(ll i=a;i<b;i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1001;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;

ll power(ll n, ll k, ll m) {
    ll ans = 1;
    while (k) {
        if (k & 1)ans = (ans * n) % m;
        k /= 2;
        n = (n * n) % m;
    }
    return ans;
}

int main() {
    IOS;

    ll T = 1; //cin >> T;
    while (T--) {
		string s;cin>>s;
		if(s[0]=='7'||s[1]=='7'||s[2]=='7')cout<<"Yes\n";
		else cout<<"No\n";
		
		
		
    }
    return 0;
}


Measured memory_bytes: 3648
import bisect

if __name__ == '__main__':
    n = int(input())
    l = list(map(int,input().split()))

    l = sorted(l)

    answer = 0
    for i in range(0,n):
        for j in range(i+1,n):
            k = bisect.bisect_left(l, l[i]+l[j])
            answer += max(0,k-(j+1))

    print(answer)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdint>

int main()
{
	std::uint32_t num_rectangles = 0;
	std::uint32_t num_lozenges = 0;
	std::uint32_t side1, side2, diagonal;
	char comma;
	while (std::cin >> side1 >> comma >> side2 >> comma >> diagonal) {
		if (side1 * side1 + side2 * side2 == diagonal * diagonal) {
			++num_rectangles;
		}
		else if (side1 == side2) {
			++num_lozenges;
		}
	}
	std::cout << num_rectangles << '\n' << num_lozenges << std::endl;
	return 0;
}

Measured memory_bytes: 1152
A,B,K=map(int,input().split())
if A+K-1>=B-K+1:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)


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

int main(){
    string s;
    cin >> s;
    long long count=0;
    long long b=0;long long w=0;
    long long counts=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            count+=i-counts;
            counts++;
            w++;    
        }
        else{
            b++;
        }
        
    }
    if(b==0){
        cout << 0 << endl;
        return 0;
    }
    if(w==0){
        cout << 0 << endl;
        return 0;
    }
    cout << count << endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int a = Integer.parseInt(tokens[0]);
		int b = Integer.parseInt(tokens[1]);
		if (a <= b) {
			System.out.println(a);
		} else {
			System.out.println((a - 1));
		}
	}

	void calc() {
	}

	void showResult() {
	}
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define pb push_back

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) {return b < a ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, T b) {return b > a ? a = b, 1 : 0;}

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

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

struct Node {
	int x, y, id;
} lt[N];

struct Cmp {
	inline bool operator () (const Node &lhs, const Node &rhs) {
		return lhs.x != rhs.x ? lhs.x < rhs.x : lhs.y < rhs.y;
	}
};

vector<int> G[N]; int con[N];

inline void Add(int u, int v) { G[u].pb(v); G[v].pb(u); }

int n, a, b, dis;
void Work(int d) {
	sort(lt + 1, lt + n + 1, Cmp());
	int l = 1, r = 0, pos = 1;
	For (i, 1, n) {
		while (l < n && (lt[l].x < lt[i].x - dis || (lt[l].x == lt[i].x - dis && lt[l].y < lt[i].y - d))) ++ l;
		while (r < n && (lt[r + 1].x < lt[i].x - dis || (lt[r + 1].x == lt[i].x - dis && lt[r + 1].y <= lt[i].y + d))) ++ r;
		con[lt[i].id] += r - l + 1;
		for (chkmax(pos, l); pos <= r; ++ pos) Add(lt[i].id, lt[pos].id); -- pos;
	}
}

long long ans = 0; bitset<N> vis;

void Dfs(int u) {
	if (vis[u]) return ; vis[u] = true; ans += con[u];
	for (int v : G[u]) Dfs(v);
}

int main() {

	File();

	n = read(), a = read(), b = read();

	For (i, 1, n) {
		int x = read(), y = read();
		lt[i] = (Node) {x + y, x - y, i};
	}
	dis = max(abs(lt[a].x - lt[b].x), abs(lt[a].y - lt[b].y));

	Work(dis); For (i, 1, n) swap(lt[i].x, lt[i].y); Work(dis - 1);

	Dfs(a); printf ("%lld\n", ans);

	return 0;

}


Measured memory_bytes: 13440
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


int main(){
    
    int N; cin>>N;
    vector<int> p(N);
    REP(i,N)cin>>p[i];
    
    vector<int> a(N),b(N);
    REP(i,N)a[p[i]-1]=(p[i])*30000+i;
    REP(i,N)b[i]=(N-i)*30000;
    
    REP(i,N-1)cout<<a[i]<<" ";
    cout<<a[N-1]<<endl;
    REP(i,N-1)cout<<b[i]<<" ";
    cout<<b[N-1]<<endl;
    
    return 0;
}


Measured memory_bytes: 896
fn main() {
	let s: String = read_line();
	let w: i32 = read_line();

	let mut i = 0;	
	for c in s.chars() {
		if i % w == 0 {
			print!("{}", c);
		}
		i += 1;
	}
	println!("");
}

fn read_line<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

typedef lli number;
typedef vector<number> vec;
typedef vector<vec> matrix;

matrix mul(const matrix &a, const matrix &b){
	int h = a.size();
	int w = b[0].size();
	int r = b.size();
	matrix c(h, vec(w, 0));
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			for(int k=0; k<r; k++){
				c[i][j] += a[i][k] *b[k][j];
				c[i][j] %= mod;
			}
		}
	}
	return c;
}

lli fibonacci(lli n){
	matrix a(2, vec(2, 1)), ret(2, vec(2, 0));
	a[1][1] = 0;
	ret[0][0] = ret[1][1] = 1;
	for(int i=63; i>=0; i--){
		ret = mul(ret, ret);
		if((1LL<<i & n) != 0){
			ret = mul(ret, a);
		}
	}
	return ret[0][1];
}

int main(){
	lli k;
	cin >> k;
	lli row, col; // 0-idx
	for(lli i=sqrt(k); ; i++){
		if(i*(i+1) >= k){
			if(i*i >= k){
				row = (i-1)*2;
				col = k -i*(i-1) -1;
			}else{
				row = (i-1)*2 +1;
				col = k -i*i -1;
			}
			break;
		}
	}
	
	lli fhalf = row/4 +1;
	lli ans;
	if(col < fhalf){
		ans = fibonacci((col+1)*2) * fibonacci(row+2 -col*2);
	}else{
		lli w = row/2 +1;
		ans = fibonacci((w-col)*2 +1) * fibonacci(row+3 -(w-col)*2);
	}
	ans %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3080
n=int(input())
a=list(map(int,input().split()))
startpt=0
indexer=0
maxi=0
i=1
while(i<n):
    if(a[i]>a[i-1]):
        maxi=max(i-startpt-1,maxi)
        startpt=i
        
    i+=1
maxi=max(i-startpt-1,maxi)
print(maxi)

Measured memory_bytes: 63856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();//データ数
		int p[] = new int[N]; //配列数を決定
		int count = 0;
		for(int i = 0; i<N; i++) {
			p[i] = sc.nextInt(); //配列の中身を挿入
			//System.out.println(d[i]);//配列の中身を確認
			if(p[i] != i+1) {
				count++;
			}
		}
		//System.out.println(count); //count数を確認
		if(count <= 2){
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
	
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
        }
        print(a);
        insertionSort(a);
    }

    private static void insertionSort(int[] a) {
        for (int i = 1; i < a.length; i++) {
            int v = a[i];
            int j = i - 1;
            while (j >= 0 && a[j] > v) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = v;
            print(a);
        }
    }

    private static void print(int[] a) {
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]);
            if (i < a.length - 1) {
                System.out.print(" ");
            } else {
                System.out.println("");
            }
        }
    }
}

Measured memory_bytes: 34528
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  vector<int> a = {1};
  for (int b = 2; b <= 32; b++) {
    int k = b;
    while (k <= 1000) {
      k *= b;
      a.push_back(k);
    }
  }
  sort(a.begin(), a.end());
  int k = upper_bound(a.begin(), a.end(), x) - a.begin();
  cout << a[k-1] << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n;cin>>n;
    int a[n],b[n];
    rep(i,n){
        cin>>a[i];b[i]=a[i];
    }
    sort(b,b+n, greater<int>());
    rep(i,n){
        co((a[i]==b[0])?b[1]:b[0]);
    }
}

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

/* MIGHT BE OF USE


#define si(x)	scanf("%d",&x)
#define pi(x)	printf("%d\n",x)

typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
*/


#define fo(i,a,b) for(i=a;i<b;i++)
#define ll long long
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define sl(x)	scanf("%lld",&x)
#define pl(x)	printf("%lld\n",x)
#define ss(s)	cin>>s
#define ps(s)	cout<<s
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back

typedef pair<ll, ll>	pl;
typedef vector<ll>		vl;
typedef vector<pl>		vpl;
typedef vector<string>	vs;

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


vl v[100001];
bool visited[100001]={0};

void dfs(ll att){
    visited[att]=1;
    for(ll i=0;i<v[att].size();i++){
        ll num = v[att][i];
        if(visited[num]) continue;
        visited[num]=1;
        dfs(num);
    }

}

void solve()
{
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ll i, j, n, m;
    cin>>n>>m;
    ll a,b;
    fo(i,0,m){
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }

    ll ans=0;

    fo(i,1,n+1){
        if(visited[i]) continue;
        dfs(i);
        ans++;
    }
    cout<<ans-1;

}



int main()
{

    ll t = 1;
    //sl(t);
    while(t--)
    {
        solve();
    }

    return 0;
}






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

class Main{
	public static void main(String[] args){
		BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
		try{
			while(true){
				int n = Integer.valueOf(sc.readLine());
				if(n==0)
					break;
				Map<String,Long> map = new HashMap<String,Long>();
				String[] key = new String[n];
				int a = 0;
				for(int i=0; i<n; i++){
					String[] st = sc.readLine().split(" ");
					if(map.containsKey(st[0])){
						long t = map.get(st[0])+Integer.valueOf(st[1])*(long)Integer.valueOf(st[2]);
						map.remove(st[0]);
						if(t>=1000000)
							t = 1000000;
						map.put(st[0],t);
					}
					else {
						long t = Integer.valueOf(st[1])*(long)Integer.valueOf(st[2]);
						if(t>=1000000)
							t = 1000000;
						map.put	(st[0],t);
						key[a]=st[0];
						a++;
					}
				}
			boolean flag = true;
			for(int i=0; i<n; i++){
				if(key[i]==null)
					break;
				if(map.get(key[i])==1000000){
					System.out.println(key[i]);
					flag = false;
				}
			}
			if(flag)
				System.out.println("NA");
			}
		}catch(Exception e){
			System.out.println("Error");
			}
		}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K;
    cin >> K;
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A.at(i);
    }
    vector<int> B(n);
    for(int i = 0; i < n - 1; i++){
        B.at(i) = (A.at(i + 1) - A.at(i));
    }
    B.at(n - 1) = A.at(0) + K - A.at(n - 1);
    sort(B.begin(), B.end());
    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        ans += B.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let ab:Vec<i32> = read_vec();
    let (a,b) = (ab[0],ab[1]);
    let ans = if (a+b) % 3 == 0 || a % 3 == 0 || b % 3 == 0{
        "Possible"
    } else {
        "Impossible"
    };
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
	int count = 0;
	int i;
	int m;
	int x=0;
	int n[200];
	scanf("%d", &i);

	for (m = 0; m < i; m++)
	{
		scanf("%d", &n[m]);
	}
	while (1) {
		
			for (m = 0; m < i; m++)
			{
				if (n[m] % 2 == 1)
				{
					x = 1;
					break;
				}
					n[m] = n[m] / 2;	
				
			}
			if(x == 1) {
				break;
			}
			count++;
		
	}

	
	printf("%d ", count);

    return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int main() {
    char S[101];
    scanf("%s", S);

    long K;
    scanf("%ld", &K);

    for (int i = 0; ; i++) {
        if (S[i] != '1' || i == K - 1) {
            printf("%c\n", S[i]);
            return 0;
        }
    }
}

Measured memory_bytes: 128