akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define INF 1e9
#define mod 998244353
#define mod2 1000000007
#define dbg(x) cout << (#x) << " --> " << x << "\n";
#define dbgarr(y)                                                                                            \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x << '\n';
#define dbgparr(y)                                                                                           \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x.first << ", " << x.second << '\n';
using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;

void goodLuckHaveFun() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
/* clang-format off */
  #ifdef _DEBUG
  freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
  #endif
  /* clang-format on */
}

vector<int> adList[2010];
vector<int> dist[2010];

// O(V + E)
void bfs(int start, int n){
  vector<ll> visited(n+1);
  queue<ll> q;
  visited[start] = 1;
  q.push(start);
  dist[start].resize(n+1);
  dist[start][start] = 0;
  while(!q.empty()){
    ll s = q.front(); q.pop();
    //process
    for(auto u : adList[s]){
      if (visited[u]) continue;
      visited[u] = 1;
      dist[start][u] = dist[start][s] + 1;
      q.push(u);
    }
  }
}

int main() {
  goodLuckHaveFun();
  int n,x,y;
  cin >> n >> x >> y;
  for(int i = 1; i < n; ++i){
    adList[i].pb(i+1);
    adList[i+1].pb(i);
  }
  adList[x].pb(y);
  adList[y].pb(x);

  for(int i = 1; i <= n; ++i){
    bfs(i,n);
  }
  vector<int> result(n);
  for(int i = 1; i <= n; ++i){
    int count = 0;
    for(int j = 1; j <= n; ++j){
      result[dist[i][j]]++;
    }
  }
  for(int i = 1; i <= n-1; ++i){
    cout << result[i]/2 << '\n';
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

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

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
#define SoArrt(a, n) sort(a, a + n);
#define SoArrtR(a, n) sort(a, a + n, std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    string s;

	cin >> s;

	bool dir[4];
  
  	Mem0(dir);

	int i, len = s.size();

	rep(i, len) {
		if (s[i] == 'N') dir[0] = 1;
		else if (s[i] == 'S') dir[1] = 1;
		else if (s[i] == 'W') dir[2] = 1;
		else if (s[i] = 'E') dir[3] = 1;
	}

	if ((dir[0] ^ dir[1]) || (dir[2] ^ dir[3])) Out("No");
	else Out("Yes");
	
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int x = Integer.parseInt(in[0]);
			int y = Integer.parseInt(in[1]);
			if (x >= 0 && x <= 10000 && y >= 0 && y <= 10000) {
				if (x == 0 && y == 0) {
					break;
				} else {
					if (x < y) {
						String inVal = String.valueOf(x) + " " + String.valueOf(y);
						output.add(inVal);
					} else if (x > y) {
						String inVal = String.valueOf(y) + " " + String.valueOf(x);
						output.add(inVal);
					} else {
						output.add(input);
					}
				}
			}
		}
		if (output.size() <= 3000) {
			for (String out : output) {
				System.out.println(out);
			}
		}
	}
}

Measured memory_bytes: 38284
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;


