akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    int num[100005],small[100005],mi=INF;
    cin >> n >> m;
    rep(i,0,n){
        cin >> num[i];
        if(i==0)small[i]=num[i];
        else small[i]=min(num[i],small[i-1]);
    }
    int ans = 0,top = 0;
    rep(i,0,n){
        int dif = num[i]-small[i];
        if(top==dif){
            ans++;
        }else if(top<dif){
            ans = 1;
            top = dif;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[][] cards=new int[3][9];
		int n=sc.nextInt();
		int[] num=new int[9];
		char[] color=new char[9];
		boolean win;
		for(int i=0;i<n;i++){
			win=true;
			for(int j=0;j<3;j++){
				for(int k=0;k<9;k++){
					cards[j][k]=0;
				}
			}
			for(int j=0;j<9;j++){
				num[j]=sc.nextInt();
			}
			for(int j=0;j<9;j++){
				color[j]=sc.next().charAt(0);
				switch(color[j]){
					case 'R':
						cards[0][num[j]-1]++;
						break;
					case 'G':
						cards[1][num[j]-1]++;
						break;
					case 'B':
						cards[2][num[j]-1]++;
						break;
				}
			}
			for(int j=0;j<3;j++){
				if(win==false){
					break;
				}
				for(int k=0;k<9;k++){
					if(cards[j][k]!=0){
						if(cards[j][k]>=3){
							cards[j][k--]-=3;
						}
						else if(k<7){
							if(cards[j][k+1]>=cards[j][k]&&cards[j][k+2]>=cards[j][k]){
								cards[j][k+1]-=cards[j][k];
								cards[j][k+2]-=cards[j][k];
								cards[j][k]=0;
							}
							else{
								win=false;
								break;
							}
						}
						else{
							win=false;
							break;
						}
					}
				}
			}
			if(win){
				System.out.println(1);
			}
			else{
				System.out.println(0);
			}
		}
	}
}


Measured memory_bytes: 28700
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), m = sc.nextInt();
		int[] a = new int[A], b = new int[B];
		for (int i = 0; i < A; i++) a[i] = Integer.parseInt(sc.next());
		for (int i = 0; i < B; i++) b[i] = Integer.parseInt(sc.next());
		int min = Integer.MAX_VALUE;
		int x, y, c;
		for (int i = 0; i < m; i++) {
			x = Integer.parseInt(sc.next())-1;
			y = Integer.parseInt(sc.next())-1;
			c = Integer.parseInt(sc.next());
			min = Math.min(min, a[x]+b[y]-c);
		}
		Arrays.parallelSort(a);
		Arrays.parallelSort(b);
		System.out.println(Math.min(min, a[0]+b[0]));
	}
}

Measured memory_bytes: 92264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m;
ll ans;
vector<vector<ll>> a;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    vector<ll> cnts(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    a.resize(n);
    vector<ll> b(m), c(m);
    for (int i = 0; i < m; i++)
    {
        cin >> b[i] >> c[i];
        if (h[b[i] - 1] > h[c[i] - 1])
            cnts[b[i] - 1]++;
        if (h[c[i] - 1] > h[b[i] - 1])
            cnts[c[i] - 1]++;
        a[b[i] - 1].emplace_back(c[i] - 1);
        a[c[i] - 1].emplace_back(b[i] - 1);
    }
    for (ll i = 0; i < n; i++)
    {
        if (cnts[i] == a[i].size())
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12140
a,b,m = gets.split(' ').map(&:to_i)
a_list = gets.split(' ').map(&:to_i)
b_list = gets.split(' ').map(&:to_i)
res_1 = a_list.min + b_list.min
res_2 = 0
m.times do |i|
  m_list = gets.split(' ').map(&:to_i)
  res_tmp = a_list[m_list[0]-1] + b_list[m_list[1]-1] - m_list[2]
  if i.zero?
    res_2 = res_tmp
  elsif res_tmp < res_2
    res_2 = res_tmp
  end
end
puts res_1 <= res_2 ? res_1 : res_2

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int tmp = N - 1;
    while(tmp >= 0){
        cout << A[tmp] << ' ';
        tmp -= 2;
    }
    if(tmp == -2) tmp = 1;
    if(tmp == -1) tmp = 0;

    while(tmp < N){
        cout << A[tmp] << ' ';
        tmp += 2;
    }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n+1); i++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
   int n,ans=0;
   cin>>n;
   for(int i=1;i<=n;i+=2){
       int divisor=0;
       rep2(j,1,i){
           if(i%j==0)divisor++;
       }
       if(divisor==8)ans++;
   }
   cout<<ans<<endl;
}

   
    

   


    

   



Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=5010;
const LL MOD=1e9+7;
const LL INV2=(MOD+1)/2;
int n,m;
char s[N];
LL dp[N][N];
int main() {
    R(n,s);
    m=strlen(s);
    dp[0][0]=1;
    REP(i,n) REP(j,n) {
        int me=dp[i][j]%MOD;
        if ( !me ) continue;
        dp[i+1][j+1]+=2*me;
        dp[i+1][max(j-1,0)]+=me;
    }
    LL ans=dp[n][m]%MOD;
    REP(i,m) ans=ans*INV2%MOD;
    W(ans);
    return 0;
}


