akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int n, k, a, b, ans = 0;
	cin >> n >> k;
	vector<int>vec(n);
	rep(i, k) {
		cin >> a;
		rep(j, a) {
			cin >> b;
			vec[b - 1] = 1;
		}
	}
	rep(i, n) {
		if (vec[i] == 0) {
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[4];
	scanf("%s",a);
	bool flag=1;
	for(int i=0;i<3;i++)
	{
		if(a[i]==a[i+1])
		{
			flag=0;
			break;
		}
	}
	if(flag)
		printf("Good\n");
	else
		printf("Bad\n");
}

Measured memory_bytes: 1624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);

        final int w = scanner.nextInt();
        final int h = scanner.nextInt();
        final int x = scanner.nextInt();
        final int y = scanner.nextInt();

        final double max = w / 2.0 * h;
        final int multi = x == w / 2.0 && y == h / 2.0 ? 1 : 0;

        System.out.println(max + " " + multi);
    }
}

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

#define f first
#define s second

#define pb push_back
#define mp make_pair

#define ll long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())

using namespace std;

const int MAXN = (int) 2e5 + 10;
const int INF = (int) 2e9 + 7;

int n, m;

int main() {
    #ifdef sony
        freopen("input.txt", "r", stdin);
    #endif // sony
    cin >> n >> m;
    multiset<int> s;
    while (n--) {
        int x;
        cin >> x;
        s.insert(x);
    }
    while (m--) {
        auto it = --s.end();
        int nval = (*it) / 2;
        s.erase(it);
        s.insert(nval);
    }
    ll sum = 0;
    for (auto it : s) sum += it;
    cout << sum;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1000000007
using namespace std;

int Adj[101][101];
int d[101],f[101];

int main(){
  int n,u,k,v,t=1;
  cin >> n;
  FOR(i,0,n){
    cin >> u >> k;
    FOR(j,0,k){
      cin >> v;
      Adj[u][v] = 1;
    }
  }
  stack<int> s;
  while(1){
    bool flag2 = 1;
    FOR(i,1,n+1){
      if(d[i] == 0){
        s.push(i);
        flag2 = 0;
        break;
      }
    }
    if(flag2)break;
    while(s.size()){
      if(!d[s.top()])d[s.top()] = t;
      bool flag = 0;
      FOR(i,1,n+1)if(Adj[s.top()][i] && !d[i]){
        s.push(i);
        FOR(j,1,n+1)Adj[j][i] = 0;
        flag = 1;
        break;
      }
      t++;
      if(!flag){
        f[s.top()] = t;
        s.pop();
      }
    }
    t++;
  }
  FOR(i,1,n+1)cout << i << " " << d[i] << " " << f[i] << endl;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
vector<vector<int>> G;
ll dp[100010][2];
ll dfs(int i,int p,int c){
    ll res=1;
    if(dp[i][c]!=-1)return dp[i][c];
    if(G[i].size()==0){
        return dp[i][c]=1;
    }
    if(G[i].size()==1&&G[i][0]==p){
        return dp[i][c]=1;
    }
    for(auto e:G[i]){
        if(e==p)continue;
        ll s=dfs(e,i,c^1);
        if(c==0){
            s+=dfs(e,i,c);
        }
        s%=MOD;
        res*=s;
        res%=MOD;
    }
    return dp[i][c]=res;
}
int main(){
    int n;cin>>n;
    memset(dp,-1,sizeof(dp));
    G.resize(n);
    for(int i=0;i<n-1;i++){
        int u,v;cin>>u>>v;--u;--v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    cout<<(dfs(0,-1,0)+dfs(0,-1,1))%MOD<<endl;
}   


Measured memory_bytes: 15616
#include<iostream>
using namespace std;
main(){
char g[42]={97,102,107,112,117,122,98,103,108,113,118,46,99,104,109,114,119,63,100,105,110,115,120,33,101,106,111,116,121,32};
string s,a;
while(cin>>s,!cin.eof()){
a="";
for(int i=0;i<s.size();i+=2){
int l=s[i]-'0',r=s[i+1]-'0';
if(s.size()%2||l<1||r<1||l>6||r>5){a="NA";break;}
a+=g[r*6+l-7];
}
cout<<a<<endl;
}	
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e9;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    ll x, i, a5, r;
    cin >> x;
    for (i = -4000; i <= 4000; i++)
    {
        a5 = x + i * i * i * i * i;
        r = floor(eps + pow(abs(a5), 0.2));
        if (r * r * r * r * r == abs(a5))
        {
            if (a5 < 0) cout << -r << ' ' << i << '\n';
            else cout << r << ' ' << i << '\n';
            exit(0);
        }
    }
    return 0;
}

Measured memory_bytes: 4128
f = lambda : map(int, input().split())

n, m = f()
ll = [[0]*n for i in range(m)]
for i in range(m):
  _, *t = f()
  for j in t:
    ll[i][j-1] = 1
lp = list(f())

import itertools as it
ans = 0

for p in it.product([0,1], repeat=n):
  if lp == [sum(a*b for a, b in zip(p,l))%2 for l in ll]:
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;
int main()
 {
	long long int n,i,j,k=0,l,m;
	cin>>n;
	vector<pair <long long, long long> > c;  
	long long int a[n];
	for(i=0;i<n;i++)
	   cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	for(i=0;i<n;i++)
	    {
	        l=0;
	        for(j=i;j<n;j++)
	           {
	               if(a[i]==a[j])
	                 l++;
	               else
	                 break;
	           } 
	        i+=l-1;     
	        if(l>=2&&k==0)
	          {
	              if(l>=4)
	                {
	                    cout<<a[i]*a[i];
	                    return 0;
	                }
	              m=a[i];
	              k++;
	          }
	        else  
	        if(l>=2&&k==1)
	          {
	              cout<<m*a[i];
	              return 0;
	          }
	    }
	cout<<'0'<<endl;    
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define print printf("==================\n")
#define ll long long
#define pi acos(-1.0)
#define eps 1e-16
#define max3(a,b,c) max(a,max(b,c))
const ll INF = 1 << 30;
typedef pair<double, double  > payar;
typedef struct
{
    ll  x, y;
} point;
priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending
vector< pair<double,payar  > > vpp;
vector < payar >  vp;
vector<int>g[100005];
int ind[100005];
int vis[100005];
int dis[100005];

int dfs(int u)
{

    vis[u]=1;
    if(dis[u]!=-1)return dis[u];
    int maxi =0;
    for(auto it: g[u])
    {
       // static int k;
     //   cout<<k++<<" "<<it<<endl;

      dis[u]=  maxi=max(maxi,1+dfs(it) );
    }
    return maxi;
}
int main()
{

    int n, m ;
    cin>>n>>m;
    memset(dis,-1,sizeof dis);
    for(int i = 0 ; i<m ; i++)
    {
        int u, v;
        cin>>u>>v;
        g[u].push_back(v);
        ind[v]++;

    }
    int ans =0;
    for(int i  = 1 ; i<= n ; i++ )
    {
        if(ind[i]==0 and vis[i]==0)
            ans=max(ans,dfs(i));
    }
    cout<<ans;
    return  0 ;
}


Measured memory_bytes: 11520
using System;
using System.Collections.Generic;

namespace AtCoder_A
{
    class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt();
            var k = cin.ReadInt();
            var s = cin.Read();
            var ss = s.ToLower();

            string outstr = "";
            for(int i=0; i<n; i++)
            {
                if(k == i + 1)
                {
                    outstr += ss[i];
                }
                else
                {
                    outstr += s[i];
                }
            }

            Console.WriteLine(outstr);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret; }
    }
}


Measured memory_bytes: 11220
/**
 *    Author:  Oak_limy
 *    Created: 2020-09-26 21:17:07
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    int f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
inline ll readll() {
    ll f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};

int main(){
    ll n;
    cin>>n;
    rp(i,1,n)cout<<"ACL";cout<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3588
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

typedef vector<double> P;
ostream& operator<<(ostream &os, const P &p){
	return os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
}
inline P operator+(const P &a, const P &b){
	P c(3);
	rep(i, 3) c[i] = a[i] + b[i];
	return c;
}
inline P operator-(const P &a, const P &b){
	P c(3);
	rep(i, 3) c[i] = a[i] - b[i];
	return c;
}
inline P operator*(double s, P a){
	rep(i, 3) a[i] *= s;
	return a;
}
inline double dot(const P &a, const P &b){
	double res = 0;
	rep(i, 3) res += a[i] * b[i];
	return res;
}
inline P cross(const P &a, const P &b){
	P c;
	c.pb(a[1] * b[2] - b[1] * a[2]);
	c.pb(b[0] * a[2] - a[0] * b[2]);
	c.pb(a[0] * b[1] - b[0] * a[1]);
	return c;
}
inline double norm(const P &a){ return dot(a, a); }
inline double abs(const P &a){ return sqrt(norm(a)); }

inline P projection(const P &a, const P &b, const P &p){
	double t = dot(p - a, a - b) / norm(a - b);
	return a + t * (a - b);
}
inline P reflection(const P &a, const P &b, const P &p) {
  return p + 2.0 * (projection(a, b, p) - p);
}

int n;
P s, t, o[100];
double r[100];

int main(){
	P zero(3);
	while(cin >> n, n){
		s = t = zero;
		rep(i, 3) cin >> t[i];
		rep(i, n){
			o[i].resize(3);
			rep(j, 3) cin >> o[i][j];
			cin >> r[i];
		}
		while(1){
			double mn = INF, lo = 0, hi, mid;
			int mni;
			rep(i, n){
				double x = dot(o[i] - s, t - s) / norm(t - s);
				if(x <= EPS || abs(s + x * (t - s) - o[i]) > r[i]) continue;
				if(x < mn) mn = x, mni = i;
			}
			if(mn == INF) break;
			
			hi = mn;
			rep(it, 100){
				mid = (lo + hi) / 2;
				if(abs(s + mid * (t - s) - o[mni]) < r[mni]) hi = mid;
				else lo = mid;
			}
			t = s + mid * (t - s);
			swap(s, t);
			t = reflection(o[mni], s, t);
		}
		printf("%.9f %.9f %.9f\n", s[0], s[1], s[2]);
	}
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

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

  map<int,int> mp;
  int maxv = 0;
  int minv = 1e9 + 7;
  for (int i = 0; i < n; i++) {
    if(a[i] > minv) {
      if(a[i] - minv >= maxv) {
        maxv = a[i] - minv;
        mp[maxv]++;
      }
    } else {
      minv = min(minv, a[i]);
    }
  }
  cout << mp[maxv] << '\n';
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
//const int INF = 1e8;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

vector<vector<int>> g;
const int dy[16] = { 0,-1, 0, 1, 1,-1};
const int dx[16] = { 1, 0,-1, 0, 1,-1};

void bfs(int k, int t, vector<bool>& used, const vector<int>& node){
	queue<int> q;
	q.emplace(k);
	while(not q.empty()){
		int pos = q.front(); q.pop();
		used[pos] = true;
		for(auto to : g[pos]){
			if(used[to] or node[to] != t) continue;
			q.emplace(to);
		}
	}
}

vector<vector<int>> getGraph(int n, int v){
	vector<vector<int>> res(v), mat(n, vector<int>(n, -1));
	int ver = 0;
	rep(i,n){
		for(int j = 0; j <= i; j++, ver++){
			mat[i][j] = ver;
		}
	}
	rep(i,n){
		rep(j,i + 1){
			rep(d,6){
				int ny = i + dy[d];
				int nx = j + dx[d];
				if(ny < 0 || ny >= n || nx < 0 || nx >= n) continue;
				if(mat[ny][nx] == -1) continue;
				res[mat[ny][nx]].emplace_back(mat[i][j]);
				res[mat[i][j]].emplace_back(mat[ny][nx]);
			}
		}
	}
	return res;
}

int main(){
	int n, c;
	while(cin >> n >> c,n||c){
		int v = (1 + n) * n / 2;
		g = getGraph(n, v);

		vector<int> node(v);
		cin >> node;

		int ans = -1e8;
		rep(i,v){
			vector<bool> used(v,0);
			if(node.at(i) == 0){
				node.at(i) = c;
				rep(j,v){
					if(node.at(j) == 0){
						for(auto k : g.at(j)){
							if(node[k] == 0) continue;
							bfs(k, node[k], used, node);
						}
					}
				}
				int sum = 0;
				rep(j,v){
					if(used[j] or node[j] == 0) continue;
					if(node[j] == c) sum--;
					else sum++;
				}
				ans = max(ans, sum);
				node.at(i) = 0;
			}
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string words[4] = {"dream", "dreamer", "erase", "eraser"};
  string S;
  cin >> S;
  bool update = true;
  while (update) {
    update = false;
    for (int i = 0; i < 4; i++) {
      int n = words[i].length();
      if (S.length() < n) continue;
      string s = S.substr(S.length() - n, n);
      if (s == words[i]) {
        update = true;
        S = S.substr(0, S.length() - n);
      }
    }
  }
  cout << (S.length() == 0 ? "YES" : "NO") << '\n';
  return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> v(n);
	while (m--) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<ll> ans(n);
	queue<ll> task;
	task.push(0);
	vector<bool> seen(n, false);
	seen[0] = true;
	while (task.size()) {
		ll sz = task.size();
		while (sz--) {
			ll x = task.front();
			task.pop();
			for (auto i : v[x]) {
				if (seen[i]) continue;
				task.push(i);
				seen[i] = true;
				ans[i] = x;
			}
		}
	}
	Yes();
	for (ll i = 1; i < n; i++) cout << ans[i] + 1 << endl;
}

Measured memory_bytes: 12892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll N, K;
string S;
void solve() {
  char tmp = S[K - 1];
  for (int i = 0; i < (int)S.size(); i++) {
    if (S[i] == tmp) {
      cout << tmp;
    }
    else {
      cout << "*";
    }
  }
  cout << "\n";
  return;
}

int main() {
  cin >> N >> S >> K;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 1e05 + 10;

int N;
int a[MAXN];

bool comp (const int& a, const int& b) {
	return a > b;
}

int getnum () {
	int num = 0;
	char ch = getchar ();

	while (! isdigit (ch))
		ch = getchar ();
	while (isdigit (ch))
		num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();

	return num;
}

int main () {
	N = getnum ();
	for (int i = 1; i <= N; i ++)
		a[i] = getnum ();
	sort (a + 1, a + N + 1, comp);
	for (int i = 1; i <= N; i ++)
		if (a[i + 1] <= i) {
			bool win = false;
			if ((a[i] - i) & 1)
				win = true;
			if (! win && a[i + 1] == i) {
				int cnt = 1;
				for (int j = i + 1; j <= N; j ++) {
					if (a[j] < i) break;
					cnt ++;
				}
				if (! (cnt & 1))
					win = true;
			}
			win ? puts ("First") : puts ("Second");
			return 0;
		}

	return 0;
}

/*
2
1 3
*/

/*
3
1 2 1
*/

/*
3
1 2 3
*/

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main(){
    int k,s;
    cin>>k>>s;
    int cnt=0;

    //0<=x,y,z<=k
    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
            (s-i-j)<=k&&(s-i-j)>=0?cnt++:cnt=cnt;
}
    }
    cout<<cnt<<endl;
return 0;
}


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