int main()
{
	ll k = 0;
	ll N;
	double ans = 0;
	cin >> N;
	vector<pair<ll, ll>> p(N);
	rep(i, N)
	{
		cin >> p[i].first >> p[i].second;
	}
	sort(p.begin(), p.end());
	do {
		rep(i, N - 1)
		{
			ans += sqrt(pow(p[i].first - p[i + 1].first, 2) + pow(p[i].second - p[i + 1].second, 2));
			

		}
		k++;
	} while (next_permutation(p.begin(), p.end()));
	cout << setprecision(15) << ans / k << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int h,w,ch,cw,dh,dw,nc=1;
char m[1005][1005];
const int fx[]={1,-1,0,0},fy[]={0,0,1,-1};
int b[1005][1005],d[1000005],vis[1000005];
vector<pair<int,int> > v[1000005];
queue<int> q;
void dfs(int x,int y){
	//cout<<"dfs"<<x<<' '<<y<<endl;
	b[x][y]=nc;
	v[nc].push_back(make_pair(x,y));
	for(int i=0;i<4;i++){
		int nx=x+fx[i],ny=y+fy[i];
		//cout<<nx<<' '<<ny<<endl;
		if(nx>=1&&nx<=h&&ny>=1&&ny<=w&&b[nx][ny]==0&&m[nx][ny]!='#') dfs(nx,ny);
	}
}
int main(){
	cin>>h>>w>>ch>>cw>>dh>>dw;
	for(int i=1;i<=h;i++) {
		for(int j=1;j<=w;j++){
			cin>>m[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(m[i][j]=='#'||b[i][j]) continue;
			dfs(i,j);nc++;
			//cout<<i<<' '<<j<<endl;
			//cout<<nc<<endl;
		}
	}
	q.push(b[ch][cw]);
	vis[b[ch][cw]]=1; 
	memset(d,-1,sizeof(d));
	d[b[ch][cw]]=0;
	while(!q.empty()){
		int nb=q.front();
		//cout<<"啊这"<<nb<<endl;
		if(nb==b[dh][dw]) break;
		q.pop();
		for(int i=0;i<v[nb].size();i++){
			for(int tx=-2;tx<=2;tx++){
				for(int ty=-2;ty<=2;ty++){
					int nx=v[nb][i].first+tx,ny=v[nb][i].second+ty;
					if(nx>=1&&nx<=h&&ny>=1&&ny<=w&&m[nx][ny]!='#'&&!vis[b[nx][ny]]) vis[b[nx][ny]]=1,d[b[nx][ny]]=d[nb]+1,q.push(b[nx][ny]);
				}
			}
		}
	}
	cout<<d[b[dh][dw]];
	return 0;
}

Measured memory_bytes: 42660
x, y, a, b, c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
ap = p + q + r
ap.sort(reverse=True)
print(sum(ap[:x+y]))

Measured memory_bytes: 23328
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <climits>
#define mk make_pair
#define pb push_back
#define scanf scanf_s
#define printf printf_s
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> pos;
const ll N = 2010, MOD = 1000000007;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}

int bb(int v1) {
	if (v1 % 2 == 0)return v1 / 2 - 1;
	else return v1 / 2;
}

ll pw(ll a, ll b) {
	ll v = 1;
	for (; b > 0; b = (b >> 1), a = (a * a) % MOD) {
		if ((b & 1) > 0)v = (v * a) % MOD;
	}
	return v;
}


struct Comb {
public:ll frc[N + 1], rv[N + 1];
	  ll pw(ll v1, ll v2) {
		  ll v3 = 1;
		  for (; v2 > 0; v2 = (v2 >> 1)) {
			  if (v2 & 1)v3 = (v3 * v2) % MOD;
			  v1 = (v1 * v1) % MOD;
		  }
		  return v3;
	  }

	  void set() {
		  frc[0] = 1;
		  rv[0] = 1;
		  for (int i = 1; i < N; i++) {
			  frc[i] = (frc[i - 1] * i) % MOD;
			  rv[i] = pw(frc[i], MOD - 2);
		  }
	  }
	  ll comb(ll a, ll b) {
		  ll v1 = frc[a];
		  v1 = (v1 * rv[b]) % MOD;
		  v1 = (v1 * rv[a - b]) % MOD;
		  return v1;
	  }
};

ll v1, v2;
int main() {
	cin >> v1 >> v2;
	for (int i = 0; i < v2; i++) {
		ll v3; cin >> v3;
		v1 -= v3;
	}
	cout << max((ll)-1, v1) << endl;
	return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

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

int main() {
    string s;
    cin >> s;
    string t = "";

    rep(i, s.length()) {
        if (i % 2 == 0) t += s[i];
    }
    cout << t << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
  int n,i,j,ans=0;
  cin >>n;
  int l[200];
  int max,tmp;
  while(cin>>j){
    l[i] = j;
    i++;
  }
  cout<<endl;
  for(i=0;i<2*n-1;++i){
    max=i;
    for(j=i+1;j<2*n;++j){
      if(l[max]<l[j]){
        max=j; 
      }
    }
    tmp=l[max];
    l[max]=l[i];
    l[i]=tmp;
  }
  
  for(i=1;i<2*n;i=i+2){
    ans+=l[i];
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}

int main() {
  ll n, a, b; cin >> n >> a >> b;
  vector<ll> x(n);
  REP(i, n) cin >> x[i];

  ll ans = 0LL;
  REP(i, n-1) ans += min((x[i + 1] - x[i]) * a, b);

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


Measured memory_bytes: 1152
n,m = gets.split.map(&:to_i)

a = Array.new(n, 1)
b = Array.new(n, false)
b[0] = true

m.times{
  x,y = gets.split.map(&:to_i)
  b[y-1] = true if b[x-1]
  a[x-1] -= 1
  a[y-1] += 1
  b[x-1] = false if a[x-1]==0
}

p b.count(true)


Measured memory_bytes: 3324
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<pair<int, int>, int> tup;

inline void solve()
{
	int k;
	cin >> k;
	vector<int> prime;
	vector<int> resh(1000 * 1000, 0);

	fore(i, 2, 1000 * 1000)
	{
		if (resh[i] == 0)
		{
			prime.push_back(i);
			for (int j = i; j < 1000 * 1000; j += i)
				resh[j] = i;
		}
	}

	cout << *lower_bound(prime.begin(), prime.end(), k);
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 4860
#include <iostream>
#include<bits/stdc++.h>
#include<string.h>
#include <cstdlib>
#include <sstream>  
#include <vector>
#include <set>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mlim 10000000
#define br break
#define pb push_back
#define pi 3.14159265358979323846
#define pob pop_back
#define pf pop_front
#define cc continue
#define ll long long int
#define vl vector<long long int>
#define pll pair<long long int,long long int>
#define sll set<long long int>
#define l length()
#define tc ll t;cin>>t; while(t--)
#define f(i,a,b) for(ll i=a; i<b; i++)
#define g(i,b,a) for(ll i=b-1; i>=a; i--)
 
using namespace std;
void solve()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes\n";
    else
    cout<<"No\n";
}
int main() {
	fio;
	    solve();
	return 0;
}


Measured memory_bytes: 256
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

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

const int MAX = 1e6 + 41;
const int MOD = 1e9 + 7;

int n, h, D;
int d[MAX];
int u[MAX];
int f[MAX];

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

int sub(int a, int b) {
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

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

void init() {
	f[0] = 1;
	fi(1, MAX - 1) f[i] = mul(f[i - 1], i);
}

void solve () {
	int sum = 0;
	fi(1, n) {
		sum = add(sum, f[i]);
	}
	u[1] = f[n];
	u[D + 1] = sub(0, f[n]);
	int cur = 0;
	
	fi(1, h) {
		cur = add(cur, u[i]);
		d[i] = cur;
		int nxt = min(MAX - 1, i + D + 1);
		int v = mul(cur, sum);
		u[i + 1] = add(u[i + 1], v);
		u[nxt] = sub(u[nxt], v);
	}
//	dbg0(u, h + 1);
//	dbg0(d, h + 1);
	printf("%d\n", d[h]);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
	init();
	
	scanf("%d %d %d", &n, &h, &D);
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
using namespace std;


int main() {
	long long n, c = 0;
	cin >> n;
	vector<pair<long long, long long> > a(n);
	for(long long i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	long long p = a[0].first + a[0].second;
	for(long long i = 1; i < n; ++i){
		long long pp = max(p, a[i].first + a[i].second);
	    if(a[i].first - a[i].second - p < 0){
			c++;
			pp = min(p, a[i].first + a[i].second);
		}
		p = pp;
	}
	cout << n - c;
}

Measured memory_bytes: 2296
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B, C;
  std::cin >> A >> B >> C;
  std::cout << B + std::min(A + B + 1, C) << std::endl;
  return 0;
}

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

int main(){
    int N ;
    cin >> N ;
    int X[N];
    for (int i = 0; i < N ; ++ i){
        cin >> X[i];
    }
    int ans[100];
    int anssub = 0;
    for (int i = 1; i <= 100; ++ i){
        anssub = 0;
        for (int j = 0; j < N; ++ j){
            anssub += ( i - X[j] ) * ( i - X[j] );
        }
        ans[i] = anssub;
    }
    int ansfinal = 100000000;
    for (int i = 1; i <= 100; ++i ){
        if (ansfinal > ans[i]) {
            ansfinal = ans[i];
        }
    }
    cout << ansfinal << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int n,d;
struct point{
	int x[11];
}p[11];
bool check(point a,point b)
{
	ll sum=0;
	for(int i=1;i<=d;i++)
	{
		sum+=(a.x[i]-b.x[i])*(a.x[i]-b.x[i]);
	}
	for(ll i=1;i<=200;i++)
	{
		if(i*i==sum) return true;
	}
	return false;
}
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=d;j++)
		{
			scanf("%d",&p[i].x[j]);
		}
	}
	int num=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(check(p[i],p[j]))
				num++;
		}
	}
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true){
			String[] line = br.readLine().split(" ");
			
			int h = Integer.parseInt(line[0]);
			int w = Integer.parseInt(line[1]);
			
			if(h == 0 && w == 0){
				break;
			}
			
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if((0 < i && i <h-1) && (0 < j && j < w-1)){
						sb.append(".");
					}
					else {
						sb.append("#");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
			System.out.print(sb);
			sb.delete(0,sb.length());
		}
	}
}

Measured memory_bytes: 25160
N, K = map(int, input().split())
D = list(map(int, input().split()))

while True:
  sN = str(N)
  flag = False
  for ins in D:
    if str(ins) in sN:
      flag = True
      break
  if flag:
  	#print(out)
  	N += 1
  else:
  	break

print(N)

Measured memory_bytes: 9076
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9 + 7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    cin >> N;
    vector<P> A(N);
    rep(i, N)
    {
        ll a;
        cin >> a;
        A[i] = { a,i + 1 };
    }
    //
    std::sort(A.begin(), A.end(), [](P l, P r)
        {
            return l.first < r.first;
        });
    rep(i, N)
    {
        cout << A[i].second << " ";
    }

    //
    return 0;
}

