akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, K;
	cin >> N >> K;
	int A[100];
	rep(i, N) cin >> A[i];
	int saishou = *min_element(A, A + N);

	int dp[100001] = {};
	
	rep(i, K) {
		if (dp[i] != 1) {
			rep(j, N) {
				if(i + A[j] <= 100000) dp[i + A[j]] = 1;
			}
		}
	}
	if (dp[K]) co("First");
	else co("Second");

	Would you please return 0;
}

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

long long calc(int i, int c, const vector<int>& v, const vector<int>& w, vector<vector<long long> >& ans){
  if(i <= -1 || c < 0){
    return 0;
  }else if(c == 0){
    ans[i][c] = 0;
  }else if(ans[i][c] >= 0){
    return ans[i][c];
  }else if(c - w[i] < 0){
    ans[i][c] = calc(i-1, c, v, w, ans);
  }else{
    // int p = 1;
    // long long q = -1;
    // while(c - p*w[i] >= 0){
    //   q = max(
    //     q,
    //     p*v[i] + calc(i-1, c - p*w[i], v, w, ans)
    //   );
    //   p++;
    // }
    ans[i][c] = max(
      v[i] + calc(i, c - w[i], v, w, ans),
      calc(i-1, c, v, w, ans)
    );

    // ans[i][c] = max(
    //   v[i] + calc(i-1, c - w[i], v, w, ans),
    //   calc(i-1, c, v, w, ans)
    // );
  }
  return ans[i][c];
}

int main(){
  int n,c;
  cin >> n >> c;
  vector<int> v(n),w(n);
  for(int i = 0; i < n; i++)
    cin >> v[i] >> w[i];
  vector<vector<long long> > ans(n, vector<long long>(c+1, -1));
  cout << calc(n-1, c, v, w, ans) << endl;
  return 0;
}

Measured memory_bytes: 11600
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

