akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
void DFS(ll n,string s,char c){
  char i,maxi='a';
  ll j;
  if(n==1){
    printf("%s\n",(s+c).c_str());
  }else{
    s+=c;
    rep(j,s.size()){
      maxi = max(maxi,s[j]);
    }
    for(i='a';i<=maxi+1;i++){
      DFS(n-1,s,i);
    }
  }
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  DFS(n,"",'a');
  return 0;
}



Measured memory_bytes: 1536
N,Ma,Mb = map(int,input().split())

INF = 10000

dp = [[INF for b in range(401)] for a in range(401)]

dp[0][0] = 0

sum_a = 0
sum_b = 0

for i in range(1,N+1):
    ai,bi,ci = map(int,input().split())
    sum_a += ai
    sum_b += bi
    for a in range(sum_a+1,-1,-1):
        for b in range(sum_b+1,-1,-1):
            if a-ai >= 0 and b-bi >= 0:
                dp[a][b] = min(dp[a][b],dp[a-ai][b-bi]+ci)


ans = INF
for j in range(1,401):
    if Ma*j > 400 or Mb*j > 400:
        break
    ans = min(ans,dp[Ma*j][Mb*j])
print(ans if ans != INF else -1)


Measured memory_bytes: 4852
N,M = (int(x) for x in input().split())
cor = 0
mis = 0
numList = [0] * N
misList = [0] * N

for _ in range(M):
    num,ans = input().split()

    if ans == 'WA':
        misList[int(num)-1] += 1
    else:
        if numList[int(num)-1] == 0:
            mis += misList[int(num)-1]
            cor += 1
            numList[int(num)-1] = 1

print(cor,mis)





Measured memory_bytes: 4596
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int h, w, x, y, r;
	cin >> h >> w >> x >> y >> r;
	if((x + r) > h || (x - r) < 0 || (y + r) > w || (y - r) < 0)
		cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 3116
N = int(input())
a = list(map(int, input().split()))
ans = 0
while True:
	odd = 0 
	for i in range(len(a)):
		if a[i] % 2 != 0:
			odd += 1
		else:
			a[i] /= 2
			ans += 1
	if odd == len(a):
		break
print(ans) 

Measured memory_bytes: 4148
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
int32_t main()
{
   string s; cin >> s;
   int ans = 0;
   for(char c: s) 	ans = (ans + c - '0') % 9;
   cout << (ans == 0? "Yes":"No");	
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ll n,x,t;
  cin>>n>>x>>t;
 if(n%x==0) cout<<n/x*t;
else cout<<(n/x+1)*t;
return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = new[] { "a" };
        for (int i = 2; i <= n; i++)
        {
            s = s.SelectMany(Nexts).ToArray();
        }

        Console.WriteLine(string.Join("\n", s.OrderBy(x => x)));
    }
    static IEnumerable<string> Nexts(string x)
    {
        var maxChar = (char)(x.Max() + 1);
        for (char i = 'a'; i <= maxChar; i++)
        {
            yield return x + i;
        }
    }
}


Measured memory_bytes: 33364
N, Y=list(map(int, input().split()))
ans=[-1, -1, -1]
flag=False
for x in range(N, -1, -1):
    for y in range(N-x, -1, -1):
        if 10000*x+5000*y+1000*(N-x-y)==Y:
            ans=[x,y,N-x-y]
            flag=True
            break
        if flag==True:
            break
    if flag==True:
        break
print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3064
n, m = map(int, input().split())
light = []
for i in range(m):
    tmp = list(map(int, input().split()))
    light.append(tmp[1:])
p = list(map(int, input().split()))
ans = 0
# 0 off, 1 on, bit全探索
for mask in range(1 << n):
    # print(mask)
    out = False
    # それぞれの電球について見る
    for i in range(len(light)):
        cnt = 0
        # 各電球が点くかを見たい
        for check in light[i]:
            if mask >> (check - 1) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            out = True
            break
    if not out:
        ans += 1

print(ans)


Measured memory_bytes: 9148
// ------------------------------------
// Date:2018/ 3/ 2
// Problem:AOJ DPL Longest Increasing Subsequence 1_D.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

//static const int MOD = 1000000007;