Measured memory_bytes: 4476
typedef long long ll;
/*
id: sadykhzadeh -> @Azer_Sadykhzadeh
Programming Language: (C++)
*/
using namespace std;
#include <iostream>
long double a, b;

int main(){ cin >> a >> b;
    if((a + b)/2 != (int)((a + b)/2)) return cout << "IMPOSSIBLE" << endl, 0;
    cout << (int)((a + b)/2) << endl;
}


Measured memory_bytes: 256
C = [list(map(int,input().split())) for i in range(3)]
c1,c2,c3 = C[0]
c1,c2,c3 = c1-c2,c2-c3,c3-c2
ans = 'Yes'
for c in C[1:]:
    cc1,cc2,cc3 = c
    cc1,cc2,cc3 = cc1-cc2,cc2-cc3,cc3-cc2
    # print(c1,cc1,c2,cc2,c3,cc3)
    if c1 == cc1 and c2 == cc2 and c3 == cc3:
        pass
    else:
        ans = 'No'
        break

c1,c2,c3 = C[0][0],C[1][0],C[2][0]
c1,c2,c3 = c1-c2,c2-c3,c3-c2
for i in range(1,3):
    cc1,cc2,cc3 = C[0][i],C[1][i],C[2][i]
    cc1,cc2,cc3 = cc1-cc2,cc2-cc3,cc3-cc2
    if c1 == cc1 and c2 == cc2 and c3 == cc3:
        pass
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		sc.close();
		int cnt = 0;
		for(int i = 0;i < S.length();i++) {
			if(S.charAt(i)==T.charAt(i)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin >> h[i];
    vector<int>yoi(n,0);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        if(h[a-1] > h[b-1])yoi[b-1]++;
        else if(h[a-1]<h[b-1])yoi[a-1]++;
        else{
            yoi[b-1]++;
            yoi[a-1]++;
        }
    }
    int ans =0;
    for(int i=0;i<n;i++){
        if(yoi[i] ==0)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, a, b, c, k);
	until(a < b) { b *= 2; k--; }
	until(b < c) { c *= 2; k--; }
	OUT(k >= 0 ? "Yes" : "No");
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n,k,l;
vector<int> v[300000],w[300000];
int a[300000],b[300000];
map<P,int> mp;

int main(){
  cin>>n>>k>>l;

  rep(i,k){
    int x,y;
    cin>>x>>y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  rep(i,l){
    int x,y;
    cin>>x>>y;
    w[x].push_back(y);
    w[y].push_back(x);
  }
  rep(i,n+1){
    a[i]=i;
    b[i]=i;
  }

  rep(i,n+1){
    queue<int> q;
    q.push(i);
    while(!q.empty()){
      int x = q.front(); q.pop();
      rep(j,v[x].size()){
        if(a[i]!=a[v[x][j]]){
          a[v[x][j]]=a[i];
          q.push(v[x][j]);
        }
      }
    }
  }

  rep(i,n+1){
    queue<int> q;
    q.push(i);
    while(!q.empty()){
      int x = q.front(); q.pop();
      rep(j,w[x].size()){
        if(b[i]!=b[w[x][j]]){
          b[w[x][j]]=b[i];
          q.push(w[x][j]);
        }
      }
    }
  }

  rep(i,n+1){
    mp[P(a[i],b[i])]++;
  }
  FOR(i,1,n+1){
    if(i!=1) cout<<' ';
    cout<<mp[P(a[i],b[i])];
  }
  cout<<endl;

}
  


Measured memory_bytes: 32932
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=list(map(int,input().split()))
    A.append(a)
    B.append(b)
C = [[A[i]+B[i],i] for i in range(N)]

C = sorted(C,key=lambda x: x[0])
C = C[::-1]
t_sum=0
a_sum=0
for i in range(N):
    if i%2==0:
        t_sum+=A[C[i][1]]
    else:
        a_sum+=B[C[i][1]]

print(t_sum-a_sum)

Measured memory_bytes: 30036
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    sc.close();
    System.out.println(solve(a, b));

  }

  static int solve(int a, int b) {
    for (int price = b * 10; price < (b + 1) * 10; price++) {
      if (price * 8 / 100 == a) {
        return price;
      }
    }
    return -1;
  }
}

