akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int N = NM[0];
		int M = NM[1];
		int[] a = readLineInt();
		int ALL = 0;
		for(int i=0;i<N;i++) {
			ALL+=a[i];
		}
		
		int ans = 0;
		for(int i=0;i<N;i++) {
			if(a[i]*4*M>=ALL) {ans++;}
		}
		
		print(ans>=M?"Yes":"No");
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	vector<int>v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(all(v));
	cout << v[0] + v[1] << endl;
	return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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;}


int main() {
  ll n;cin>>n;

  vector<ll> x;
  while(n>0){
      n--;
    x.pb(n%26);
    n=n/26;
  }
  reverse(ALL(x));
  for(auto y:x)cout<<char(y+97);
  //cout<<char(25+96);
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int X;
  cin >> X;

  int ans=0,x;
  if(X<3){
    cout << 1 << endl;
    return 0;
  }
  for(int i=2;i<=X;i++){
    for(int j=2;j<=X;j++){
      x=1;
      for(int k=0;k<j;k++){
        x*=i;
      }
      if(x<=X && ans<x) ans=x;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

const int inf = numeric_limits<int>::max();


int main(){   
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe";
    }
    else{
        cout<<"safe";
    }

}

















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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void resolve() {
    int n,k;
    cin >> n >> k;
    VP p(n);
    // REP(i,0,n) mins[i] = (LL)1000000000 * (LL)1000000000 * (LL)5;
    set<int> xs, ys;
    {
        int x,y;
        REP(i,0,n) {
            cin >> x >> y;
            p[i] = MP(x,y);
            xs.insert(x);
            ys.insert(y);
        }
    }
    VLL xss, yss;
    xss.push_back(*(xs.begin()));
    yss.push_back(*(ys.begin()));
    EACH(i, xs) xss.push_back(i);
    EACH(i, ys) yss.push_back(i);
    VVI cs(xss.size(), VI(yss.size()));
    REP(i,0,xss.size()) REP(j,0,yss.size()) {
        REP(index,0,n) {
            if (p[index].first == xss[i] && p[index].second == yss[j]) ++cs[i][j];
        }
    }
    VVI ru(xs.size()+1, VI(ys.size()+1));
    REP(i,1,xs.size()+1) REP(j,1,ys.size()+1) {
        ru[i][j] = cs[i][j] + ru[i-1][j] + ru[i][j-1] - ru[i-1][j-1];
    }
    VLL mins(n+1, (LL)1000000000 * (LL)1000000000 * (LL)5);
    REP(xr,1,xs.size()+1) REP(yr,1,ys.size()+1) {
        REP(xl,0,xr) REP(yl,0,yr) {
            int cnt = ru[xr][yr] - ru[xl][yr] - ru[xr][yl] + ru[xl][yl];
            // LL sq = xss[xr] * yss[yr] - xss[xl] * yss[yr] - xss[xr] * yss[yl] + xss[xl] * yss[yl];
            LL sq = (xss[xr] - xss[xl+1]) * (yss[yr] - yss[yl+1]);
            mins[cnt] = min(mins[cnt], sq);
        }
    }
    LL ans = mins[k];
    REP(i,k,n+1) {
    // REP(i,0,n+1) {
        ans = min(ans,mins[i]);
        //cout << mins[i] << endl;
    }
    cout << ans << endl;
    /*
    REP(xr,1,xs.size()+1) {
        REP(yr,1,ys.size()+1) {
            cout << ru[xr][yr] << " ";
        }
        cout << endl;
    }
    */
}

int main() {
    resolve();
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int a,b;

int main(){
	cin >> a >> b;
	if(a < 10 && b < 10)
		cout << a * b << endl;
	else
		cout << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    FIN;

    //freopen("../input.txt", "r", stdin);freopen("../output.txt", "w", stdout);
    
    int k,l,r;cin>>k>>l>>r;
    bool posible = false;
    int step = k;
    while(k<=r){
        if(k<=r && l<=k){
            posible = true;
            break;
        }
        k += step;
    }
    if(posible){
        cout<<"OK\n";
    }else{
        cout<<"NG\n";
    }
	return 0;
}

Measured memory_bytes: 3656
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [i - 1 for i in a]
g = [-1] * n

i = 0
j = 0
while g[j] == -1:
    if i == k:
        print(j + 1)
        exit()
    g[j] = i
    i += 1
    j = a[j]

for i in range((k - g[j]) % (i - g[j])):
    j = a[j]
print(j + 1)

Measured memory_bytes: 32312
/* 

 */
/* ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;

// defines
#define int long long
typedef long long ll;
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define mp make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define debug(x) cout << #x << " = " << (x) << endl
#define debug2(x, y) cout<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<< endl
#define debug3(x, y, z) cout<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<endl
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)

//permanent constants
const long long INF64 = 1e18; const int INF32 = 1e9; const int BIG = (int)(1e9 + 239);
const int MOD = 998244353; //1e9 + 7;  const ll MOD2 = (ll)MOD * (ll)MOD;
const double PI = 2.0*acos(0.0); //acos(-1.0L);
const double EPS = static_cast<double>(1e-10);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0};
//const ll INF = (ll)(1e18 + 239);

//random
mt19937 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO()   {freopen("in.txt", "w", stdout);}
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

int cost[10][10][10][10]; // cost[s][k][x][y] = min cost to get k from s, with counter x - y 


void solve() {
	int a, b; cin >> a >> b;
	cout << max(max(a+b, a-b), a*b) << endl;
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

//	int const T=10, N = 100000;
//	cout << T << endl;
//	FOR(i, 0, T) {
//		cout << N << endl;
//		FOR(i, 0, N) cout << "0 " ;
//		cout << endl;
//	}

//  int test = 0;
//  int t; cin >> t;
//  while(t--)
  {
//	  cout << "Case " << ++test << ": ";
	  solve();
  }

//  auto endProgram = chrono::steady_clock::now();
//  cout << chrono::duration_cast<chrono::milliseconds>(endProgram - beginProgram).count() << " ms" << endl;

  return 0;
}



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

int main() {
	int a;
	cin >> a;

	int b = a / 100;
	int c = (a - b * 100) / 10;
	int d = a - (b * 100 + c * 10);

	cout << b + c + d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

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

void solve(long long N, long long T, std::vector<long long> A)
{
    ll ans = 0;
    ll minimum = A[0];
    ll maximum = A[0];
    ll sub = -1;
    for (int i = 0; i < N; i++)
    {
        minimum = min(minimum, A[i]);
        if (sub == (A[i] - minimum))
        {
            ans++;
        }
        else
        {
            if (sub < A[i] - minimum)
            {
                sub = max(sub, A[i] - minimum);
                ans = 1;
            }
        }
    }

    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long T;
    scanf("%lld", &T);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, T, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int arr[5];
    for(int i=0;i<5;i++){
        cin>>arr[i];
    }
    for(int i=0;i<5;i++){
        if(arr[i]==0){
            cout<<i+1;
        }
    }
    return 0;
}

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

int main(){
	using ll = long long;
	ll n, wlim, tmp;
	cin >> n >> wlim;
	vector<ll> v[4];
	for(int i = 0; i < n; i++){
		ll w, value;
		cin >> w >> value;
		if(i == 0) tmp = w;
		v[w - tmp].emplace_back(value);
	}
	for(int i = 0; i < 4; i++){
		sort(v[i].begin(), v[i].end());
		reverse(v[i].begin(), v[i].end());
	}
	vector<ll> vv[4];
	for(int i = 0; i < 4; i++){
		vv[i].resize(v[i].size() + 1);
		vv[i][0] = 0;
		for(int j = 1; j < vv[i].size(); j++) vv[i][j] = vv[i][j - 1] + v[i][j - 1];
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n - i; j++){
			for(int k = 0; k <= n - i - j; k++){
				if(v[0].size() < i || v[1].size() < j || v[2].size() < k) continue;
				if(wlim < i * tmp + j * (tmp + 1) + k * (tmp + 2)) continue;
				int l = min(ll(v[3].size()), (wlim - i * tmp - j * (tmp + 1) - k * (tmp + 2)) / (tmp + 3));
				ans = max(ans, vv[0][i] + vv[1][j] + vv[2][k] + vv[3][l]);
			}
		}
	}
	cout << ans << endl;
}

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

int main()
{
int n;
cin >> n;
vector <int> cnt(n+1);
for (int i=1; i<n; i++)
{
    int a;
    cin >> a;
    cnt[a]++;
}
for (int i=1; i<=n; i++)
    cout << cnt[i] << "\n";
}







/*
#include <bits/stdc++.h>
using namespace std;

int main()
{
int r;
cin >> r;
cout << 2 * r * 3.14159265359;
}
*/


Measured memory_bytes: 4044
if __name__ == "__main__":
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    # p = sorted(p)

    ans = float('inf')
    ans2 = 0

    for i in range(0, 102):
        isin = False
        for j in range(len(p)):
            if i == p[j]:
                isin = True
        
        if isin:
            continue

        if ans > abs(x - i):
            ans = abs(x - i)
            ans2 = i

        
    print(ans2)

Measured memory_bytes: 9208
<?php
$N = trim(fgets(STDIN));
$A = explode(" ",trim(fgets(STDIN)));
$ans = 0;
for($i = 0;$i<$N;$i++){
  for($j = $i + 1 ;$j<$N;$j++){
  if ($ans<abs($A[$i]-$A[$j])){
  $ans = abs($A[$i]-$A[$j]);
  }
}
}
echo $ans;

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int x[100010], w[100010], ans[100010];
int main() {
	int n,l,t;
	cin >> n >> l >> t;

	rep(i,n) {
		cin >> x[i] >> w[i];
		if (w[i] == 1) {
			ans[i] = (x[i] + t) % l; 
		} else {
			ans[i] = ((x[i]-t)%l+l) % l;
		}
	}
	int p = 0;
	rep(i,n) {
		if (w[i] == 1) p = (p+(x[i]+t)/l)%n;
		else p = ((p-(l-x[i]+t-1)/l)%n+n)%n;

	}
	sort(ans,ans+n);
	rep(i,n) {
		cout << ans[(i+p)%n] << endl;
	}
	return 0;
}

Measured memory_bytes: 4756
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
bool great(string x, string y) {
	if (x == y)return true;
	int len1 = x.length();
	int len2 = y.length();
	if (len1 > len2)return true;
	else if (len1 < len2)return false;
	else {
		int now = 0;
		while (now<len1) {
			if (x[now] - '0' > y[now] - '0')return true;
			else if (x[now] - '0' < y[now] - '0')return false;
			now++;
		}
	}
	return true;
}
bool intgreat(string x, string y) {
	while (x.length() && x[0] == '0')x.erase(x.begin());
	while (y.length() && y[0] == '0')y.erase(y.begin());
	return great(x, y);
}
bool alf(string x) {
	if (x.length()&&'A' <= x[0] && x[0] <= 'Z')return true;
	return false;
}
string large(string s, string t) {
	if (alf(s) && alf(t))return "";
	else if (alf(s))return t;
	else if (alf(t))return s;
	else {
		if (great(s, t))return s;
		else return t;
	}
}
string intlarge(string s, string t) {
	if (alf(s) && alf(t))return "";
	else if (alf(s))return t;
	else if (alf(t))return s;
	else {
		if (intgreat(s, t))return s;
		else return t;
	}
}
int main() {
	int w, h;
	while (cin >> w >> h, w) {
		string s;
		string t[71][71];
		rep(i, 71) {
			rep(j, 71) {
				t[i][j] = "A";
			}
		}
		rep(i, h) {
			cin >> s;
			rep(j, w) {
				t[i][j] = s[j];
			}
		}
		for (int i = h - 1; i >= 0; i--) {
			for (int j = w - 1; j >= 0; j--) {
				if (!alf(t[i][j])) {
					t[i][j] += large(t[i + 1][j], t[i][j + 1]);
				}
			}
		}
		string ma = "0";
		rep(i, h) {
			rep(j, w) {
				if (!alf(t[i][j])) {
					ma = intlarge(ma, t[i][j]);
				}
			}
		}
		while (ma.length()&&ma[0] == '0')ma.erase(ma.begin());
		cout << ma << endl;
	}
	return 0;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define	inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;


const int S=200100;
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
	char ch[30];
	while(~sf(" %s",ch))
	{
		string s=(string)ch;
		s[5]=' ';
		s[13]=' ';
		ps(s),nl;
	}
    return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <utility>
#include <numeric>

using namespace std;

int gcd(int a, int b){
    int r,tmp;
    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }
 
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b; 

}

int main(){
    int N,t;
    int tmp;
    int mt = 1e9;
    int ans = 1e9;
    cin >> N;
    vector<int> vi;
    for(int i = 0; i < N; i++){
        cin >> t;
        vi.push_back(t);
    }
    ans = gcd(vi[0], vi[1]);
    for(int i = 2; i < N; i++){
        ans = gcd(ans, vi[i]);      
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 892
import math

q, h, s, d = map(int, input().split())
n = int(input())*100

qq = [q, q, 25]
hh = [h/2, h, 50]
ss = [s/4, s, 100]
dd = [d/8, d, 200]
qhsd = [qq, hh, ss, dd]
qhsd.sort()

ans = 0
for i in range(4):
    num = n//qhsd[i][2]
    n -= num*qhsd[i][2]
    ans += num*qhsd[i][1]
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    string S;
    string T;
  cin>>S>>T;
 int ans = 0;
  
  if(S[0]==T[0]) ans++;
    if(S[1]==T[1]) ans++;
      if(S[2]==T[2]) ans++;
  cout<<ans<<endl;
  
  
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define int long long

void solve() {
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	int i=0, j=n-1;
	while(i <= j){
		if(s[i] == 'W' && s[j] == 'R'){
			swap(s[i], s[j]);
			cnt++;
			i++;
			j--;
		}else if(s[i] == 'R' && s[j] == 'W'){
			i++;
			j--;
		}else if(s[i] == 'W' && s[j] == 'W'){
			j--;
		}else{
			i++;
		}
	}
	cout << cnt;
}

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

	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const LL INFLL = 999999999999999LL;

template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){fill((T*)array,(T*)(array+N),val);}

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;
}

LL dp[100005];
int main(){
    int n,k;
    cin>>n>>k;

    Vi h(n);
    for(int i=0; i<n; i++){
        cin>>h[i];
    }

    FILL(dp,INFLL);
    dp[0]=0;

    for(int i=1; i<n; i++){
        int w = ((i-k>=0)?k:i);
        for(int j=1; j<=w; j++) chmin(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string o,e; cin >>o>>e;
    int n = o.length() + e.length();

    string s = "";
    int count1 = 0;
    int count2 = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            s += o[count1];
            count1++;
        } else {
            s += e[count2];
            count2++;
        } 
    }
    
    cout << s << endl;
    return 0;
}




Measured memory_bytes: 256
'''input
3
1
2 1
1
1 1
1
2 0
'''
# A coding delight
from sys import stdin, stdout
import gc
from copy import deepcopy
# gc.disable()
input = stdin.readline



def consistent(choose):
	T = set()
	F = set()
	for i in choose:
		T.add(i + 1)

	for i in choose:
		aux = data[i]
		for j in range(len(aux)):
			p, v = aux[j]
			if v == 0:
				if p in T:
					return False 
				else:
					F.add(p)
			else:
				if p in F:
					return False
				else:
					T.add(p)
	pT = set()
	pF = set()
	while len(T) + len(F) != len(pT) + len(pF):
		# print(T, F)
		pT = deepcopy(T)
		pF = deepcopy(F)
		for i in range(n):
			aux = data[i]
			if i + 1 in T:
				for j in range(len(aux)):
					p, v = aux[j]
					if v == 0:
						if p in T:
							return False 
						else:
							F.add(p)
					else:
						if p in F:
							return False
						else:
							T.add(p)
	# print(T, F)		
	return True

	
# main starts
n = int(input().strip())
data = []
for _ in range(n):
	k = int(input().strip())
	temp =[]
	for i in range(k):
		x, y = list(map(int, input().split()))
		temp.append([x, y])
	data.append(temp)
ans = 0

# generating subset
for i in range(1, 2**n):
	choose = []
	for k in range(n):
		if (1 << k) & i:
			choose.append(k)

	if consistent(choose):
		ans = max(ans, len(choose))
		# print(choose)

print(ans)

Measured memory_bytes: 41628
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))
def oon(x,n,nn):
	global c,ppp
	for i in range(len(x[n])):
		if x[n][i] != nn:
			kk[x[n][i]] = c[ppp]
			ppp += 1
			oon(x,x[n][i],n)

q = int(input())

k = [0 for i in range(q)]
kk = [0 for i in range(q)]
aa = [[]for i in range(q)]
for i in range(q-1):
	a,b  = m()
	k[a-1] += 1
	k[b-1] += 1
	aa[a-1].append(b-1)
	aa[b-1].append(a-1)
k.sort(reverse = True)
c = l()
c.sort(reverse = True)
kk[0] = c[0]
ppp = 1
oon(aa,0,0)
su = sum(c[1:])

print(su)
for i in range(q-1):
	print(kk[i],end = " ")
print(kk[-1])


Measured memory_bytes: 61912
/*  -*- coding: utf-8 -*-
 *
 * 1395.cc: What Goes Up Must Come Down
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

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

template <typename T, const int MAX_N>
struct BIT {
  int n;
  T bits[MAX_N + 1];
  BIT() {}

  void init(int _n) {
    n = _n;
    //memset(bits, 0, sizeof(bits));
  }

  T sum(int x) {
    T s = 0;
    while (x > 0) {
      s += bits[x];
      x -= (x & -x);
    }
    return s;
  }

  void add(int x, T v) {
    while (x <= n) {
      bits[x] += v;
      x += (x & -x);
    }
  }
};

/* global variables */

pii as[MAX_N];
BIT<int,MAX_N> bit;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++)
    scanf("%d", &as[i].first), as[i].second = i + 1;
  sort(as, as + n);

  bit.init(n);
  for (int i = 1; i <= n; i++) bit.add(i, 1);

  ll cnt = 0;
  for (int i = 0, m = n; i < n;) {
    int j = i + 1;
    while (j < n && as[i].first == as[j].first) j++;

    int i0 = i, i1 = j - 1;
    while (i0 < i1) {
      int &k0 = as[i0].second, &k1 = as[i1].second;
      int l = bit.sum(k0) - 1, r = m - bit.sum(k1);
      if (l <= r) {
	cnt += l;
	bit.add(k0, -1);
	i0++;
      }
      else {
	cnt += r;
	bit.add(k1, -1);
	i1--;
      }
      m--;
    }

    int &k0 = as[i0].second;
    int s0 = bit.sum(k0);
    int l = s0 - 1, r = m - s0;
    cnt += min(l, r);
    bit.add(k0, -1);
    m--;

    i = j;
  }

  printf("%lld\n", cnt);
  return 0;
}