int top, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop() {
  top--;
  return S[top+1];
}

int main() {
  int a, b;
  top = 0;
  char s[100];

  while( scanf("%s", s) != EOF ) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a+b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a-b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a*b);
    } else {
      push(atoi(s));
    }
  }

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

  return 0;
}

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

using namespace std;


struct CWW{CWW(){ios::sync_with_stdio(false);cin.tie(0);}}cww;

namespace _UF{
    #define SZ 100010
    int mem[2][SZ];
};
class UnionFind{
public:
    int *par,*rank;
    int find(int x){
	if(par[x]==x)return x;
	else{
	    int p=find(par[x]);
	    rank[x]+=rank[par[x]];
	    return par[x]=p;
	}
    }
    UnionFind(int n):par(_UF::mem[0]),rank(_UF::mem[1]){
	for(int i=0;i<n;i++)par[i]=i,rank[i]=0;
    }
    bool unite(int x,int y,int diff){
	int xp=find(x),yp=find(y);
	if(xp==yp)return false;
	diff-=rank[x];
	diff+=rank[y];
	if(diff<0){
	    diff*=-1;
	    swap(xp,yp);
	}
	par[xp]=yp;
	rank[xp]=diff;
	return true;
    }
    bool same(int x,int y){
	return find(x)==find(y);
    }
    int  get(int x,int y){
	int p=find(x);
	return rank[x]-rank[y];
    }
};