Measured memory_bytes: 35856
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
  string str;
  int q;
  cin>>str>>q;
  for(int i=0;i<q;i++)
  {
    string x;
    int a,b;
    cin>>x>>a>>b;
    if(x=="replace"){
      string y;
      cin>>y;
      str.replace(a,b-a+1,y);
    }
    else if(x=="print")
    {
      cout<<str.substr(a,b-a+1)<<endl;}
    else if(x=="reverse"){
      string h=str.substr(a,b-a+1);
      reverse(h.begin(),h.end());
      str=str.substr(0,a)+h+str.substr(b+1,str.size()-b);
    }
  }
  return 0;
}


Measured memory_bytes: 3212
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
class E { static void Main() { new J(); } }
class J
{
	int F() { return int.Parse(Console.ReadLine()); }
	int[] G() { return Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(_ => int.Parse(_)).ToArray(); }
	public J()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		while (true)
		{
			var S = Console.ReadLine();
			if (S == null) break;
			var I = S.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(_ => int.Parse(_)).ToArray();
			var g = GCD(I[0], I[1]);
			Console.WriteLine("{0} {1}", g, (I[0] / g) * I[1]);
		}
		Console.Out.Flush();
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Math.Abs(a); var m = (ulong)Math.Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Math.Min(zm, zn);
	}
}