Measured memory_bytes: 4392
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int INF = 1 << 30;

struct E
{
	int u, v, cost;
};
bool comp(const E& l, const E& r)
{	return l.cost < r.cost;	}



vint par;
vint rank;

void init(int n)
{
	rep(i, n)
	{
		::par.push_back(i);
		::rank.push_back(0);
	}
}

int find(int x)
{
	if(par[x] == x) return x;
	else			return par[x] = find(par[x]);
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);

	if(x == y) return;


	if(::rank[x] < ::rank[y])	par[x] = y;
	else
	{
		par[y] = x;
		if(::rank[x] == ::rank[y]) ::rank[x]++;
	}
}

bool same(int x, int y)
{
	return find(x) == find(y);
}


int main()
{
	int n, m;
	while(cin >> n && n)
	{
		cin >> m;

		vector<E> es(m);

		char k;
		rep(i, m)
			cin >> es[i].u >> k >> es[i].v >> k >> es[i].cost;

		sort(ALL(es), comp);
		init(n);

		int res = 0;
		rep(i, m)
		{
			E e = es[i];
			if(!same(e.u, e.v))
			{
				unite(e.u, e.v);
				res += e.cost - 100;
			}
		}

		cout << res / 100 << endl;

		par.clear();
		::rank.clear();
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){

	int n,i,j,k,d=0,c;
	char s[101];

	scanf("%d%s",&n,s);

	for(i=2;i<n-1;i++){
		char x[27]={},y[27]={};

		for(j=0;j<n;j++){
			if(j<i)
				x[s[j]-'a']=1;
			else
				y[s[j]-'a']=1;
		}
		c=0;
		for(k=0;k<27;k++){
			if(x[k]==y[k])
				c+=x[k];
		}
		if(c>d)
			d=c;
	}
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

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 n;
string s;
int d[3010][3010];

signed main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++)d[1][i] = 1;
	for (int i = 2; i <= n; i++) {
		if (s[i - 2] == '<') {
			int cnt = d[i - 1][n - i + 1];
			for (int j = n - i; j >= 0; j--) {
				d[i][j] = cnt;
				cnt = (cnt + d[i - 1][j]) % mod;
			}
		}
		else {
			int cnt = d[i - 1][0];
			for (int j = 0; j <= n - i; j++) {
				d[i][j] = cnt;
				cnt = (cnt + d[i - 1][j + 1]) % mod;
			}
		}
	}
	cout << d[n][0] << endl;
}

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