int main(){
    for(int N,Q;cin>>N>>Q,N+Q;){
	UnionFind uf(N+1);
	while(Q--){
	    string s;
	    cin>>s;
	    int x,y;
	    cin>>x>>y;
	    if(s=="!"){
		int w;cin>>w;
		uf.unite(x,y,w);
	    }
	    else{
		if(uf.same(x,y)){
		    cout<<uf.get(x,y)<<endl;
		}
		else{
		    cout<<"UNKNOWN"<<endl;
		}
		    
	    }
	}
    }
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}



long mod = 1000000007;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

ll intpow(mint_t m, int n)
{
    if (n == 0) return 1;
    mint_t ans(1);
    while (n >= 1)
    {
        if ((n % 2) == 0){
            m *= m.x;
            n /= 2;
        }else {
            ans *= m.x;
            n -= 1;
        }
    }
    return ans.x;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

    //自分と被っていない子を求める
    mint all(1);
    int tmp = m;
    rep(i, n){
        all *= tmp;
        tmp--;
    }

    combination cb(m);

    mint ans(0);
    rep1(i, n){
        mint score = cb(n, i);
        score *= cb.fact[m-i];
        score /= cb.fact[m-n];
        if (i%2) ans+=score;
        else ans-=score;
    }
    ans-=1;
    mint ans_fin = all-1 - ans; //被ってない子
    ans_fin *= all;
    
    cout << ans_fin.x << endl;
}