Measured memory_bytes: 9440
import numpy as np

# 行、列の番号を受けて周りの地雷の数を返す
def mnum(i,j):
    Acand=np.asarray([[r,c] for r in range(i-1,i+2) for c in range(j-1,j+2)])
    condh=np.logical_and(Acand[:,0]>=0,Acand[:,0]<H)
    condw=np.logical_and(Acand[:,1]>=0,Acand[:,1]<W)
    cond=np.logical_and(condh,condw)
    A=Acand[cond,:] # 周りの8マス
    mcount=0 # 地雷の数

    for a in A: # 各周りのマスについて、地雷だったら数をインクリメントする
        mcount+=int(S[a[0],a[1]]=="#")

    return mcount

H,W=list(map(int,input().split(" ")))
S=np.full((H,W),".",np.str)
MC=np.zeros((H,W),np.str) # 地雷の数

# 入力してゆく
for s in range(H):
    S[s,:]=list(input())

# 周り8マスの地雷の数を取得してゆく
for i in range(H):
    for j in range(W):
        if S[i,j]==".": # 空きマスの場合
            MC[i,j]=str(mnum(i,j)) # 地雷の数
        elif S[i,j]=="#": # 地雷マスの場合
            MC[i,j]="#" # 地雷

    print("".join(MC[i,:]))

Measured memory_bytes: 12484
x,k,d = [int(p) for p in input().split()]
x=abs(x)
ans = min(x%d,d-x%d);
if(ans==0):
    p = x//d
    t = k;
    k-=p;
    if(k<0):
        print((x-t*d))
    elif(k%2==0):
        print(0)
    else:
        print(d)
elif(k*d>x):
    p = x//d
    k-=p
    if(x%d==ans):
        if(k%2==0):
            print(ans)
        else:
            print(d-ans)
    else:
        k-=1
        if(k%2==0):
            print(ans)
        else:
            print(d-ans)
else:
    print((x-k*d))


Measured memory_bytes: 8988
#include <bits/stdc++.h>
using namespace std;
int calc();
int main(){
    cout<<calc()<<endl;
    return 0;
}
int calc(){
    
    int koma;
    int masu;
    cin>>koma;
    cin>>masu;
    if(koma>=masu){
        return 0;
    }
    vector<int> vec(masu);
    for(int i=0;i<masu;i++){
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());

    vector<int> diffs(masu-1);
    for(int i=0;i<masu-1;i++){
        diffs[i]=vec[i+1]-vec[i];
    }
    sort(diffs.begin(),diffs.end());
    diffs.erase(diffs.end()-koma+1,diffs.end());
    return accumulate(diffs.begin(), diffs.end(), 0);
}