int K;
pair<int, int> golf(int x, int y) {
  if (x < 0) {
    auto p = golf(-x, y);
    return {-p.first, p.second};
  }
  if (y < 0) {
    auto p = golf(x, -y);
    return {p.first, -p.second};
  }
  if (x > y) {
    auto p = golf(y, x);
    return {p.second, p.first};
  }
  if (x+y >= 2*K) return {x, y-K};
  if (x+y == K) return {0, 0};
  auto r = K - (x + y) / 2;
  return {-r, x + y + r - K};
}
 
int main() {
  cin >> K;
  int X,Y; cin >> X >> Y;

  if (abs(X+Y) % 2 == 1 and K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
 
  vector<pair<int, int>> moves;
  moves.emplace_back(X, Y);
  while (moves.back().first or moves.back().second) {
    moves.push_back(golf(moves.back().first, moves.back().second));
  }
 
  cout << moves.size() - 1 << endl;
  for (int i = moves.size() - 2; i >= 0; i--) {
    auto p = moves[i];
    cout << p.first << ' ' << p.second << endl;
  }
 
  return 0;
}

Measured memory_bytes: 4208
#include<stdio.h>

int main()
{
    int a, b, m= 0, n= 0, k= 0;
    scanf("%d", &a);

    while(k<3) {
        b= a%10;
        a= a/10;
        if(b == 7) {
            m +=1;
        }
        else
            n +=1;
    k++;
    }
    if(m != 0)
    printf("Yes\n");
  else  printf("No\n");
    return 0;

}

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

long double dp[301][301][301];
long double solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;
 
    if(dp[one][two][three] > 0)
        return dp[one][two][three];
 
    double remaining = one + two + three;
    long double exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);
 
    return dp[one][two][three] = exp_val/remaining;
}
 

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
// #ifndef ONLINE_JUDGE 
//     freopen("input.txt", "r", stdin); 
//     freopen("output.txt", "w", stdout); 
// #endif
    int i,j,t,n,m,p,k;
    //fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        int one=0,two=0,three=0;
 
        for(int i=0;i<n;i++){
            int x;
            cin >> x;
            if(x == 1)one++;
            else if(x == 2)two++;
            else three++;
        }
 
        memset(dp, -1, sizeof dp);
        cout << setprecision(10) << fixed;
        cout<<solve(one,two,three,n);
    }
    return 0;
}

