akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class Hello
{
    const int INF = int.MaxValue;

    public static void Main()
    {
        var N_M = Console.ReadLine().Trim().Split();
        var N = int.Parse(N_M[0]);
        var M = int.Parse(N_M[1]);

        var to = new List<int>[100005];

        for(var i=0; i < M; i++) {
            var A_B = Console.ReadLine().Trim().Split();
            var A = int.Parse(A_B[0]);
            var B = int.Parse(A_B[1]);
            A--;
            B--;
            if(to[A] == null) to[A] = new List<int>(); to[A].Add(B);
            if(to[B] == null) to[B] = new List<int>(); to[B].Add(A);
        }

        var q = new Queue<int>();
        var dist = Enumerable.Repeat(INF, N).ToList();
        var pre = Enumerable.Repeat(-1, N).ToList();
        dist[0] = 0;

        q.Enqueue(0);
        while (q.Count() > 0)
        {
            int v = q.Dequeue();
            foreach(var u in to[v]) {
                if(dist[u] != INF) continue;
                dist[u] = dist[v] + 1;
                pre[u] = v;
                q.Enqueue(u);
            }
        }

        Console.WriteLine("Yes");
        for(var i = 1; i < N; i++)  {
            var ans  = pre[i];
            ++ans;
            Console.WriteLine(ans);
        }
   }
}

Measured memory_bytes: 50936
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define int long long int
#define FILEIO  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
#define maxn 1000000
 

using namespace std;

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

signed main() {
//FILEIO;
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
int x , y;
cin>>x>>y;
if(y&1)
{
    cout<<"No";
    return 0;
}
int val = (y - 2*x)/2;
if(val > x or val < 0)
{
    cout<<"No";
    return 0;
}
cout<<"Yes";










    return 0;
}