Measured memory_bytes: 1024
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = long.Parse(Console.ReadLine());
		var m = new int[5].Select(_ => long.Parse(Console.ReadLine())).Min();
		Console.WriteLine(n / m + (n % m == 0 ? 4 : 5));
	}
}


Measured memory_bytes: 11348
#include<stdio.h>

int main(){

	int a[110];
	int n = 0;
	int i = 0,j = 0;
	int k = 0;

	scanf("%d",&n);
	
	for(i = 0; i < n; i++){
		scanf("%d",&a[i]);
	
	}
	
	for(i = n-1; i >= 0; i--){
	printf("%d",a[i]);
		
		if(i!=0)printf(" ");
	}
	
	printf("\n");
	
	
	
	
	
return 0 ;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1e5+5;

int main(){
	/*freopen(".gir", "r", stdin);
	freopen(".cik", "w", stdout); 
    */ios_base::sync_with_stdio(false);cin.tie(NULL);
	int a;string s;
	cin >> a;cin >> s;
	if(a>=3200)cout << s << endl;
	else cout << "red" << endl;
}
	

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=2009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int dp[M+5][M+5],n,a[M+5];
vector<pi>vec;
int solve(int pos,int lft)
{
    int total=pos-1;
    int lft_use=lft-1;
    int rgt_use=total-lft_use;
    int rgt=n-rgt_use;
    if(pos>n)return 0;
    int &ret=dp[pos][lft];
    if(ret!=(-1))return ret;
    ret=0;
    int cidx=vec[pos-1].si;
    int val=vec[pos-1].fi;
    int yo=abs(lft-cidx)*val;
    ret=solve(pos+1,lft+1)+yo;
    yo=abs(rgt-cidx)*val;
    ret=max(ret,solve(pos+1,lft)+yo);
    return ret;
}
 main()

{
    fast
    memset(dp,-1,sizeof dp);
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
        vec.pb(mp(a[i],i));
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int ses=solve(1,1);
    cout<<ses<<endl;
    return 0;

}













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

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

	int res = 0;
	int count = 1,i = 1;

	for(i = 1; i*10 <= n; i*=10){
		 if(count%2){
		 	res+=(i*10) - i;
		    //cout<<count<<" "<<i*10<<" "<<i<<endl;

		 }
		 count++;
	}

	if(count%2){
		res+=(n-i+1);
	}
	cout<<res;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long LL;
typedef double D;

int W, H, s, t;
int convert(int i, int j)
{
	return i * W + j + 1;
}

bool matrix[100][100];

struct edge
{
	int from, to, cap, flow;
};

const int N = 20003;

vector<int> G[N];
vector<edge> E;
int q[N], level[N], ptr[N];

const int inf = 1e9;

void add_edge(int from, int to, int cap)
{
	G[from].push_back((int)E.size());
	E.push_back({from, to, cap, 0});
	G[from].push_back((int)E.size());
	E.push_back({to, from, 0, 0});
}

bool bfs()
{
	int l = 0, r = 0;
	q[r++] = s;
	memset(level, -1, sizeof(level));
	level[s] = 0;
	
	while(l < r && level[t] == -1)
	{
		int v = q[l++];
		for (int id : G[v])
		{
			int to = E[id].to;
			if (level[to] == -1 && E[id].cap > E[id].flow)
			{
				level[to] = level[v] + 1;
				q[r++] = to;
			}
		}
	}
	
	return level[t] != -1;
}

int dfs(int v = s, int flow = inf)
{
	if (!flow)
		return 0;
	if (v == t)
		return flow;
	for (; ptr[v] < G[v].size(); ++ptr[v])
	{
		int id = G[v][ptr[v]], to = E[id].to;
		if (level[to] != level[v] + 1)
			continue;
		int pushed = dfs(to, min(flow, E[id].cap - E[id].flow));
		if (pushed)
		{
			E[id].flow += pushed;
			E[id ^ 1].flow -= pushed;
			return pushed;
		}
	}
	return 0;
}

int dinic()
{
	int flow = 0;
	while (bfs())
	{
		memset(ptr, 0, sizeof(ptr));
		while (int pushed = dfs())
			flow += pushed;
	}
	return flow;
}

int main()
{
	ios_base::sync_with_stdio(0);
	char c;
	pair<int, int> S, T;
	cin >> H >> W;
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
		{
			cin >> c;
			if (c == 'S')
				S = {i, j};
			if (c == 'T')
				T = {i, j};
			
			matrix[i][j] = c == '.' ? 0 : 1;
		}
	
	if (S.first == T.first || S.second == T.second)
	{
		cout << -1;
		return 0;
	}
	
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
		{
			if (!matrix[i][j])
				continue;
			add_edge(convert(i, j) * 2, convert(i, j) * 2 + 1, 1);
			add_edge(convert(i, j) * 2 + 1, convert(i, j) * 2, 1);
			int k = 1;
			while (i + k < H)
			{
				if (matrix[i + k][j])
				{
					add_edge(convert(i, j) * 2 + 1, convert(i + k, j) * 2, inf);
					add_edge(convert(i + k, j) * 2 + 1, convert(i, j) * 2, inf);
				}
				k++;
			}
			k = 1;
			while (j + k < W)
			{
				if (matrix[i][j + k])
				{
					add_edge(convert(i, j) * 2 + 1, convert(i, j + k) * 2, inf);
					add_edge(convert(i, j + k) * 2 + 1, convert(i, j) * 2, inf);
				}
				k++;
			}
		}
	
	s = convert(S.first, S.second) * 2 + 1;
	t = convert(T.first, T.second) * 2;
	
	cout << dinic();
}

Measured memory_bytes: 86108
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n = parseInt(input[0], 10);
    var dstr = input[1].split(' ');
    var d = new Array(n);
    for (var i = 0; i < n; i++) {
        d[i] = parseInt(dstr[i], 10);
    }
    var m = parseInt(input[2], 10);
    var tstr = input[3].split(' ');
    var t = new Array(m);
    for (var i = 0; i < m; i++) {
        t[i] = parseInt(tstr[i], 10);
    }

    d.sort(function(a, b) {
        if (a < b) {
            return -1;
        }
        if (a > b) {
            return 1;
        }
        return 0;
    });

    t.sort(function(a, b) {
        if (a < b) {
            return -1;
        }
        if (a > b) {
            return 1;
        }
        return 0;
    });

    for (var i = 0, j = 0; i < m; i++) {
        var found = false;
        for (; j < n; j++) {
            if (t[i] == d[j]) {
                found = true;
                j++;
                break;
            }
        }
        if (!found) {
            break;
        }
    }

    if (found) {
        console.log('YES');
    }
    else {
        console.log('NO');
    }

    return 0;
}