int main()
{
  int n;
  int a[101010];
  // dp[num]:num番目までのLISの長さ
  int dp[101010];

  memset(a, 0, sizeof(a));
  scanf("%d", &n);
  fill_n(dp, n, 1e9+1);
  REP(i, n) {
    scanf("%d", &a[i]);
  }
  
  REP(i, n) {
    *lower_bound(dp, dp+n, a[i]) = a[i];
  }
  printf("%d\n", distance(dp, lower_bound(dp, dp + n, 1e9+1)));
  /*
  REP(i, n) {
    printf("dp[%d] = %d\n", i, dp[i]);
  }
   */
  return 0;
}




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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    ll a , b ;
    cin >> a >> b ;

    ll t  = a * 3 + b ;
    t >>= 1 ;

    cout << t ;
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    string s,t;
    cin>>s>>t;
    s+=t;

    int a;
    stringstream ss(s);ss>>a;

    for(int i=1;i<11111;i++){
        if(i*i==a){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
int N;
int A[222222];
 
vint get(int n){
    vint ret;
    for(int i=1;i<=n;i++){
        if(n%i==0)ret.pb(i);
    }
    return ret;
}
 
signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
 
    vint lis=get(N);
 
    for(int k:lis){
        bool ok=true;
        for(int i=0;i+k<N;i++){
            if(A[i]!=A[i+k])ok=false;
        }
        if(ok){
            cout<<N/k<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4704
N = int(input())
ans = N
for i in range(N+1):
  t = i
  cc = 0
  while t > 0:
    cc += t % 6
    t //= 6
  t = N - i
  while t > 0 :
    cc += t % 9
    t //= 9
  if ans > cc:
    ans = cc
print(ans)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> S;

    N = S.size();
    if (S.at(N-1)=='s'){
        S.push_back('e');
    }
    S.push_back('s');
    cout << S << endl;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;


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

  int N;
  cin >> N;
  const int B = 1<<N;

  VVL xs(N, VL(N));
  cin >> xs;

  VL cost(B);
  REP(b,B){
    REP(i,N) REP(j,i){
      if((b>>i&1) && (b>>j&1)){
        cost[b] += xs[i][j];
      }
    }
  }

  VL dp(B);
  REP(b,B){
    for(int mask=b;;mask=(mask-1)&b){
      maxi(dp[b], dp[b^mask] + cost[mask]);
      if(mask == 0) break;
    }
  }

  cout << dp[B-1] << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

// ??????????????§??°
#define MAX_V 10000

class edge {
public:
  int from, to, cost;
  edge(int from = 0, int to = 0, int cost = 0): from(from), to(to), cost(cost) {}
  bool operator < (const edge &e) const {
    return e.cost < cost;
  }
};

int V;
vector <edge> graph[MAX_V];

// ??????????????§????°???¨?????¨????±???????
// O(|E|log|E|)
int prim() {
  bool used[MAX_V];
  memset(used, false, sizeof(used));
  int ret = 0;
  int cnt = 0;

  priority_queue<edge> pque;
  for (int i = 0; i < graph[0].size(); i++) {
    // ??????0????????????????????????????????????????????\????????????
    pque.push(graph[0][i]);
  }
  cnt++;
  used[0] = true;
  while (true) {
    // ??¢????¨????????????????????????????????????????
    while (!pque.empty() && used[pque.top().to]) pque.pop();
    if (pque.empty()) break;

    int p = pque.top().to;
    used[p] = true;
    ret += pque.top().cost;
    pque.pop();
    // ??????p???????¨??????????????????????????????????????????????????????\????????????
    for (int i = 0; i < graph[p].size(); i++) {
      edge e = graph[p][i];
      if (used[e.to]) continue;
      cnt++;
      pque.push(e);
    }
  }

  return ret;
}

int main() {
  int E;
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    graph[s].push_back(edge(s, t, w));
    graph[t].push_back(edge(t, s, w));
  }
  cout << prim() << endl;
}

Measured memory_bytes: 6912
n=int(input())
a=list(map(int,input().split()))
asum=sum(a)
b=list(map(int,input().split()))
for i in range(n):
    if a[n-i]<=b[n-i-1]:#勇者の次の街にいるモンスターが勇者が倒せる数より少ない場合
        b[n-i-1]-=a[n-i]
        a[n-i]=0
        if a[n-i-1]<=b[n-i-1]:#勇者の街にいるモンスターが勇者が倒せる数ののこりより少ない場合
            b[n-i-1]-=a[n-i-1]
            a[n-i-1]=0
        else:
            a[n-i-1]-=b[n-i-1]
            b[n-i-1]=0
    else:
        a[n-i]-=b[n-i-1]
        b[n-i-1]=0
answer=asum-sum(a)
print(answer)

Measured memory_bytes: 19004
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

alias Monster = Tuple!(long, "x", long, "h");

long calc(long d, long a, Monster[] ms) {
    int n = cast(int)ms.length;
    ms.sort!"a.x < b.x";
    auto xs = ms.map!"a.x".assumeSorted;

    auto bit = new BIT2!long(ms.length);

    foreach (i; 0..n) bit.add(i+1, i+1, ms[i].h);
    long ans = 0;
    foreach (i; 0..n) {
        auto s = bit.sum(i+1) - bit.sum(i);
        if (s <= 0) continue; // 生きているモンスターはいない

        // モンスターを倒すのに必要な爆弾の数
        long cnt = (s + a - 1) / a;

        // 左端から爆弾がとどく範囲
        auto len = cast(int)xs.lowerBound(ms[i].x + 2 * d + 1).length;
        bit.add(i+1, len, -a * cnt);
        ans += cnt;
    }
    return ans;
}

void main() {
    long n, d, a; scan(n, d, a);
    Monster[] ms;
    foreach (_; 0..n) {
        long x, h; scan(x, h);
        ms ~= Monster(x, h);
    }
    writeln(calc(d, a, ms));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;

class BIT2(T) {
    private T[] _data0;
    private T[] _data1;

    T __sum(const T[] data, int p) const {
        T s = 0;
        while (p > 0) {
            s += data[p];
            p -= p & -p;
        }
        return s;
    }

    void __add(T[] data, int p, T x) {
        while (p < data.length) {
            data[p] += x;
            p += p & -p;
        }
    }

    /// [1, n]
    this(size_t n) {
        _data0 = new T[n + 10];
        _data1 = new T[n + 10];
    }

    /// [1, ind] の和(1 based)
    T sum(int ind) const {
        return __sum(_data0, ind) + __sum(_data1, ind) * ind;
    }

    /// 区間 [l, r] に x を加える(1 based)
    void add(int l, int r, T x) {
        __add(_data0, l, -x * (l - 1));
        __add(_data0, r + 1, x * r);
        __add(_data1, l, x);
        __add(_data1, r + 1, -x);
    }
}


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

int ggg(int a, int b){
    if(b==0)return a;
    else return ggg(b,a%b);
}
int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while(k != 0);
	return result;
}
int lcm(int a, int b) {
	int g;
	g = gcm(a, b);
	return a*b/g;
}
int lcm_n(vector<int> &numbers) {
	int l;
	l = numbers[0];
	for (int i = 1; i < numbers.size(); i++) {
		l = lcm(l, numbers[i]);
	}
	return l;
}

int main(){
int n;
cin >> n;
vector<int>aa(n);
rep(i,n){
    cin >>aa.at(i);
}
int lc = lcm_n(aa);

int count = 0;
rep(i,n){
    count += lc/aa.at(i);
}
cout<<(double)lc/(double)count<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];

        for(int i=0;i<n;i++){
            a[i]=in.nextInt();
        }

        int count=0;
        for(int i=1;i<n-1;i++){
            if((a[i]> a[i+1] && a[i]<a[i-1]) || (a[i]< a[i+1] && a[i]>a[i-1]))
                count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		String y = s.next();

		if (n < y.length()) {
			y = y.substring(0, n);
			System.out.println(y + "...");

		} else
			System.out.println(y);

	}
}



Measured memory_bytes: 38716
#include <bits/stdc++.h>
template <typename T>
std::vector<T> prime(const T max) {
  std::vector<bool> sieve(max - 1, true);
  const auto lim = std::floor(std::sqrt(max));

  if (max < 2) {
    return {};
  }

  T var = 2;
  while (var <= lim) {
    for (T i = 2; i * var <= max; i++) {
      sieve[i * var - 2] = false;
    }
    do {
      var++;
    } while (!sieve[var - 2] && var <= lim);
  }

  std::vector<T> ans;
  ans.reserve(std::count(sieve.cbegin(), sieve.cend(), true));
  for (T i = 0; i < max - 1; i++) {
    if (sieve[i]) {
      ans.push_back(i + 2);
    }
  }

  return ans;
}

int main() {
  int n;
  std::cin >> n;
  const auto p = prime(55555);
  int count = 0;
  for (const auto i : p) {
    if (((i - 1) % 5) == 0) {
      if (count == n - 1) {
        std::cout << i << std::endl;
        return 0;
      } else {
        std::cout << i << " ";
        count++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mx = 1e5+5;
const long long  INF =1e10;
ll  dp[mx],wi[105],val[105];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,W;
    ll V=0;
    cin>>n>>W;
    for(int i=0;i<n;i++)
    {
        cin>>wi[i]>>val[i];
        V+=val[i];
    }
    for(int i=0;i<=V;i++)
        dp[i] = INF;
        dp[0] =0;
    for(int i=0;i<n;i++)
    {
        ll w = wi[i],v = val[i];
        for(int k = V;k>=v;k--)
            dp[k] = min(dp[k],dp[k-v]+w);
    }
    ll ans =0;
    for(int i=V;i>=0;i--)
       {
           if(dp[i]<=W)
            {
                ans = i;
                break;
            }
       }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;

int main(){
  double n,m,d,ans;
  cin>>n>>m>>d;
  cout<<fixed<<setprecision(10);
  if(d==0) ans=(m-1)/n;
  else ans=2*(n-d)*(m-1)/n/n;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int c[51];
int main()
{
    int n,m;
    int a,b;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d %d",&a,&b);
        c[a]++;
        c[b]++;
    }
    for(int i=1;i<=n;i++)
        printf("%d\n",c[i]);
}


Measured memory_bytes: 760
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();

		//listの配列を作りたい
		List<List<Integer>> list = new ArrayList<List<Integer>>();
		for(int i = 0; i < n; i++) {
			list.add(new ArrayList<Integer>());
		}

		for(int i = 0; i < q; i++)	{
			int query = sc.nextInt();
			int t = sc.nextInt();

			switch(query){
			case 0:
				int x = sc.nextInt();
				list.get(t).add(x);  //listの中のt番目の要素を取得し、それにaddする
				break;

			case 1:
				for(int j = 0; j < list.get(t).size(); j++) {
					if(j != 0) System.out.print(" ");
					System.out.print(list.get(t).get(j));
				}
				System.out.println();
				break;

			case 2:
				list.get(t).clear();
				break;
		}

		}
	}

}



Measured memory_bytes: 309628
list1 = []
for x in range(3):
    list1.append([int(i)for i in input().split()])
n = int(input())
indices = []
for x in range(n):
    val = int(input())
    if val in list1[0]:
        indices.append([list1[0].index(val),0])
    elif val in list1[1]:
        indices.append([list1[1].index(val),1])
    elif val in list1[2]:
        indices.append([list1[2].index(val),2])
    else:
        indices.append(-1)
if [0,0] in indices and [0,1] in indices and [0,2] in indices:
    print("Yes")
elif [1,0] in indices and [1,1] in indices and [1,2] in indices:
    print("Yes")
elif [2,0] in indices and [2,1] in indices and [2,2] in indices:
    print("Yes")
elif [0,0] in indices and [1,0] in indices and [2,0] in indices:
    print("Yes")
elif [0,1] in indices and [1,1] in indices and [2,1] in indices:
    print("Yes")
elif [0,2] in indices and [1,2] in indices and [2,2] in indices:
    print("Yes")
elif [0,0] in indices and [1,1] in indices and [2,2] in indices:
    print("Yes")
elif [0,2] in indices and [1,1] in indices and [2,0] in indices:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int n,k; 

  k=0;
  cin >> n;
  
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i) >> y.at(i);
  }
  
  for (int i = 0; i < n; i++) {
    if (x.at(i) == y.at(i)){
      k = k + 1;
      if (k == 3){
        break;
      }
    }
    else{
      k = 0;
    }

  }
  if (k ==3){
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    long x,k,d;cin>>x>>k>>d;
    x=abs(x);
    long m=x%d;
    long mm=min(m,d-m);
    long move;
    long res;
    if(mm<m){
        move=(x+mm)/d;
    }else{
        move=(x-m)/d;
    }
    if(k<=move){
        res=abs(x-k*d);
    }
    if(k>move){
        long kk=k-move;
        if(kk%2==0)res=mm;
        if(kk%2==1)res=min(abs(mm-d),abs(mm+d));
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3632
from itertools import accumulate
N, K = map(int, input().split())
S = [0] + list(accumulate(range(N+2)))
M = 10**9 + 7
ans = 0
for i in range(K, N+2):
    ans += S[N+2] - S[N+2-i] - S[i+1] + 1
    ans %= M
print(ans)

Measured memory_bytes: 20696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    
    char x = s[0];
    char y = s[n-1];
    rep(i,n-1){
        if(s[i+1]==x){
            ans++;
            break;
        }
    }
    rep(i,n-1){
        if(s[i]==y){
            ans = max(ans,1);
            break;
        }
    }
    
    
    for(int i=1;i<n-1;++i){
        int res=0;
        string a,b;
        map<char,int> A,B;
        a = s.substr(0,i+1);
        b = s.substr(i+1);
        rep(i,a.size()) A[a[i]]++;
        rep(i,b.size()) B[b[i]]++;
    for(auto itr=A.begin();itr!=A.end();++itr){
        if(B[itr->first] > 0) res++;
        }
        ans = max(ans,res);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

n, q = map(int, input().split())
stx = []
for _ in range(n):
    s, t, x = map(int, input().split())
    stx.append([x, s - x, t - x])
stx.sort(reverse=True)
d = [int(input()) for _ in range(q)]

N = q
N0 = 2**(N-1).bit_length()
data = [None]*(2*N0)
INF = (-1, 10**9 + 1)
def update(l, r, v):
    L = l + N0; R = r + N0
    while L < R:
        if R & 1:
            R -= 1
            data[R-1] = v

        if L & 1:
            data[L-1] = v
            L += 1
        L >>= 1; R >>= 1
def _query(k):
    k += N0-1
    s = INF
    while k >= 0:
        if data[k]:
            s = max(s, data[k])
        k = (k - 1) // 2
    return s
def query(k):
    return _query(k)[1]



import bisect

for i, (x, start, last) in enumerate(stx):
    l = bisect.bisect_left(d, start)
    r = bisect.bisect_left(d, last)
    update(l, r, (i, x))

for i in range(q):
    res = query(i)
    if res == 10**9 + 1:
        print(-1)
    else:
        print(res)
    



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

int main(void) {
	long long int sum = 0;
	unordered_map<int, int> umap;
	int N; cin >> N;
	int A[N]; for(int& Ai: A) {
		cin >> Ai;
		sum += Ai;
		umap[Ai]++;
	}
	int Q; cin >> Q;
	while(Q--) {
		int Bi, Ci; cin >> Bi >> Ci;
		int c = umap[Bi];
		sum -= 1ll*c*Bi;
		sum += 1ll*c*Ci;
		umap[Bi] = 0;
		umap[Ci] += c;
		
		cout << sum << '\n';
	}
}


Measured memory_bytes: 7524
fun main (args : Array<String>) {
	val n = readLine()
	val N : Int = n!!.toInt()
	val l = readLine()!!.split(" ")
	var list : MutableList<Int> = mutableListOf()
	var calc : Int = 0
	for (i in l) {
		list.add(i.toInt())
	}
	list.sort()
	for (i in 0..list.size - 2) {
		calc += list[i]
	}
	return if (list[N - 1] < calc) {
		println("Yes")
	} else {
		println("No")
	}
}

Measured memory_bytes: 37872
# D
from itertools import permutations
from collections import deque

N, M, R = map(int, input().split())
r_list = list(map(int, input().split()))



# read graph
G = dict()
for i in range(N):
    G[i+1] = dict()
for _ in range(M):
    A, B, C = map(int, input().split())
    G[A][B] = C
    G[B][A] = C

# minimum length
dist_list = [[0]*R for _ in range(R)]

for i in range(R):
    # BFS
    que = deque([r_list[i]])
    d_list_i = [M*100000+1]*(N+1)
    d_list_i[r_list[i]] = 0
    while len(que) > 0:
        s = que.popleft()
        for t in G[s].keys():
            if d_list_i[s] + G[s][t] < d_list_i[t]:
                d_list_i[t] = d_list_i[s] + G[s][t]
                que.append(t)
            else:
                pass
        
    for j in range(R):
        dist_list[i][j] = d_list_i[r_list[j]]
    
# power forever    
perms = list(permutations(range(R)))

res = (M*100000+1)*R
for p in perms:
    res_ = 0
    for i in range(R-1):
        res_ += dist_list[p[i]][p[i+1]]
    res = min(res, res_)
    
# print(G)
# print(dist_list)
print(res)

Measured memory_bytes: 11556
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp, mpo;
    rep(i, n){
        cin >> a[i];
        mp[a[i]]++;
    }

    ll sum = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        sum += (itr->second)*(itr->second-1)/2;
    }
    
    rep(i, n){
        ll tmp = sum - (mp[a[i]])*(mp[a[i]]-1)/2;
        if (mp[a[i]]>=2) tmp += (mp[a[i]]-1)*(mp[a[i]]-2)/2;

        cout << tmp << endl;
    }

    return 0;
}

Measured memory_bytes: 11136
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long  x; cin >> x;
	long long  ans = (x / 500) * 1000;
	x %= 500;
	debug(x);
	ans += (x / 5) * 5;
	cout << ans;

	return 0;
}

Measured memory_bytes: 3152
N, L = map(int, input().split())

t = [L + _ - 1 for _ in range(1, N+1)] # 絶対値が一番小さい要素を0に変えてsumをとりたい
abseat = 299
eat = 299

for i in range(N):
    abst = abs(t[i])
    if abst < abseat:
        abseat = abs(t[i])
        eat = t[i]

ans = sum(t) - eat
print(ans)

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!

def roundRobin(task_list, q):
    total_time = 0
    task_result = []

    while len(task_list) > 0:
        task = task_list.pop(0)

        if task[1] > q:
            total_time += q
            task[1] -= q
            task_list.append(task)
        else:
            total_time += task[1]
            task_result.append([task[0], str(total_time)])

    for res in task_result:
        print(' '.join(res))


if __name__ == "__main__":
    n, q = [int(i) for i in input().split()]

    task_list = []

    for _ in range(n):
        key, value = input().split()
        task_list.append([key, int(value)])
    roundRobin(task_list, q)




Measured memory_bytes: 15668
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

ll arr[200005];

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

	ll x = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		x = x ^ arr[i];
	}

	for (int i = 0; i < n; i++)
	{
		cout << (x ^ arr[i]) << ' ';
	}
}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
struct mat{
	int a[4][4];
	mat(){memset(a,0,sizeof a);}
	void init(){for(int i=0;i<4;i++)a[i][i]=1;}
	mat operator*(const mat&b)const
	{
		mat c;
		for(int k=0;k<4;k++)
		for(int i=0;i<4;i++)
		for(int j=0;j<4;j++)
		c.a[i][j]=(c.a[i][j]+1ll*a[i][k]*b.a[k][j])%mod;
		return c;
	}
}ans,p,q;
int n,m;
mat qpow(mat a,int b)
{
	mat ret;
	ret.init();
	while(b)
	{
		if(b&1)ret=ret*a;
		a=a*a,b>>=1;
	}
	return ret;
}
int main()
{
	scanf("%d%d",&n,&m);
	p.a[0][0]=2;p.a[0][1]=1;p.a[0][2]=1;p.a[0][3]=1;
	p.a[1][0]=1;p.a[1][1]=1;p.a[1][2]=0;p.a[1][3]=1;
	p.a[2][0]=1;p.a[2][1]=0;p.a[2][2]=1;p.a[2][3]=1;
	p.a[3][0]=1;p.a[3][1]=0;p.a[3][2]=0;p.a[3][3]=1;
	q.a[0][0]=1;q.a[0][1]=1;q.a[0][2]=1;q.a[0][3]=1;
	q.a[1][0]=0;q.a[1][1]=1;q.a[1][2]=0;q.a[1][3]=1;
	q.a[2][0]=0;q.a[2][1]=0;q.a[2][2]=1;q.a[2][3]=1;
	q.a[3][0]=0;q.a[3][1]=0;q.a[3][2]=0;q.a[3][3]=1;
	ans.init();
	int x,lst=0;
	while(m--)
	{
		scanf("%d",&x);
		ans=ans*qpow(p,x-lst-1)*q;
		lst=x;
	}
	ans=ans*qpow(p,n-lst);
	cout<<ans.a[0][3]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll a[(1<<18)],w[(1<<18)],dp[(1<<9)][100005],dep[(1<<18)];
void solve(){
	ll n,q;
	cin>>n;
	for(ll i=1;i<=n;i++)
	cin>>a[i]>>w[i];
	for(ll i=2;i<=n;i++){
		dep[i]=dep[i-1];
		if(!(i&(i-1)))
		dep[i]++;
	}
	for(ll i=1;i<=min(ll((1<<9)-1),n);i++){
		for(ll j=1;j<=100000;j++){
			dp[i][j]=dp[i/2][j];
			if(j>=w[i])
			dp[i][j]=max(dp[i][j],dp[i/2][j-w[i]]+a[i]);
		}
	}
	cin>>q;
	for(ll qc=0;qc<q;qc++){
		ll v,l,res=0;
		cin>>v>>l;
		if(dep[v]<9)
		res=dp[v][l];
		else{
			vector<ll> g;
			while(dep[v]>=9){
				g.push_back(v);
				v>>=1;
			}
			ll m=ll(g.size());
			for(ll i=0;i<(1<<m);i++){
				ll sum=0,tot=0,tr=i,c=0;
				while(tr>0){
					if(tr&1){
						tot+=w[g[c]];
						sum+=a[g[c]];
					}
					tr>>=1;
					c++;
				}
				if(tot<=l)
				res=max(res,sum+dp[v][l-tot]);
			}
		}
		cout<<res<<"\n";
	}
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
    solve();		
}


Measured memory_bytes: 408956
#include <bits/stdc++.h>
using namespace std;
int read() {
	int f = 1, x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -f;
		ch = getchar();
	} while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return f * x;
}
	long long a, b, n;
	long long calc(long long x) {
		return a * x / b - a * (x / b); 
	}