Measured memory_bytes: 3692
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> M >> K;
	if (M == 1) {
		if (K == 0)
			cout << "0 0 1 1" << endl;
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	N = pow2(M);
	if (K >= N) {
		cout << -1 << endl;
		return 0;
	}
	rep(i, N) if (i != K) cout << i << " ";
	cout << K << " ";
	rep(i, N) if (N - 1 - i != K) cout << N - 1 - i << " ";
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n;
bool con[205][205];
signed main() {
	cin >> n;
	rep(i, n)rep(j, n) {
		char c; cin >> c; if (c == '1')con[i][j] = true;
	}
	int ans = -1;
	rep(i, n) {
		int far[205];
		rep(j, n)far[j] = inf;
		far[i] = 1;
		queue<int>que; que.push(i);
		while (!que.empty()) {
			int k = que.front(); que.pop();
			rep(j, n) {
				if (!con[j][k])continue;
				if (far[j] == inf) {
					que.push(j); far[j] = far[k] + 1;
				}
				else {
					if (abs(far[k] - far[j]) != 1) {
						goto ng;
					}
				}
			}
		}
		rep(j, n)chmax(ans, far[j]);
	ng:;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;
/*
class dfs {
public:
	dfs(const vector<int>& h, const vector<vector<int>>& p);
	~dfs();
	int main_calc();
private:
	void recursive(vector<int> d, int ind);
private:
	vector<bool> recode;
	bool jdg = true;
	int ans = 0;
	int N;
	const vector<int>& H;
	const vector<vector<int>>& p;
};

dfs::dfs(const vector<int>& h, const vector<vector<int>>& p) :H(h), p(p) {
	N = H.size();
	recode.clear();
	for (int i = 0; i < N; i++) {
		recode.push_back(false);
	}
}

dfs::~dfs() {
}

void dfs::recursive(vector<int> d, int ind) {
	for (int j = 0; j < d.size(); j++) {
		if (recode[d[j]] == false && H[ind] <= H[d[j]]) {
			jdg = false;
			return;
		}
	}
	for (int j = 0; j < d.size(); j++) {
		if (recode[d[j]] == false){
			recode[d[j]] = true;
			recursive(p[d[j]], ind);
		}
	}
	return;
}

int dfs::main_calc() {

	vector<bool> rd = recode;
	vector<int> dum;
	dum.clear();

	for (int i = 0; i < N; i++) {
		jdg = true;
		recode = rd;
		dum = p[i];
		recode[i] = true;
		if (dum.size() == 0) {
			ans += 1;
		}
		else {
			recursive(dum, i);
			if (jdg == true) {
				ans += 1;
			}
		}
	}

	return ans;
}
*/
int main() {

	int N, M;
	cin >> N >> M;

	vector<int> H(N, 0);
	for (int i = 0; i < H.size(); i++) {
		cin >> H[i];
	}

	vector<vector<int>> p(N, vector<int>());
	int A, B;
	for (int i = 0; i < M; i++) {
		cin >> A >> B;
		A--;
		B--;
		p[A].push_back(B);
		p[B].push_back(A);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (p[i].size() == 0) {
			ans += 1;
		}
		else {
			for (int j = 0; j < p[i].size(); j++) {
				if (H[i] <= H[p[i][j]]) {
					ans -= 1;
					break;
				}
			}
			ans += 1;
		}
	}

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



Measured memory_bytes: 8804
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    long N,D;
    long X,Y;
    double dd;
    double num;
    int count=0;
    cin>>N>>D;
    for(int i=0;i<N;i++){
        cin>>X>>Y;
        num=X*X+Y*Y;
        dd=sqrt(num);
        if(dd<=D){
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 3648
#include <cstdio>
int n;
int dats[15]={};
int mat[100]={};
int main(void){
	int i,j,co;
	bool fl;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d",&(dats[i]));
		}
		co=0;
		while(1){
			fl=true;
			for(i=0;i<100;i++)mat[i]=0;
			for(i=0;i<n;i++){
				mat[dats[i]]++;
			}
			for(i=0;i<n;i++){
				if(mat[dats[i]]!=dats[i]){
					fl=false;
					dats[i]=mat[dats[i]];
				}
			}
			if(fl)break;
			co++;
		}
		printf("%d\n",co);
		for(i=0;i<n-1;i++){
			printf("%d ",dats[i]);
		}
		printf("%d\n",dats[n-1]);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int a,b;
    scanf("%d%d", &a, &b);
    printf("%d %d\n", a*b, 2*(a+b));

    return 0;
}



Measured memory_bytes: 2760
public class Main {
  
  public static boolean
  smallerp (
    int h1,
    int w1,
    int h2,
    int w2
    )
  {
    if ( h1 * h1 + w1 * w1 <  h2 * h2 + w2 * w2 ) return ( true );
    if ( h1 * h1 + w1 * w1 == h2 * h2 + w2 * w2
      && h1 < h2 ) return ( true );
    
    return ( false );
  }
  
  public static void
  main (
    String[ ] args
    )
  {
    java.util.Scanner sc = new java.util.Scanner ( System.in );
    int i, j;
    
    for ( ; ; )
    {
      int h, w;
      int p = 150, q = 150;
      
      h = sc.nextInt ( );
      w = sc.nextInt ( );
      if ( h == 0 && w == 0 ) break ;
      
      for ( i = 1; i <= 150; ++i )
      for ( j = i + 1; j <= 150; ++j )
      if ( smallerp ( h, w, i, j )
        && smallerp ( i, j, p, q ) )
      {
        p = i;
        q = j;
      }
      
      System.out.println ( p + " " + q );
    }
    
    return ;
  }
}

Measured memory_bytes: 20396
a = list(map(int,input().split()))
A = a[0]
B = a[1]
C = a[2]
K = a[3]
if A >= K:
  print(K)
elif A<K and B>=(K-A):
  print(A)
elif B<(K-A):
  print(A+(-1)*(K-A-B))

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

int main() {
    int n;
    cin >> n;
    long long cnt[10][10] = {};
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        int k = s.length();
        int a = s[0] - '0', b = s[k - 1] - '0';
        cnt[a][b]++;
    }
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        int k = s.length();
        int a = s[0] - '0', b = s[k - 1] - '0';
        ans += cnt[b][a];
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3756
import java.util.Scanner;

/**
 *
 * @author Cummin
 */
public class Main {
    static String C[] = {"dream", "dreamer", "erase", "eraser" } ;
    static int len[] = {5,7,5,6} ;
    static char[] s ;
    static int ptr ;
    static char [][] c ;
    public static void main(String[] args) {
        String S ;
        Scanner sc = new Scanner(System.in);
        S = sc.next();
        s = S.toCharArray() ;
        c = new char[4][] ;
        for (int i=0 ; i<4 ;i++) {
            c[i] = C[i].toCharArray() ;
        }
        ptr = S.length()-1 ;
        while (0<=ptr) {
            switch (s[ptr]) {
                case 'm' :
                    if (match(0)) ptr = ptr -5 ; // dream
                    break;
                case 'e' :
                    if (match(2)) ptr = ptr -5 ; // erase
                    break ;
                case 'r' :
                    if (match(1)) { // deramer
                        ptr = ptr - 7 ; 
                        break ;
                    }
                    if (match(3)) { // eraser
                        ptr = ptr - 6 ;
                        break; 
                    }
                default :
                    ptr = -999 ;
            }
        }
        if (ptr == -1 ) {
            System.out.println("YES") ;
        } else {
            System.out.println("NO") ;
        }        
    }
    static boolean match(int i) {
        int flag = 0 ;
        int ptr2 = ptr ;
        for (int k=len[i]-1 ; 0<=k; k--  ) {
            if (s[ptr2] == c[i][k]) {
                ptr2 -- ;
                continue ;
            } else {
                flag = -1 ;
                break ;        
            }
        }
        if (flag == -1) return false ;
        else return true ;
    }
    
}


Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

const ll MAX_V = 1010 * 1010;

class dijkstra_pair {
private:

    struct edge {
        ll to;
        ll cost;
    };
    vector<edge> E[MAX_V];
    ll d[MAX_V];
    ll H, W;

public:

    dijkstra_pair(ll H_in, ll W_in) : H(H_in), W(W_in) {
    }

    void set_E(ll fi, ll fj, ll ti, ll tj, ll cost = 1) {
        E[fi * W + fj].push_back({ti * W + tj, cost});
    }

    ll get_d(ll vi, ll vj) {
        return d[vi * W + vj];
    }

    void calc(ll si, ll sj) {
        ll s = si * W + sj;
        priority_queue <pll, vector<pll>, greater<pll> > que;
        rep(i, MAX_V) d[i] = LINF; //INF
        que.emplace(0LL, s);
        d[s] = 0LL;
        while (!que.empty()) {
            pll p = que.top();
            que.pop();
            ll v = p.second;
            if (d[v] < p.first) continue;
            for (auto&& e : E[v]) {
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.emplace(d[e.to], e.to);
                }
            }
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    int h, w;
    cin >> h >> w;
    dijkstra_pair ds(h + 1, w + 1);
    char a[1001][1001];

    rep(i, h) rep(j, w) {
        cin >> a[i][j];
        if (a[i][j] == '#') {
            ds.set_E(h, w, i, j, 1);
            ds.set_E(i, j, h, w, 1);
        }
    }

    rep(i, h) rep(j, w - 1) {
        ds.set_E(i, j, i, j + 1, 1);
        ds.set_E(i, j + 1, i, j, 1);
    }

    rep(i, h - 1) rep(j, w) {
        ds.set_E(i, j, i + 1, j, 1);
        ds.set_E(i + 1, j, i, j, 1);
    }

    ds.calc(h, w);
    ll ans = 0;

    rep(i, h) rep(j, w) {
        ans = max(ans, ds.get_d(i, j) - 1);
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 215396
local n=io.read("*n","*l")
local a={}
for i=1,n do
    local bar=io.read("*n")
    if not a[bar] then
        a[bar]=1
    else
        a[bar]=a[bar]+1
    end
end

local barmax=0
for length,number in pairs(a) do
    if number>1 then
        barmax=math.max(length,barmax)
    end
end
if barmax==0 then
    print(0)
    return
end
if a[barmax]>=4 then
    print(barmax*barmax)
else
    local barmax2=0
    for length,number in pairs(a) do
        if length<barmax and number>1 then
            barmax2=math.max(length,barmax2)
        end
    end
    print(barmax*barmax2)
end

Measured memory_bytes: 6508
S=list(input())


import sys
for i in range(len(S)):
    del S[-1]
    for j in range(len(S)):
        if len(S)%2==0:
            if S[0:len(S)//2]==S[len(S)//2:len(S)]:
                print(len(S))
                sys.exit()
else:
    print(0)

Measured memory_bytes: 9020
toFloat :: Int -> Float
toFloat = fromRational . toRational

solve :: Int -> Int -> [Int] -> Int
solve a b [] = -1
solve a b (s:ss)
    | a == a' && b == b' = s
    | otherwise = solve a b ss
        where
            s' = toFloat s
            a' = floor $ s' * 0.08
            b' = floor $ s' * 0.1

main = do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    print $ solve a b [1..1000]


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
char str[N];
int cut1,cut2,n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>str[i];
    for(int i=1;i<=n;i++)
    {
        if(str[i]=='(') cut1++;
        if(str[i]==')')
        {
            cut1--;
            if(cut1<0) cut2++,cut1 = 0;
        }
    }
    for(int i=1;i<=cut2;i++)
        cout<<"(";
    for(int i=1;i<=n;i++)
        cout<<str[i];
    for(int i=1;i<=cut1;i++)
        cout<<")";
    cout<<"\n";
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int h, w;
  cin >> h >> w;
  char mas[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> mas[i][j];
    }
  }
  int count;
  for (int i = 0; i < h; i++) {
    count = 0;
    for (int j = 0; j < w; j++) {
      if (mas[i][j] == '.') {
        count++;
      }
    }
    if (count == w) {
      for (int k = 0; k < w; k++) {
        mas[i][k] = '*';
      }
    }
  }

  for (int i = 0; i < w; i++) {
    count = 0;
    for (int j = 0; j < h; j++) {
      if (mas[j][i] == '.' || mas[j][i] == '*') {
        count++;
      }
    }
    if (count == h) {
      for (int k = 0; k < h; k++) {
        mas[k][i] = '*';
      }
    }
  }

  count = 0;
  int flag = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (mas[i][j] == '*') {
        count++;
        continue;
      } else {
        cout << mas[i][j];
      }
    }
    if (count == w) {
      flag = 1;
    }
    if (flag == 0) {
      cout << endl;
    }
    flag = 0;
    count = 0;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

int main(){
  int n;
  cin >> n;
  if(n==1){cout << "Hello World" << endl; return 0;}
  int a,b;
  cin >> a >> b;
  cout << a+b << endl;
  return 0;
}

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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll sx,sy,gx,gy;
ll d[30][30];
ll dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
ll h,w;
char s[30][30];

ll bfs(){
  queue<pll> que;
  ll ans=0;
  rep(i,0,h){
    rep(j,0,w){
      rep(k,0,h){
        rep(l,0,w){
          if(s[i][j]!='#'&&s[k][l]!='#'){
            sx=i;sy=j;gx=k;gy=l;
            que.push(pll(sx,sy));
            rep(i,0,h){
              rep(j,0,w){
                d[i][j]=-1e5;
              }
            }
            d[sx][sy]=0;
            while(que.size()){
              pll p=que.front();
              que.pop();
              //if(p.first==gx&&p.second==gy)break;
              rep(t,0,4){
                ll nx=p.first+dx[t],ny=p.second+dy[t];
                if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]!='#'&&d[nx][ny]==-1e5){
                  que.push(pll(nx,ny));
                  d[nx][ny]=d[p.first][p.second]+1;
                }
              }
            }
            ans=max(ans,d[gx][gy]);
          }
        }
      }
    }
  }
  return ans;
}
main(){
  
  cin>>h>>w;
  rep(i,0,h){
    rep(j,0,w){
      cin>>s[i][j];
    }
  }
  ll tmp=bfs();
  cout<<tmp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n; cin >> n;
    int ct = 0;
    map<int,int> mp;
    rep(i,n) {
        int x; cin >> x;
        if (x >= 3200) {
            ct++;
            continue;
        }
        for (int l = 0; l <= 7; l++) {
            if (l*400 <= x && x < (l+1)*400) mp[l]++;
        }
    }
    int mn, mx;
    mx = mp.size()+ct;
    if (mp.size() >= 1) mn = mp.size();
    else mn = 1;
    cout << mn << " " << mx << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
am, az, ap = [], [], []
n.times do |i|
  if a[i] < 0
    am << a[i]
  elsif a[i] == 0
    az << a[i]
  else
    ap << a[i]
  end
end
if am != [] && ap != []
  puts ap.inject(:+) + am.inject(:+) * (-1)
  m = am[0]
  (ap.length-1).times do |i|
    puts "#{m} #{ap[i]}"
    m -= ap[i]
  end
  puts "#{ap[-1]} #{m}"
  m = ap[-1] - m
  (am.length-1).times do |i|
    puts "#{m} #{am[i+1]}"
    m -= am[i+1]
  end
  az.length.times do
    puts "#{m} 0"
  end
elsif am == [] && ap == []
  puts 0
  (az.length-1).times do
    puts "0 0"
  end
elsif am == []
  if az != []
    puts ap.inject(:+)
    m = 0
    (ap.length-1).times do |i|
      puts "#{m} #{ap[i]}"
      m -= ap[i]
    end
    puts "#{ap[-1]} #{m}"
    m = ap[-1] - m
    (az.length-1).times do
      puts "#{m} 0"
    end
  else
    ap.sort!
    puts ap.inject(:+) - ap[0] * 2
    m = ap[0]
    (ap.length-2).times do |i|
      puts "#{m} #{ap[i+1]}"
      m -= ap[i+1]
    end
    puts "#{ap[-1]} #{m}"
  end
else
  if az != []
    puts am.inject(:+) * (-1)
    m = 0
    (am.length).times do |i|
      puts "#{m} #{am[i]}"
      m -= am[i]
    end
    (az.length-1).times do
      puts "#{m} 0"
    end
  else
    am.sort!.reverse!
    puts (am.inject(:+) - am[0] * 2) * (-1)
    m = am[0]
    (am.length-1).times do |i|
      puts "#{m} #{am[i+1]}"
      m -= am[i+1]
    end
  end
end


Measured memory_bytes: 13984
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
T, X, Y = 0, 0, 0
result = "Yes"
for t, x, y in txy:
    d =  (x-X) + (y-Y)
    if t<d or (t-d)%2==1:
        result = "No"
        break
print(result)

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

int n, a, b, z, x[262144];

int lsb (int I) {return (I & (-I));}

void solve (int I, int K, int D) {
    if(I == 1) return;
    if(z == 0) {
        int X = lsb(~D);
        x[K+(1<<(I-2))-1] = X;
        x[K+(1<<(I-1))+(1<<(I-2))-1] = X;
        solve(I-1, K, D+X);
        solve(I-1, K+(1<<(I-1)), D+X);
    }
    else {
        int X = lsb(z);
        z -= X;
        int Y = lsb(z);
        z -= Y;
        x[K+(1<<(I-2))-1] = X;
        x[K+(1<<(I-1))+(1<<(I-2))-1] = Y;
        solve(I-1, K, D+X);
        solve(I-1, K+(1<<(I-1)), D+Y);
    }
}

int main()
{
    scanf("%d%d%d",&n,&a,&b);
    if(__builtin_popcount(a^b) % 2 == 0) {
        puts("NO");
        return 0;
    }
    puts("YES");
    printf("%d", a);
    x[(1<<(n-1))-1] = lsb(a^b);
    z = (a^b^lsb(a^b));
    solve(n, 0, lsb(a^b));
    for(int i=0;i<(1<<n)-1;i++) {
        a ^= x[i];
        printf(" %d", a);
    }
}


Measured memory_bytes: 1536
s = input()
l = len(s)
if l%2==0:
    b = s[:l//2]
    e = s[l//2:]
else:
    b = s[:l//2]
    e = s[l//2+1:]

ee = list(reversed(e))



c = 0
for i,j in zip(b,ee):
    if i!=j:
        c+=1

print(c)

Measured memory_bytes: 3060
n, k = map(int, input().split())
a = list(map(int, input().split()))


def check(l):
    cnt = 0
    for L in a:
        cnt += L // mid
        if L % mid != 0:
            cnt += 1
        cnt -= 1

    return cnt <= k


lb, ub = 0, max(a)
while ub - lb > 1:
    mid = (ub + lb) // 2

    if check(mid):
        ub = mid
    else:
        lb = mid

print(ub)


Measured memory_bytes: 30856
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;




int main(){
    ll n,h;

    cin>>n>>h;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a.push_back(x);
        b.push_back(y);
    }
    
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    
    ll nage=0;
    ll nokori=0;
    ll ans=0;
    
    
    ll mi=h/a[0];
    
    if(h%a[0]!=0)mi++;
    
    
    for(ll i=0;i<n;i++){
        nage+=b[i];
        nokori=h-nage;
        if(nokori>0){
        ans=(nokori-1)/a[0]+1;
       /* if(nokori%a[0]!=0)ans++;*/
        ans+=i+1;
            
        }else{
            ans=i+1;
         }
        mi=min(ans,mi);
    }
    
    
    cout<<mi<<endl;
    

return 0;
}


Measured memory_bytes: 3424
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	ll n, m, N, M;
	cin >> n >> m;
	N = min(n, m), M = max(n, m);


	if (4 <= N) cout << (N - 4) * (M - 4) + 2 * ((N - 4) + (M - 4)) + 4 << endl;
	else if (N == 2) cout << 0 << endl;
	else if (M == 1) cout << 1 << endl;
	else if (N == 1 && M == 2) cout << 0 << endl;
	else if (N == 1 && M == 3) cout << 1 << endl;
	else cout << max((ll)0, M - 4) + 2 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int X , t ;
    cin >> X >> t;
    int ans ;
    ans = X -t ;
    if(ans < 0)
       cout << 0 << endl;
    
    else
       cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int max(int a,int b)
{
    return a>b?a:b;
}
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n],res=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    res=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2560
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
        

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
modFacts, invs = prepare(max(N, M))

ans = 0
for i in range(N + 1):
    cnt = (modFacts[N] * invs[i] * invs[N - i]) % MOD
    cnt *= (modFacts[M] * invs[M - i]) % MOD
    cnt %= MOD
    cnt *= pow(modFacts[M - i] * invs[(M - i) - (N - i)], 2, MOD)
    cnt %= MOD
    ans += pow(-1, i) * cnt
    ans %= MOD

print(ans)


Measured memory_bytes: 48320
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void makenode(void);
void insert(int);
void delete(int);
void print(void);

struct node{
	int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer head;

int main(){
	char str[20];
	int n, i, val;
	NodePointer temp;
	
	makenode();
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%s", str);
		if(strcmp(str, "deleteFirst") == 0){
			temp = head->next;
			temp->next->prev = temp->prev;
			temp->prev->next = temp->next;
			free(temp);
		}
		else if(strcmp(str, "deleteLast") == 0){
			temp = head->prev;
			temp->next->prev = temp->prev;
			temp->prev->next = temp->next;
			free(temp);
		}
		else{
			scanf("%d", &val);
			if(strcmp(str, "insert") == 0) insert(val);
			else if(strcmp(str, "delete") == 0) delete(val);
		}
	}
	print();
	
	return 0;
}

void makenode(void){
	head = malloc(sizeof(struct node));
	head->next = head;
	head->prev = head;
}

void insert(int val){
	NodePointer temp = malloc(sizeof(struct node));
	temp->key = val;
	temp->next = head->next;
	temp->prev = head;
	head->next->prev = temp;
	head->next = temp;
}

void delete(int val){
	NodePointer temp = head->next;
	for(; temp != head; temp = temp->next){
		if(temp->key == val){
			temp->next->prev = temp->prev;
			temp->prev->next = temp->next;
			free(temp);
			return;
		}
	}
}

void print(void){
	NodePointer temp = head->next;
	for(; temp != head->prev; temp = temp->next)
	printf("%d ", temp->key);
	printf("%d\n", temp->key);
}

Measured memory_bytes: 31788
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = (Console.ReadLine().Split(' ')).Select(long.Parse).ToArray();
        var k = inputs[0];
        var n = inputs[1];

        var ak = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var route1 = ak.Max() - ak.Min();

        var route2 = route1;

        for (int i = 0; i < ak.Length-1; i++)
        {
            var val = ak[i] + (k - ak[i + 1]);
            if (route2 > val) route2 = val;
        }

        if (route1 > route2) Console.WriteLine(route2);
        else Console.WriteLine(route1);
    }
}

Measured memory_bytes: 36680
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
const int64_t INF = 1000000000000000;
const int64_t MOD = 1000000007;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm

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

int64_t N; cin >> N;
int64_t LCM = 1; 
rep(i, 0, N) {
    int64_t T; cin >> T;
    LCM = boost::integer::lcm(LCM, T);
}

cout <<  LCM << endl;



}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
vector<string> stlist;
string line;
int n,l;
cin>>n>>l;
for(int i=0;i<n;i++){
	cin>>line;
	stlist.push_back(line);
}
sort(stlist.begin(),stlist.end());
for(int i=0;i<n;i++){
	cout<<stlist[i];
}
cout<<endl;
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

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

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};
class rcompare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<0>(a) < get<0>(b));
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, x;
	ll ans = LINF;
	cin >> n >> x;
	vl v(n);
	vvl vv(n, vl(n, LINF));
	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		rep(j, n) {
			vv[i][j] = min(vv[i][j - (j == 0 ? 0 : 1)], v[(i-j+n)%n]);
		}
	}
	rep(i, n) {
		ll tmp = i*x;
		rep(j, n) {
			tmp += vv[j][i];
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 31616
#include <stdio.h>

int main(void) {
    long long N, A[200005], B[10], X, K, i, j;
    scanf("%lld", &N);
    for (i=1; i<=N; i++) scanf("%lld", &A[i]);
    for (i=1; i<=3; i++) B[i]=0;
    X=1;
    for (i=1; i<=N; i++) {
        K=0;
        for (j=1; j<=3; j++) {
            if (B[j]==A[i]) {
                if (K==0) B[j]++;
                K++;
            }
        }
        if (K==0) X=0;
        if (K==3) X*=3;
        else if (K==2) X*=2;
        X%=1000000007;
        // printf("%d: %d\n", i, X);
    }
    // printf("%lld %lld %lld\n", B[1], B[2], B[3]);
    printf("%lld", X); 
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;

typedef long long ll;

template<typename T>
class MonotoneCHT{
private:
    struct line{
        T a,b;
        line(T a,T b):a(a),b(b){}
        bool operator<(const line& r)const{
            return (a!=r.a? a<r.a:b<r.b);
        }
        bool operator>(const line& r)const{
            return (a!=r.a? a>r.a:b>r.b);
        } 
    };
    //直線群
    vector<line> lines;
    //単調性があるか
    bool isMonotonicX;
    function<bool(T l, T r)> comp;

public:
    MonotoneCHT(bool flagX,function<bool(T l, T r)> compFunc)
                :isMonotonicX(flagX),comp(compFunc){
//                    lines.emplace_back(0,0);
    }
    
    bool check(line l1,line l2,line l3){
        if(l1<l3) swap(l1,l3);
        return (l3.b-l2.b)*(l2.a-l1.a)>=(l2.b-l1.b)*(l3.a-l2.a);
    }

    void add(T a,T b){
        line l(a,b);
        while(lines.size()>=2 && check(*(lines.end()-2),lines.back(),l)) lines.pop_back();
        lines.emplace_back(l);
    }

    T f(int i,T x){
        return lines[i].a*x+lines[i].b;
    }

    T f(line l,T x){
        return l.a*x+l.b;
    }
    //最小値/最大値を返す
    T get(T x){
        if(isMonotonicX){
            static int head = 0;
            while(lines.size()-head>=2 && comp(f(head, x), f(head + 1, x))) head++;
            return f(head,x);
        }else{
            int l = -1,r = lines.size()-1;
            while(l+1<r){
                int m = (l+r)/2;
                (comp(f(m,x),f(m+1,x))? l:r) = m;
            }
            return f(r,x);
        }
    }
};

constexpr ll inf = 1e18;

int main(){
    int N;
    ll C;
    cin >> N >> C;
    vector<ll> H(N+1);
    vector<ll> dp(N+1,inf);
    for(int i=1;i<=N;i++) cin >> H[i];
    dp[1] = 0;
    MonotoneCHT<ll> cht(true,[](ll a,ll b){return a>=b;});
    cht.add(-2*H[1],H[1]*H[1]);
    for(int i=2;i<=N;i++){
        dp[i] = cht.get(H[i])+H[i]*H[i]+C;
        cht.add(-2*H[i],H[i]*H[i]+dp[i]);
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 9200
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
using namespace std;
int gcd(int a,int b)
{
        if(b==0)
                return a;
        else
                return gcd(b,a%b);
}
int s[100005];
int main()
{
        bool flag=false;
        int n,k;
        scanf("%d%d",&n,&k);
        for(int i=0;i<n;i++)
        {
                scanf("%d",&s[i]);
                if(s[i]==k)
                        flag=true;
        }
        sort(s,s+n);
        if(k>s[n-1])
        {
                cout<<"IMPOSSIBLE"<<endl;
                return 0;
        }
        int a=s[0];
        for(int i=n-1;i>=1;i--)
        {
                a=gcd(a,s[i]);
                if(k%a==0)
                {
                        flag=true;
                        break;
                }
        }
        if(flag)
        {
                cout<<"POSSIBLE"<<endl;
        }
        else
        {
                cout<<"IMPOSSIBLE"<<endl;
        }
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] x = new int[3000];
		int[] y = new int[3000] ;
	//Input 
		for (int i = 0; i<x.length ; i++) {
			
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if(x[i] == 0 & y[i] == 0) break;
		}
	// Output
		for (int i = 0; i<x.length ; i++) {
			if(x[i] == 0 & y[i] == 0) {
				break;
			}else {
			   if(x[i] > y[i]) {
				System.out.println(y[i] + " " + x[i]);
			   }
			   if(x[i] < y[i]) {
				System.out.println(x[i] + " " + y[i]);
			   }
			   if(x[i] == y[i]) {
				System.out.println(x[i] + " " + x[i]);
			   }
		    }
		}
		
	    sc.close();
	
  }
	
}

Measured memory_bytes: 37328
package main

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

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func primeFactorize(n int) [][2]int {
	var result [][2]int
	rn := int(math.Sqrt(float64(n)))
	for i := 2; i < rn+1; i++ {
		if n%i != 0 {
			continue
		}
		t := [2]int{i, 0}
		for n%i == 0 {
			n /= i
			t[1]++
		}
		result = append(result, t)
	}
	if n != 1 {
		result = append(result, [2]int{n, 1})
	}
	return result
}

func main() {
	A := readInt()
	B := readInt()

	fmt.Println(len(primeFactorize(gcd(A, B))) + 1)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (auto&& v : a) {
        cin >> v;
        sum += v;
    }

    int cnt = 0;
    for (auto&& v : a) {
        if (v * m * 4 >= sum)
            cnt++;
    }

    cout << (cnt >= m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll H,N,a,sum=0;
    cin >> H >> N;
    REP(i,N) {cin >> a; sum += a;}
    if(sum>=H)cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

int N;
int A[100010];
int d[100010];

int main() {
	cin>>N;
	A[0]=0;
	rep(i,N) cin>>A[i];
	A[N+1]=0;
	rep(i,N+1) d[i]=abs(A[i]-A[i-1]);
	int sum =0;
	rep(i,N+1) sum+=d[i];
	rep(i,N){
		cout<<sum+abs(A[i+1]-A[i-1])-d[i+1]-d[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <string.h>
#include <string>
#include <algorithm>
using namespace std;

struct node{
	int k,num;
};
node a[50];
int n,m,p,q;

bool cmp(node a,node b){
	return a.num<b.num;
}

int main(){
	while (scanf("%d",&n)==1 && n){
		for (int i=1;i<=n;++i) scanf("%d%d",&a[i].k,&a[i].num);
		sort(a+1,a+n+1,cmp);
		m=0;
		bool bi=false;
		for (int i=1;i<=n;++i){
			if (m>a[i].num){
				bi=true;
				break;
			}
			m+=a[i].k;
			if (m>a[i].num){
				bi=true;
				break;
			}
		}
		if (bi) puts("No");
		else puts("Yes");
	}
	return 0;
}

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

int main(void){
  int a,b,c,num,count;
  cin >> a >> b >> c;
  count = 0;
  for (num = a; num >= a and num <= b; num++){
    if (c % num == 0){
      count = count + 1;
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3096
L, R = map(int, input().split())
 
if R - L >= 2017:
  print(0)
  exit()
 
ans_list = []
 
for x in range(L, R):
  for y in range(x+1, R+1):   
    ans_list.append((x * y) % 2019)
    
print(min(ans_list))

Measured memory_bytes: 43504
import Control.Applicative

getDigits :: Int -> [Int]
getDigits n | n < 10 = [n]
            | otherwise = (n `mod` 10) : (getDigits (n `div` 10))

getBigger :: Int -> [Int] -> Int
getBigger n bads | n `elem` bads = getBigger ((n+1) `mod` 10) bads
                 | otherwise = n

solve :: [Int] -> [Int] -> ([Int],Bool)
solve [] _ = ([],False)
solve (x:xs) bads | x `elem` bads = (nextN:(take (length xs) [small,small..]),nextN<x)
                  | otherwise = case b of
                                    False -> (x:a,False)
                                    True -> (nextN:a,nextN<=x)
                where nextN = getBigger ((x+1) `mod` 10) bads
                      (a,b) = solve xs bads
                      small = head $ filter (\x -> not (x`elem` bads)) [0..9]

solve' :: [Int] -> [Int] -> [Int]
solve' xs bads | b = (head $ filter (\x -> not (x `elem` bads)) [1..9]):a
               | otherwise = a
             where (a,b) = solve xs bads

main :: IO ()
main = do
    [n,k] <- map read . words <$> getLine
    bads <- map read . words <$> getLine
    mapM_ (\x -> putStr . show $ x) $ solve' (reverse . getDigits $ n) bads
    putStrLn ""


Measured memory_bytes: 508
def resolve():
    N = int(input())
    S = input()

    S_list = list(S)

    answer_list = []
    answer_list.append(S_list[0])

    for i in range(len(S_list) - 1):
        if answer_list[-1] != S_list[i+1]:
            answer_list.append(S_list[i+1])


    print(len(answer_list))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n;
vector<int> g[110000];
int dp[110000][2];
void rec(int x, int p){
  if(dp[x][0] != -1)return;
  int white = 1, black = 1;
  for(auto to : g[x]){
    if(to == p)continue;
    rec(to, x);
    white = (white * ((dp[to][0] + dp[to][1])%MOD))%MOD;
    black = (black * dp[to][0])%MOD;
  }
  dp[x][0] = white;dp[x][1] = black;
}

signed main(){
  cin>>n;
  rep(i,110000)rep(j,2)dp[i][j] = -1;
  rep(i,n-1){
    int xx, yy;cin>>xx>>yy;xx--;yy--;
    g[xx].push_back(yy);
    g[yy].push_back(xx);
  }
  rec(0, -1);
  cout << (dp[0][0] + dp[0][1])%MOD << endl;
}


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

int main(){
  int n;
  unsigned long long int a[10000];
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  int count = 0;
  for(int i = 0; i < n; ++i){
    while(a[i]%2 == 0){
      count++;
      a[i] /= 2;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 384
a,v = gets.chomp.split.map(&:to_i)
b,w = gets.chomp.split.map(&:to_i)
t = gets.chomp.to_i

if w >= v
  puts 'NO'
  exit
end

l = (a-b).abs
oi = l.to_f/(v-w)

if oi <= t
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 14420
#include<iostream>
#include<algorithm>
#include<utility>
#define MAX_R 100001
using namespace std;
int n,m;
pair<int,int> p[100000];
int min(int a,int b){
  if(a<b) return a;
  else return b;
}
int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> p[i].first >> p[i].second;
  }
  sort(p,p+m);
  int ans=1,r=MAX_R;
  for(int i=0;i<m;i++){
    if(p[i].first<r) r=min(r,p[i].second);
    else{
      ans++;
      r=p[i].second;
    }
  }
  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define f(i,n) for(int i=0;i<n;i++)
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	f(i,n)cin>>a[i];
	vector<int> dp(k+1,1);
	// memset(dp,1,sizeof dp)    ;
	//keeps track of winners
// cout<<dp[1]<<endl;
	dp[0]=1;
	for(int i=1;i<=k;i++){
		for(int j=0;j<n;j++){
			if(a[j]<=i)dp[i]=min(dp[i],1-dp[i-a[j]]);
		}
	}
	dp[k]==0?cout<<"First"<<endl:cout<<"Second"<<endl;		//1 is second and 0 is first
	return 0;
}


Measured memory_bytes: 3776