Measured memory_bytes: 71068
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
ll p=1000000007;
struct ball
{
	int c;
	int w;
	int id;
	ball(int a=0,int b=0,int d=0)
	{
		c=a;
		w=b;
		id=d;
	}
};
pii a[200010];
int b[200010];
pii c[200010];
ball d[200010];
int cmp(ball a,ball b)
{
	return a.w<b.w;
}
list<int> l[200010];
void add(int x,int y)
{
	l[x].push_back(y);
	l[y].push_back(x);
}
int e[200010];
int vis[200010];
int tot;
void dfs(int x)
{
	if(vis[x])
		return;
	vis[x]=1;
	e[++tot]=a[x].first;
	for(auto v:l[x])
		dfs(v);
}
ll fac[200010];
ll ifac[200010];
ll inv[200010];
int main()
{
#ifdef DEBUG
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	int i;
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
	for(i=2;i<=n;i++)
	{
		inv[i]=-(p/i)*inv[p%i]%p;
		fac[i]=fac[i-1]*i%p;
		ifac[i]=ifac[i-1]*inv[i]%p;
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].first,&a[i].second);
		if(!b[a[i].first]||a[i].second<c[a[i].first].first)
		{
			b[a[i].first]=1;
			c[a[i].first]=pii(a[i].second,i);
		}
	}
	int cnt=0;
	for(i=1;i<=n;i++)
		if(b[i])
			d[++cnt]=ball(i,c[i].first,c[i].second);
	sort(d+1,d+cnt+1,cmp);
	int j,k;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=3&&j<=cnt;j++)
			if(d[j].c!=a[i].first&&d[j].w+a[i].second<=y)
				add(d[j].id,i);
		if(c[a[i].first].second!=i&&c[a[i].first].first+a[i].second<=x)
			add(c[a[i].first].second,i);
	}
	ll ans=1;
	for(i=1;i<=n;i++)
		if(!vis[i])
		{
			tot=0;
			dfs(i);
			sort(e+1,e+tot+1);
			ans=ans*fac[tot]%p;
			for(j=1;j<=tot;j=k+1)
			{
				for(k=j;k<tot&&e[k+1]==e[j];k++);
				ans=ans*ifac[k-j+1]%p;
			}
		}
	ans=(ans%p+p)%p;
	printf("%lld\n",ans);
	return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int  arr[82], n;