int main() {
	cin >> a >> b >> n;
	long long l = 0, r = n;
	while (r - l > 2000000) {
		long long ql = l + (r - l) / 3, qr = r - (r - l) / 3;
		if (calc(ql) < calc(qr)) l = ql;
		else r = qr; 
	}
	long long ans = 0;
	for (long long t = l; t <= r; ++t) ans = max(ans, calc(t));
	for (long long i = 1; i <= min(n, 2000000LL); ++i) ans = max(ans, calc(i));
	cout << ans << endl;
	return 0;
}






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

typedef long long ll;

int a[25], b[25], c[25];

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

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

  int sat = 0;

  for (int i = 1; i <= n; i++) {
    sat += b[a[i]];
  }

  for (int i = 2; i <= n; i++)
    if (a[i] == a[i - 1] + 1) sat += c[a[i - 1]];

  cout << sat << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
	int N;
	cin >> N;
	int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout << a[N] << endl;
}	

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

using namespace std;

int main() {
    // Input
    string S, T;
    cin >> S;
    cin >> T;

    // Process
    string ans;
    if (T.substr(0, S.size()) == S) {
        ans = "Yes";
    } else {
        ans = "No";
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

H, W = get_ints

S = []
H.times do |i|
  S[i] = gets.chomp.split('')
end

def check(i, j, array)
  return true if array[i][j] != '#'

  test = []
  if i > 0
    test << array[i-1][j]
  end
  if i < array.length - 1
    test << array[i+1][j]
  end
  if j > 0
    test << array[i][j-1]
  end
  if j < array[0].length - 1
    test << array[i][j+1]
  end
  test.any? { |s| s == '#' }
end

ans = true
S.each.with_index do |h, i|
  S.each.with_index do |s, j|
    unless check(i, j, S)
      ans = false
      break
    end
  end
  break unless ans
end

puts ans ? 'Yes' : 'No'


Measured memory_bytes: 14712
using System;
using System.Text;
using System.Collections.Generic;

public class MainCls
{
	public static void Main(string[] args)
	{
		string[] a = Console.ReadLine().Split(' ');
		bool m = (a[0] == a[1]) && (a[0] == a[2]) && (a[1] == a[2]);
		Console.WriteLine(m ? "Yes" : "No");
	}

}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main() {
  int n;
  
  int res = 0;
  
  cin >> n;
  
  while (n--) {
    int k;
    cin >> k;
    
    res += (k-1);
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3632
X, Y = map(int, input().split())

l = [[300000,200000,100000],[300000,200000,100000]]
x = 0
y = 0


if X == 1 and Y == 1:
    print(1000000)
else:
    if 1<= X <= 3:
        x = l[0][X-1]
    if  1 <= Y <= 3:
        y=l[1][Y-1]
    print(x+y)

Measured memory_bytes: 3060
INPUTS = list(map(int, input().split()))

INPUTS.sort()
ans = INPUTS[2] - INPUTS[1]
INPUTS[0] += ans
if (INPUTS[2] - INPUTS[0]) % 2 == 0:
    ans += (INPUTS[2] - INPUTS[0]) // 2
else:
    ans += (INPUTS[2] - INPUTS[0] + 1) // 2
    ans += 1

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int a=0,b=0,o=0,ab=0;
	int n;
	char blood[3];
	while(scanf("%d,%s",&n,blood)!=EOF){
		if(blood[0]=='A'&&blood[1]=='\0') a++;
		if(blood[0]=='B'&&blood[1]=='\0') b++;
		if(blood[0]=='O'&&blood[1]=='\0') o++;
		if(blood[0]=='A'&&blood[1]=='B') ab++;
	}
	printf("%d\n%d\n%d\n%d\n",a,b,ab,o);	
	return 0;
}

Measured memory_bytes: 596
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		int P = 0;
		for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		}
		double avg = (double)P/N;
		//System.out.println(avg);
		int zahyou = (int)Math.floor(avg);
		//System.out.println(zahyou);
		int zahyou2 = (int)Math.ceil(avg);
		//System.out.println(zahyou2);

		int souwa = 0;
		int souwa2 = 0;
	
		for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			}
		System.out.println(Math.min(souwa, souwa2));
		}
}

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

