akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int nodes[300];

signed main(){
    int N;
    cin >> N;
    nodes[0] = -1;
    for(int i = 1; i <= N; i++){
        int a;
        cin >> a;
        nodes[i] = a;
    }
    for(int i = 1; i <= N; i++){
        printf("node %d: ", i);
        printf("key = %d, ", nodes[i]);
        if(i / 2 > 0)printf("parent key = %d, ", nodes[i / 2]);
        if(i * 2 <= N)printf("left key = %d, ", nodes[i * 2]);
        if(i * 2 + 1 <= N)printf("right key = %d, ", nodes[i * 2 + 1]);
        printf("\n");
    }//node 2: key = 8, parent key = 7, left key = 2, right key = 3, 

    return 0;
}
/*



*/


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second
#define all(x) ((x.begin()), (x.end()))

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    int n, q;
    string s;
    set<int> positions[26];

    cin >> n >> s >> q;

    REP(i, s.size())
        positions[s[i]-'a'].insert(i);
    
    int l, r, idx, t;
    REP(i, q) {
        cin >> t;
        if (t == 1){
            char x;
            cin >> idx >> x;
            positions[s[idx-1]-'a'].erase(idx-1);
            s[idx-1] = x;
            positions[x-'a'].insert(idx-1); 
        }else if (t == 2) {
            cin >> l >> r;
            ll ans = 0;
            REP(i,26){
                auto it = positions[i].lower_bound(l-1);
                if (it != positions[i].end() && *it <= r-1)
                    ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24196
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<lint> a(n);

  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int q;
  cin>>q;
  vector<lint> b(q),c(q);
  for(int i=0;i<q;i++){
    cin>>b[i]>>c[i];
  }

  unordered_map<lint,lint> cnt;
  for(auto v:a){
    if(cnt.find(v)==cnt.end()){
      cnt[v]=1;
    }else{
      cnt[v]++;
    }
  }

  lint result=0;
  for(auto v:a){
    result+=v;
  }

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

    lint diff=(c[i]-b[i])*cnt[b[i]];
    result+=diff;
    cout<<result<<endl;
    if(cnt.find(c[i])==cnt.end()){
      cnt[c[i]]=cnt[b[i]];
    }else{
      cnt[c[i]]+=cnt[b[i]];
    }

    cnt[b[i]]=0;
  }

  return 0;
}




Measured memory_bytes: 9404
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e18;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long, long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1)%mod;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////