Measured memory_bytes: 116864
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin>>N>>D;
  vector<vector<int>>X(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++)cin>>X[i][j];
  }
  
  vector<vector<double>>Dis(N,vector<double>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      int s=0;
      for(int k=0;k<D;k++){
        s+=pow(X[i][k]-X[j][k],2);
      }
      Dis[i][j]=s;
    }
  }
  int x=0;
  for(int i=0;i<N;i++){
	for(int j=0;j<N;j++){
      if(Dis[i][j]!=0){
        int root=sqrt(Dis[i][j]);
        if(root==sqrt(Dis[i][j])){
          x++;
        }
      }
    }
  }
 cout<<x/2<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <limits>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if(a > m) continue;
        jobs[m-a].push_back(b);
    }

    priority_queue<int> q;
    ll ans = 0;
    for(int i = m-1; i >= 0; --i) {
        for (int b: jobs[i]) {
            q.push(b);
        }

        if(!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 5632
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll x[5];
    rep(i,0,5) cin >> x[i];
    rep(i,0,5){
        if(x[i] == 0){
            print(i+1);
            return;
        }
    }
    

}

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

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N,C,K; cin >> N >> C >> K;
    vector<ll> T(N);
    for(auto& in:T)cin >> in;
    sort(T.begin(),T.end());
    ll l,r;
    l = r = 0;
    ll cnt = 0;
    ll res = 0;
    while(true){
        if(r == N)break;
//        cout << r << " " << l << endl;
        if(l == r){
            cnt++;
            if(cnt == C){
                cnt = 0;
                res++;
                l = r + 1;
            }
            r++;
            continue;
        }
        if(T[r] - T[l] <= K){
            cnt++;
            if(cnt == C){
                res++;
                cnt = 0;
                l = r + 1;
            }
            r++;
        }else{
            res++;
            l = r;
            cnt = 0;
        }
    }
    if(l != r) res++;
    cout << res << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;

  int n = s.size();

  vector<string> t(4);
  t[0] = "dream";
  t[1] = "dreamer";
  t[2] = "erase";
  t[3] = "eraser";

  bool flag = true;
  int cur = n - 1;
  while(cur >= 0) {
    bool ok = false;
    for (int i = 0; i < 4; i++) {
      int m = t[i].size();
      if(cur - m + 1 < 0) continue;
      string tmp = s.substr(cur - m + 1, m);
      if(tmp == t[i]) {
        cur -= m;
        ok = true;
        break;
      }
    }
    if(!ok) {
      flag = false;
      break;
    }
  }

  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if(S.equals("AAA") || S.equals("BBB")){
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 35480
// https://atcoder.jp/contests/abc176/tasks/abc176_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int H, W, M;
    cin >> H >> W >> M;
    vector<int> row(H), col(W);
    set<pair<int, int>> st;
    REP(i, M) {
        int r, c;
        cin >> r >> c;
        r--, c--;
        row[r]++;
        col[c]++;
        st.insert({r, c});
    }
    vector<int> R, C;
    int maxr = -1, maxc = -1;
    REP(i, H) {
        if (row[i] > maxr)
            maxr = row[i], R.clear(), R.push_back(i);
        else if (row[i] == maxr)
            R.push_back(i);
    }
    REP(i, W) {
        if (col[i] > maxc)
            maxc = col[i], C.clear(), C.push_back(i);
        else if (col[i] == maxc)
            C.push_back(i);
    }
    // 爆弾の数が最大の行と列に爆弾があるか確認
    for (auto &r : R) {
        for (auto &c : C) {
            if (st.count({r, c}) == 0) {
                cout << maxr + maxc << endl;
                return;
            }
        }
    }
    cout << maxr + maxc - 1 << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 35008
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] tri = new int[200];
		for (int i = 0; i < tri.length; i++)
			tri[i] = i * (i + 1) * (i + 2) / 6;
		int[] answer = new int[1000001];
		int[] answer_odd = new int[1000001];
		answer[0] = 0;
		answer_odd[0] = 0;
		for (int i = 1; i < answer.length; i++) {
			answer[i] = i;
			answer_odd[i] = i;
			for (int j = 0; tri[j] <= i; j++) {
				answer[i] = Math.min(answer[i], answer[i - tri[j]] + 1);
				if (tri[j] % 2 == 1)
					answer_odd[i] = Math.min(answer_odd[i], answer_odd[i
							- tri[j]] + 1);
			}
		}
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			System.out.println(answer[n] + " " + answer_odd[n]);
		}
		sc.close();
	}
}