int main()
{
    long long i ,o ,t ,j ,l ,s ,z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    if((i&1) == (j&1) && (i&1) == (l&1))
        cout << o+i+j+l << endl;
    else if(i&&j&&l)
        cout << o+max(i+j+l-(i&1)-(j&1)-(l&1) ,i+j+l-!(i&1)-!(j&1)-!(l&1)) << endl;
    else
        cout << o+(i+j+l-(i&1)-(j&1)-(l&1)) << endl;
}

Measured memory_bytes: 256
from collections import Counter

n,k = map(int, input().split())
l=[]
for i in range (k):
    d = int(input())
    a = input().split()
    lena = int(len(a))
    for j in range(lena):
        l.append(a[j])

c = Counter(l)
print(n-len(c))


Measured memory_bytes: 9836
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll H, W;
  cin >> H >> W;

  char m[H][W];
  rep(i, H) {
    string S;
    cin >> S;
    ll dot_count = 0;
    rep(j, W) {
      if (S[j] == '.') {
        dot_count++;
      }
    }
    if (dot_count == (ll)S.size()) {
      rep(j, W) {
        m[i][j] = 'A';
      }
    } else {
      rep(j, W) {
        m[i][j] = S[j];
      }
    }
  }

  rep(j, W) {
    ll dot_count = 0;
    rep(i, H) {
      if (m[i][j] == '.' || m[i][j] == 'A') {
        dot_count++;
      }
    }

    if (dot_count == H) {
      rep(i, H) {
        m[i][j] = 'A';
      }
    }
  }

  rep(i, H) {
    ll a_count = 0;
    rep(j, W) {
      if (m[i][j] == 'A') {
        a_count++;
      }
    }
    if (a_count != W) {
      rep(j, W) {
        if (m[i][j] != 'A') {
          cout << m[i][j];
        }
      }
      ENDL;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    long long int N, A, B;
    if (scanf("%lld%lld%lld", &N, &A, &B) < 3) return 0;

    if (A > B) printf("%d\n", 0);
    else if (A != B && N == 1LL) printf("%d\n", 0);
    else if (A == B && N == 1LL) printf("%d\n", 1);
    else printf("%lld\n", (N - 2LL) * (B - A) + 1LL);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d1,d2;
  int count=0;
  bool ans = false;
  int n;
  cin>>n;

  rep(i,n){
    cin>>d1>>d2;
    if(d1 == d2) count++;
    else count = 0;
    if(count >= 3) ans = true;
  }

  if(ans) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}


Measured memory_bytes: 3168
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;



pair<double,double>Z[51];
ll ans, N, K;
ll A[100005];
bool flagsei = false;
bool flaghu = false;
priority_queue<ll> plu;
priority_queue<ll>minu;
priority_queue<ll>zer;
priority_queue<ll, vector<ll>, greater<ll> > plu2;
int main() {
	cin >> N;
	FOR(i, 0, N) {
		cin >> A[i];
		ans += abs(A[i]);
		if (A[i] > 0) {
			plu.push(A[i]);
			plu2.push(A[i]);
		}
		if (A[i] < 0) {
			minu.push(A[i]);
		}
		if (A[i] == 0) { plu.push(0); plu2.push(0); }
	}
	if (!plu.empty() == true&&!minu.empty()==true) {
		cout << ans << endl;
		ll last = plu.top(); plu.pop();
		while (!plu.empty()) {
			cout <<minu.top() <<" "<<plu.top() << endl;
			ll cur = minu.top()-plu.top();
			plu.pop(); minu.pop();
			minu.push(cur);
		}
		while (!minu.empty()) {
			cout << last << " " << minu.top() << endl;
			last -= minu.top();
			minu.pop();
		}
	}
	else if(plu.empty()){
		ll last = minu.top(); minu.pop();
		ans += 2 * last;
		cout << ans << endl;
		cout << last << " " <<minu.top() << endl;
		
		last -= minu.top();
		minu.pop();
		while (!minu.empty()) {
			cout << last << " " << minu.top() << endl;
			last -= minu.top();
			minu.pop();
		}
	}
	else if(minu.empty()){
		ll last = plu2.top(); plu2.pop();
		ans -= 2 * last;
		cout << ans << endl;
		cout << last << " " << plu2.top() << endl;
		
		last -= plu2.top();
		plu2.pop();

		while (!plu2.empty()) {
			int ue = plu2.top();
			plu2.pop();

			if(!plu2.empty())cout <<last<<" "<< ue << endl;
			else cout << ue<<" "<<last << endl;
			last -= ue;
		}
	}
	return 0;
}

Measured memory_bytes: 4460