akhauriyash/Code-Regression huggingface dataset:
#include <bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
int n; vector<int> a;
template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0; vector<Abel> dat;
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
};
int main() {
    cin >> n;a.resize(n);
    rep(i, n) cin >> a[i];
    int right = 1<<30,left = 0;// right > 10^10以上で
    while (right - left > 1) {
        int mid = (right + left) / 2,sum = 0;
        ll cnt = 0;BIT<ll> bit(n * 2 + 10);
        bit.add(n + 1, 1);
        rep(i, n) {
            sum += (a[i] <= mid) ? 1 : -1;
            cnt += bit.sum(1, sum + n + 1);
            bit.add(sum + n + 1, 1);
        }if (cnt >(ll)n * (n + 1) / 4)right = mid;
        else left = mid;
    }cout << right << endl;
}

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

int main(){
    int n,T,c,t,m=1001;
    cin>>n>>T;
    for(int i=0;i<n;i++){
        cin>>c>>t;
        if(t<=T) m=min(m,c);
    }
    if(m==1001) cout<<"TLE"<<endl;
    else cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    vector<ll> dp(n, 0);
    rep(i, n) cin >> a[i];
    rep(i, n)
    {
        dp[a[i]]++;
    }
    if (n % 2 == 0)
    {
        for (int i = 1; i <= n; i += 2)
        {
            if (dp[i] == 1)
                ans = 0;
            ans *= dp[i];
            ans %= mod;
        }
    }
    else
    {
        for (int i = 0; i <= n; i += 2)
        {
            if (i != 0)
                if (dp[i] == 1)
                    ans = 0;
            ans *= dp[i];
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()
mylist = tuple(tuple(MI()) for i in range(n-1))

def main(j):
    time = 0
    for i in range(j,n-1):
        c, s, f = mylist[i]
        if time < s:
            time = s
        elif (time - s) % f != 0:
            time += (f - (time - s) % f) #待ち時間を足す
        time += c
    print(time)
    
def main2():    
    for i in range(n-1):
        main(i)
    print(0)
main2()

Measured memory_bytes: 3188
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int N;vec X;
ll f(ll x){
    ll rev=0;
    rep(i,N){
        rev+=(X[i]-x)*(X[i]-x);
    }
    return rev;
}

int main(){
    scanf("%d",&N);
    X.resize(N);
    rep(i,N) scanf("%lld",&X[i]);
    ll ans=INF;
    rep(i,101){
        ans=min(ans,f(i));
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i<n;i++)
#define nforn(i,n) for(ll i=n-1;i>=0;i--)
#define forne(i,n) for(ll i=1;i<=n;i++)
#define forse(i,s,e) for(ll i=s;i<e;i++)
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define d1(x) cerr <<"> "<<#x<<" = "<<x<<'\n'
#define d2(x, y) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<'\n'
#define d3(x, y, z) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<' '<<#z<<" = "<<z<<'\n'
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t = 1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		pair<ll,ll> arr[n];
		forn(i,n){
			ll x,y;
			cin>>x>>y;
			arr[i] = {x+y,x-y};
		}
		sort(arr,arr+n);
		ll prev = -ll(1e10);
		ll ans = 0;
		forn(i,n){
			if(arr[i].second>=prev){
				ans++;
				prev = arr[i].first;
			}
		}
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    char b;
    cin >> b;

    switch (b) {
        case 'A':
            cout << "T\n";
            break;
        case 'C':
            cout << "G\n";
            break;
        case 'G':
            cout << "C\n";
            break;
        case 'T':
            cout << "A\n";
            break;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;

int main(void) {
  int k, x;
  cin >> k >> x;

  cout << (k * 500 >= x ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        int count = 0;
        while (A > 0 && C > 0) {
            if (count % 2 == 0) {
                C = C - B;
            } else {
                A = A - D;
            }
            count++;
        }

        if (A>0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef vector<vector<int>> Graph;
typedef pair<int,bool> P;

int main() {
	int N,M,K,L;
	cin >> N >> M;
	Graph p(N),l(M);
	vector<int> sp(N,0),sl(M,0);
	queue<P> q;
	bool ok = 1;

	rep(i,N) {
		cin >> K;
		rep(j,K) {
			cin >> L;
			p.at(i).push_back(L-1);
			l.at(L-1).push_back(i);
		}
	}

	q.push(P(0,0));
	while(!q.empty()) {
		auto x = q.front();
		q.pop();
		if(x.second == 0) {
			sp.at(x.first) = 1;
			for(auto y : p.at(x.first))
				if(!sl.at(y))
					q.push(P(y,1));
		} else {
			sl.at(x.first) = 1;
			for(auto y : l.at(x.first))
				if(!sp.at(y))
					q.push(P(y,0));
		}
	}

	rep(i,N)
		ok &= sp.at(i);
	
	cout << ((ok) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 10104
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



// kが偶数なら点、奇数なら辺を中心にして、そこからの距離がk/2を超える点を全部消せばok
int n, k, a[2020], b[2020], d[2020], res = inf;
vector<int> e[2020];

void rec(int v) {
	each(i,e[v]) if (d[i]==-1) d[i] = d[v]+1, rec(i);
}

void ev() {
	rep(i,n) {
		rep(j,n) d[j] = -1;
		d[i] = 0;
		rec(i);
		int cnt = 0;
		rep(j,n) if (d[j]>k/2) cnt++;
		chmin(res, cnt);
	}
}

void od() {
	rep(i,n-1) {
		rep(j,n) d[j] = -1;
		d[a[i]] = d[b[i]] = 0;
		rec(a[i]), rec(b[i]);
		int cnt = 0;
		rep(j,n) if (d[j]>k/2) cnt++;
		chmin(res, cnt);
	}
}

signed main() {
	cin >> n >> k;
	rep(i,n-1) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		e[a[i]].push_back(b[i]), e[b[i]].push_back(a[i]);
	}
	if (k%2==0) ev();
	else od();
	cout << res << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		PrintWriter pw = new PrintWriter(out);
		for(i=0;i<s.length;i+=2) {
			pw.print(s[i]);
		}
		pw.flush();
	}
}


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


vector<vector<int>> make_permutation(int N)
{
    vector<vector<int>> pos;
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);
    do {
        if (v.at(0) == 1)
        {
          pos.push_back(v);
        }
    } while( next_permutation(v.begin(), v.end()) );
    return pos;

    // for (int i = 0; i < 6; i++)
    // {
    //   cout << pos.at(i).at(0);
    //   cout << pos.at(i).at(1);
    //   cout << pos.at(i).at(2) << endl;
    // }
}

int main()
{
  int N,M;
  int ans = 0;
  cin >> N >> M;
  vector<bitset<8>> conect(N);
  int a,b;
  vector<vector<int>> pos = make_permutation(N);
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    conect.at(a - 1).set(b - 1);
    conect.at(b - 1).set(a - 1);
  }

  for (vector<int> tops : pos)
  {
    for (int i = 0; i < N - 1; i++)
    {
      if (conect.at(tops.at(i) - 1).test(tops.at(i + 1) - 1))
      {
        if (i == N - 2)
        {
          ans++;
          // for (int t : tops)
          // {
          //   cout << t;
          // }
          // cout << endl;
        }
        continue;
      }
      else
      {
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 234567;
char s[MAXN];
int dp[87], cur[87];
int pre[MAXN];

int main() {
    while (~scanf("%s", s)) {
          int n = strlen(s);
          for (int i = 0; i < 26; i++) {
              dp[i] = 1;
              pre[i + n] = n + 26 + i;
              s[i + n] = i + 'a';
              cur[i] = i + n;
          }
          for (int i = n - 1; i >= 0; i--) {
              int idx = 0;
              for (int i = 1; i < 26; i++) {
                  if (dp[i] < dp[idx]) idx = i;
              }
              pre[i] = cur[idx];
              cur[s[i] - 'a'] = i;
              dp[s[i] - 'a'] = dp[idx] + 1;
          }
          int ans_i = 0;
          for (int i = 1; i < 26; i++) {
              if (dp[i] < dp[ans_i]) ans_i = i;
          }
          int ans_cur = cur[ans_i];
          while (ans_cur < n + 26) {
                printf("%c", s[ans_cur]);
                ans_cur = pre[ans_cur];
          }
          puts("");
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>

#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define vpii vector<pii>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define pdd pair<double, double>
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define forstl(i,v) for(auto &i: v)

#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define pdd pair<double, double>

using namespace std;

int main(){
    /*
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    */
    int t, p;
    cin >> t >> p;
    cout << (3*t + p)/2;
    

    //cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int X;
  cin >> X;
  if(X >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> a(n);
    REP(i, n) { cin >> a[i]; }
    sort(all(a), greater<ll>());
    priority_queue<tuple<ll, ll, ll>> que;
    que.push({a[0], a[0], a[0]});

    ll ans = 0;
    rep(i, 1, n) {
        auto [v, l, r] = que.top();
        que.pop();
        ans += v;
        que.push({a[i], a[i], l});
        que.push({a[i], a[i], r});
    }
    cout << ans << en;
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t)
    solve();
    */

    return 0;
}


Measured memory_bytes: 11088
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for B - Card Game for Two
	var N int
	fmt.Scanf("%d", &N)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(A)))

	var sum1, sum2 int
	for i := 0; i < N; i++ {
		if i%2 == 0 {
			sum1 += A[i]
		} else {
			sum2 += A[i]
		}
	}
	fmt.Println(sum1 - sum2)
}


Measured memory_bytes: 1840
import collections
h,w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]

result = [0]*10
    
    
def way(n,e,i,p): #現在の数字、現在の必要魔力、始点、暫定最低魔力
    for j in range(0,10):
        if (n == j):
            continue
        if (n == 1):
            if (e < result[i]):
                result[i] = e
            break
        if (e +  c[n][j] < p):
            q = e + c[n][j]
            way(j,q,i,p)
        
for i in range(0,10):
    result[i] = c[i][1]
    way(i,0,i,result[i])
    

r = []
for w in range(0,10):
    t = 0
    for k in range(0,h):
        l = collections.Counter(a[k])
        t += l[w]
    r.append(t)

ans = 0
for z in range(0,10):
    ans += result[z] * r[z]
print (ans)
        
    

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll INF = 1LL << 40;
int N, M;
ll dis[1010][1010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  fill((ll*)dis, (ll*)(dis + 1010), INF);
  for (int i = 0; i < N; i++) dis[i][i] = 0;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dis[a][b] = -c;
  }
  for (int k = 0; k < N; k++) for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
    if (dis[i][k] == INF || dis[k][j] == INF) continue;
    dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  }
  for (int i = 0; i < N; i++) {
    if (dis[i][i] < 0 && dis[0][i] < INF && dis[i][N - 1] < INF) {
      cout << "inf" << endl;
      return 0;
    }
  }
  cout << -dis[0][N - 1] << endl;

  return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	int h,w; cin>>h>>w;
	vector<string> board(h+5);
	
	for(int i=0;i<h;i++) cin>>board[i];
	
	int left[h+5][w+5], right[h+5][w+5], up[h+5][w+5], down[h+5][w+5];
	
	for(int i=0; i<h; i++){
		for(int j=0;j<w; j++){
			left[i][j]=right[i][j]=up[i][j]=down[i][j]=0;
		}
	}
	
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(board[i][j]=='#') continue;
			
			if(j==0) left[i][j]=0;
			else if(board[i][j-1]=='#') left[i][j]=0;
			else left[i][j]=left[i][j-1]+1;
			
			if(i==0) up[i][j]=0;
			else if(board[i-1][j]=='#') up[i][j]=0;
			else up[i][j]=up[i-1][j]+1;
		}
	}
	
	for(int i=h-1; i>=0; i--){
		for(int j=w-1; j>=0; j--){
			if(board[i][j]=='#') continue;
			
			if(j==w-1) right[i][j]=0;
			else if(board[i][j+1]=='#') right[i][j]=0;
			else right[i][j]=right[i][j+1]+1;
			
			if(i==h-1) down[i][j]=0;
			else if(board[i+1][j]=='#') down[i][j]=0;
			else down[i][j]=down[i+1][j]+1;
		}
	}  
	
	int ans=0;
	
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(board[i][j]=='#') continue;
			ans=max(ans, 1+left[i][j]+right[i][j]+up[i][j]+down[i][j]);
		}
	}
		
	cout<<ans;
		
	return 0;
}


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

int n, m;
int inf = 1e9+7;
int a[100010];
int ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i=0; i<=n; ++i)
		a[i] = inf;
	for(int i=0; i<m; ++i){
		int s, t;
		cin >> s >> t;
		if(a[s] > t)
			a[s] = t;
	}
	for(int i=n-1; i>0; --i)
		if(a[i] > a[i+1])
			a[i] = a[i+1];
	for(int i=1; i<=n; ++i){
		if(a[i] != inf){
			++ans;
			i = a[i] - 1;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        x: i64,
    }

    let mut a = 0;
    let mut b = 0;
    loop {
        let a5 = a * a * a * a * a;
        if a5 == x {
            b = 0;
            break;
        }
        let mut flag = false;
        if a5 > x {
            while a5 > x + b * b * b * b * b {
                b += 1;
                let b5 = b * b * b * b * b;
                if a5 == x + b5 {
                    flag = true;
                    break;
                }
            }
        } else {
            while a5 < x + b * b * b * b * b {
                b -= 1;
                let b5 = b * b * b * b * b;
                if a5 == x + b5 {
                    flag = true;
                    break;
                }
            }
        }
        if flag {
            break;
        }
        a += 1;
        b = 0;
    }
    println!("{} {}", a, b);
}


Measured memory_bytes: 2172
#include <iostream>

using namespace std;

int main(){
  int n, m, l;
  long sum=0;
  int a[100][100], b[100][100];

  cin >> n >> m >> l;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0;i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> b[i][j];
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      for(int k = 0; k < m; k++){
	sum += a[i][k] * b[k][j];
      }
      cout << sum;
      sum = 0;
      if(j != l-1){ cout << " "; }
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int n, k, g[130][130], q, a, b, c, d, e;
int f() {
	int a1[123]; for1(i, n)a1[i] = mod;
	set<pair<int, int>>s;
	s.insert(mp(0, a));
	while (s.size()) {
		int cost = (*(s.begin())).first, island = (*(s.begin())).second;
		if (island == b)return cost;
		if (a1[island] < cost) {
			s.erase(s.begin());
			continue;
		}
		a1[island] = cost;
		for1(i, n) {
			if (a1[i] == mod && g[island][i] < mod)
				s.insert(mp(g[island][i] + cost, i));
		}
		s.erase(s.begin());
	}
	return -1;
}
signed main() {
	while (cin >> n >> k, n) {
		for1(i, n)for1(j, n)g[i][j] = mod * (i != j);
		while (k--) {
			cin >> q;
			if (!q) {
				scanf("%d%d", &a, &b);
				printf("%d\n", f());
			}
			else {
				scanf("%d%d%d", &c, &d, &e);
				g[c][d] = min(g[c][d], e);
				g[d][c] = g[c][d];
			}
		}
	}
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#define ini ll_MAX
#define inl LLONG_MAX
#define MOD 1000000007
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define pbds tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
 
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
 
ll mod(ll a,ll b)
{
    return (b+a%b)%b;
}
 
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}
 
ll sqdist(ll a,ll b,ll c,ll d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}
ll fact(ll n)
{
    if(n==0)return 1;
    ll ans = 1;
    FOR(i,1,n+1)ans*=i;
    return ans;
}

 
void solve()
{
    ll a,b;
    string p,q;
    cin>>a>>b;
    FOR(i,0,b)p.insert(p.end(),a+'0');
    FOR(i,0,a)q.insert(q.end(),b+'0');
    if(p>q)cout<<q;
    else cout<<p;
}
 
 
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    // ll t;
    //cout<<"Y"<<endl;
    //cin>>t;
    //while(t--)
        solve();
}

Measured memory_bytes: 256
def li():
    return [int(x) for x in input().split()]


N = int(input())
L = []
for i in range(N):
    L.append(li())

# 1.全探索は間に合うか: 再帰で全探索するとO(3**N)で間に合わない
# 2.貪欲法は使えるか: 一手での最善(部分最適)は次の一手の大きなメリットを逃す可能性があルため最善ではない
# 3.DPは使えるか: 一手ごとにA,B,Cの状態別に最大値1つだけに注目すれば良く、残りは切り捨てて良いので使える

# dp[i][k]: i番目の選択でk(a,b,c)を選択した時の最大値
dp = [[0]*3 for i in range(N+1)]
dp[0] = L[0]
for i in range(1, N):
    for k in range(3):
        if k == 0:
            dp[i][k] = max(dp[i][k], dp[i-1][1] + L[i][0], dp[i-1][2] + L[i][0])
        elif k == 1:
            dp[i][k] = max(dp[i][k], dp[i-1][0] + L[i][1], dp[i-1][2] + L[i][1])
        elif k == 2:
            dp[i][k] = max(dp[i][k], dp[i-1][0] + L[i][2], dp[i-1][1] + L[i][2])

print(max(dp[N-1]))

Measured memory_bytes: 104964
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

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

    int n;

    cin >> n;

    vector<int> a(n),b(n),c(n);

    for(int i = 0;i < n;i++) cin >> a[i];
    for(int i = 0;i < n;i++) cin >> b[i];
    for(int i = 0;i < n;i++) cin >> c[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    vector<long long> bc(n+1);
    int j = 0;

    for(int i = 0;i < n;i++)
    {
        while(j < n)
        {
            if(c[j]>b[i] and j==0){ bc[i] = n-j; break; }
            if(c[j]>b[i] and c[j-1]<=b[i]){ bc[i] = n-j; break; }
            j++;
        }
    }

    long long ans = 0;
    j = 0;
    bc[n] = 0;
    for(int i = n-1;i >= 0;i--) bc[i]+=bc[i+1];

    for(int i = 0;i < n;i++)
    {
        int idx = -1;
        while(j < n)
        {
            if(b[j]>a[i] and j==0){ idx = j; break; }
            if(b[j]>a[i] and b[j-1]<=a[i]){ idx = j; break; }
            j++;
        }
        if(idx==-1) continue;
        ans+=bc[idx];
    }

    cout << ans;
}


Measured memory_bytes: 2176
n, k = map(int, input().split())
sunuke = [0]*n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        sunuke[a[j]-1] = 1

ans = 0
for i in range(n):
     if sunuke[i] == 0:
         ans += 1
print(ans)


Measured memory_bytes: 67256
/// meowa 

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef hitorie
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    long double a, b;
    cin >> a >> b;
    cout << ll(a*b);
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        maincode(); 
    }
    return 0;
}