void solve()
{
	cin >> n;
	lop(i, 0, n) cin >> arr[i];

	int i = 0, ans = 1000, initial = 1000;
	while (i < n)
	{
		int j = i;
		while (j < n - 1  and arr[j] <= arr[j + 1] )j++;

		int cash = initial;
		int total = cash / arr[i];
		cash -= total * arr[i];

		cash += arr[j] * total;
		initial = max(initial, cash);
		ans = max(cash, ans);

		i = j + 1;
	}

	cout << ans << endl;

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





















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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll k; cin>>k;
  vll a(50,50);
  ll mod=k%50;
  rep(i,50-mod){
    a[i]=49-mod;
  }
  ll d=k/50;
  rep(i,50) a[i]+=d;
  
  cout<<50<<endl;
  rep(i,50){
    if(i) cout<<' ';
    cout<<a[i];
  }
  cout<<endl;
  
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
n,m=map(int,input().split())
adjacent_list=[[] for i in range(n+1)]
for i in range(m):
  x,y=map(int,input().split())
  adjacent_list[x].append(y)

#print(adjacent_list)

dp=[-1]*(n+1)

def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  res=0
  for j in adjacent_list[i]:
    res=max(res,dfs(j)+1)
  dp[i]=res
  return dp[i]
ans=0
for i in range(1,n+1):
  ans=max(ans,dfs(i))
  
print(ans)

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

using namespace std;

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

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

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

double dot(Pint p1,Pint p2){
	return p1.first*p2.first + p1.second*p2.second;
}
double vector_length(Pint p){
	return pow(p.first*p.first+p.second*p.second,0.5);
}

double cos_(Pint p1,Pint p2){
	return dot(p1,p2)/(vector_length(p1)*vector_length(p2));
}

void proj(Pint p1,Pint p2,Pint a,Pint b){
	Pint pp = Pint(p2.first-p1.first,p2.second-p1.second);
	double ans_x = (double)p1.first + vector_length(a)*cos_(a,b)*pp.first/vector_length(pp);
	double ans_y = (double)p1.second + vector_length(a)*cos_(a,b)*pp.second/vector_length(pp);
	printf("%.12f %.12f\n", ans_x,ans_y);
}

bool vector_equal(Pint p,Pint q){
	return (p.first == q.first) && (p.second == q.second);
}

int main()
{
	Pint p1,p2;
	cin >> p1.first >> p1.second >> p2.first >> p2.second;
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int x,y;
		cin >> x >> y;

		Pint pp = Pint(x,y);
		if(vector_equal(pp,p1)||vector_equal(pp,p2)){
			cout << x << " " << y << endl;
			continue;
		}

		Pint a = Pint(x-p1.first,y-p1.second);
		Pint b = Pint(p2.first-p1.first,p2.second-p1.second);


		// cout << "a = " << a.first << " " << a.second << "  " << vector_length(a) << endl;
		// cout << "b = " << b.first << " " << b.second << endl;
		// cout << "cos = " << cos_(a,b) << endl;

		proj(p1,p2,a,b);
	}

	return 0;
}


Measured memory_bytes: 3356
def test():

	faces = list(map(int,input().split()))
	command_stream = list(input())

	for command in command_stream:

		tmp_face = []
		for face in faces:
			tmp_face.append(face)

		#S:1->2,2->6,6->5,5->1
		if command == 'S':
			faces[0] = tmp_face[4]
			faces[4] = tmp_face[5]
			faces[5] = tmp_face[1]
			faces[1] = tmp_face[0]
		#N:1->5,5->6,6->2,2->1
		elif command == 'N':
			faces[0] = tmp_face[1]
			faces[1] = tmp_face[5]
			faces[5] = tmp_face[4]
			faces[4] = tmp_face[0]
		#W:1->4,4->6,6->3,3->1
		elif command == 'W':
			faces[0] = tmp_face[2]
			faces[2] = tmp_face[5]
			faces[5] = tmp_face[3]
			faces[3] = tmp_face[0]
		#E:1->3,3->6,6->4,4->1
		elif command == 'E':
			faces[0] = tmp_face[3]
			faces[3] = tmp_face[5]
			faces[5] = tmp_face[2]
			faces[2] = tmp_face[0]

	print(faces[0])

if __name__ == "__main__":
	test()



Measured memory_bytes: 5608