Measured memory_bytes: 426496
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin  >> a[i];
  int nxt = 1, ans = 0;
  rep(i,n){
    if(nxt == a[i]){
      ++nxt;
    }
    else{
      ++ans;
    }
  }
  if(ans == n) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3984
def main():
    n, = map(int, open(0).read().split())
    first_place_of_n = n % 10

    ans = ''
    if first_place_of_n in [2, 4, 5, 7, 9]:
        ans = 'hon'
    elif first_place_of_n in [0, 1, 6, 8]:
        ans = 'pon'
    else:
        ans = 'bon'

    print(ans)
    return(ans)


if __name__ == '__main__':
    main()


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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
string s,t;
ll n;
ll m;
ll dp[3030][3030];
int main(){
	fast;
	cin>>s;
	cin>>t;
	n=s.length();
	m=t.length();
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=m;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}
			else if(s[i-1]==t[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	// for(ll i=0;i<=n;i++){
	// 	for(ll j=0;j<=m;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	ll i=n;
	ll j=m;
	string ans="";
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			ans+=s[i-1];
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 71936
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int box = sc.nextInt();
    
    int[] list = new int[box];
    
    for(int i = 0 ; i < list.length ; ++i){
      list[i] = sc.nextInt();
    }
    
    int intMin = list[0];
    int count = 1;
    for(int i = 1 ; i < list.length ; ++i){
      if(intMin > list[i]){
        intMin = list[i];
        count += 1;
      }
    }
    
    System.out.println(count);
  }
}

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