Measured memory_bytes: 29312
from heapq import*

x,y,z,K=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
b=sorted(list(map(int,input().split())))[::-1]
c=sorted(list(map(int,input().split())))[::-1]

h=[]
se=set((0,0,0))
#ans=[]
heappush(h,(-a[0]-b[0]-c[0],0,0,0))

for _ in range(K):
#  print(h)
  
  
  
  tmp,xx,yy,zz=heappop(h)
  print(-tmp)
  for i in range(2):
    for j in range(2):
      for k in range(2):
        if i+j+k==1:
          xn,yn,zn=xx+i,yy+j,zz+k
          if xn>=x:continue
          if yn>=y:continue
          if zn>=z:continue
          if (xn,yn,zn) in se:
            continue 
          heappush(h,(-a[xn]-b[yn]-c[zn],xn,yn,zn))
          se.add((xn,yn,zn))


Measured memory_bytes: 78428
#include <iostream>
 #include <math.h>
using namespace std;
int main() {
  long long ans=1;
  long long n;
  cin >> n;
  long long div = pow(10,9) + 7;
  for(long long i = n;i > 0;i--){ 
    ans = ((ans) * i % div) % div;
  }
  std::cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
// vector<pair<int, int>> v;
// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.second < b.second);
// }
bool isPalindrome(string s, int m, int n)
{
    for (int i = m; i < n / 2; i++)
    {
        if (s[i] != s[n - i - 1])
        {
            return false;
        }
    }
    return true;
}
void solve()
{
    string s;
    cin >> s;
    bool ok = isPalindrome(s, 0, s.size());
    if (ok)
    {
        ok = isPalindrome(s, 0, (s.size() - 1) / 2);
        if (ok)
        {
            ok = isPalindrome(s, (s.size() + 3) / 2, s.size());
        }
    }
    if (ok)
    {
        cout << "Yes" << lin;
    }
    else
    {
        cout << "No" << lin;
    }
}

int main()
{
    auto start = clock();
    fast_io;
    // freopen("test.txt", "r", stdin);
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    auto stop = clock();
    cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    if(n%2==0){
        sort(all(a));
        ll s = 0;
        for(int i=1;i<n;i++){
            s += a[i]-a[0];
        }
        if(s%2==0){
            if(a[0]%2==0){
                cout << "Second" << endl;
            }else{
                cout << "First" << endl;
            }
        }else{
            cout << "First" << endl;
        }
    }else{
        ll s = 0;
        rep(i,n)s += a[i];
        if(s%2){
            cout << "First" << endl;
        }else{
            cout << "Second" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4416
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
lint mod=1'000'000'007;/*{{{*/
lint inverse(lint x){
    assert(x%mod);
    lint y=1,u=mod,v=0;
    while(x){lint q=u/x;u-=q*x;std::swap(u,x);v-=q*y;std::swap(v,y);}
    assert(x==0&&std::abs(u)==1&&std::abs(y)==mod&&std::abs(v)<mod);
    return v<0?v+mod:v;
}
lint normalized(lint x){if(x<=-mod||mod<=x)x%=mod;if(x<0)x+=mod;return x;}
struct mint{
    lint value;
    mint()=default;
    mint(lint x):value(normalized(x)){}
};
std::ostream&operator<<(std::ostream&os,mint x){return os<<x.value;}
mint operator+(mint x,mint y){lint z=x.value+y.value;if(mod<=z)z-=mod;return mint{z};}
mint operator-(mint x,mint y){lint z=x.value-y.value;if(z<0)z+=mod;return mint{z};}
mint operator*(mint x,mint y){return mint{x.value*y.value%mod};}
mint operator/(mint x,mint y){return mint{x.value*inverse(y.value)%mod};}
mint&operator+=(mint&x,mint y){return x=x+y;}
mint&operator-=(mint&x,mint y){return x=x-y;}
mint&operator*=(mint&x,mint y){return x=x*y;}
mint&operator/=(mint&x,mint y){return x=x/y;}
bool operator==(mint x,mint y){return x.value==y.value;}
bool operator!=(mint x,mint y){return x.value!=y.value;}
mint power(mint x,lint y){mint z=1;for(;y;y>>=1){if(y&1)z*=x;x*=x;}return z;}/*}}}*/
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint h,w,k;std::cin>>h>>w>>k;
    std::vector<lint>a(w,1);
    for(lint i=2;i<w;i++)a.at(i)=a.at(i-1)+a.at(i-2);
    std::vector<std::vector<mint>>mat(w,std::vector<mint>(w));
    for(lint i=0;i<w;i++){
        mat.at(i).at(i)=a.at(i)*a.at(w-i-1);
        if(i)mat.at(i).at(i-1)=a.at(i-1)*a.at(w-i-1);
        if(i)mat.at(i-1).at(i)=a.at(i-1)*a.at(w-i-1);
    }
    auto mul=[&](auto&&p,auto&&q){
        std::vector<std::vector<mint>>c(w,std::vector<mint>(w));
        for(lint i=0;i<w;i++)for(lint j=0;j<w;j++)for(lint k_=0;k_<w;k_++){
            c.at(i).at(j)+=p.at(i).at(k_)*q.at(k_).at(j);
        }
        return c;
    };
    std::vector<std::vector<mint>>ans(w,std::vector<mint>(w));
    for(lint i=0;i<w;i++)ans.at(i).at(i)=1;
    while(h--)ans=mul(ans,mat);
    std::cout<<ans.at(0).at(k-1)<<'\n';
}


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();
        long[] x = new long[n];
        long[] y = new long[n];
        long mod = 1000000007;
        long[] p2 = new long[1000000];
        p2[0] = 1;
        for(int i=1; i<1000000; i++) {
            p2[i] = p2[i-1]*2;
            p2[i] %= mod;
        }

        Map<String, Integer> mapa = new HashMap<>();
        Map<String, Integer> mapb = new HashMap<>();

        boolean zero = false;
        int zn = 0;
        for(int i=0; i<n; i++) {
            long xx = sc.nextLong();
            long yy = sc.nextLong();
            if(xx == 0 && yy == 0) {
               zn++;
            } else if (xx == 0) {
                yy = 1;
            } else if (yy == 0) {
                xx = 1;
            } else {
                long gcd = gcd(Math.abs(xx), Math.abs(yy));
                xx /= gcd;
                yy /= gcd;
                if(xx < 0) {
                    xx = -xx;
                    yy = -yy;
                }
            }
            x[i] = xx;
            y[i] = yy;
        }
        for(int i=0; i<n; i++) {
            if(x[i]==0 && y[i] == 0) {
                continue;
            }
            if(y[i] > 0) {
                String key = key(x[i], y[i]);
                mapa.put(key, mapa.getOrDefault(key, 0)+1);
                mapb.put(key, mapb.getOrDefault(key, 0));
            } else {
                String key = key(-y[i], x[i]);
                mapa.put(key, mapa.getOrDefault(key, 0));
                mapb.put(key, mapb.getOrDefault(key, 0)+1);
            }
        }
        long res = 1;
        for(String key : mapa.keySet()) {
            int a = mapa.get(key);
            int b = mapb.get(key);
            if(a == 0 || b == 0) {
                res *= p2[a+b];
                res %= mod;
            } else {
                long c = (p2[a] + p2[b] - 1 + mod) % mod;
                res *= c;
                res %= mod;
            }
        }

        res += mod - 1;
        res += zn;
        res %= mod;

        System.out.println(res);
    }

    static private String key(long x, long y) {
        if(x >= 0) {
            return x + ":" + y;
        } else {
            return -x + ":" + (-y);
        }
    }
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}

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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	ll N;
	cin >> N;
	vll A(N);
	cin >> A;
	sortall(A);

	//cout << A << endl;

	ll sum = A[0];
	for (int i = 1; i < N; i++) {
		if (sum * 2 < A[i]) {
			A[i - 1] = -1;
		}

		sum += A[i];
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans++;
		if (A[i] == -1)
			ans = 0;
	}

	//cout << A << endl;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1152
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int H, W;
	int ans[52][52] = {0};

	cin >> H >> W;

	vector<string>S(H);

	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = -1; k <= 1; k++) {
				for (int l = -1; l <= 1; l++) {
					if (i + k < 0 || j + l < 0 || i + k >= H || j + l >= W || (k==0 && l==0)) {
						continue;
					}
					if (S[i + k][j + l] == '#') {
						ans[i + 1][j + 1]++;
					}
				}
			}
		}
	}

	for (int i = 1; i < H + 1; i++) {
		for (int j = 1; j < W + 1; j++) {
			if (S[i - 1][j - 1] == '#') {
				cout << "#";
			}
			else {
				cout << ans[i][j];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(15)
#define M_PI 3.141592653589793
using namespace std;

int main() {
  fcout;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  cout << sqrt(a*a+b*b-2*a*b*cos(fabs(m*M_PI/30.0-(M_PI*h/6.0+M_PI*m/360.0))));
}

Measured memory_bytes: 4224
import sys
input = sys.stdin.readline
n = int(input())
num = list(map(int, input().split()))
mod = 10**9+7
num = tuple(num)

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
 
    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret
  
lcd = dict()
for i in num:
  j = primeFactor(i)
  for x,y in j.items():
    if not x in lcd.keys():
      lcd[x] = y
    else:
      lcd[x] = max(lcd[x],y)

lc = 1
for i,j in lcd.items():
  lc *= pow(i,j,mod)
  
ans =0
for i in range(n):
  ans += lc*pow(num[i], mod-2, mod)
  ans %= mod
print(ans)

Measured memory_bytes: 74960
#include <iostream>
#include <vector>
#include <tuple>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
const int inf = 1e9+7;
int main() {
    int n, m; cin >> n >> m;
    vector<vector<pair<int, int> > > g(n);
    repeat (i,m) {
        int a, b, c; cin >> a >> b >> c; -- a; -- b;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    vector<vector<int> > dist = vectors(n, n, inf);
    repeat (i,n) dist[i][i] = 0;
    repeat (i,n) for (auto it : g[i]) dist[i][it.first] = it.second;
    repeat (k,n) repeat (i,n) repeat (j,n) setmin(dist[i][j], dist[i][k] + dist[k][j]); // warshall floyd
    int cnt = 0;
    repeat (i,n) for (auto it : g[i]) {
        int j, cost; tie(j, cost) = it;
        if (i > j) continue;
        bool used = false;
        repeat (k,n) {
            if (dist[i][k] == cost + dist[j][k]) {
                used = true;
                break;
            }
        }
        if (not used) cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace ABC88_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = new int[3][];
            for (int i = 0; i < 3; i++)
            {
                c[i] = ReadLine().Split().Select(int.Parse).ToArray();
            }
            var d0 = new int[3];
            var d1 = new int[3];
            for (int i = 0; i < 3; i++)
            {
                d0[i] = c[i][0] - c[i][1];
                d1[i] = c[i][1] - c[i][2];
            }
            bool f0 = d0[0] == d0[1] && d0[1] == d0[2];
            bool f1 = d1[0] == d1[1] && d1[1] == d1[2];
            WriteLine(f0 && f1 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

#define HMAX 22
#define WMAX 22

int main()
{
    lol result{0};
    lol h, w; cin >> h >> w;
    int a[HMAX][WMAX];
    vector<vector<vector<pair<int, int>>>> b(HMAX, vector<vector<pair<int, int>>>(WMAX));
    memset(a, -1, sizeof(a));
    REP(i, h)
        REP(j, w)
        {
            char ch;
            cin >> ch;
            if(ch == '.')
                a[i][j] = 0;
            else
                a[i][j] = 1;
        }

    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    
    REP(x, h)
        REP(y, w)
        {
            REP(i, 4)
            {
                if(a[x+dx[i]][y+dy[i]] == 0)
                {
                    b[x][y].push_back(make_pair(x+dx[i], y+dy[i]));
                }
            }
        }
    REP(x, h)
        REP(y, w)
        {
            if(a[x][y] == 1) continue;
            int c[HMAX][WMAX] = {};
            int depth[HMAX][WMAX] = {};
            queue<pair<int, int>> que;
            que.push(make_pair(x, y));
            while(!que.empty())
            {
                pair<int, int> u = que.front(); que.pop();
                c[u.first][u.second] = 1;
                REP(i, b[u.first][u.second].size())
                {
                    if(c[b[u.first][u.second][i].first][b[u.first][u.second][i].second] == 0)
                    {
                        c[b[u.first][u.second][i].first][b[u.first][u.second][i].second] = 1;
                        depth[b[u.first][u.second][i].first][b[u.first][u.second][i].second] = depth[u.first][u.second]+1;
                        result = max((int)result, depth[u.first][u.second]+1);
                        que.push(make_pair(b[u.first][u.second][i].first, b[u.first][u.second][i].second));
                    }
                }
            }
            //cout << result << endl;
        }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,sum=0;
	scanf("%d %d",&n,&k);
	int i,arr[n];
	for(i=0;i<n;i++)
	{
		scanf("%d ",&arr[i]);
	}
	sort(arr,arr+n);
	for(i=0;i<k;i++)
	{
		sum+=arr[i];
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 3804
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int a[]=new int[N];
		int start=0,back=0,z=0,ans=100000,ir=1;
		while(z<N){
			a[z]=stdIn.nextInt();
			back+=a[z];
			z++;
		}z=0;
		while(z<N){
			start+=a[z];
			back-=a[z];
			if(start-back<0)
				ir=-1;
			if(ans>(start-back)*ir)
				ans=(start-back)*ir;
			ir=1;z++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
  long long n, a, b, c;
  scanf("%lld %lld %lld",&n, &a, &b);
  if((b-a)%2 == 0) printf("%lld",(b-a)/2);
  else if(a <= n-b+1){
      c = a;
      b -= a;
      a = 1;
      printf("%lld",c + (b-a)/2);
  }else{
      c = n - b + 1;
      a += n - b + 1;
      b = n;
      printf("%lld",c + (b-a)/2);
  }
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    s = list(input().strip())
    ans = 0
    for i in range(len(s)):
        ans += int(s[i])
    if ans % 9 == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 77416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll>t(n);
    rep(0,i,n)cin>>t[i];
    ll m;
    cin>>m;
    vector<ll>d(m);
    rep(0,i,m)cin>>d[i];
    sort(t.begin(),t.end());
    sort(d.begin(),d.end());
    ll c=0;
    rep(0,i,n){
        if(c!=m&&t[i]==d[c])++c;
    }
    if(c==m)cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
int vac(int n,int a[],int b[],int c[])
{
    int dp[n+1][3]={0};
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    return max(dp[n-1][0],max(dp[n-1][2],dp[n-1][1]));
}

int main()
{
    int n;cin>>n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    cout<<vac(n,a,b,c);
}


Measured memory_bytes: 5940
#include<iostream>
#include<cstdio>
using namespace std;
 int dp[200][200] = {0};

 void pgraph(int n){
      for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout << dp[i][j];
      if(j != n)cout << " ";
    }
    cout << endl;
  }

 }
int main(){
  int n,u,k;
  int ad;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      dp[u][ad] = 1;
    }
  }
  pgraph(n);
  return 0;
}


Measured memory_bytes: 3152
n, k = map(int, input().split())
r, s, p = map(int, input().split())
d = {"r":p, "s":r, "p":s}
t = list(input())
dp = [0]*n
for i in range(n):
  if i>=k and t[i]==t[i-k]:
    dp[i] = 0
    t[i] = "x"
  else:
    dp[i] = d[t[i]]
print(sum(dp))


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

using namespace std;

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

  vector<int> as(n);
  for (auto&& a : as) {
    cin >> a;
    --a;
  }

  int ans = 0;
  for (int i = 0; i < as.size(); ++i) {
    if (as[i] <= i) {
      continue;
    }

    if (as[as[i]] == i) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N, vector<int>(N)), y(N, vector<int>(N));
    for (int i=0; i<N; i++){
        cin >> A.at(i);
        for(int j=0; j<A.at(i); j++){
            cin >> x.at(i).at(j) >> y.at(i).at(j);
          	x.at(i).at(j) -= 1;
        }
    }
    int max=0;
    for (int i=0; i<pow(2,N); i++){
        int I=i;
        vector<int> binary(N);
        for(int j=0; j<N; j++){
            binary.at(j) = I%2;
            I = I/2;
        }
        
        bool judge = true;
        for(int j=0; j<N; j++){
            if(binary.at(j)==1){
                for(int k=0; k<A.at(j); k++){
                    if(y.at(j).at(k) == 1){
                        if(binary.at(x.at(j).at(k)) == 0) judge = false; 
                    }else{
                        if(binary.at(x.at(j).at(k)) == 1) judge = false;
                    }
                  	
                }
            }
        }
        if(judge){
            int sum=0;
            for(int j=0; j<N; j++){
                sum += binary.at(j);
            }
            if (sum > max) max=sum;
        }
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
   sort(a,a+3);
    cout << a[2] -a[0];
}

Measured memory_bytes: 256
s=[]
t=[]
n=gets.to_i
n.times{s<<gets.chomp}
m=gets.to_i
m.times{t<<gets.chomp}
h=Hash.new(0)
s.each{|x|h[x]+=1}
t.each{|x|h[x]-=1}
puts h.values.push(0).max

Measured memory_bytes: 1916
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = 1, 1
frac = 1
for i in range(N - 1):
  frac *= (i + 1)
for i in range(N):
  a += (A[i] - 1) * frac
  b += (B[i] - 1) * frac
  if i != N - 1:
    for j in range(i + 1, N):
      if A[j] > A[i]:
        A[j] -= 1
      if B[j] > B[i]:
        B[j] -= 1
    frac //= (N - 1 - i)
print(abs(a - b))

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

int main(){
  int n,y;
  double b,r,t;
  int ans;
  double val,tmp;

  while(cin >> n, n){
    cin >> y;
    val = 0.0;
    for(int i=0;i<n;i++){
      cin >> b >> r >> t;
      if(t==1)tmp = 1+y*r/100;
      else tmp = pow(1+r/100,y);
      if(val<tmp){
	val = tmp;
	ans = b;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
A,B,C= map(int,input().split())
K=int(input())

counter=0
while B<=A:
    B*=2
    counter+=1
    if counter>K:
        break
while C<=B:
    C*=2
    counter+=1
    if counter>K:
        break
if counter>K:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

bool black[3000100];
int main(){
    string S;
    cin >> S;
    int N = S.length();
    REP(i,N){
        char x = S[i];
        if(x == 'B')
            black[i] = true;
        else
            black[i] = false;
    }

    ll num = 0;
    ll ans = 0;
    //for(int i = N-1; i >= 0; i--){
    //   int T = N-1-num;
    //   if(black[i]){
    //       num++;
    //       ans += T - i;
    //   }
    //}
    //cout << ans << endl;
    //ans = 0;
    //num = 0;
    for(int i = 0; i < N; i++){
       if(!black[i]){
           ans += i - num;
           num++;
       }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 772
import copy
N,K,C = list(map(int, input().split()))
S = list(input())
mae = [0]*K
ushiro = [0]*K
hi = 0
youso = 0

while True:
    if S[hi] == 'o':
        mae[youso] = hi+1
        youso += 1
        if youso == K:
            break
        hi += C
    hi += 1

hi = N-1
youso = 0

while True:
    if S[hi] == 'o':
        ushiro[youso] = hi+1
        youso += 1
        if youso == K:
            break
        hi -= C
    hi -= 1
ushiro.reverse()

for j in range(len(mae)):
    if mae[j] == ushiro[j]:
        print(mae[j])











Measured memory_bytes: 22396
import collections
n=int(input())
a=list(map(int,input().split()))
M=max(a)
c=collections.Counter(a)
com=[[0] for i in range(M+1)]
for i in range(M+1):
    com[i]=c[i]*(c[i]-1)//2
s=sum(com)
for i in range(n):
    newcom=(c[a[i]]-1)*(c[a[i]]-2)//2
    print(s-com[a[i]]+newcom)


Measured memory_bytes: 110156
#include <iostream>
#include <cstdio>
#include <cstring>
#define re register int
using namespace std;
string str;
int l;
int main()
{
	cin>>str;
	l=str.length();
	std::cout<<str[0]<<l-2<<str[l-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            double[] height = new[] { -1.0, -1.0 };
            while((input = Console.ReadLine()) != null) {
                double temp = double.Parse(input);
                height[0] = height[0] == -1 ? temp : height[0] > temp ? temp : height[0];
                height[1] = height[1] == -1 ? temp : height[1] < temp ? temp : height[1];
            }
            Console.WriteLine("{0:F2}", height[1] - height[0]);
        }
    }
}

Measured memory_bytes: 5768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

int main()
{
	int N;
	cin >> N;
	queue<string> que;
	vector<char> c;

	for (int i = 0; i < N; i++)
	{
		c.push_back(i + 'a');
	}

	que.push("a");
	for (int i = 1; i < N; i++)
	{
		// 長さiのphase
		int M = que.size();
		for (int j = 0; j < M; j++)
		{
			string p = que.front();
			que.pop();
			map<char, int> mp;
			for (int k = 0; k < p.size(); k++)
			{
				mp[p[k]]++;
			}

			for (int k = 0; k < i + 1; k++)
			{
				if (mp[c[k]] > 0)
					que.push(p + c[k]);
			}
			for (int k = 0; k < i + 1; k++)
			{
				if (mp[c[k]] == 0)
				{
					que.push(p + c[k]);
					break;
				}
			}
		}
	}
	int M = que.size();
	vector<string> s;
	for (int i = 0; i < M; i++)
	{
		s.push_back(que.front());
		que.pop();
	}

	sort(s.begin(), s.end());

	for (int i = 0; i < M; i++)
	{
		cout << s[i] << "\n";
	}
}


Measured memory_bytes: 10744
#include <iostream>
#include<vector>
#include<string>
#include<bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
using namespace std;





int main(){
ios::sync_with_stdio(false);
  cin.tie(0);
int n;
cin>>n;
string s;

int a,b,c,d;
cin>>a>>b>>c>>d;
cin>>s;
for(int i=b-1;i<d;i++){
    if(s[i]=='#' && s[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
    }
}
for(int i=a-1;i<c;i++){
     if(s[i]=='#' && s[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
    }
}
if(d>c){
    cout<<"Yes"<<endl;
    return 0;
}
for(int i=b-1;i<d;i++){
    if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){
        cout<<"Yes"<<endl;
        return 0;
    }
}
cout<<"No"<<endl;
}


Measured memory_bytes: 592