akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_9_D
{
    class Program
    {
        static IEnumerable<string> ReadLines()
        {
            while (true)
            {
                yield return Console.ReadLine();
            }
        }


        static IEnumerable<string[]> ReadSplitWords(IEnumerable<string> strings, char splitChar)
        {
            foreach (var n in strings)
            {
                yield return n.Split(splitChar);
            }                
        }


        static void Print(string str, int startIndex, int endIndex)
        {
            for (var i = startIndex; i <= endIndex; ++i)
            {
                Console.Write(str[i]);
            }
            Console.WriteLine();
        }


        static string Reverse(string str, int startIndex, int endIndex)
        {
            var result = str.Substring(0, startIndex);
            for (var i = startIndex; i < str.Length; ++i)
            {
                if (i <= endIndex) 
                {
                    result += str[endIndex - (i - startIndex)];
                }
                else
                {
                    result += str[i];
                }
            }
            return result;
        }


        static string Replace(string str, int startIndex, int endIndex, string add)
        {
            var result = str.Substring(0, startIndex) + add;
            if ((endIndex + 1) < str.Length)
            {
                result += str.Substring(endIndex + 1);
            }
            return result;
        }


        static bool IsValidArgment(int strLength, int startIndex, int endIndex)
        {
            if (startIndex < 0 || strLength <= startIndex) return false;
            if (endIndex < 0 || strLength <= endIndex) return false;
            if (endIndex < startIndex) return false;
            return true;
        }


        static void Main(string[] args)
        {
            var word = Console.ReadLine();
            var count = int.Parse(Console.ReadLine());

            foreach (var n in ReadSplitWords(ReadLines(), ' ').Take(count))
            {
                var arg1 = int.Parse(n[1]);
                var arg2 = int.Parse(n[2]);
                var arg3 = n.Length < 4 ? null : n[3];

                if (IsValidArgment(word.Length, arg1, arg2) == false)
                {
                    continue;
                }

                switch (n[0]) 
                {
                    case "print": Print(word, arg1, arg2); break;
                    case "reverse": word = Reverse(word, arg1, arg2); break;
                    case "replace": word = Replace(word, arg1, arg2, arg3); break;
                }

            }
            
        }
    }
}

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

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector< set< int > > is(26);
    for (int i = 0; i < n; i++) {
        is.at(s.at(i) - 'a').insert(i);
    }
    for (int qi = 0; qi < q; qi++) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            --i;
            is[s.at(i) - 'a'].erase(i);
            s.at(i) = c;
            is[s.at(i) - 'a'].insert(i);
        } else {
            int l, r;
            cin >> l >> r;
            --l;
            int ans = 0;
            for (int j = 0; j < 26; j++) {
                auto it = is.at(j).lower_bound(l);
                if (it != is.at(j).end() && *it < r) {
                    ++ans;
                }
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

vector <ll> dp(50, -1);

ll fib(ll n) {
  if (n==0 || n==1) {
    dp.at(n) = 1;
    return dp.at(n);
  }
  if (dp.at(n) != -1) {
    return dp.at(n);
  }
  dp.at(n) = fib(n-1) + fib(n-2);
  return dp.at(n);
}

int main() {
  ll n;
  cin >> n;
  cout << fib(n) << endl;
}


Measured memory_bytes: 3112
#include<stdio.h>
int main(void){
  int a,b,c,d,sum=0;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  sum+=(a<b)?a:b;
  sum+=(c<d)?c:d;
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const long long maxn=200010LL;
long long n,d,a,xx,yy,res=0LL,pre[maxn];
pair<long long,long long> v[maxn];
long long num(long long x)
{
	long long ans=x/a;
	if(x%a) ++ans;
	return ans;
}
int main()
{
	cin>>n>>d>>a;
	long long ld=d*2+1; 
	for(long long i=1LL;i<=n;i++) cin>>v[i].first>>v[i].second;
	sort(v+1LL,v+1LL+n);
	v[n+1]=make_pair(1e18,1e18);
	for(long long i=1LL;i<=n;i++)
	{
		pre[i]+=pre[i-1];
		long long di=v[i].second-pre[i];
		if(di<=0LL) continue;
		long long tim=num(di);
		res+=tim;
		long long att=tim*a;
		long long ind=upper_bound(v+1LL,v+2LL+n,make_pair(v[i].first+ld,0LL))-v;
		pre[i]+=att;
		pre[ind]-=att;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int n;

void dfs(string s, char mx) {
	if (s.size() == n) {
		cout << s << endl;
		return;
	}
	for (char c = 'a'; c <= mx + 1; c++) {
		string ns = s + c;
		dfs(ns, max(mx, c));
	}
}

int main() {
	cin >> n;
	dfs("", 'a'-1);
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
//#define ll long long
using namespace std;
int a[1001];
const double PI = 3.141592653589793238462643383279;
int main()
{
	double a, b, x, v1, v2;
	double jd;
	double h;
	cin >> a >> b >> x;
	v1 = a * a * b;
	if (v1 - (2 * x) >= 1e-6)
	{
		h = x / (a * b) * 2.0;
		jd = b / h;
		jd = (atan(jd) / PI * 180.0);
		printf("%.10lf\n", jd);
		return 0;
	}
	v2 = (v1 - x) * 2.0;
	h = v2 / (a * a);
	jd = h / a;
	jd = (atan(jd)/PI*180.0);
	printf("%.10lf\n",jd);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
long long ab(long long a,long long b){
 long long c=a-2*b;
 if(c>=0)
  return c;
 return -c;
 }
long long a[200010],n,mx,mx1,mx2,ans;
int main(){
cin>>n;
for(int i=0;i<n;i++){
 cin>>a[i];
 mx+=a[i];}
ans=10000000000;
for(int i=0;i<n-1;i++){
 mx1+=a[i];
 ans=min(ans,ab(mx,mx1));
 }
cout<<ans;
system("pause");
return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> a(n + 1);
	for (int i = 0; i < n; ++i) {
		if (s[i] == '<') {
			a[i + 1] = max(a[i + 1], a[i] + 1);
		}
	}
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == '>') {
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}
	ll ans = 0;
	rep(i, n + 1) ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2820
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<int64_t> vec;

static inline int32_t parent(uint32_t index)
{
  if (index < 1) return -1;
  return (index - 1) / 2;
}

static inline uint32_t left(uint32_t index)
{
  return 2 * index + 1;
}

static inline uint32_t right(uint32_t index)
{
  return 2 * index + 2;
}

int32_t main()
{
  uint32_t num;
  cin >> num;

  for (uint32_t i = 0; i < num; i++) {
    int64_t val;
    cin >> val;
    vec.push_back(val);
  }

  for (uint32_t i = 0; i < num; i++) {
    cout << "node " << i + 1 << ": ";
    cout << "key = " << vec[i] << ", ";
    if (parent(i) >= 0) {
      cout << "parent key = " << vec[parent(i)] << ", ";
    }
    if (left(i) < vec.size()) {
      cout << "left key = " << vec[left(i)] << ", ";
    }
    if (right(i) < vec.size()) {
      cout << "right key = " << vec[right(i)] << ", ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  bool h = true;
  for (int i = 0; i < 3; i++) {
    if (s[i] == s[i+1]) {
      h = false;
    }
  }
  if (h) {
    cout << "Good" << endl;
  } else {
    cout << "Bad" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    int res=0;
    int maxi=0;
    for(int i=0;i<n;i++){
        if(i==0){res++;maxi=v[i];continue;}
        if(v[i]>=maxi)res++;
        maxi=max(maxi,v[i]);
    }
    cout<<res<<endl;
    return 0;
    }


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

int main () {
	int sn, tn, t, l, r, m, c = 0;
	cin >> sn;
	int *s = new int[sn];
	for (int i = 0; i < sn; i++)
		cin >> s[i];
	cin >> tn;
	for (int i = 0; i < tn; i++) {
		cin >> t;
		l = 0;
		r = sn;
		while(l < r) {
			m = (l + r) / 2;
			if (s[m] == t) {
				c++;
				break;
			}
			else if (t < s[m])
				r = m;
			else
				l = m + 1;
		}
	}
	cout << c << endl;
	return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;

constexpr int inf = 1ll<<62;
constexpr int mod = 1e9+7;

main(){
  int n,x; cin >> n >> x;
  vi a(n); rep(i,n) cin >> a[i];
  sort(all(a));
  int res = 0;
  rep(i,n){
    if(x >= a[i]){
      x -= a[i];
      res++;
    }
  }
  if(res == n and x) res--;
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

int main(void){
    int s, w;
    cin >> s >> w;
    cout << (w >= s? "unsafe":"safe");
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    for(ll i = k; i < n; i++){
        if(a[i-k]<a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4848
Sa = list(input())
Sb = list(input())
Sc = list(input())
dic = {"a": Sa, "b": Sb, "c": Sc}
hiku = "a"
while True:
    try:
        sasareta = dic[hiku].pop(0)
    except IndexError:
        print(hiku.upper())
        break
    hiku = sasareta


Measured memory_bytes: 38384
import sys
n, p = map(int, input().split())
s = input()
if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if int(s[i])%p == 0:
            ans+=i+1
    print(ans)
    sys.exit()

res = 0
cnt = [0]*p
for i in range(n):
    res = (res+int(s[-i-1])*pow(10, i, p))%p
    cnt[res]+=1
ans = 0
for c in cnt:
    ans+=c*(c-1)//2
ans+=cnt[0]
print(ans)





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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<typename T>
class WeightedUnionFind {
    int N;
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    vector<T> weight;

public:
    explicit WeightedUnionFind(int n) : N(n + 1) {
        par.resize(n + 1);
        rank.resize(n + 1, 0);
        weight.resize(n + 1, 0);
        size.resize(n + 1, 1);
        for (int i = 0; i < n + 1; ++i) {
            par[i] = i;
        }
    }

    int find(int x) {
        if (par[x] == x) return x;
        int y = find(par[x]);
        weight[x] += weight[par[x]];
        par[x] = y;
        return y;
    }

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

    T get_weight(int x) {
        find(x);
        return weight[x];
    }

    /**
     * x -> y の重みの差分
     */
    T diff(int x, int y) {
        return get_weight(y) - get_weight(x);
    }

    /**
     * get_weight(y) - get_weight(x) = w となるように結合
     * @return true:　結合成功, false: すでに結合済み
     */
    bool unit(int x, int y, T w) {
        w += get_weight(x);
        w -= get_weight(y);
        x = find(x);
        y = find(y);
        if (x == y) return false;
        // 木の高さの低い方から高い方へ繋げる
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        weight[y] = w;
        size[x] += size[y];
        return true;
    }
};

void Main() {
    int N, M;
    cin >> N >> M;
    WeightedUnionFind<ll> weightedUnionFind(N);
    rep(i, M) {
        int l, r;
        ll d;
        cin >> l >> r >> d;
        if (weightedUnionFind.is_same(l, r)) {
            if (weightedUnionFind.diff(l, r) != d) {
                cout << "No" << '\n';
                return;
            }
        }else{
            weightedUnionFind.unit(l, r, d);
        }
    }
    cout << "Yes" << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2176
n = int(input())
l = sorted(map(int, input().split()))
ans=0
for i in range(n):
  for j in range(i):
    for k in range(j):
      if l[i]!=l[j]and l[k]!=l[j]and l[k]!=l[i]:
        if l[k] +l[j] > l[i]:
          ans+=1
print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> dp(n, vector<ll>(n));
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        dp[i][i] = a[i];
    }
    for (int i = n-2; i >= 0; i--) {
        for (int j = i+1; j < n; j++) {
            dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
        }
    }
    cout << dp[0][n-1];
  return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, m, k;
	cin>>n>>m>>k;

	FOR (i, 0, n + 1)
	{
		FOR (j, 0, m + 1)
		{
			int res = j * (n - i) + i * (m - j);
			if (res == k)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}

	cout<<"No"<<endl;
	return 0;
}


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

int n;
long long int k;
int cnt[40];

long long int dfs(int i, int f) {
    if(i < 0){
        return 0;
    }
    long long int m = 1LL << i;
    if(f){  // greedy
        return dfs(i-1, 1) + m*max(n - cnt[i], cnt[i]);
    }else{  // not greedy
        if(k >> i & 1){
            return max(dfs(i-1, 1) + m*(cnt[i]),
                       dfs(i-1, 0) + m*(n - cnt[i]));
        }else{
            return dfs(i-1, 0) + m*(cnt[i]);
        }
    }
}

int main() {
    // input
    cin >> n >> k;
    for(int i=0;i<n;i++){
        long long int a; cin >> a;
        for(int j=0;j<40;j++){
            cnt[j] += a >> j & 1;
        }
    }
    // output
    cout << dfs(39, 0) << endl;
    return 0;
}


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

const ll MOD = 1000000007;

int main(void) {
  ll N;
  cin >> N;
  vector<vector<ll>> A(N, vector<ll>(N));
  REP(i, 0, N) REP(j, 0, N) cin >> A[i][j];

  vector<vector<ll>> dp(N + 1, vector<ll>(1 << N, 0));
  dp[0][0] = 1;

  REP(i, 0, N) REP(s, 0, 1 << N) if (__builtin_popcount(s) == i) {
    REP(j, 0, N) if (A[i][j] == 1) {
      dp[i + 1][s | (1 << j)] += dp[i][s];
      dp[i + 1][s | (1 << j)] %= MOD;
    }
  }

  cout << dp[N][(1 << N) - 1] << endl;
}

Measured memory_bytes: 377216
//q1
// pactice
 
#pragma warning(disable:4996)
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX_NUMBER 100000
#define MAX_STRING 1000000

	int anNumber[MAX_NUMBER];
	int anMinusNumber[MAX_NUMBER];
	char sInput[MAX_STRING+1]="";

int main() {
 
	char* psInput=NULL;
	int nNumberOfNumber=0;
	int nQuotaNumber=0;

	int nMinChamp=1100000000;
	int nMinTemp=1100000000;
	int nMPChangedPos=-1;
	int nMinusCount=0;
	int nPlusCount=0;

	int i=0;
	int nTemp=0;
	int nPatternNo=0;

	for(i=0;i<MAX_NUMBER;i++){
		anNumber[i]=0;
	}
	// read line 1
	gets(sInput);
	psInput = strtok(sInput," ");
	nNumberOfNumber=atoi(psInput);
	psInput = strtok(NULL," ");
	nQuotaNumber=atoi(psInput);

	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<nNumberOfNumber;i++){
		nTemp=atoi(psInput);
		anNumber[i]=nTemp;
		if(nTemp<0){
			nMinusCount++;
		} else if (nTemp>0){
			nPlusCount++;
			if(nMPChangedPos==-1){
				if(nMinusCount>0){
					nMPChangedPos=i;
				}
			}
		} else {
			nQuotaNumber--;
		}
		psInput = strtok(NULL," ");
	}
	if (nQuotaNumber==0){
		printf("0\n");
	} else {
		if (nMinusCount==0&&nPlusCount>0){
			printf("%d\n",abs(anNumber[nQuotaNumber-1]));
		} else if (nMinusCount>0&&nPlusCount==0){
			printf("%d\n",abs(anNumber[nNumberOfNumber-nQuotaNumber]));
		} else {
			for(nPatternNo=0;nPatternNo<nQuotaNumber;nPatternNo++){
				if(nPatternNo==0){
					//左にだけ走る
					if(nMinusCount>=nQuotaNumber){
						nMinTemp=abs(anNumber[nMPChangedPos-nQuotaNumber]);
						if(nMinTemp<nMinChamp){
							nMinChamp=nMinTemp;
						}
					}
					//右にだけ走る
					if(nPlusCount>=nQuotaNumber){
						nMinTemp=abs(anNumber[nQuotaNumber-1+nMPChangedPos]);
						if(nMinTemp<nMinChamp){
							nMinChamp=nMinTemp;
						}
					}
				} else {
					//左に走ってから右に折り返す
					if(nMinusCount>=nPatternNo&&nPlusCount>=(nQuotaNumber-nPatternNo)){
						//左に走った分
						nMinTemp=abs(anNumber[nMPChangedPos-nPatternNo]*2);
						//右に走った分
						nMinTemp=nMinTemp+abs(anNumber[(nQuotaNumber-nPatternNo)-1+nMPChangedPos]);
						if(nMinTemp<nMinChamp){
							nMinChamp=nMinTemp;
						}
					}
					//右に走ってから左に折り返す
					if(nPlusCount>=nPatternNo&&nMinusCount>=(nQuotaNumber-nPatternNo)){
						//右に走った分
						nMinTemp=abs(anNumber[nPatternNo-1+nMPChangedPos]*2);
						//左に走った分
						nMinTemp=nMinTemp+abs(anNumber[nMPChangedPos-(nQuotaNumber-nPatternNo)]);
						if(nMinTemp<nMinChamp){
							nMinChamp=nMinTemp;
						}
					}
				}
			}
			printf("%d",nMinChamp);
		}
	}

	return 0;
}



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

int main(){
	int N;
	cin >> N;
	int H[N];
	for(int i=0;i<N;i++)cin>>H[i];
	
	int maxv=0;
	int ans=0;
	for(int i=0;i<N;i++){
		if(H[i]>=maxv)ans++;
		maxv=max(maxv,H[i]);
		}	
	cout << ans<<endl;
}


Measured memory_bytes: 256
def main():
    w,h=map(int,input().split())
    if w==0 and h==0 : exit()
    #接続リストを作る
    con=[[[] for j in range(w)] for _ in range(h)]

    token=0 
    for i in range(2*h-1):
        lst=input().split()
        if token==0 :
            for j,x in enumerate(lst):
                if x=="0":
                    con[i//2][j].append((i//2,j+1))
                    con[i//2][j+1].append((i//2,j))
            token=1
        else :
            for j,x in enumerate(lst):
                if x=="0" :
                    con[(i+1)//2][j].append(((i-1)//2,j))
                    con[(i-1)//2][j].append(((i+1)//2,j))
            token=0
        #print(i,con)
    
    seen=[[-1]*w for _ in range(h)]
    seen[0][0]=1
    bfs_new=[(0,0)]
    token=1
    
    while bfs_new:
        bfs_old=bfs_new[:]
        bfs_new=[]
        token+=1
        for ax,ay in bfs_old:
            for bx,by in con[ax][ay]:
                if seen[bx][by]>=0 : continue
                seen[bx][by]=token
                bfs_new.append((bx,by))
    
    if seen[h-1][w-1]==-1 : print(0)
    else : print(seen[h-1][w-1])

while 1:
    main()


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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

bool f(string a,string b)
{
	if(a.size()<
	
	b.size())return 0;
	else if(a.size()>b.size())return 1;
	return a>b;
	
}
int main()
{
	
	string a,b;
	cin>>a>>b;
	if(a==b)cout<<"EQUAL"<<endl;
else	if(f(a,b))cout<<"GREATER"<<endl;
else	cout<<"LESS"<<endl;
}



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

int main(){
  int a,b,c,ans,m;
  ans=0;
  cin>>a>>b>>c;
  if (a%2==b%2&&a%2==c%2){
    m=max(a,max(b,c));
    ans=abs(m-a)/2+abs(m-b)/2+abs(m-c)/2;
  }
  else if (a%2==b%2){
    m=max(a+1,max(b+1,c));
    ans=1+abs(m-a)/2+abs(m-b)/2+abs(m-c)/2;
  }
  else if (a%2==c%2){
    m=max(a+1,max(b,c+1));
    ans=1+abs(m-a)/2+abs(m-b)/2+abs(m-c)/2;
  }
  else if (b%2==c%2){
    m=max(a,max(b+1,c+1));
    ans=1+abs(m-a)/2+abs(m-b)/2+abs(m-c)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int,vector<int>,greater<int>> que;


llint n,x;


void solve(){
	cin >> n >> x;
	llint a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;i++){
		if(i==n-1){
			if(x==a[i])ans++;
			break;
			}
		if(x>=a[i]){
			x-=a[i];
			ans++;
			}
		}
		cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
N = int(input())

As = sorted(map(int, input().split()), reverse=True)

score = As[0]
counter = 0
index = 1

for i in range(2, N):
  score += As[index]
  if counter == 0:
    counter += 1
  else:
    counter -= 1
    index += 1
    
print(score)



            
         

Measured memory_bytes: 105040
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-7)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define reo(i,n) for(int (i) = 1 ; (i) <= (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(n,i) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem0(x) memset(x,0,sizeof(x))
#define vec vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'a')
#define itoc(c) (char)(c+'a')
#define itn int
#define pri_que priority_queue
#define pp(x,y) pb(H{x,y})
#define ppp(x,y,z) pb(Q(x,y,z))
#define cyes cout<<"Yes\n"
#define cno cout<<"No\n"
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
const vec<int>dx{ 0,0,-1,1 }, dy{ 1,-1,0,0 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
ll read() { ll u, k = scanf("%lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 600000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------------------
int n;
signed main() {
	if (read() == read()) cyes;
	else cno;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

// 木じゃないならたかだか1個

struct edge{
    int to;ll s;
    edge(int to,ll s):to(to),s(s){}
    edge(){}
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,m;cin>>n>>m;
    vector<vector<edge>> g(n);
    rep(i,m){
        int u,v;ll s;cin>>u>>v>>s;u--,v--;
        g[u].push_back(edge(v,s));
        g[v].push_back(edge(u,s));
    }

    vector<ll> con(n,0);// 定数項
    vector<bool> pos(n);// rの符号が正か

    vector<bool> check(n,false);
    ll r=-1;
    function<void(int,int)> dfs=[&](int pre,int now){
        // cout<<pre<<" -> "<<now<<endl;
        for(auto &e:g[now]){
            if(e.to==pre) continue;
            if(check[e.to]){
                // 成立するかチェック
                // 式now + 式to = e.sが成立すればrをチェック
                if(pos[now]!=pos[e.to]){
                    if(con[now]+con[e.to]!=e.s){
                        cout<<0<<endl;
                        exit(0);
                    }
                }else{
                    // 2*(±r) + con[now]+con[e.to]=e.s
                    ll tmp=e.s-con[now]-con[e.to];
                    if(tmp%2!=0){
                        cout<<0<<endl;
                        exit(0);
                    }
                    ll rtmp=tmp/2;
                    if(!pos[now]) rtmp=-rtmp;
                    if(rtmp<=0){
                        cout<<0<<endl;
                        exit(0);
                    }
                    // 既存のrと一致するか
                    if(r<0){
                        r=rtmp;
                    }else{
                        if(r!=rtmp){
                            cout<<0<<endl;
                            exit(0);
                        }
                    }
                }
            }else{
                // go
                ll c=e.s-con[now];
                con[e.to]=c;
                pos[e.to]=(1^pos[now]);
                check[e.to]=true;
                dfs(now,e.to);
            }
        }
    };

    con[0]=0;
    pos[0]=true;
    check[0]=true;
    dfs(-1,0);

    // debug(pos);
    // debug(con);
    

    if(r<0){
        // 未決定なら範囲を調べる
        ll lw=1,hi=LINF;
        rep(i,n){
            if(pos[i]){
                // lw
                // r+con[i]>=1
                chmax(lw,1-con[i]);
            }else{
                // hi
                // -r+con[i]>=1
                chmin(hi,con[i]-1);
            }
        }
        cout<<max(0ll,hi-lw+1)<<endl;
    }else{
        //決定済みならそれ1個が達成できるかを調べる
        bool f=true;
        rep(i,n){
            ll res=con[i]+(pos[i]?r:-r);
            if(res<1) f=false;
        }
        cout<<f<<endl;
    }
    return 0;
}


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

long long N;
long long cnt=0;

int main(){
	scanf("%lld",&N);
	if(N%2==1){
		puts("0");
		return 0;
	} 
	N/=2;
	while(N){
		cnt+=N/5;
		N/=5;
	}
	printf("%lld\n",cnt);
	return 0;
}

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

int main()
{char s[11];
int i,cnt=0;
    scanf("%s",s);
    if(s[0]=='A'){
        for(i=2;i<= strlen(s)-2;i++){
            if(s[i]=='C'){
                cnt++;
            }
        }
        if(cnt>1||cnt==0){
            printf("WA");
        }else {
            cnt=0;
            for(i=0;i<=strlen(s)-1;i++){
            if((s[i]>='A')&&(s[i]<='Z')){
                cnt++;
            }    
            }
            if(cnt!=2){
                printf("WA");
            }else{
                printf("AC");
            }
        }
        }else {
        printf("WA");
    }

    return 0;
}



Measured memory_bytes: 128
use std::io;
use std::str::FromStr;

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
      a
    } else {
      gcd(b, a % b)
    }
  }
  

fn main() {
    let (n, x) = input_tuple();
    let x_vec = input_vec();
    let mut whole_gcd =  (x_vec[0] - x as i64).abs() as u64;
    for i in 0..n {
        whole_gcd = gcd(whole_gcd, (x_vec[i as usize] - x as i64).abs() as u64);
    }
    println!("{}", whole_gcd);
}


Measured memory_bytes: 3936
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();

		if (H > W) {
			if (N%H ==0) {
				System.out.println(N/H);
			} else {
				System.out.println((N/H) + 1);
			}
		} else {
			if (N%W ==0) {
				System.out.println(N/W);
			} else {
				System.out.println((N/W) + 1);
			}

		}

	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

ll d[11][1001];
ll s[11][1001];
ll ss[11][11][1001];

int main(){
    ll H,W,K; cin>>H>>W>>K;
    ll ans=INF;
    rep(i,H) {
        string S; cin>>S;
        rep(j,W) {d[i][j]=S.at(j)-'0'; s[i][j+1]=s[i][j]+d[i][j];}
    }
    rep(i,H) rep(j,W+1) ss[i][i][j]=s[i][j];
    rep(i,H-1) REP(k,i+1,H) rep(j,W+1) ss[i][k][j]=s[k][j]+ss[i][k-1][j];

    /*rep(i,H) {
        rep(j,W+1) cout<<ss[1][i][j]<<' ';
        cout<<endl;
    }*/

    ll HH=1<<(H-1);
    rep(i,HH){
        ll Co=0;
        vec An;
        An.pb(0);
        rep(j,H-1) {
            if(1<<j & i) {
                Co++;
                An.pb(j+1);
            }
        }
        An.pb(H);
        //cout<<Co<<' '<<An.size()-2<<endl;
        ll F=An.size()-1;
        ll memory=0;
        rep(j,W+1){
            bool okay=true;
            bool ikeru=true;
            rep(k,F) if(ss[An.at(k)][An.at(k+1)-1][j]>ss[An.at(k)][An.at(k+1)-1][memory]+K) okay=false;
            if(!okay){
                Co++;
                memory=j-1;
                
                rep(k,F) if(ss[An.at(k)][An.at(k+1)-1][j]>ss[An.at(k)][An.at(k+1)-1][memory]+K) ikeru=false;
            }
            if(!ikeru) {Co=INF; break;}
        }
        ans=min(Co,ans);
        //rep(j,F+1) cout<<An.at(j)<<' ';
        //cout<<Co<<endl;

    }
    cout<<ans<<endl;

}

Measured memory_bytes: 896
r,c=map(int,input().split())
a = [ [0]*(c+1) for i in range(0, r+1) ]
for i in range(0, r):
    a[i] = list(map(int, input().split()))
    a[i].append(sum(a[i]))
    for j in range(0, len(a[i])):
        a[r][j] += a[i][j]
    print(" ".join(map(str, a[i])))
print(" ".join(map(str, a[r])))

Measured memory_bytes: 7840
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

bool check(string &s, char &g){
    
    for(int i=0; i<s.size(); i++)
        if(s[i]!=g) return false;
    return true;
}

int main(){
    string S; cin >> S;
    int ans = INF;
    for(int i=0; i<26; i++){
        char g = 'a' + i;
        string C = S;
        int cnt = 0;
        while(!check(C, g)){
            cnt++;
            for(int j=0; j<C.size()-1; j++){
                
                if(C[j]!=g && C[j+1]==g) C[j] = g;
            }
            C.pop_back();
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		if(N%2!=0)ans = ans+1;
		ans += N/2;
		System.out.println(ans);
	}
}


	

Measured memory_bytes: 23764
#include <string.h>
#include <stdio.h>
	int main(void) {


		int a, b;
		scanf("%d %d", &a, &b);
		if (a > b) printf("a > b\n");
		else if (a < b) printf("a < b\n");
		else printf("a == b\n");

    return 0;
}

Measured memory_bytes: 580
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;




signed main(){
	IOS;

	string s; 
	cin >> s;
	if (s == "ARC")cout << "ABC";
	else cout << "ARC";
	
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    for(char i = 'a';i <= 'z'; i++){
        if(s.find(i) == std::string::npos){
            cout << i << endl;
            return 0;
        } 
    }
    cout << "None"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;

int main()
{
    int b[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> b[i][j];
        }
    }

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (b[i][j] == num) {
                    b[i][j] = 0;
                }
            }
        }
    }

    bool isBingo = false;
    for (int i = 0; i < 3; i++) {
        if (b[i][0] + b[i][1] + b[i][2] == 0) {
            isBingo = true;
        }
    }

    for (int i = 0; i < 3; i++) {
        if (b[0][i] + b[1][i] + b[2][i] == 0) {
            isBingo = true;
        }
    }

    if (b[0][0] + b[1][1] + b[2][2] == 0 || b[2][0] + b[1][1] + b[0][2] == 0) {
        isBingo = true;
    }

    if (isBingo) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    sc.nextLine();
    String line = sc.nextLine();
    Queue<Card> queue = new PriorityQueue<>();
    for (String s : line.split(" ")) {
      queue.add(new Card(Integer.parseInt(s), 1));
    }
    for (int i = 0; i < m; i++) {
      int b = sc.nextInt();
      int c = sc.nextInt();
      queue.add(new Card(c, b));
    }
    long sum = 0;
    int capacity = n;
    while (queue.size() != 0 && capacity > 0) {
      Card card = queue.poll();
      int num = card.num;
      if (num > capacity) num = capacity;
      sum += (long) card.no * (long) num;
      capacity -= num;
    }
    System.out.println(sum);
  }

  public static class Card implements Comparable<Card> {
    public final int no;
    public final int num;
    public Card(int no, int num) {
      this.no = no;
      this.num = num;
    }
    @Override
    public int compareTo(Card card) {
      return card.no - this.no;
    }
    @Override
    public String toString() {
      return String.format("No: [%d], Num: [%d]", no, num);
    }
  }
}

Measured memory_bytes: 101240
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A,B;
LL S[100002];
LL dp[100002];
LL MOD=1000000007;

const int MAX_N=100001;
LL bit[MAX_N+1];

LL sum(int i){
    LL s=0;
    while(i>0){
       s=(bit[i]+s+MOD)%MOD;
       i-=(i&-i);
    }
    return s;
}
void add(int i,LL x){
     while(i<=N+1){
        bit[i]=(bit[i]+x+MOD)%MOD;
        i+=(i&-i);
     }
}

int main(){
        REP(i,100002){
            dp[i]=0;
        }
        dp[0]=1;
	cin>>N;
	cin>>A>>B;
	if(A>B){
	   LL temp=A;
	   A=B;
	   B=temp;
	}
	S[0]=-1000000000000000001;
	REP(i,N){
	    cin>>S[i+1];
	}
	//A+S[i]>S[i+2]は解なし
	REP(i,N-1){
	    if(A+S[i]>S[i+2]){
	       cout<<0<<endl;
	       return 0;
	    }
	}
	
	int p=0;
	int s0=0;
	add(1,1);
	REP(i,N){
	   //S[i+1]をyに振り分ける時
	   int pp=((upper_bound(S,S+N+1,S[i+1]-B))-S);
	   //cout<<pp<<endl;
	   //REP(j,pp){
	   //    dp[i+1]+=dp[j];
	   //}
	   if(0<pp){
	      dp[i+1]=sum(pp)%MOD;
	      add(i+1+1,dp[i+1]);
	   }
	   //S[i+1]をxに振り分ける時
	   if(S[i+1]-S[i]<A){
	   //cout<<"aaa"<<endl;
	      for(int j=s0;j<=i-1;j++){
	         add(j+1,-dp[j]);
	         dp[j]=0;
	      }
	      s0=i-1;
	   }
	   //REP(j,i+2){
	   //    cout<<dp[j]<<endl;
	   //}
	   //cout<<endl;
	}
	LL ans=0;
	REP(i,N+1){
	    ans=(ans+dp[i])%MOD;
	}
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 2560
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

bool chmax(int &a,int b){if(a<b){a=b;return 0;}return 1;}
bool chmin(int &a,int b){if(a>b){a=b;return 0;}return 1;}

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s,t;
  cin>>s>>t;
  int xs=s.size(),xt=t.size();
  vec2(dp,xs+1,xt+1);//dp[i][j]:=sのi,tのjまでの共通部分列の長さ
  rep(i,xs+1)rep(j,xt+1){
    if(i>0) chmax(dp[i][j],dp[i-1][j]);
    if(j>0) chmax(dp[i][j],dp[i][j-1]);
    if(i>0 && j>0 && s[i-1]==t[j-1]) chmax(dp[i][j],dp[i-1][j-1]+1);
  }
  //cout<<dp[4][5]<<endl;
  string ans ="";
  int cnt=dp[xs][xt];
  int i=xs,j=xt;
  while(cnt>0){
  	if(dp[i][j]==dp[i][j-1]) j --;
    else if(dp[i][j]==dp[i-1][j]) i --;
    else{i--;ans =s[i]+ans;j--;cnt --;}
  }
  cout<<ans<<'\n';
}


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

#define int long long
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int H, W;
  cin >> H >> W;

  char s[H][W];
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      cin >> s[i][j];
    }
  }

  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      if ( s[i][j] == '.' ) continue;
      bool is_colored = false;      
      for ( int k = 0; k < 4; k++ ) {
	int x = j+dx[k], y = i+dy[k];
	if ( x < 0 || y < 0 || x >= W || y >= H ) continue;
	if ( s[y][x] == '#' ) {
	  is_colored = true;
	  break;
	}
      }

      if ( !is_colored ) {
	cout << "No" << endl;
	return 0;	
      }
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <fstream>
#include <sstream>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <vector>
#include <cassert>
#include <cctype>
using namespace std;

const int MAXN=10000;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;

    return 0;
}


Measured memory_bytes: 256
/*
 *  Author : Jun_SH
 *  Solution for ABC 140 F
 */
#include<bits/stdc++.h>
#define int long long
#define sd(a) scanf("%lld",&a)
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=(1<<18)+10;
multiset<int>a;
main(){
    int n,x;
    sd(n);
    for(int i=1;i<=(1<<n);++i){
        sd(x);
        a.insert(-x);
    }
    vector<int>tmp;
    tmp.emplace_back(*a.begin());
    a.erase(a.begin());
    for(int i=0;i<n;++i){
        vector<int>contain;
        for(auto j:tmp){
            auto pos=a.upper_bound(j);
            if(pos==a.end()){
                puts("No");
                return 0;
            }
            a.erase(pos);
            int num=*pos;
            contain.emplace_back(num);
        }
        for(auto j:contain){
            tmp.emplace_back(j);
        }
        sort(tmp.begin(),tmp.end());
    }
    puts("Yes");
}


Measured memory_bytes: 15432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
typedef double D;     
typedef complex<D> P;  
typedef pair<P, P> L;  
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) { return (conj(a)*b).Y;}
P proj(P a1, P a2, P p) {
  return a1 + dot(a2-a1,p-a1)/norm(a2-a1)*(a2-a1);
}
D distLP(P a1, P a2, P p) {
  return abs(proj(a1, a2, p) - p);
}
D distLC(P a1, P a2, P c, D r) {
  return max(distLP(a1, a2, c) - r, 0.0);
}
vector<L> tangentLines(P a, D ar, P b, D br) {
  vector<L>ls;
  D d = abs(b-a);
  rep (i,2) {
    D sin = (ar - (1-i*2)*br) / d;
    if (!LE(sin*sin, 1)) break;
    D cos = sqrt(max(1 - sin*sin, 0.0));
    rep (j,2) {
      P n = (b-a) * P(sin, (1-j*2)*cos) / d;
      ls.push_back(L(a + ar*n, b + (1-i*2)*br*n));
      if (cos < EPS) break;
    }
  }
  return ls;
}
int main(){
  int n;
  while(cin>>n,n){
    P p[n];
    double r[n],a,b;
    int cost[n],sum=1;
    rep(i,n){
      cin>>a>>b>>r[i]>>cost[i];
      p[i]=P(a,b);
    }
    rep(i,n)for(int j=i+1;j<n;j++){
      vector<L>l=tangentLines(p[i],r[i],p[j],r[j]);
      vector<L>l1=tangentLines(p[i],r[i]+cost[i],p[j],r[j]+cost[j]);
      rep(k,l.size()){
        int t=0;
        rep(u,n)if(distLP(l[k].first,l[k].second,p[u])>=r[u]-EPS&&distLP(l[k].first,l[k].second,p[u])<=r[u]+cost[u]+EPS)t++;
        sum=max(sum,t);
      }
      rep(k,l1.size()){
        int t=0;
        rep(u,n)if(distLP(l1[k].first,l1[k].second,p[u])>=r[u]-EPS&&distLP(l1[k].first,l1[k].second,p[u])<=r[u]+cost[u]+EPS)t++;
        sum=max(sum,t);
      }
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 3216