// 頂点の持つ情報
struct edge {
    ll to;
    ll cost;
};

//最短距離と、頂点の番号
using P = pair<ll, ll>;

int N;
int inf = 1e9;
// グラフと距離
vector<vector<edge>> G(10);
vector<ll> d(10);

void dijkstra(int s) {
    // Pの最初の値（距離）が小さい順で並べるpriority_queue
    priority_queue<P, vector<P>, greater<P>> que;
    // 距離をinfで初期化
    d.assign(N, INF);
    d[s] = 0;
    que.push({0, s});

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        //　戻る場合や他の方が早い場合は最短にならないので飛ばす
        if (d[v] < p.first)
            continue;

        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            // 他より早い場合は更新
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

    cin >> N;
    G.resize(N);
    rep(i, N - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    ll Q, K;
    cin >> Q >> K;
    K--;
    dijkstra(K);
    rep(i, Q) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        cout << d[a] + d[b] << endl;
    }
}

Measured memory_bytes: 13932
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<cassert>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
struct D {
	int pos, cost, can, end;
	//頂点、コスト、この頂点の可能範囲、この範囲の最後
};
bool operator<(D a, D b) { return a.can < b.can; }
bool operator>(D a, D b) { return a.can > b.can; }
int n, A, B, C, m, k, t;
//個数、各停、準急、急行、急行の停車、準急の停車、時間
int a[4000];
int pos, cost, can, end;
signed main() {
	cin >> n >> m >> k >> A >> C >> B >> t;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		a[i]--;
	}
	priority_queue<D>p;
	int ans = 0;
	for (int i = 0; i < m - 1; i++) {
		if (a[i] * C > t) break;
		ll r = (t - a[i] * C) / A + 1;
		r = min(r, a[i + 1] - a[i]);
		ans += r;
		pos = a[i] + r;
		cost = a[i] * C + r * B;
		can = (t - cost) / A + 1;
		can = min(can, a[i + 1] - pos);
		if (pos >= a[i + 1] || cost > t) continue;
		p.push(D{ pos,cost,can,a[i + 1] });
	}
	for (int z = 0; z < k - m && !p.empty(); z++) {
		D q = p.top(); p.pop();
		ans += q.can;
		pos = q.pos + q.can;
		cost = q.cost + q.can * B;
		can = (t - cost) / A + 1;
		can = min(can, q.end - pos);
		if (pos >= q.end || cost > t) continue;
		p.push(D{ pos,cost,can,q.end });
	}
	if ((n - 1)*C <= t) ans++;
	cout << ans-1 << endl;
}