Measured memory_bytes: 3808
#include <stdio.h>

int main(void){
	int _array[100];
	int i, n;
	scanf("%d", &n);
	i = n;
	while (i--)
		scanf("%d", &_array[i]);
	for (i = 0; i < n ; i++){
		if (i) printf(" ");
		printf("%d", _array[i]);
	}
	printf("\n");
	return 0;
}

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

int main(){

int n;
cin>>n;
string a;
cin>>a;
int cn=0;
for(int i=1;i<a.length();i++)
{
    if(a[i]!=a[i-1])
        cn++;

}
cout<<cn+1<<endl;
}


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

using namespace std;

vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}

#define ANTHRO(args...) {__anthro_begin(__LINE__); __anthro(split(#args, ',').begin(), args);}

inline void __anthro_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __anthro_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __anthro_out_var(T* val) { cerr << arrStr(val,2); } //Change the values in case you want to debug something
template<typename T> inline void __anthro_out_var(T val) { cerr << val; }
inline void __anthro(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __anthro(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __anthro_out_var(a);
    cerr << "; ";
    __anthro(++it, args...);
}
//Simple Debugger

#define ll long long
#define MOD 1000000007
#define EPS 1e-9
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
/*
    This is D.Unbalanced
*/

int main(){
    string s; cin>>s;
    for(auto& c:s) c-='a';
    vector<vector<int>> a(100010,vector<int> (26,0));
    bool flag=false;
    int k=0,st=0,en=0;
    for(int i=1;i<=s.length();i++){
        a[i]=a[i-1];
        a[i][s[i-1]]++;
        //ANTHRO(a[i-1],a[i],a[i][s[i-1]],a[i-2][s[i-1]]);
        if((i-2)>=0 && (a[i][s[i-1]]-a[i-2][s[i-1]])>=2){
            st=i-1;
            en=i;
            break;
        }
        else if((i-3)>=0 && (a[i][s[i-1]]-a[i-3][s[i-1]])>=2)
        {
            st=i-2;
            en=i;
        }
    }
    if(st==0&&en==0){
        cout<<-1<<" "<<-1;
    }
    else{
        cout<<st<<" "<<en;
    }
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    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;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
    // vector size : n + 1
    vector<mint> fact, ifact;
    // precaliculation O(n)
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        // 0! = 1;
        fact[0] = 1;
        // 1! = 0! * 1 ... n! = (n-1)! * n
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
        // 1/n! = n!^(-1)
        ifact[n] = fact[n].inv();
        // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    // combination O(1)
    // nCk = n! / (k! * (n-k)!)
    //     = n! * k!^(-1) * (n-k)!^(-1)
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};
/* function */
/* main */
int main(){
    string S;
    int K;
    cin >> K >> S;
    int N = S.size();
    combination c = combination(N + K);

    mint ans = 0;
    for (int i = 0; i <= K; i++) {
        mint now = mint(26).pow(K - i);
        now *= mint(25).pow(i);
        now *= c(N-1+i, N-1);
        ans += now;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 35628
#include<stdio.h>
int main(){
    int a,b,c;
    char op;
    for(;;){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?'){
            break;
        }
        else if(op=='+'){
            c=a+b;
        }
        else if(op=='-'){
            c=a-b;
        }
        else if(op=='/'){
            c=a/b;
        }
        else if(op=='*'){
            c=a*b;
        }
        
    printf("%d\n",c);
    }
    return 0;
}

Measured memory_bytes: 600
/*       Don't try to hack it :|

            _/﹋\_
            (҂`_´)
            <,︻╦╤─҉- - - - - - - - - - - - - - -
            _/﹋\_
*/
//@Yuvraj Garg

#include <bits/stdc++.h>

#define ull unsigned long long int
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define itr vi:iterator
#define vpll vector < pair<long long,long long> >
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define pdd pair<double, double>
#define retrun return // Bcoz of typing error :(
#define foo() cout << "Err\n"

#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)

using namespace std;  

void solve(int t){
    int n;
    cin >> n;
    vi v(n);
    int count = 0;
    rep(i, n) cin >> v[i];
    rep(i, n-2){
        vi tmp(3);
        rep(j, 3) tmp[j] = v[i+j];
        sort(all(tmp));
        if(tmp[1] == v[i+1]) count++;
    }
    cout << count;
}

int main(){

    // ios::sync_with_stdio(0);
    // cin.tie(0); cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int t, tmp = 0;
    // cin >> t;
    t = 1;
    while(tmp++ < t){
        solve(tmp-1);
        // cout << "\n";        
    }
    // cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 256
/*    
 *  eat_code    
 *  IIIT Allahabad
 */
#include <bits/stdc++.h>
//#include "pretty_print.h"
using namespace std;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define CONTAINS(a, x) (a.find(x) != a.end())
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define nl cout << endl
#define F first
#define S second

#define what_is(x) cout << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define CASET int ___T, case_n = 1; cin >> ___T; while (___T-- > 0) 


#define rep(it, st, en) for(ll it = st; it < en; it++)
#define rep1(it, st, en) for(ll it = st; it <= en; it++)
#define per(it, st, en) for(ll it = en - 1; it >= st; it--)

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef vector<vi> vvi;

ll INF = 1E9;
ll M = 1E9 + 7;

inline ll power (ll a,ll p){
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}

template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

int main() {
    boost;
    if(fopen("input.txt", "r")){
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    }
    string s;
    cin >> s;
    int n = SZ(s);
    n -= 8;
    rep(i, 0, n)cout << s[i];

    return 0;
}
//  Train Insane or Remain the same
 

Measured memory_bytes: 256
def func():
    N = int(input())
    data = [list(map(int, input().split())) for i in range(N)]

    now = [0, 0, 0]
    flg = True
    for t, x, y in data:
        dt = t - now[0]
        dx = abs(x-now[1])
        dy = abs(y-now[2])
        
        if dt == dx + dy or ((dt >= (dx + dy))and(dt - (dx + dy)) % 2 == 0):
            now[0] = t
            now[1] = x
            now[2] = y
        
        else:
            flg = False
            break
    
    if flg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    func()


Measured memory_bytes: 60120
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    L1 = []
    L2 = []
    for i in range(N):
        t = 0
        mint = 0
        for s in S[i]:
            if s == "(":
                t += 1
            else:
                t -= 1
            mint = min(mint, t)
        if t >= 0:
            L1.append((t, mint))
        else:
            t = 0
            mint = 0
            for j in range(len(S[i]) - 1, -1, -1):
                if S[i][j] == ")":
                    t += 1
                else:
                    t -= 1
                mint = min(mint, t)
            L2.append((t, mint))

    L1.sort(key=lambda x: x[1], reverse=True)
    L2.sort(key=lambda x: x[1], reverse=True)
    t1 = 0
    for l, m in L1:
        if t1 + m < 0:
            return False
        t1 += l
    t2 = 0
    for l, m in L2:
        if t2 + m < 0:
            return False
        t2 += l
    if t1 == t2:
        return True
    return False


if main():
    print("Yes")
else:
    print("No")


Measured memory_bytes: 215684
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int main(){
    int n, m; cin>>n>>m;
    vector<int> l(m), r(m);
    vector<int> imos(n+10, 0);
    for(int i=0; i<m; i++){
        cin>>l[i]>>r[i];
        imos[l[i]]++;
        imos[r[i]+1]--;
    }

    for(int i=0; i<n+5; i++){
        imos[i+1] += imos[i];
    }

    int ans=0;
    for(int i=0; i<n+5; i++){
        if(imos[i] == m) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
/**
* Copyright(c)
* Author : tiketiskte
**/
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long
#define PLL pair<ll, ll>
#define SZ(X) (int)X.size()
#define INF 0x3f3f3f3f

using namespace std;

const int maxn = 100 + 5;
int n;
ll a[maxn], ans;
int main(void)
{
    IOS
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    for(int i = 1;  i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            if(a[i] == a[j]) {
                continue;
            }
            for(int k = j + 1; k <= n; k++) {
                if(a[k] == a[j] || a[k] == a[i]) {
                    continue;
                }
                if(a[i] + a[j] > a[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    // system("pause");
    return 0;
}


Measured memory_bytes: 3652
n, x = map(int, input().split())
ng = [1, 2*n-1]
if x in ng:
    print("No")
else:
    print("Yes")
    tmp = [i for i in range(2, 2*n-1) if i != x]
    ans = tmp[:n-2] + [1, x, 2*n - 1] + tmp[n-2:]
    for item in ans:
        print(item)


Measured memory_bytes: 59888
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int x, y, a, b, c, z;
    cin >> x >> y >> a >> b >> c;
    int r[a];
    for (int i = 0; i < a; i++) cin >> r[i];
    sort(r, r + a);
    int g[b];
    for (int i = 0; i < b; i++) cin >> g[i];
    sort(g, g + b);
    vector<int> v;
    for (int i = a - 1; i >= a - x; i--) v.push_back(-r[i]);
    for (int i = b - 1; i >= b - y; i--) v.push_back(-g[i]);
    for (int i = 0; i < c; i++) {
        cin >> z;
        v.push_back(-z);
    }
    sort(v.begin(), v.end());
    long long res = 0;
    for (int i = 0; i < x + y; i++) res -= v[i];
    cout << res << "\n";
}

Measured memory_bytes: 3188
n, x = map(int, input().split())
a_l = list(map(int, input().split()))
a_l = sorted(a_l)
ans = 0
for a in a_l:
    x = x-a
    if x < 0:
        break
    ans += 1
if x > 0:
    ans -= 1
print(ans)

Measured memory_bytes: 9184
use std::cmp::min;
use std::collections::HashMap;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        s: [chars; h]
    }
    let mut ans = 10 * 1000;
    for i in 0..(1 << h) {
        let mut current: usize = 0;
        let mut r_group: HashMap<usize, usize> = HashMap::new();
        for j in 0..h {
            if i >> j & 1 == 1 {
                current += 1;
            }
            r_group.insert(j, current);
        }
        let mut counts: Vec<usize> = vec![0; current + 1];
        let mut res = current;
        let mut prev: i32 = -1;
        let mut j = 0;
        let mut ok = true;
        while j < w && ok {
            for l in 0..h {
                counts[r_group[&l]] += s[l][j].to_digit(10).unwrap() as usize;
                if counts[r_group[&l]] > k {
                    if j as i32 > prev + 1 {
                        res += 1;
                        prev = (j as i32) - 1;
                        counts = vec![0; current + 1];
                        j -= 1;
                        break;
                    } else {
                        ok = false;
                    }
                }
            }
            j += 1;
        }
        if ok {
            ans = min(ans, res);
        }
    }
    println!("{}", ans);
}

#[macro_export(local_inner_maccros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


Measured memory_bytes: 2228
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

int main()
{
    // cinだとスペース取れない
    // scanfだと変数をうまく用意しないと死ぬ
    // 一文字目スペースだと死ぬ
    string n = "";
    vector<string> x;
    bool flag;
    int k = 0;
    while (1)
    {
        char line[512];
        cin.getline(line, sizeof(line)); //スペースを含む入力を、ちぎらず受け付ける
                                         // cout << "input : " << line << endl;
        for (int i = 0; i < 256; i++)
        {
            if (line[i] == ' ')
            {
                line[i] = '0';
            }
        }
        n = line;
        if (n.at(0) == '.')
            break;
        vector<char> a;
        for (int i = 0; i < n.size(); i++)
        {
            char c = line[i];
            if (c == '(' || c == ')' || c == '[' || c == ']')
            {
                a.push_back(c);
            }
         }
        // for (auto i : a)
        // {
        //     cout << i << " ";
        // }
        flag = (a.size() + 1) % 2; // 1 == true
        int zerocnt = 0;
        if (flag && a.size() > 0)
        {
            for (int i = 0; i < a.size() - 1; i++)
            {
                if (a[i] != '0')
                {
                    for (int j = i + 1; j < a.size(); j++)
                    {
                        if ((a[i] == '(' && a[j] == ')') || (a[i] == '[' && a[j] == ']'))
                        {
                            a[i] = '0';
                            a[j] = '0';
                            zerocnt += 2;
                            if (zerocnt == a.size())
                                break;
                            j = a.size() - 1;
                            i = -1;
                        }
                        else if (a[j] == '0')
                        {
                            continue;
                        }
                        else
                        {
                            j = a.size() - 1;
                        }
                    }
                }
            }
        }
        // ここも変更
        if (flag && zerocnt == a.size())
        {
            x.push_back("yes");
        }
        else
        {
            x.push_back("no");
        }
        k++;
    }
    for (int i = 0; i < x.size(); i++)
    {
        cout << x[i] << endl;
    }
}



Measured memory_bytes: 3396
//#pragma GCC optimize("O2147483647")
//#pragma GCC optimize("inline")
//#pragma GCC optimize("-ffast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("inline-small-functions")
//#pragma GCC optimize("-finline-small-functions")
//#pragma GCC optimize("-fexpensive-optimizations")
//#pragma GCC optimize("-funsafe-loop-optimizations")
//#pragma GCC optimize("inline-functions-called-once")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimze("fast-math")
//#define GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include "testlib.h"
#define rep(i, j, k) for (int i = (int)(j); i<(int)(k); i++)
#define per(i, j, k) for (int i = (int)(k); i>=(int)(j); i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)((x).size())
#define fprd fprintf(stderr,
#define fi first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
//#define int ll
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int N=2e5+5;
ll n;

int main() {
    scanf("%lld",&n);
    ll num=1,ans=0;
    while(n>0) {
        ans+=num;
        num*=2;
        n/=2;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256