//メイン関数
int main(){
  //doubleの桁数
  
  lin(N);lin(Q);
  UnionFind T(N);
  rep(i, Q){
    lin(t);lin(u);lin(v);
    if(t == 0) T.unite(u, v);
    else{
      if(T.same(u, v)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 6392
import bisect
n = int(input())
ps = [0] * (1 << 16)
for i in range(1 << 16):
    temp = 0
    for j in range(16):
        if (i >> j) & 1:
                temp += (-2) ** (2 *j)
    ps[i] = temp

pattern1 = None
pattern2 = None

for i in range(1 << 16):
    temp2 = 0
    for j in range(16):
        if (i >> j) & 1:
                temp2 += (-2) ** (2 *j + 1)
    n2 = n - temp2
    pattern1 = bisect.bisect_left(ps, n2)
    if pattern1 != (1 << 16) and ps[pattern1] == n2:
        pattern2 = bin(i)[2:].zfill(16)
        pattern1 = bin(pattern1)[2:].zfill(16)
        break

ans = ""
for i in range(16):
    ans += pattern2[i]
    ans += pattern1[i]
    
true_ans = ""
flag = False
for i in range(len(ans)):
    if ans[i]=="1":
        true_ans += "1"
        flag = True
    elif flag:
        true_ans += "0"

if true_ans == "":
    true_ans = "0"
        
print(true_ans)

Measured memory_bytes: 5916
#include<stdio.h>
int main(){
  long int a,b,v,w,t;
  scanf("%ld%ld%ld%ld%ld",&a,&v,&b,&w,&t);
  printf(a<b?(a+v*t<b+w*t?"NO":"YES"):(a-v*t>b-w*t?"NO":"YES"));
}


Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	string str,str2;
	int i,j;
	vector<short int> ss[4001];
	
	for(i=0;i<4000;i++)
		for(j=0;j<4000;j++)
			ss[i].push_back(0);
	
	for(;cin >> str;)
	{
		cin >> str2 ;
		
		int ans=0;
		
		
		for(i=0;i<str.size();i++)
		{
			for(j=0;j<str2.size();j++)
			{
				ss[i][j]=0;
				if(str[i]==str2[j] && i!=0 && j!=0)
					ss[i][j]=ss[i-1][j-1]+1;
				else if(str[i]==str2[j])
					ss[i][j]++;
				
				if(ss[i][j]>ans)
					ans=ss[i][j];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 32000
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long

int main () {
  ll n, k;
  cin >> n >> k;
  ll sub = 0;
  vector<ll> a(n), b(n);
  vector<pair<ll, ll> > ab;
  for (ll i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    ab.push_back(make_pair(a[i], b[i]));
  }    
  sort(ab.begin(), ab.end());
  for (ll i = 0; i < n; i++) {
    sub += ab[i].second;
    if (sub >= k) {
      cout << ab[i].first << endl;
      break;  
    }  
  }
}

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


int main(){
    int X, N;
	bool p[101] = {false};
	int dis = 100000, res;

	cin >> X >> N;
	if(N == 0){
		cout << X;
		return 0;
	}

	rep(i, N){
		int tmp;
		cin >> tmp;
		p[tmp] = true;
	}

	for(int i = -101; i<0; i++){
		if(abs(X-i) < dis){
			dis = abs(X-i);
			res = i;
		}
	}
	
	for(int i = 0; i<101; i++){
		if(abs(X-i) < dis && !p[i]){
			dis = abs(X-i);
			res = i;
		}
	}
	
	for(int i = 101; i<300; i++){
		if(abs(X-i) < dis){
			dis = abs(X-i);
			res = i;
		}
	}


	cout << res;

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main()
{
	int a, b;

	while (cin >> a >> b) {
		int sum = a + b;
		int n;
		for (n = 0; sum > 0; n++) {
			sum /= 10;
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
def c_string_transformation(S, T):
    from collections import defaultdict
    cs = defaultdict(str)
    ct = defaultdict(str)
    for k, (c1, c2) in enumerate(zip(S, T)):
        if c1 not in cs[c2]:
            cs[c2] += c1
        if c2 not in ct[c1]:
            ct[c1] += c2
    ans = 'Yes'
    for _, v in cs.items():
        if len(v) >= 2:
            ans = 'No'
            break
    for _, v in ct.items():
        if len(v) >= 2:
            ans = 'No'
            break
    return ans

S = input()
T = input()
print(c_string_transformation(S, T))

Measured memory_bytes: 3812
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n;
  set<int> a;
  for(int i = 0; i < n; ++i){
  	int aa;
  	cin >> aa;
  	a.insert(aa);
  }

  if(a.size() == n)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 9600
if __name__ == '__main__':
    N = int(input())

    L_list = list(map(int, input().split()))

    max_L = max(L_list)

    sum_L = 0
    for L in L_list:
        sum_L += L

    if max_L < sum_L - max_L:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n, m, s, d;
	while(scanf("%d%d%d%d", &n, &m, &s, &d) == 4){
		--s; --m;
		vector<string> hori(d);
		rep(i, d) cin >> hori[i];

		vi res(n);
		rep(i, n) res[i] = i;
		rep(i, d) rep(j, n-1)
			if(hori[i][j] == '1')
				swap(res[j], res[j+1]);
		s = res[s];
		if(s == m){
			puts("0");
			continue;
		}
		
		pii result(-1, -1);
		rep(i, n) res[i] = i;
		rep(i, d) rep(j, n-1){
			if(hori[i][j] == '1')
				swap(res[j], res[j+1]);
			else{
				if(!((res[j]==s && res[j+1]==m) || (res[j]==m && res[j+1]==s)))
					continue;
				if((j && hori[i][j-1]=='1') || (j<n-1 && hori[i][j+1]=='1'))
					continue;
				result = pii(i+1, j+1);
				i=d; break;
			}
		}

		if(result.first == -1)
			puts("1");
		else
			printf("%d %d\n", result.first, result.second);
	}
}

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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if (W >= x+r && 0 <= x-r){
        if (H >= y+r && 0 <= y-r){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
const int MAX = 100010;

int main() {
	int N;
	int table[MAX] = { 0 };
	int m = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		for (int j = -1; j <= 1; j++) {
			if (a + j < 0)continue;
			table[a + j]++;
			m = max(table[a + j], m);
		}
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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; }

using ll = long long;

ll N, A, B;
ll h[100010];

bool C( ll x )
{
  ll sum = 0;

  rep( i, N ) if( h[i] > x*B )
    sum += (h[i]-x*B+A-B-1)/(A-B);

  return sum <= x;
}

ll S = 0;

int main()
{
  std::cin >> N >> A >> B;
  rep( i, N )
  {
    std::cin >> h[i];

    S += h[i];
  }

  ll ng = 0, ok = (S+B-1)/B;

  while( ok-ng > 1 )
  {
    ll mid = (ng+ok)/2;

    (C(mid) ? ok : ng) = mid;
  }

  std::cout << ok << std::endl;

  return 0;
}

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

#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); i++ )
#define REP( i, n )		FOR( i, 0, n )
#define ALL( x )		(x).begin(), (x).end()

int top = 0;
int S[1000];

void push( int a );
int pop();

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

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

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

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


Measured memory_bytes: 3212
import sys
input = sys.stdin.readline


def read():
    N, A, B = map(int, input().strip().split())
    X = list(map(int, input().strip().split()))
    return N, A, B, X


def solve(N, A, B, X):
    ans = 0
    for i in range(N-1):
        d = X[i+1] - X[i]
        ans += min(A * d, B)
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

int main() {
    string s; cin >> s;
    int n = s.size();
        
    vector<int64_t> v(n + 1, 0);
    int64_t run = 0;

    for (int i = 0; i < n; i += 1) {
        if (s[i] == '<') {
            run += 1;
        } else {
            run = 0;
        }
        v[i + 1] = max(run, v[i + 1]);
    }
    
    run = 0;

    for (int i = n - 1; i >= 0; i -= 1) {
        if (s[i] == '>') {
            run += 1;
        } else {
            run = 0;
        }
        v[i] = max(v[i], run);
    }
       
    int64_t sum = accumulate(v.begin(), v.end(), 0LL);

    cout << sum << "\n";
}

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

int main() {
  int k;
  cin >> k;
  ll mod = 7 % k;
  int ans = 1;
  while (mod != 0) {
    mod = (10 * mod + 7) % k;
    ++ans;
    if (ans > k) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3572
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

type sushi struct {
	t, d int
}

type sushiList []sushi

func (a sushiList) Len() int           { return len(a) }
func (a sushiList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a sushiList) Less(i, j int) bool { return a[i].d > a[j].d } // 実態はMax Heap
func (a *sushiList) Push(x interface{}) {
	*a = append(*a, x.(sushi))
}
func (a *sushiList) Pop() interface{} {
	old := *a
	n := len(*a)
	x := old[n-1]
	*a = old[0 : n-1]

	return x
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := scanInt(), scanInt()
	L := make(sushiList, N)
	for i := 0; i < N; i++ {
		L[i].t, L[i].d = scanInt(), scanInt()
	}
	sort.Sort(L)

	var selected, menu sushiList
	tMap := make([]bool, N+1)

	heap.Init(&selected)
	for i := 0; i < K; i++ {
		if tMap[L[i].t] {
			heap.Push(&selected, sushi{t: L[i].t, d: -L[i].d})
		} else {
			tMap[L[i].t] = true
		}
	}

	heap.Init(&menu)
	for i := K; i < N; i++ {
		if !tMap[L[i].t] {
			heap.Push(&menu, L[i])
		}
	}

	tSum := 0
	for _, flg := range tMap {
		if flg {
			tSum++
		}
	}
	dSum := 0
	for i := 0; i < K; i++ {
		dSum += L[i].d
	}

	ans := (tSum * tSum) + dSum

LOOP:
	for {
		if selected.Len() == 0 {
			break LOOP
		}
		removed := heap.Pop(&selected).(sushi)
		dSum += removed.d

		var added sushi
		for added.t == 0 {
			if menu.Len() == 0 {
				break LOOP
			}

			kouho := heap.Pop(&menu).(sushi)

			if !tMap[kouho.t] {
				added = kouho
				tMap[added.t] = true
				tSum++
				dSum += added.d
			}
		}

		ans = intMax(ans, (tSum*tSum)+dSum)
	}

	fmt.Println(ans)
}


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

int main()
{
    char f[10];
    int a;
    while(~scanf("%s",f))
    {
        a=0;
        for(int i=0;i<4;i++)
        {
            if(f[i]=='+')
            a+=1;
            else
                a-=1;
        }
      printf("%d\n",a);
    }

}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>

using namespace std;



/*-----------------------------------------------main関数-------------------------------------------------------------*/
int main(int, char**) {
    char c;
    long long w_count = 0, w_pos = 0;
    int i= 0;
    while(c = cin.get()) {
        if(c == '\n' || c == '\r' || c== '\0') break;
        if (c == 'W')  {
            w_count++;
            w_pos += i; 
        }
        i++;
    }
    cout << w_pos - (w_count-1)*w_count/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  cin>>k;
  int s = 7;
  REP(j,k+1) {
    s %= k;
    if (s == 0) {
      cout<<(j+1)<<endl;
      return 0;
    }
    s *= 10;
    s += 7;
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main (){
  int N, K, Q;
  cin >> N >> K >> Q;
  
  vector<int> A(Q);
  
  for(int i=0; i<Q; i++){
    cin >> A[i];
  }
  
  vector<int> B(N,K-Q);
  
  for(int i=0; i<Q; i++){
    B[A[i] -1]++;
  }
  
  
  for(int i=0; i<N; i++){
    if(B.at(i) >= 1){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}
  


Measured memory_bytes: 1408
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
h = Hash.new()
n.times do |i|
  h[i+1] = a[i]
end
ret = 0
h.each do |k, v|
  if k == h[v] then
    ret += 1
  end
end
puts ret / 2

Measured memory_bytes: 15108
#include <bits/stdc++.h>
using namespace std;
int Cnt[10][10];
int N,M,A[10];
void Divide(int v)
{
	M=0;
	while (v) A[++M]=v%10,v/=10;
}
int main()
{
	cin>>N;
	long long Ans=0;
	for (int i=1;i<=N;++i)
	{
		Divide(i);
		if (A[1]==A[M]) ++Ans;
		Ans+=Cnt[A[M]][A[1]]*2;
		++Cnt[A[1]][A[M]];
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){


string S;
cin >> S;


	if(S[0]=='R' && S[1] == 'R' && S[2] == 'S'){
		cout << "2";
	}

	else if(S[0]=='S' && S[1] == 'R' && S[2] == 'R'){
		cout << "2";
	}
	else if(S[0]=='R' && S[1] == 'R' && S[2] == 'R'){
		cout << "3";
	}
	else if(S[0]=='S' && S[1] == 'S' && S[2] == 'S'){
		cout << "0";
	}
	else{
		cout << "1";
	}











	return 0;

}



Measured memory_bytes: 3620
/**
 *		author:  zvm
 *		created: 27.09.2020 16:49:43
**/

#include <bits/stdc++.h>

using namespace std ;

typedef long long int ll ;

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

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

	vector<int> count(n+1,0);
	for( int i = 0, val ; i < n ; ++i ) {
		cin >> val ;
		count[val]++ ;
	}

	int distinct = 0 ;
	priority_queue<int> q ;
	for( int i = 1 ; i <= n ; ++i ) {
		if( !count[i] ) {
			continue ;
		}
		distinct++ ;
		q.push({-count[i]}) ;
	}
	
	ll ans = 0 ;

	while( distinct > k ) {
		ans -= q.top();
		q.pop();
		distinct-- ;
	}

	cout << ans << endl ;
}


Measured memory_bytes: 4884
n = int(input())
a = list(map(int,input().split()))
cl = [0] * (10**5+1)
ans = 0
for i in a:
    cl[i] += 1
for i in range(1,10**5):
    ans = max(ans, cl[i-1]+cl[i]+cl[i+1])
print(ans)

Measured memory_bytes: 13964
n = int(input())

A = list(map(int, input().split()))

A.sort()
A.reverse()

ans = A[0]

L = [0 for i in range(n-1)]

j = 0
for i in range(n-2):
  if L[j] < 2:
    L[j] += 1
    ans += A[j+1]
  else:
    while L[j] >= 2:
      j += 1
    L[j] += 1
    ans += A[j+1]
print(ans)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}

double dis(double a, double b) {
    return sqrt((a+b)*(a+b)-(a-b)*(a-b));
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 N;
    cin >> N;
    vector<double> r(N), cen(N);

    REP(i, N) cin >> r[i];

    REP(i, N) {
        double now = r[i];
        REP(j, i) {
//            cout << dis(r[j], r[i]) + cen[j] << " ";
            chmax(now, dis(r[j], r[i]) + cen[j]);
        }
        cen[i] = now;
    }
    double res = 0;
    REP(i, N) {
        chmax(res, cen[i]+r[i]);
    }
    cout << fixed << setprecision(10) << res << endl;
}



Measured memory_bytes: 3324
#include <cstdio>
const double pi = 3.14159265358979323846;

int main(void) {
	double r;
	std::scanf("%lf", &r);
	const double s = pi * r * r,
		l = 2. * pi * r;
	std::printf("%.6lf %.6lf\n", s, l);
	return 0;
}

Measured memory_bytes: 2684
#include<stdio.h>
int main(void) {
	int a, b, k;
	int ans[10000];
	int count = 0;
	//int countb = 0;
	scanf("%d %d %d", &a, &b, &k);
	int x=0 ;
	int flag = 0;
	int count1 = 0;
	if (b <= k) {
		for (int i = a; i <= b; i++) {
			printf("%d\n", i);
		}
		return 0;
	}
	else {
		if (a == b) {
			printf("%d\n", a);
			return 0;
		}
		else {
			for (int i = a; i <=b; i++) {
              count1++;
              if(count1>k){
				break;
              }
				ans[count++] = i;
			}
          count1=0;
			for (int i = b; i >=a; i--) {
				flag = 0;
              count1++;
              if(count1>k){
                break;
              }
				for (int j = 0; j < count; j++) {
					if (ans[j] == i) {
						flag = 1;
						break;
					}
					
				}
				if (flag == 0) {
					ans[count++] = i;
				}
			}
			//int same = 0;
			//printf("%d %d\n", counta, countb);
			/*if(flag==1){
				same = counta - countb;
				if (same < 0) {
					same = -1 * same;
				}
				same++;
			}*/
			//printf("%d\n", same);
			/*for (int i = a; i <= a + k - 1 - same; i++) {
				//printf("2\n");
				printf("%d\n", i);
			}*/
			int temp;
			for (int i = 0; i < count - 1; i++) {
				for (int j = i + 1; j < count; j++) {
					if (ans[i] > ans[j]) {
						temp = ans[i];
						ans[i] = ans[j];
						ans[j] = temp;
					}
				}
			}

			for (int i = 0; i < count; i++) {
				printf("%d\n", ans[i]);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    int N; cin >> N;
    vi h(N); rep(i,N) cin >> h[i];

    int ans = -1;
    rep(i,100005){
        int l = N,r = N;
        rep(j,N) if(h[j] > 0) {l = j; break;}
        FOR(j,l,N) if(h[j] <= 0) {r = j; break;}
        if(l == N) {ans = i; break;}
        FOR(j,l,r) h[j]--;
    }

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


Measured memory_bytes: 3620
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    int N;
    string S;
    cin >> N >> S;

    ll ans=0;
    REP(i,10)REP(j,10)REP(k,10){
        auto ptr = S.begin();
        bool flag = false;
        while(ptr != S.end()){
            if(*ptr == '0'+i){flag = true; break;}
            ptr++;
        }
        if(flag) ptr++;
        else continue;

        flag = false;
        while(ptr != S.end()){
            if(*ptr == '0'+j){flag = true; break;}
            ptr++;
        }
        if(flag) ptr++;
        else continue;

        flag = false;
        while(ptr != S.end()){
            if(*ptr == '0'+k){flag = true; break;}
            ptr++;
        }
        if(flag) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/* Takyoaki Festival 2019 */
#include <stdio.h>

int main(void)
{
	int n, d[50], i, k, sum=0;

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

	for(i = 0; i < n-1; ++i)
	{
		for(k = i+1; k < n; ++k)
		{
			sum += d[i] * d[k];
		}
	}

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

	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
const int maxn=1e5;
int n,m,a[maxn+10];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		int l,r; scanf("%d%d",&l,&r);
		a[l]^=1; a[r]^=1;
	}
	for(int i=1;i<=n;++i) if(a[i]){
		printf("NO"); return 0;
	}
	printf("YES");
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
      while(true){
        int n = sc.nextInt();
        int r = sc.nextInt();
        if(n==0&&r==0)break;
        int [] fuda = new int[n];
        for(int i=0;i<n;i++){
          fuda[i] = i + 1;
        }
        for(int i=0;i<r;i++){
          int p = sc.nextInt();
          int c = sc.nextInt();
          int [] swap = new int[p - 1];
          for(int j=0;j<p-1;j++){
            swap[j] = fuda[n - 1 - j];
          }
          for(int j=0;j<c;j++){
            fuda[n - 1 - j] = fuda[n - j - p];
          }
          for(int j=0;j<p-1;j++){
            fuda[n - 1 - j - c] = swap[j];
          }
        }
        System.out.println(fuda[n - 1]);
      }
    }
  }
}



Measured memory_bytes: 36176
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		ArrayList<Integer> A = new ArrayList<Integer>();
		long sum = 0;
		int mod = 1000000007;
		int N = stdIn.nextInt();
		for(int i = 0; i < N; i ++) {
			A.add(stdIn.nextInt());
			sum += A.get(i);
			sum %= mod;
		}
		
		long ans = 0;
		
		for(int i = 0; i < N; i ++) {
			sum -= A.get(i);
			if(sum < 0) {
				sum += mod;
			}
			
			ans += A.get(i) * sum;
			ans %= mod;
		}
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 65748
#include<bits/stdc++.h>
#define N 109
using namespace std;

int m,n,cnt,a[N],b[N],ans[N];
void add(int x){ ans[++cnt]=x; }
int main(){
	scanf("%d%d",&m,&n);
	int i,j;
	for (i=1,j=0; i<=n; i++){
		scanf("%d",&a[i]);
		if (a[i]&1) j++;
	}
	if (j>2){
		puts("Impossible"); return 0;
	}
	for (i=1; i<=n; i++) if (a[i]&1){
		swap(a[1],a[i]); break;
	}
	for (i=n; i>1; i--) if (a[i]&1){
		swap(a[i],a[n]); break;
	}
	for (i=1; i<=n; i++) printf("%d%c",a[i],(i<n)?' ':'\n');
	if (n==1){
		if (a[1]==1){ puts("1"); puts("1"); }
		else{ puts("2"); printf("1 %d\n",a[1]-1); }
		return 0;
	}
	add(a[1]+1);
	for (i=2; i<n; i++) add(a[i]);
	if (a[n]>1) add(a[n]-1);
	printf("%d\n",cnt);
	for (i=1; i<=cnt; i++) printf("%d%c",ans[i],(i<cnt)?' ':'\n');
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  int N;
  ins(N);

  cout << (1000 - N % 1000) % 1000 << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC\n" : "ARC\n");

    return 0;
}

Measured memory_bytes: 256
def selectionSort(A, N):
    cnt = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        cnt = cnt + int(i != minj)
        A[i], A[minj] = A[minj], A[i]
    return cnt
N = int(input())
A = [int(i) for i in input().split()]
cnt = selectionSort(A, N)
 
for i in range(N):
    if i != 0:
        print(" ", end = "")
    print(A[i], end = "")
     
print()
print(cnt)


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

int N,M;
int C[20];
int X[20001];

int dp[20001][257];

#define INF (1<<30)

int main(){
  while(  cin >> N >> M && (N||M) ){
    for(int i=0;i<M;i++) cin >> C[i];
    for(int i=0;i<N;i++) cin >> X[i];
    
    fill(dp[0],dp[20001],INF);
    dp[0][128] = 0;
    for(int i=0;i<N;i++){
      for(int j=0;j<256;j++){
	if( dp[i][j] == INF ) continue;
	for(int k=0;k<M;k++){
	  int nd = max ( 0 , min( 255, j + C[k]) );
	  dp[i+1][nd] = min( dp[i+1][nd],
			     dp[i][j] + (nd-X[i])*(nd-X[i]) );
	}
      }
    }
    int res = INF;
    for(int i=0;i<256;i++) res = min( res ,dp[N][i] );
    cout << res << endl;
  }
}

Measured memory_bytes: 21316
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2000;
const int OFFSET = MAXN*3;

int N, M;

int sum(int a, int b) {
    return a + b >= M ? a + b - M : a + b;
}
int sub(int a, int b) {
    return a - b < 0 ? a - b + M : a - b;
}
int mul(int a, int b) {
    return (1LL*a*b)%M;
}
int pw(int a, int b) {
	if (!b) return 1;
	int r = pw(a, b/2);
	r = mul(r, r);
	if (b%2) r = mul(r, a);
	return r;
}

int dp[OFFSET+7][2*OFFSET+7];
int solve(int n, int d) {
    if (n < 0) return 0; //PII(0, 0);
    if (n == 0) return d <= 0; //PII(d<=0, d<=0);
    int &ans = dp[n][d+OFFSET];
    if (ans != -1) return ans;

    ans = solve(n-1, d-1);
    if (n >= 2) ans = sum(ans, mul(solve(n-2, d+1), n-1));
    if (n >= 3) ans = sum(ans, mul(solve(n-3, d), (n-1)*(n-2)));

    return ans;
}

int main() {
    cin >> N >> M;

    memset(dp, -1, sizeof dp);
    int ways = solve(N+N+N, 0);
    cout << ways << endl;

    return 0;
}


Measured memory_bytes: 285720
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b[110000],scnt=0,cnt=0;
string s;
signed main()
{
	cin>>a;
	rep(i,a){
		cin>>b[i];
	}
	rep(i,a-1){
		if(b[i]>=b[i+1]){
			cnt++;
		}else{
			scnt=max(scnt,cnt);
			cnt=0;
		}
	}
	scnt=max(scnt,cnt);
	cout<<scnt;
}

Measured memory_bytes: 1024
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		Scanner sc = new Scanner(System.in);
		
		long N = sc.nextLong();
		if(N <= 6) System.out.println(1);
		else if(N <= 11) System.out.println(2);
		else{
			System.out.println((N / 11) * 2 + ((N % 11 == 0) ? 0 : (N % 11 <= 6 ? 1 : 2)));
		}
	}
}

Measured memory_bytes: 23764
import Data.List

substrings :: [a] -> [[a]]
substrings = ([]:) . concatMap (tail . inits) . tails

acgt :: [Char] -> Bool
acgt [] = True
acgt (x:xs)
  | x `elem` "ACGT" = acgt xs
  | otherwise = False

main = do
	s <- getLine
	print.maximum.map length $ filter acgt $ substrings s

Measured memory_bytes: 3780
#include <iostream>
#include <string>
using namespace std;
 
int main(){
 
  string s[10];
 
  while(cin >> s[0]){
    for(int i=1;i<8;i++) cin >> s[i];
 
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
 
    if(s[i][j] == '1'){
      if(s[i][j+1] == '1' && s[i+1][j] == '1' && s[i+1][j+1] == '1') cout << 'A' << endl;
      else if(s[i+1][j] == '1' && s[i+2][j] == '1' && s[i+3][j] == '1') cout << 'B' << endl;
      else if(s[i][j+1] == '1' && s[i][j+3] == '1' && s[i][j+3] == '1') cout << 'C' << endl;
      else if(s[i+1][j-1] == '1' && s[i+1][j] == '1' && s[i+2][j-1] == '1') cout << 'D' << endl;
      else if(s[i][j+1] == '1' && s[i+1][j+1] == '1' && s[i+1][j+2] == '1') cout << 'E' << endl;
      else if(s[i+1][j] == '1' && s[i+1][j+1] == '1' && s[i+2][j+1] == '1') cout << 'F' << endl;
      else if(s[i][j+1] == '1' && s[i+1][j-1] == '1' && s[i+1][j] == '1') cout << 'G' << endl;
    }
 
      }
    }
  }
}


Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,x;
	scanf("%d%d",&m,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		m-=x;
	}
	if(m<0)
		m=-1;
	printf("%d\n",m);
	return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




int cnt[200005];

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,x;
    cin >> n;
    for(i=1;i<n;i++)cin >> x,++cnt[x];
    for(i=1;i<=n;i++)cout << cnt[i] << '\n';
    return 0;
}


Measured memory_bytes: 4352
#include <cmath>
#include <iostream>
#include <unordered_map>
using namespace std;

unordered_map<int, long long> height;
unordered_map<int, long long> pate;

long long f(int N, long long X) {
  if (N == 0) {
    if (X <= 0)
      return 0;
    else
      return 1;
  } else if (X <= 1 + height[N - 1]) {
    return f(N - 1, X - 1);
  } else
    return pate[N - 1] + 1 + f(N - 1, X - 2 - height[N - 1]);
}

int main() {
  int N;
  long long X;
  cin >> N >> X;
  height[0] = 1LL;
  pate[0] = 1LL;
  for (int level = 1; level <= N; ++level) {
    height[level] = height[level - 1] * 2 + 3;
    pate[level] = pate[level - 1] * 2 + 1;
  }
  cout << f(N, X) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string S;
ll A[500050];
queue<int> que;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    int N = S.size() + 1;
    if(S[0] == '<') {
        A[0] = 0;
        que.push(0);
    }
    if(S.back() == '>') {
        que.push(N - 1);
    }
    for(int i = 0; i < S.size(); i++) {
        if(S.substr(i, 2) == "><") {
            A[i+1] = 0;
            que.push(i + 1);
        }
    }
    while(!que.empty()) {
        int now = que.front();
        que.pop();
        if(now != N - 1 && S[now] == '<') {
            if(chmax(A[now+1], A[now] + 1)) {
                que.push(now + 1);
            }
        }
        if(now != 0 && S[now - 1] == '>') {
            if(chmax(A[now-1], A[now] + 1)) {
                que.push(now - 1);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5532
/*
    author:@bhaskar_8998
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;  
typedef long long i64;
typedef vector<int> vi;
typedef vector<long> vl;
typedef pair<int,int>pii;
#define all(A) (A).begin(),(A).end()
#define pb push_back
#define MOD 1000000007
#define fastio() {ios_base::sync_with_stdio(false);cin.tie(NULL);}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    fastio();
    i64 ss[31];
    for(int i=1,ts=2;i<=30;i++){
        ss[i]=ts;
        ts*=2;
    }
    clock_t beg=clock();
    int t=1;
    // cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        int h[n];
        for(int i=0;i<n;i++)cin>>h[i];
        vector<vi> v(n);
        for(int i=0;i<m;i++){
            int a,b;
            cin>>a>>b;
            v[a-1].pb(h[b-1]);
            v[b-1].pb(h[a-1]);
        }
        for(int i=0;i<n;i++)sort(all(v[i]),greater<int>());
        int ans=0;
        for(int i=0;i<n;i++){
            if(v[i].size()==0){
                ans+=1;
                continue;
            }
            if(h[i]>v[i][0])ans+=1;
        }     
        cout<<ans;

    }

    clock_t end=clock(); 
    fprintf(stderr, "\n%lf sec\n", (double)(end-beg)/(CLOCKS_PER_SEC));
    return 0;
}


    

Measured memory_bytes: 8772
#include <iostream>
#include <cmath>

using namespace std;

int cntDigit(unsigned long long n) {
    int digit = 1;
    while (n >= 10) {
        digit += 1;
        n /= 10;
    }
    return digit;
}

int main() {
    // int N;
    unsigned long long N;
    int num;

    cin >> N;

    num = cntDigit(N);

    for (unsigned long long A = 1; A * A <= N; ++A) {
        if (N % A == 0) {
            // cout << A << endl;
            unsigned long long B = N / A;
            num = min(num, cntDigit(B));
        }
    }

    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=map(int, input().split())  #複数数値入力

import sys

sys.setrecursionlimit(10**9)

def countWays_memo(n):
    memo = [-1]*(n+1)
    def _countWays(n):
        if n < 0:
            return 0
        elif n == 0:
            return 1
        else:
            if memo[n] > -1:
                return memo[n]
            else:
                memo[n] = _countWays(n-1) + _countWays(n-2) 
                return memo[n]
    return _countWays(n)
    
if m == 0:
    print(countWays_memo(n)% 1000000007)
else:
    list_a = []
    for i in range(m):
        list_a.append(int(input()))

    steps = [list_a[0]]
    now_step=list_a[0]+1
    for i in range(len(list_a)-1):
        steps.append(list_a[i+1]-now_step)
        now_step = list_a[i+1]+1
    steps.append(n-now_step+1)


    dict_steps = {}
    for s in set(steps):
        dict_steps[s] = steps.count(s)

    ans = 1
    for k,v in dict_steps.items():
        ans *= countWays_memo(k-1)**v

    print(ans% 1000000007)

Measured memory_bytes: 513140
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 7;
const int mod = 1e9+7;
int a[10];
int main()
{
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7)puts("YES");
    else puts("NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int N;
    cin >> N;
    
    vector<int> d(N);
    int i = 0;
    int n = N;
    while(n--){
        cin >> d[i];
        i++;
    }
    
    sort(d.begin(),d.end());
    d.erase( unique(d.begin(),d.end()), d.end());
    cout<<d.size()<<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
cnt = [0, 0, 0]
ans = 1
for e in a:
    idx = -1
    c = 0
    for i, cnt_e in enumerate(cnt):
        if e == cnt_e:
            c += 1
            idx = i

    if idx == -1:
        print(0)
        exit()

    cnt[idx] += 1
    ans *= c
    ans %= mod

print(ans)


Measured memory_bytes: 14056