Measured memory_bytes: 3252
import sys
import numpy as np
import fractions
input = sys.stdin.readline
N, M  = [int(x) for x in input().split()]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
ans = make_divisors(M)
ans = sorted(ans)[::-1]
for i in ans:
    if i <= M/N:
        print(i)
        sys.exit()

Measured memory_bytes: 15564
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main{

	static PrintWriter out;
	static InputReader ir;

	static void solve(){
		while(true){
			int n=ir.nextInt();
			if(n==0)
				break;
			int[] a=ir.nextIntArray(n);
			int mi=Integer.MAX_VALUE;
			Arrays.sort(a);
			for(int i=0;i<n-1;i++){
				mi=Math.min(mi,a[i+1]-a[i]);
			}
			out.println(mi);
		}
	}

	public static void main(String[] args) throws Exception{
		ir=new InputReader(System.in);
		out=new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer=new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

		public boolean hasNextByte() {
			if(curbuf>=lenbuf){
				curbuf= 0;
				try{
					lenbuf=in.read(buffer);
				}catch(IOException e) {
					throw new InputMismatchException();
				}
				if(lenbuf<=0) return false;
			}
			return true;
		}

		private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

		private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

		private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

		public boolean hasNext(){skip(); return hasNextByte();}

		public String next(){
			if(!hasNext()) throw new NoSuchElementException();
			StringBuilder sb=new StringBuilder();
			int b=readByte();
			while(!isSpaceChar(b)){
				sb.appendCodePoint(b);
				b=readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			int res=0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public long nextLong() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			long res = 0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public double nextDouble(){return Double.parseDouble(next());}

		public int[] nextIntArray(int n){
			int[] a=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}

		public long[] nextLongArray(int n){
			long[] a=new long[n];
			for(int i=0;i<n;i++) a[i]=nextLong();
			return a;
		}

		public char[][] nextCharMap(int n,int m){
			char[][] map=new char[n][m];
			for(int i=0;i<n;i++) map[i]=next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 26812
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n+1);
    rep(i, m) {
        int a;
        cin >> a;
        c[a] = 1;
    }

    int ans1 = 0, ans2 = 0;

    rep(i, x) ans1 += c[i];
    for (int i = x; i < n; i++) ans2 += c[i];

    int ans = min(ans1, ans2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

ostream& operator<<(ostream& os, Pll& a)
{
    return os << a.first << " " << a.second;
}

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << endl;
    cout << endl;
}

bool compAngle(Pll& a, Pll& b)
{
    return atan2(a.second, a.first) < atan2(b.second, b.first);
}

ll norm2(ll& X, ll& Y)
{
    return X*X + Y*Y;
}

int main()
{
    int N;
    cin >> N;
    vector<Pll> vecs(N);
    for(auto& v: vecs) cin >> v.first >> v.second;
    sort(vecs.begin(), vecs.end(), compAngle);
    // debug(vecs);

    vector<ll> sx(N+1), sy(N+1);
    sx[0] = 0;
    sy[0] = 0;
    for(int i=0; i<N; i++){
        sx[i+1] = sx[i] + vecs[i].first;
        sy[i+1] = sy[i] + vecs[i].second;
    }

    ll ans = norm2(sx[N], sy[N]);
    for(int i=0; i<N; i++){
        for(int j=i; j<N; j++){
            ll X = sx[j+1] - sx[i];
            ll Y = sy[j+1] - sy[i];
            ans = max(ans, norm2(X, Y));
            X = sx[N] - X;
            Y = sy[N] - Y;
            ans = max(ans, norm2(X, Y));
        }
    }

    cout << fixed << setprecision(20) << sqrt(ans) << endl;
}

Measured memory_bytes: 384