Measured memory_bytes: 11176
#include<iostream>
#include<utility>
using namespace std;
int main(){
    int a,b,c,t;
    cin>>a>>b>>c;
    if(a>b){
        swap(a,b);
    }
    if(b>c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
    
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

int n, m;
VVI g;
map<pair<int, int>, int> edge;

void wf() {
    REP(k,n) {
        REP(i,n) {
            REP(j,n) {
                MIN(g[i][j], g[i][k] + g[j][k]);
                g[j][i] = g[i][j];
            }
        }
    }
}

int main()
{
    cin>>n>>m;
    g.resize(n, VI(n, INF));
    REP(i,m) {
        int a, b, c;
        cin>>a>>b>>c;
        a--; b--;
        g[a][b] = c;
        g[b][a] = c;
        if (a > b) swap(a,b);
        edge[make_pair(a,b)] = c;
    }
    REP(i,n) g[i][i] = 0;

    wf();

    int cnt = m;
    REP(i,n) {
        REP(j,n) {
            REPITR(itr,edge) {
                if (g[i][j] == g[i][itr->e1.e1] + edge[itr->e1] + g[itr->e1.e2][j]) {
                    //cout<<i<<" "<<j<<" "<<itr->e1.e1<<" "<<itr->e1.e2<<" "<<g[i][j]<<" "<<g[i][itr->e1.e1] + edge[itr->e1] + g[itr->e1.e2][j]<<endl;
                    auto tmp = itr;
                    itr--;
                    edge.erase(tmp);
                    cnt--;
                }
            }
        }

        if (edge.empty())
            break;
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 384
use std::io::stdin;

fn main() {
    let mut values = String::new();
    {
        let mut input = String::new();
        stdin().read_line(&mut input);
        values = input;
    }

    let mut values: i64 = values.trim().parse::<i64>().unwrap();
    let mut count: i64 = 1;
    let mut times: i64 = 0;
    loop {
        times += 1 * count;
        values /= 2;
        count *= 2;
        if values == 0 {
            break;
        }
    }
    println!("{}", times);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

long long f(vector<pair<long long, long long>> vec){
    long long n = vec.size();
    for(int i=0; i<n; ++i){
        vec[i].first = min(n, vec[i].first);
    }
    vector<vector<long long>> pos_sec(n+1);

    for(int i=0; i<n; ++i){
        pos_sec[vec[i].first].push_back(vec[i].second);
    }
    long long res = 0;
    priority_queue<long long> q;

    for(int i=n; i>=1; --i){
        for(auto x : pos_sec[i]){
            q.push(x);
        }
        if(q.size() > 0){
            res += q.top();
            q.pop();
        }
    }

    return res;

}


long long solve(){
    int n; cin >> n;

    //first: position, second: score;
    vector<pair<long long, long long>> camels_left;
    vector<pair<long long, long long>> camels_right;

    long long ans = 0;
    for(int i=1; i<=n; ++i){
        long long k, l, r; 
        cin >> k >> l >> r;
        long long small = min(l, r);
        ans += small;
        long long score;
        if(l - small > 0 ){
            score = l - small;
            camels_left.push_back({k, score});
        }else{
            score = r - small;
            camels_right.push_back({n-k, score});
        }
    }
    ans += f(camels_left);
    ans += f(camels_right);

    return ans;
}


int main(){
    int t; cin >> t;
    for(int i=0; i<t; ++i){
        cout << solve() << endl;
    }
}

Measured memory_bytes: 14260
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top,s[1000];


void push(int x){
  s[++top]=x;
}

int pop(){
  top--;
  return s[top+1];
}


int main(){
  top=0;
  char S[100];
  int a,b,c;
  while(scanf("%s",S)!=EOF){



    if(S[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(S[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(S[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else {
      push(atoi(S));
    }

  }

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

  return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            #define pi 3.14159265358979323846
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli i,t,n,j,k,m,g;
                string s;
                cin>>s;
                lli a=(s[0]-'0')*10+(s[1]-'0');
                lli b=(s[2]-'0')*10+(s[3]-'0');
                if(a>0&&b>0&&a<=12&&b<=12){
                    cout<<"AMBIGUOUS";
                }
                else if(a>=0&&b<=12&&b>0){
                    cout<<"YYMM";
                }
                else if(b>=0&&a<=12&&a>0){
                    cout<<"MMYY";
                }
                else{
                    cout<<"NA";
                }

                return 0;
            }


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

#define endl "\n"
#define int long long
#define vec(x) vector<x>
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);
int power(int a,int b,int m=MOD)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}
int dir[]={-1, 0, 1, 0, -1};
int dx[]={1,1,0,-1,-1,-1, 0, 1};
int dy[]={0,1,1, 1, 0,-1,-1,-1};

const int N = 1e3+1;
int val[N],wt[N];
int n,w;

int knapsack()
{
    int i,j,V=0;    // V is the maximum value possible
    for(i=0;i<n;i++)
    V+=val[i];
    vector<int> dp(V+1,INF); // the minimum total weight of items with total value exactly i
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(j=V;j>=val[i];j--)
        dp[j]=min(dp[j],wt[i]+dp[j-val[i]]);
    }
    for(i=V;i>=0;i--)
        if(dp[i]<=w)
        return i;
    return 0;
}

void solve()
{
	int i;
	cin>>n>>w;
    for(i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    cout<<knapsack()<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	t=1;
	//cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
int main()
{
       int n,m;
       cin>>n>>m;
       pll a[n];
       fri(i,0,n){
              cin>>a[i].fr>>a[i].sc;
       }

       sort(a,a+n);
       int i = 0;
       ll sum = 0;
       ll curr = 0;
       while(i<n){
              if(curr+a[i].sc>m){
                     sum += (m-curr)*a[i].fr;
                     break;
              }
              sum += a[i].sc*(a[i].fr);
              curr += a[i].sc;
              i++;
       }
       cout<<sum<<endl;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.a = Integer.parseInt(sa[i]);
			arr[i] = o;
		}
		sa = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			arr[i].b = Integer.parseInt(sa[i]);
		}
		br.close();

		int[] a = new int[n];
		Arrays.parallelSort(arr, (o1, o2) -> o1.a - o2.a);
		for (int i = 0; i < n; i++) {
			arr[i].i = i;
			a[i] = arr[i].a;
		}
		Arrays.parallelSort(arr, (o1, o2) -> o1.b - o2.b);

		int[] cnt = new int[n];
		int x = 0;
		for (int i = 0; i < n; i++) {
			while (x < n && a[x] <= arr[i].b) {
				x++;
			}
			cnt[i] = x;
		}

		boolean flg = false;
		for (int i = 0; i < n; i++) {
			if (cnt[i] < i + 1) {
				System.out.println("No");
				return;
			}
			if (cnt[i] > i + 1) {
				flg = true;
			}
		}
		if (flg) {
			System.out.println("Yes");
			return;
		}

		int cnt2 = 0;
		int y = arr[0].i;
		while (y != 0) {
			y = arr[y].i;
			cnt2++;
		}
		if (cnt2 > n - 2) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

	static class Obj {
		int i, a, b;
	}
}


Measured memory_bytes: 56348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    long n,ans=0,r[4001]={},g[4001]={},b[4001]={};;
    string s;
    cin >> n >> s;
    rep(i,n){
        if(s[i]=='R') r[i+1] = r[i] + 1;
        else r[i+1] = r[i];
        if(s[i]=='G') g[i+1] = g[i] + 1;
        else g[i+1] = g[i];
        if(s[i]=='B') b[i+1] = b[i] + 1;
        else b[i+1] = b[i];
    }
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int a = 'R'+'B'+'G';
            if(s[i]==s[j]) continue;
            char d = a-s[i]-s[j];
            if(d=='R') ans += r[n]-r[j];
            if(d=='G') ans += g[n]-g[j];
            if(d=='B') ans += b[n]-b[j];
            if(s[2*j-i]==d) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include<stdio.h>
#include<string.h>

int lcs(char *x, char *y){
    int c[1001][1001],i,j;
    int numberx = strlen(x)+1;
    int numbery = strlen(y)+1;
    int maxl=0,max=0;

    
    for(i=1;i<numberx;i++){
        for(j=1;j<numbery;j++){
            if(x[i-1]==y[j-1])
                c[i][j]=c[i-1][j-1]+1;
            else{
                if(c[i-1][j]>c[i][j-1]) c[i][j] = c[i-1][j];
                else c[i][j]=c[i][j-1];
            }
            if(c[i][j]>maxl) maxl=c[i][j];
        }
    }
    return maxl;
}

int main(){
    char s1[1001],s2[1001];
    int n,i;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s",s1);
        scanf("%s",s2);
        printf("%d\n",lcs(s1,s2));
    }
    return 0;
}



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

int main() {
	long long int n, m;
	string s, t;
	cin >> n >> m;
	cin >> s >> t;
	long long int x = lcm(n, m);

	int sidx = 0;
	int tidx = 0;
	long long int snum = 1;
	long long int tnum = 1;
	long long int ans = x;
	while (sidx < n && tidx < m) {
		if (snum == tnum) {
			if (s[sidx] != t[tidx]) {
				ans = -1;
				break;
			}
		}
		if (snum < tnum) {
			snum = ++sidx * (x / n);
		}
		else {
			tnum = ++tidx * (x / m);
		}
	}
	cout << ans << endl;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    cout << N * N * N << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();
        String ans = "YES";
        if (A+B < X || X < A) {
            ans = "NO";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
<?php

fscanf(STDIN, "%s", $x);

$result = 9999;

for ($i = 0; $i < strlen($x) - 2; $i++) {
    $num = (int)($x[$i].$x[$i+1].$x[$i+2]);
    $diff = abs($num-753);
    if ($result > $diff) {
        $result = $diff;
    }
}
echo "$result\n";


Measured memory_bytes: 4856
#include <stdio.h>

int map[100][100];
int w, h, s, t;
int ans;

void tansaku();

main(){
  int n, x, y, i, j;

  while(1){
    scanf("%d", &n);
    if(n==0) break;

    scanf("%d %d", &w, &h);

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        map[i][j]=0;
      }
    }

    for(i=0;i<n;i++){
      scanf("%d %d", &x, &y);
      x--;
      y--;
      map[y][x]=1;
    }

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

    ans=-1;
    tansaku();

    printf("%d\n", ans);
  }
  return 0;
}

void tansaku(){
  int i, j, k, l, sum;

  for(i=0;i<h;i++){
    if((i+t-1)>=h) break;
    for(j=0;j<w;j++){
      if((j+s-1)>=w) break;

      sum=0;
      for(k=0;k<t;k++){
        for(l=0;l<s;l++){
          if(map[i+k][j+l]==1) sum++;
        }
      }
      if(ans<sum) ans=sum;
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", &s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define sz(x) x.size()
#define rep(n) for (int i = 0; i < n; i++)
#define repc(i, n) for (int i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;

// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;

template <typename T>
T modpow(T base, T exp, T modulus)
{
    base %= modulus;
    T result = 1;
    while (exp > 0)
    {
        if (exp & 1)
        result = (result * base) % modulus;
        base = (base * base) % modulus;
        exp >>= 1;
    }
    return result;
}

ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }

// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const long double pi = 1.00 * acos(-1.00);



int find(string s1, string s2)
{
    int cnt = 0;
    FOR(i, 0, sz(s1))
    {
        if(s1[i]!=s2[i]){
            cnt++;
        }
    }

    return cnt;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
        freopen("./input.txt", "r", stdin);
        freopen("./output.txt", "w", stdout);
    #endif

    */

    string s, t;
    cin >> s >> t;

    int ans = INT_MAX;

    int n = sz(s), m = sz(t);
    for (int i = 0; i <= n - m; i ++){
        ans = min(ans, find(s.substr(i, m), t));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <algorithm>

using namespace std;

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);

	while( 1 ) {
		int n;
		cin >> n;
		if( n == 0 ) break;

		int ans = 0;
		bool ps = false;
		bool f[2] = {false,false};

		for(int i = 0; i < n; i++) {
			string s;
			cin >> s;
			if( s == "lu" )	f[0] = true;
			else if( s == "ru" ) f[1] = true;
			else if( s == "ld" ) f[0] = false;
			else if( s == "rd" ) f[1] = false;
			if( f[0] == false && f[1] == false ) {
				if( ps == true ) ans ++;
				ps = false;
			}
			if( f[1] == true && f[0] == true ) {
				if( ps == false ) ans ++;
				ps = true;
			}

			
		}
		cout << ans << endl;

	}

//	while(1){}
	return 0;
}

Measured memory_bytes: 1208