using namespace std;
int a, b, c;
int main(void){
	cin >> a >> b >> c;
	int d = c-b;
	if(d>0 && a>=d) cout << "safe";
	if(d <= 0) cout << "delicious";
	if(a<d) cout << "dangerous";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> v(n);
	for (auto &x : v)
		scanf("%d", &x);
	int res = 2e9;
	for (int i = 0; i + k <= n; ++i) {
		int l = v[i];
		int r = v[i + k - 1];
		if (r <= 0)
			res = min(res, 0 - l);
		else if (l >= 0)
			res = min(res, r);
		else {
			res = min(res, abs(l) * 2 + r);
			res = min(res, abs(l) + 2 * r);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;
vector<int> adj[NN];


integer main() {
    ios_base::sync_with_stdio(false);

    int t = 1;
//    cin >> t;
    while (t--) {
        cin >> n >> m;
        int sum = 0;
        for (int i = 0; i < m; i++){
            int a;
            cin >> a;
            sum += a;
        }
        if (sum > n) cout << -1 << endl;
        else cout << n - sum << endl;

    }

}



Measured memory_bytes: 8344
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define REPR(i,n) for (int i = n-1; i >= 0; --i)

const int MAX = 1e5+10;

int N;
ll A[MAX];

int main() {
    cin >> N;
    bool has0 = false;
    int minus = 0;
    ll minAbs = 2e9;
    REP (i, N) {
        cin >> A[i];
        has0 |= (A[i] == 0);
        if (A[i] < 0) minus++;
        minAbs = min(minAbs, abs(A[i]));
    }

    ll ans = 0;
    REP (i, N) ans += abs(A[i]);
    if (!has0 && (minus&1 == 1)) {
        ans -= minAbs*2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

void shell_sort(int R[],int n);
void insertion_sort(int R[],int n,int g);

int cnt;
int l;
int R[1000000];
int n;
std::vector<int> G;

void shell_sort(int R[],int n){
    for(int h = 1;;){
        if(h > n) break;
        G.push_back(h);
        h = 3 * h + 1;
    }

    for(int i = G.size() - 1;i >= 0;i--) insertion_sort(R,n,G[i]);
}

void insertion_sort(int R[],int n,int g){
    for(int i = g;i < n;i++){
        int v = R[i];
        int j = i - g;
        while((j >= 0) && (R[j] > v)){
            R[j + g] = R[j];
            j = j - g;
            cnt++;
        }
        R[j + g] = v;
    }
}

int main(int argc, char const *argv[])
{
    std::cin >> n;

    for(int i = 0;i < n;i++) scanf("%d",&R[i]);
    cnt = 0;

    shell_sort(R,n);

    std::cout << G.size() << std::endl;
    for(int i = G.size() - 1;i >= 0;i--){
        printf("%d",G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    for(int i = 0;i < n;i++) printf("%d\n",R[i]);

    return 0;
}



Measured memory_bytes: 7208
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int m,n;
  map<int,int> date;
  map<int,int> juni;
  set<int> num;
  while(scanf("%d,%d",&m,&n)){
    if(m==0&&n==0) break;
    date[m]=n;
    num.insert(n);
  }
  int c=1;
  for(int i=30;i>=0;i--){
    if(num.find(i)!=num.end()){
      juni[i] = c++;
    }
  }
  int a;
  while(cin>>a){
    cout<<juni[date[a]]<<endl;
  }
  return 0;
}

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

#define forn(i,n) for(int i = 1; i < n; i++)

int main() {

    int n;
    cin >> n;
    vector<double> a(n);
    for(auto &i : a) cin >> i;
	sort(a.begin(), a.end());

    forn(i,n) {
		a[i] = ( a[i-1] + a[i] ) / 2.0;
    }
	cout << setprecision(9) << fixed << a[n-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
const double PI=3.14159265358979323846;
const long long INF = 1LL << 60;

int main() {
	string T;
	cin >> T;
	int a=0, b=0, c=0, x, y, z;
	rep(i, T.size()) {
		if (T.at(i) == '?') {
			T.at(i) = 'D';
		}
	}
	std::cout << T << '\n';
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2])cout << "No" << endl;
  else{
    cout << "Yes" << endl;
  }
  system("pause");
}


Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		WriteLine(GetLongs(N).Aggregate((a, e) => a = gcd(a, e)));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 37692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    int sum = 0;
    rep(i, n-1) {
        sum += l[i];
    }
    if(l[n-1] < sum) print("Yes");
    else print("No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
signed main(){
    map<int,int>mp;
    int n,cnt=0,ans=0;
    cin>>n;
    mp[0]++;
    rep(i,n){
        int in;
        cin>>in;
        cnt+=in;
        mp[cnt]++;
    }
    for(auto it:mp){
        ans+=it.second*(it.second-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12800
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int (t); cin>>(t);while((t)--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

int main (void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	lli a,b,c,k;
	
	cin>>a>>b>>c>>k;
	
	if (k<=a)
		cout<<k<<endl;
		
	else if (k<=a+b)
		cout<<a<<endl;
		
	else
		cout<<a-(k-a-b)<<endl;

	return 0;
}


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

int main() {
  
  int N, K, x = 0, A = 0;
  cin >> N >> K;

  for(int i = 0; i < N; i++) {
    cin >> x;

    if(x <= K / 2) {
      A += x*2;
    }
    
    else {
      A += (K - x) * 2;
    }
    
  }

  cout << A << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
//main
int main(){
    long long int X;
    cin>>X;
    long long int sum=100;
    long long int risi=1;
    long long int ans=0;
    for(int i=1;i<3761;i++){
        if((long long int)(sum/100)>risi)risi=(sum/100);
        if((long long int)(sum/100)<=risi)risi=risi;
        sum+=risi;
        if(X<=sum){ans=i;break;}
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(){
  int n,k,i,j,buff,swi;
  int s[100];
  
  while(1){
    swi=0;
    scanf("%d%d",&n,&k);
    if(n==0&&k==0)
      return 0;
    for(i=0;i<k;i++)
      scanf("%d",&s[i]);
    //input the s[i]
    for(i=0;i<n;i++)
      for(j=0;j<k;j++){
	scanf("%d",&buff);
	s[j]-=buff;
      }
    //input the b
    for(i=0;i<k;i++)
      if(s[i]<0){
	printf("No\n");
	swi=3333;
	break;	
      }
    if(swi==0)
      printf("Yes\n");
  }
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mini(ll a,ll b)
{
	if(a<=b) return a;
	else return b;
}
int main()
{
	int n;  // no of objects
	cin>>n;
	int W;   // max capacity
	cin>>W;
	vector<int> w(n);
	vector<int> v(n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
		sum+=v[i];
	}
	
	ll dp[sum+1][n];
	for(int i=0;i<=sum;i++)
	{
		if(v[n-1]==i)
		dp[i][n-1]=w[n-1];
		else
		dp[i][n-1]=1000000000;
	
	}
	
	
	for(int i=0;i<n;i++)
	{
		dp[0][i]=0;
	}
	for(int i=1;i<=sum;i++)
	{
		for(int j=n-2;j>=0;j--)
		{
			dp[i][j]=0;
			if(v[j]>i)
			dp[i][j]=dp[i][j+1];
			else
			{
				dp[i][j]=mini(dp[i][j+1] ,  w[j] + dp[i-v[j]][j+1]);
			}
		}
	}
	int res;
	for(int i=sum;i>=0;i--)
	{
		if(dp[i][0]<=W) 
		{
		  res=i;
		  break;
	    }
	}
	cout<<res<<endl;
}


Measured memory_bytes: 78336
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin>>N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	sort(A.begin(),A.end());
	cout << A[N-1]-A[0] << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pld pair <ld, ld>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
#define cld complex <double>

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6 + 100;
const ll mod = 1e9 + 7;

ll n, m, k, t;

ll st2[maxn];

// vector <ll> ANS;

ll xr;

vector <ll> dfs(ll i, ll to) {
    if (i == 0) {
        return {0, 1};
    }
    if ((to & st2[i]) == 0) {
        // cout << "CASE 1 " << endl; 
        vector <ll> ANSL = dfs(i - 1, to);
        ll to1 = ANSL[1];
        vector <ll> ANSR = dfs(i - 1, to1);
        for (ll q = 0; q < ANSR.size(); q++) {
            ANSR[q] += st2[i];
        }
        vector <ll> ANS;
        ANS.pb(ANSL[0]);
        for (ll q = 0; q < ANSR.size(); q++) {
            ANS.pb(ANSR[q]);
        }
        for (ll q = 1; q < ANSR.size(); q++) {
            ANS.pb(ANSL[q]);
        }
        // cout << "OUT" << endl;
        // for (auto x : ANS) {
        //     cout << x << " ";
        // }
        // cout << endl;
        return ANS;
    }
    else {
        // cout << "CASE 2 " << endl;
        vector <ll> ANSL = dfs(i - 1, 1);
        vector <ll> ANSR = dfs(i - 1, to ^ 1);
        for (ll q = 0; q < ANSR.size(); q++) {
            ANSR[q] += st2[i];
            ANSR[q] ^= 1;
        }
        vector <ll> ANS;
        for (ll q= 0 ; q < ANSL.size(); q++) {
            ANS.pb(ANSL[q]);
        }
        for (ll q = 0; q < ANSR.size(); q++) {
            ANS.pb(ANSR[q]);
        }
        // cout << "OUT" << endl;
        // for (auto x : ANS) {
        //     cout << x << " ";
        // }
        // cout << endl;
        return ANS;
    }
}

int main() {
    pyshnapyshnakaa
    ll q, w, e, a, b, c;
    cin >> n >> m >> k;
    st2[0] = 1;
    for (q = 1; q < 63; q++) {
          st2[q] = st2[q - 1] * 2;
    }
    if (__builtin_popcount(m) % 2 == __builtin_popcount(k) % 2) {
        cout << "NO";
        return 0;
    }
    xr = m ^ k;
    // ANS.pb(m);
    vector <ll> ANS = dfs(n - 1, xr);
    cout << "YES" << endl;
    for (auto x : ANS) {
        cout << (x ^ m) << " ";
    }
    return 0;
}


Measured memory_bytes: 5332
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n, m;
    cin >> n;
    string s[150];
    string t[150];
    for(int i = 1; i <= n; i++){
        cin >> s[i];
    }
    cin >> m;
    map<string, int> mp;
    for(int i = 1; i <= m; i++){
        cin >> t[i];
        mp[t[i]]--;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        mp[s[i]]++;
        ans = max(ans, mp[s[i]]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()

def sum_li(n):
  return ((n+1) * n )//2

m=[]
now=1
tmp=s[0]
for i in range(1,len(s)):
  if s[i]==tmp:
    now += 1
  elif tmp == "<" and s[i] == ">":
    m.append("#")
  if tmp != s[i]:
    m.append(now)
    now = 1
    tmp = s[i]
m.append(now)

ans=0
for j in range(len(m)):
  if m[j] == "#":
    ans -= min(m[j+1],m[j+2])
  else:
  	ans += sum_li(m[j])
print(ans)


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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str = br.readLine();
		int num = Integer.parseInt(br.readLine());

		for(int i = 0; i < num; i++){

			String[] token = br.readLine().split(" ");
			String ope = token[0];
			int start = Integer.parseInt(token[1]);
			int end = Integer.parseInt(token[2]);

			if(ope.equals("print")){
				sb.append(str.substring(start, end + 1) + "\n");
			}else if(ope.equals("reverse")){

				char[] array = str.toCharArray();

				while(start < end){
					char temp = array[start];
					array[start] = array[end];
					array[end] = temp;
					str = String.valueOf(array);
					start++;
					end--;
				}

			}else if(ope.equals("replace")){

				char[] array = str.toCharArray();
				String word = token[3];

				for(int j = 0; j < word.length(); j++){
					array[start + j] = word.charAt(j);
				}

				str = String.valueOf(array);

			}

		}

		System.out.print(sb);

	}
}

Measured memory_bytes: 34252
#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;

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

int n,m;

signed main()
{
	n=read();
	for ( int i=1;i<=n;i++ )
	{
		if(i%3==0||i%5==0) continue;
		m+=i;
	}
	printf("%lld\n",m);
	return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

using namespace std;
typedef pair<int, int> P;

int main(){
    char c;
    cin >> c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') out("vowel");
    else out("consonant");
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

	if(n >= 30){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3540
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int a;
	cin >> a;
	if (a % 2 ==0)
	{
		cout << pow(a / 2, 2) << endl;
	}
	else {
		cout << (a - a / 2) * (a/2) << endl;
	}
}

Measured memory_bytes: 764
#include <stdio.h>

int main(void){
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    for(int i=0; i<(a>b ? a: b); ++i){
        printf("%d", a>b ? b: a);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std; 
typedef long long LL; 
const int mod=1e9+7; 
int n; 
vector<int> v[100005];
LL memo[100005][2];

LL dp(int idx,int colour,int prev){ 
  if(v[idx].size()==1 && v[idx][0] == prev) return 1; 
  if(memo[idx][colour]!=-1) return memo[idx][colour]; 	 
  LL ret=1; 	
  for(int i=0;i<v[idx].size();i++){ 		
    if(v[idx][i]==prev) continue; 		
    if(colour==1){
      ret*=(dp(v[idx][i],0,idx)%mod);
      ret%=mod;
    }
    else{
      ret*=( ((dp(v[idx][i],1,idx)%mod) + (dp(v[idx][i],0,idx)%mod))%mod);
   ret%=mod;
    }
  
  } 	 	
  ret%=mod; 	
  return memo[idx][colour]=ret%mod;
} 

int main(){ 	
  memset(memo,-1,sizeof(memo)); 	
  scanf("%d",&n); 	
  for(int i=0;i<n-1;i++){ 		
    int x,y; 		
    scanf("%d%d",&x,&y); 	
    v[x].push_back(y); 	
    v[y].push_back(x); 
  } 	 	
  LL ans=dp(1,0,1); 
  ans%=mod; 
  ans+=dp(1,1,1); 
  ans%=mod; 	
  printf("%lld\n",ans%mod);
}


Measured memory_bytes: 17024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

int main(){
  // startupcpp();
  ll i,j,N,Q,K,ans,cnt[2]={},p=0;
  cin>>N;
  string s;
  cin>>s;
  cin>>Q;
  while(Q--){
    cin>>K;
    j=ans=0;
    rep(i,N){
      if(s[i]=='D'){
        if(j<=i){
          cnt[0]=cnt[1]=p=0;
          j=i+1;
        }
        while(j<min(i+K,N)){
          if(s[j]=='M'){
            ++cnt[0];
          }else if(s[j]=='C'){
            ++cnt[1];
            p+=cnt[0];
          }
          ++j;
        }
        ans+=p;
      }else if(s[i]=='M'){
        --cnt[0];
        p-=cnt[1];
      }else if(s[i]=='C'){
        --cnt[1];
      }
    }
    print(ans);
  }
}

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

int main() {
  int n;
  cin >> n;
  int fr = n /100;
  int af = n % 100;
  int flag1 =0;
  int flag2 =0;
  if( fr >= 1 && fr <= 12){
    flag1 = 1;
  }
  if( af >= 1 && af <= 12){
    flag2 = 1;
  }
  if( flag1 == 1 ){
    if(flag2 == 1){
      cout << "AMBIGUOUS" ;
    }
    else{
      cout << "MMYY";
    }
  }
  else{
    if(flag2 == 1){
      cout << "YYMM" ;
    }
    else{
      cout << "NA";
    }    
  }
}

Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int a=999;
bool sm(int i){
    int x=i%10;
    int y=i/10;
    if(x%10==y%10)return true;
    return false;
    }
bool la(int i){
    int x=i%10;
    int y=i/100;
    int z=i/10%10;
    if(x%10==y%10 && y%10==z%10)return true;
    return false;
}
int main()
{
    
    int n;
    cin>>n;
    for(int i=n;i<=a;i++)
    {
        if(i<100 && sm(i)){
            cout<<i;
            a=0;
        }
        if(i>=100 && la(i))
        {
            cout<<i;
            a=0;
        }
        
    }
        
system("pause");
return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        //入力(基本)
        String line = br.readLine();




		//　　文字列が見つからなかった場合、戻り値は-1
		String str = "にわにはにわにわとりがいる";
		int i = line.indexOf("C"); // 結果：0
		int j = line.indexOf("F", i); // 結果：4
			//System.out.println("i=[" + i + "], j=[" + j + "]" + line.indexOf("F") );
		boolean b = false;
		
		b = (b || (i<0));
		b = (b || (j<0));
		b = (b || (i>j));

		if (b) { 
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		
    }
}




Measured memory_bytes: 8148
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	//sv();
	ll a,b;
	cin>>a>>b;
	ll ans=max(a,b);
	ans*=2;
	if(a!=b)
	ans--;
	cout<<ans;
	
    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
A = []
for i in range(a):
    array = list(map(int, input().split()))
    A.append(array)
B = []
for j, k in enumerate(A):
    if j == 0:
        B = k[1:]
    else:
        B = list(set(k[1:]) & set(B))
print(len(B))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int H, W;
int move_x[4] = {-1, 0, 0, 1};
int move_y[4] = {0, -1, 1, 0};
vector< vector<char> > Field;

void DFS(int y, int x, int c)
{
	Field[y][x] = '.';
	for(int i = 0; i < 4; ++i)
	{
		int nx = x + move_x[i];
		int ny = y + move_y[i];
		if(0 <= nx && nx < W && 0 <= ny && ny < H && Field[ny][nx] == c)
		{
			DFS(ny, nx, c);
		}
	}
}

void solve()
{
	while(cin >> H >> W, H || W)
	{
		int count = 0;
		Field.resize(H);
		for(int i = 0; i < H; ++i)
		{
			Field[i].resize(W);
			for(int j = 0; j < W; ++j)
			{
				cin >> Field[i][j];
			}
		}
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				if(Field[i][j] != '.')
				{
					++count;
					char c = Field[i][j];
					DFS(i, j, c);
				}
			}
		}
		cout << count << endl;
	}
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,m;cin>>n>>m;
    if(n*500>=m)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define int ll
const ll MAX_N = 1 << 13;
int n;
vl dat(2 * MAX_N - 1);
vi a(MAX_N);

void init(int k, int l, int r) {
	if (r - l == 1) {
		dat[k] = a[l];
	}
	else {
		int lch = 2 * k + 1, rch = 2 * k + 2;
		init(lch, l, (l + r) / 2);
		init(rch, (l + r) / 2, r);
		dat[k] = min(dat[lch], dat[rch]);
	}
}

//k番目の値をaに変更
void update(int k, int a, int v, int l, int r) {
	if (r - l == 1) {
		dat[v] = a;
	}
	else {
		if (k < (l + r) / 2)
			update(k, a, 2 * v + 1, l, (l + r) / 2);
		else {
			update(k, a, 2 * v + 2, (l + r) / 2, r);
		}
		dat[v] = min(dat[v * 2 + 1], dat[v * 2 + 2]);
	}
}

//[a,b)の最小値を求める
//後ろのほうの引数は計算の簡単のための引数
//kは接点の番号,l,rはその接点が[l,r)に対応していることを表す
//従って、外からはquery(a,b,0,0,n)としてよぶ
int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) {
		return inf;
	}
	if (a <= l && r <= b) {
		return dat[k];
	}
	else {
		ll ul = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll ur = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(ul, ur);
	}
}

signed main() {
	int _n, x, i, j;
	scanf("%lld%lld", &_n, &x);
	a.resize(2*_n);
	vi b(_n);
	for (i = 0; i < _n; i++) {
		scanf("%lld", &b[i]);
	}
	n = 2 * _n;
	init(0, 0, n);
	for (i = 0; i < _n; i++) {
		update(i, b[i], 0, 0, n);
		update(i + _n, b[i], 0, 0, n);
	}
	ll ans = INF;
	for (i = 0; i < _n; i++) {
		ll res = 0;
		res += i*x;
		for (j = 0; j < _n; j++) {
			res += query(j, j + i + 1, 0, 0, n);
		}
		ans = min(ans, res);
	}
	for (i = 0; i < _n; i++) {
		ll res = 0;
		res += i*x;
		for (j = _n; j < 2*_n; j++) {
			res += query(j - i, j + 1, 0, 0, n);
		}
		ans = min(ans, res);
	}
	printf("%lld\n", ans);
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int c[2] = {0};
    for (int i = 0; i < 3; i++) {
        int x;
        cin >> x;
        if (x == 5) {
            c[0]++;
        } else if (x == 7) {
            c[1]++;
        }

    }

    if (c[0] == 2 && c[1] == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = sc.nextInt();
    }

    System.out.println(solve(arr, N, K));
  }

  private static String solve(int[] arr, int n, int k) {
    String ans = "";
    boolean[] dp = new boolean[k + 1];
    for (int i = 0; i <=k; i++) {
      for (int j = 0; j < n; j++) {
        if (i >= arr[j] && !dp[i - arr[j]]) {
          dp[i] = true;
        }
      }
    }
    ans = dp[k] ? "First" : "Second";
    return ans;
  }
}


Measured memory_bytes: 23636
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, x, a[108];

int main(){
	cin >> n >> x;
	for(ll i = 1; i <= n; i++){cin >> a[i];}
	
	sort(a+1, a+n+1);
	
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		if((i < n && a[i] <= x) || (i == n && a[n] == x)){
			x -= a[i];
			ans++;
		}
		else{break;}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if(a<=x&&x<=(a+b))cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define PLL pair<ll,ll>
#define F first
#define S second
#define MP make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100001

int main()
{
    ll i,n,k,j;
    cin >> n>>k;
    
    ll a[n+1];
    
    for(i=1;i<=n;i++)
    cin >> a[i];
    
    ll vis[n+1]={0};
    
    vector<ll> v;
    i=1;
    
    while(!vis[i])
    {
        v.pb(i);
        vis[i]=1;
        i=a[i];
    }
    
    
    ll index;
    
    for( j=0;j<v.size();j++)
    {
        if(v[j]==i)
        {
            index=j;
            break;
        }
    }
    
    ll rep=v.size()-index;
   //cout << index<<" "<<rep <<'\n';
    if(k<=(index))
    cout << v[k];
    else
    {
        k-=(index+1);
        //cout << index+(k%rep)<<'\n';
        
        cout << v[index+((k%rep)+1)%rep];
    }
    
}

Measured memory_bytes: 8484
gets
a = gets.split(' ').map(&:to_i)
gets
b = gets.split(' ').map(&:to_i)
def bi(a, b)
  cnt = 0
  b.each do |key|
    left = 0
    right = a.length
    while left < right
      mid = (left + right) / 2
      if a[mid] == key
        cnt += 1
        break
      elsif a[mid] < key
        left = mid + 1
      else
        right = mid
      end
    end
  end
  cnt
end

puts bi(a, b)

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


int main() {
    int A,B;
    cin >> A;
    cin >> B;
    if(A>=13){
        cout << B<<endl;;
    }else if(A>=6){
        cout << (int)(B / 2)<<endl;;
    }else{
        cout << 0<<endl;;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;

ll H,W;
ll ans = 100100100100100100;
int main(){
  cin >> H >> W;
  ll a,b,c;
  if(H%3 ==0 || W % 3 == 0){
    cout << "0" << endl;
    return 0;
  }
  else{
    ans = min(H,W);
  }
  for(int i=0;i<H;i++){
    a = i*W;
    b = (W/2)*(H-i);
    c = (W-W/2)*(H-i);
    ans = min(ans,max(a,max(b,c)) - min(a,min(b,c)));
  }
  ll tmp = H;
  H =W;
  W = tmp;
  for(int i=0;i<H;i++){
    a = i*W;
    b = (W/2)*(H-i);
    c = (W-W/2)*(H-i);
    ans = min(ans,max(a,max(b,c)) - min(a,min(b,c)));
  }
  cout <<ans << endl;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	ll h[alength];
	cin>>n;
	fori(n){cin>>h[i];}

	int a=0;int l=-2;
	fori(n){
		if(a<h[i]){
			a=h[i];
			l=i;
		}
		if(a>h[i]){
			if(l-i<3&&a-1==h[i]){
				continue;
			}
			cout<<"No\n";return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <stack>
#include <map>
#include <math.h>
using namespace std;

int main() {

	string a;
	cin >> a;
	int b = 0;
	for(int i=0; i<a.size(); i++){
		if(a[i] == '+'){
			b += 1;
		}else{
			b -= 1;
		}
	}
	cout << b;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

struct Info
{
    int x, y, h;
    Info(int x, int y, int h) {
        this->x = x;
        this->y = y;
        this->h = h;
    }
};



int main(){
    int n;
    std::cin >> n;
    std::vector<Info> vec1, vec2;
    for(int i = 0; i < n; i++){
        int x, y, h;
        std::cin >> x >> y >> h;
        if(h){
            vec1.push_back(Info(x, y, h));
        }else{
            vec2.push_back(Info(x, y, h));
        }
    }
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 101; j++){
            bool flag1 = true;
            int H = vec1[0].h + std::abs(i-vec1[0].x) + std::abs(j-vec1[0].y);
            for(auto item : vec1){
                flag1 &= (H == (item.h + std::abs(i-item.x) + std::abs(j-item.y)));
            }
            if(flag1){
                bool flag2 = true;
                for(auto item : vec2){
                    flag2 &= (H - std::abs(i-item.x) - std::abs(j-item.y) <= 0);
                }
                if(flag2){
                    std::cout << i << ' ' << j << ' ' << H << std::endl;
                }
            }
        }
    }

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Array.Sort(A);
		long n = A[N-1];
		int idx = -1;
		long min = (long) 1e18;
		for(int i=0;i<N;i++){
			long dist = Math.Abs((2 * A[i] - n));
			if(min > dist){
				idx = i;
				min = dist;
			}
		}
		Console.WriteLine("{0} {1}",n, A[idx]);
		
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 21088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int x;
  int flag=0;
  cin >> N;
  
  x = N % 10;
  N /= 10;
  
  if(x == N % 10){
    N /= 10;
    if(x == N % 10){
      flag = 1;
    }
  }else{
    x = N % 10;
    N /= 10;
    if( x == N % 10){
      N /= 10;
      if( x == N % 10){
        flag = 1;
      }
    }
  }
  
  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,m;
vector<ll> g[100010];
bool vis[100010];

bool dfs(ll v,ll pre,ll s){
  vis[v]=true;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    if(nv==s)return true;
    if(vis[nv])continue;
    if(g[nv].size()==4)continue;
    if(dfs(nv,v,s))return true;
  }
  return false;
}

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

  cin>>n>>m;
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bool ok=true;
  ll cnt0=0;
  ll cnt1=0;
  rep(i,n){
    if(g[i].size()%2!=0)ok=false;
    if(g[i].size()>=4)cnt0++;
    if(g[i].size()>=6)cnt1++;
  }
  if(!ok||(cnt0<=1&&cnt1==0)){
    cout<<"No"<<endl;
    return 0;
  }else if(cnt0>2||cnt1>=1){
    cout<<"Yes"<<endl;
    return 0;
  }

  rep(i,n){
    if(g[i].size()==4){
      rep(j,n)vis[j]=false;
      if(dfs(i,i,i)){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 7040
# include "cstdio"

using namespace std;

const int maxm=200000+10; 

int 
	num[maxm], 
	n;
long long 
	sum,
	ans;

inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') w=-w;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}

int main(){
	n=read(); 
	register int i,j;
	for(i=j=1;i<=n;i++){
		num[i]=read();   
        while((sum^num[i])!=sum+num[i])sum^=num[j],j++;  
        sum^=num[i];  
        ans+=(i-j+1);  
    }  
	printf("%lld",ans);
	return 0; 
} 

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

int main(){
  int d,m,n,L=141,ans;
  cin>>d;
  while(d--){
    cin>>m>>n;
    ans=0;
    for(int i=-L;i<L;i++)
      for(int j=-L;j<L;j++){
	if(!i&&!j)continue;
	int a=i*i+j*j;
	if(!((i*m+j*n)%a)&&!((i*n-j*m)%a))ans++;
      }
    if(ans==8)cout<<"P"<<endl;
    else cout<<"C"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

bool check( VI ls, int r )
{
	REP( i, 0, 3 )
	{
		REP( j, i + 1, 3 )
		{
			if ( sqrt( pow( ls[i], 2 ) + pow( ls[j], 2 ) ) < 2 * r )
			{
				return true;
			}
		}
	}

	return false;
}

int main()
{
	while ( true )
	{
		VI ls( 3 );
		
		bool notlast = false;

		REP( i, 0, 3 )
		{
			cin >> ls[i];
			notlast |= ls[i] != 0;
		}

		if ( !notlast )
		{
			break;
		}

		int n;
		cin >> n;

		REP( i, 0, n )
		{
			int r;
			cin >> r;

			if ( check( ls, r ) )
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NA" << endl;
			}
		}
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(ll i = a ; i < b ; i++) // for i in range(a,b)
#define REP(i,n) for(ll i = 0 ; i < n ; i++) // for i in range(b)
#define FORD(i,a,b) for(ll i = a ; i > b ; i--) // for i in range(a,b,-1)
#define ALL(x) x.begin(),x.end()

#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGL(xl) dbgl_f(#xl,xl)
#define DEBUGLL(xll) dbgll_f(#xll,xll)
template<class T> void dbgl_f(string name, vector<T> xl){cerr<<name<<": "; for(T x: xl) cerr<<x<<" "; cerr << '\n';}
template<class T> void dbgll_f(string name, vector<vector<T>> xll){
    cerr<< name << ": " << '\n'; 
    for(vector<T> xl: xll){
        for(T x : xl) cerr << x << " ";
        cerr << '\n';
    }
}

const int IINF = 1'001'001'001;
const ll INF = 1'001'001'001'001'001'001ll;
const int MOD = 1'000'000'007;


void solve(){
    int n; cin >> n;
    REP(i,n){
        int a; cin >> a;
        if( a%2 == 0 && (a%3 != 0 && a%5 != 0)){
            cout << "DENIED" << endl;
            return;
        }
    }
    cout << "APPROVED" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Measured memory_bytes: 3664