akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
	IoSetup() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int A, B, C;

void solve() {
	if (A <= C && C <= B || B <= C && C <= A) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

int main() {
	cin >> A >> B >> C;
	solve();
	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <time.h>
#include <vector>

using namespace std;
typedef long long ll;
template <class T = ll>
T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T x) {
    cout << x << "\n";
}
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define reps(x, c) for (auto x : c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a)
#define mp(a, b) make_pair((a), (b))
#define pl pair<ll, ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x "=" << (x) << "\n"
#define dbgv(x) \
    cerr << #x << "\n"; \
    reps(y, x) { cerr << y << " "; } \
    cerr << "\n"

int main() {
    ll temp;
    ll ans = 0, ans_res = 0, res;
    rep(i, 5) {
        temp    = in();
        res     = temp % 10;
        res     = (10 - res) % 10;
        ans_res = max(ans_res, res);
        ans += temp + res;
    }
    print(ans - ans_res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

ll dp[300001][3][3];
ll all[300001];
int m,s[300003];
string t;

ll rec(int n,int a,int b){
  if(dp[n][a][b]!=-1)return dp[n][a][b];
  ll ret=0;
  if(a!=0&&b!=0)ret+=all[n+2];
  if(a!=0&&b!=1){
    if(n==m-3)ret+=rec(n+2,s[n+2],0);
    else {
      if(s[n+2]!=0)ret+=rec(n+2,1,s[n+3]);
      if(s[n+2]!=1)ret+=rec(n+2,1,0)*max(s[n+3],1);
      }
    }
  if(a!=1&&b!=0)
      ret=(ret+rec(n+2,s[n+2],s[n+3]))%mod;
    if(a!=1&&b!=1)
      ret=(ret+rec(n+2,0,s[n+3])*max(s[n+2],1))%mod;
  return dp[n][a][b]=ret%mod;
  }

int main(){
  cin>>t;
   m=t.size();
  rep(i,m){
    if(t[i]=='0')s[i]=0;
    if(t[i]=='1')s[i]=1;
    if(t[i]=='?')s[i]=2;
    }
  s[m]=0;
  rep(i,m+1)rep(j,3)rep(k,3){
    dp[i][j][k]=-1;
    }
  dp[m-1][0][0]=0;
  dp[m-1][2][0]=1;
  dp[m-1][1][0]=1;
  
  all[m]=1;
  rep(i,m){
    if(s[m-i-1]==2)all[m-i-1]=2*all[m-i]%mod;
    else all[m-i-1]=all[m-i];
    }
  cout<<rec(0,s[0],s[1])<<endl;
  return 0;
  }

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
    C*=2;
    chmin(C,A+B);
    ll ans=(ll)1e15;
    FOR(i,min(X,Y),max(X,Y)){
        ll cand=0;
        cand+=(ll)i*C;
        int x=X-i,y=Y-i;
        chmax(x,0); chmax(y,0);
        cand+=(ll)x*A;
        cand+=(ll)y*B;
        chmin(ans,cand);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	int n,m,aaa,max=0,h=0;
	Scanner in = new Scanner(System.in);
	n = in.nextInt();
	m = in.nextInt();
	for(int i=0;i<n;i++){
	    for(int j=0;j<m;j++){
		aaa = in.nextInt();
		if(aaa == 1)h++;
	    }
	    if(max<h)max=h;
	    h=0;
	}
	System.out.println(max);
    }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = (n - 2) * (m - 2);
  if (n == 1 && m == 1)
    ans = 1;
  else if (n == 1)
    ans = m - 2;
  else if (m == 1)
    ans = n - 2;
  cout << ans << endl;
}


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

int main() {
	int i,j,k;
	int a[5][4][11];
	for(i=0;i<5;i++){
		for(j=0;j<4;j++){
			for(k=0;k<11;k++){
				a[i][j][k]=0;
			}
		}
	}
	int n,b,f,r,v;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> b >> f >> r >> v;
		a[b][f][r] += v;
	}
	for(i=1;i<5;i++){
		for(j=1;j<4;j++){
			for(k=1;k<11;k++){
				cout << " " <<a[i][j][k] ;
			}
			cout << endl;
		}
		if(i<4)
			cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<string>
using namespace std;
void yn(bool ok) {
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


int main(){
  string s;
  cin>>s;
  vector<int> a(26,0);
  for(int i=0;i<s.size();i++) a[s[i]-'a']++;
  bool ok=1;
  for(int i=0;i<26;i++) if(a[i]%2==1) ok=0;
  yn(ok);
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << 'A' << endl;
    } else {
        cout << 'B' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;
const int  M = 1e4 ;
ll dp[N];


void solve(){
    ll h , n; cin>>h>>n;
    vector< pair<ll , ll > > v(n);
    for(int i = 0 ; i < n ; i++){
        cin>>v[i].F>>v[i].S;
    }
    dp[0] = 0;
    for(int i = 1; i <= h + M ; i++) dp[i] = LLONG_MAX;
    
    for(int i = 1 ; i <= h + M ; i++){
        for(int j = 0 ; j < n ; j++){
            if(v[j].F > i || dp[i - v[j].F] == LLONG_MAX) continue;
            
            dp[i] = min(dp[i] , dp[i - v[j].F] + v[j].S);
        }
    }
    for(int i = h + 1 ; i <= h + M ; i++) dp[h] = min(dp[h] , dp[i]);
    cout<<dp[h]<<endl;
}	
 
int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

int main(){
    vector<int> a(3);
    for (int i = 0; i < 3; i++) cin >> a.at(i);
    vector<bool> odd(3, 0);
    int oddcount = 0;
    int res = 0;

    for (int i = 0; i < 3; i++) {
        if (a.at(i) % 2 != 0) {
            oddcount++;
            odd.at(i) = 1;
        }
    }

    if (oddcount == 0 || oddcount == 3) {
        sort(a.begin(),a.end());
        res = (a.at(2) * 2 - a.at(0) - a.at(1)) / 2;
    }
    else if (oddcount == 1) {
        for (int i = 0; i < 3; i++) {
            if (odd.at(i) == 0) a.at(i)++;
        }
        sort(a.begin(),a.end());
        res =(a.at(2) * 2 - a.at(0) - a.at(1)) / 2 + 1;
    }
    else {
        for (int i = 0; i < 3; i++) {
            if (odd.at(i) == 1) a.at(i)++;
        }
        sort(a.begin(),a.end());
        res =(a.at(2) * 2 - a.at(0) - a.at(1)) / 2 + 1;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define sfi(a) scanf("%d",&a)
#define m_p make_pair
#define inf 1e9
#define ff first
#define ss second
#define pi(x) pair<x,x>
#define mem(x) memset(x,-1,sizeof(x))
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int sz = 20;
const ld pi = acos(-1);

int main()
{
    int n,l;
    cin >> n >> l;
    vector<string> vec;
    while(n--){
        string str;
        cin >> str;
        vec.push_back(str);
    }

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

    for(auto x:vec){
        cout << x;
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
import math
MOD = 10**9 + 7 #　素数
x, y = map(int, input().split())

if (x+y)%3 != 0:
    print(0)
    exit()

if x == 0 or y == 0:
    print(0)
    exit()

X = max(x,y)
Y = min(x,y)

all_move = (X+Y)//3
diff = (X-Y)
Y_move = (all_move - diff)//2


def mod_cmb(n, r, mod): # nCr mod p
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]

    for i in range( 2, n + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

print(mod_cmb(all_move, Y_move,MOD))


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

using ull = unsigned long long;

bool rolling_hash2(int pll, int Q, const vector<string>& a, vector<vector<ull>>& res) {
	const ull B1 = 9973;
	const ull B2 = 100000007;
	if ((int)a.size() < pll || (int)a[0].size() < Q) return false;
	vector<vector<ull>> tmp(a.size(), vector<ull>(a[0].size() - Q + 1));
	res = vector<vector<ull>>(a.size() - pll + 1, vector<ull>(a[0].size() - Q + 1));
	ull t1 = 1;
	for (int j = 0; j < Q; j++) t1 *= B1;
	for (int i = 0; i < (int)a.size(); i++) {
		ull e = 0;
		for (int j = 0; j < Q; j++) e = e * B1 + a[i][j];
		for (int j = 0; j + Q <= (int)a[0].size(); j++) {
			tmp[i][j] = e;
			if (j + Q < (int)a[0].size()) e = e * B1 - t1 * a[i][j] + a[i][j + Q];
		}
	}
	ull t2 = 1;
	for (int i = 0; i < pll; i++) t2 *= B2;
	for (int j = 0; j + Q <= (int)a[0].size(); j++) {
		ull e = 0;
		for (int i = 0; i < pll; i++) e = e * B2 + tmp[i][j];
		for (int i = 0; i + pll <= (int)a.size(); i++) {
			res[i][j] = e;
			if (i + pll < (int)a.size()) e = e * B2 - t2 * tmp[i][j] + tmp[i + pll][j];
		}
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vector<string> S(N), T(N, string(N, ' '));
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			T[i][j] = S[j][i];
		}
	}
	for (int i = 0; i < N; i++) {
		S[i] += S[i];
		T[i] += T[i];
	}
	for (int i = 0; i < N; i++) {
		S.push_back(S[i]);
		T.push_back(T[i]);
	}
	vector<vector<ull>> hs1, hs2;
	rolling_hash2(N, N, S, hs1);
	rolling_hash2(N, N, T, hs2);
	int res = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			res += (hs1[i][j] == hs2[j][i]);
		}
	}
	cout << res << endl;
	return 0;
}


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

int n;
array<int, 3> p[1005];

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

  cin >> n;
  rep(i, n) rep(j, 3) cin >> p[i][j];
  rep(i, n) sort(p[i].begin(), p[i].end());
  sort(p, p+n);
  cout << p+n - unique(p, p+n) << "\n";
}


Measured memory_bytes: 3252
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[100005]={},d=inf,ans=-1;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  cout << a[n-1] << " ";
  for(int i=0; i<n-1; i++) {
    if(d>=abs(a[n-1]/2-a[i])) {
      d=abs(a[n-1]/2-a[i]);
      ans=a[i];
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N,X,sum=0,count=0;
  cin >>N>>X;
  
  for (int i=0;i<N;i++){
    int Li;
    cin >>Li;
    sum+=Li;
    if (sum<=X){
      count++;
    }
  }
  cout <<count+1<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;

int main(void)
{
	int l,a,b,c,d;
	int koku,suu,mn;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	koku=a/c;
	if(a%c!=0)	koku++;
	suu=b/d;
	if(b%d!=0)	suu++;
	mn=max(koku,suu);
	printf("%d\n",l-mn);
	return 0;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    string a, b, c; cin >> a >> b >> c;
    cout << char(a[0] - 0x20) << char(b[0] - 0x20) << char(c[0] - 0x20);
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>

#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 llong long long
#define pb(a) push_back(a)

using namespace std;

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




const ll INF = 1e9;


/******************************************************************************************/


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

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

	

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if (s == "E869120") {
			ans++;
		}

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



Measured memory_bytes: 3236
from collections import deque
def bfs():
    d = [[False] * w for i in range(h)]
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]

    que = deque([])
    que.append((sx,sy))
    d[sx][sy] = True
    cnt = 1

    while que:
        p = que.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx < h and 0 <= ny < w and Map[nx][ny] != "#" and d[nx][ny] == False:
                cnt += 1
                que.append((nx,ny))
                d[nx][ny] = True
    return cnt

while 1:
    w,h = map(int,input().split())
    if w == 0 and h == 0:
        break
    Map = [str(input()) for i in range(h)]
    for i in range(h):
        for j in range(w):
            if Map[i][j] == "@":
                sx = i
                sy = j
    print(bfs())


Measured memory_bytes: 6012
import heapq

n,m=map(int,input().split())

a=list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(a)

for _ in range(m):
    amin=heapq.heappop(a)
    heapq.heappush(a,(-1)*(-amin//2))

print(-sum(a))

Measured memory_bytes: 20576
# AOJ 2882: Generalized Leap Years
# Python3 2018.7.10 bal4u

while True:
	n, l, r = map(int, input().split())
	if n == 0: break
	A = [int(input()) for i in range(n)][::-1]
	y = [0]*(r+1)
	v = 2 - (n&1)	# v = 1 if n is odd
	for a in A:
		for i in range(a, r+1, a): y[i] = v
		v = 3-v
	ans = k = 0
	for i in range(l, r+1):
		if y[i] == 0: k += 1
		elif y[i] == 1: ans += 1
	if n & 1 == 0: ans += k
	print(ans)



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

long long int N, a[101010];

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", a + 101000);
        a[100010] += !a[a[101000]];
        ++a[a[101000]];
    }
    cout << a[100010] - (~a[100010] & 1) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <climits>
#include <cstdlib>
#include <iostream>
using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

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

	for(int n; cin >> n && n;) {
		int mn = INT_MAX, mx = 0;
		while(n--) {
			int sum = 0;
			for(int i = 0; i < 5; ++i) {
				int score;
				cin >> score;
				sum += score;
			}
			chmin(mn, sum);
			chmax(mx, sum);
		}
		cout << mx << " " << mn << endl;
	}

	return EXIT_SUCCESS;
}

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

int main(){
    int s;
    cin >> s;
    int s1 = s / 100;
    int s2 = (s / 10) % 10;
    int s3 = s % 10;
    cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define VALS(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define INF 1234567890ll
#define EPS (1e-7)
#define PI (acos((ld)-1.0))
#define ll long long int 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
typedef pair <int, int> pi;
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << '\n'; err(++it, args...);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(ll x){stringstream s; s << x; return s.str(); }
ll stl(string x){stringstream s(x); ll temp; s >> temp; return temp; }
const int MOD = 1e9 + 7;

int main()
{
	IAMSPEED
	int n; cin >> n;
	FOR(i,1,9) {
		if(n%i==0 && (n/i<=9 && n/i>=1)) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();

		double h = sc.nextDouble();
		double m = sc.nextDouble();


		double radH = 360 * ((h * 60 + m) / 720);
		double radM = 360 * (m / 60);

		double rad = Math.abs(radH - radM);

		if (rad > 180) {
			rad = 360 - rad;
		}
		double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - (Math.cos(Math.toRadians(rad)) * 2 * a * b));
		System.out.println(ans);
	}


}

Measured memory_bytes: 37544
from itertools import permutations
from math import sqrt,factorial
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

def distance(point1, point2):
    return sqrt((point1[0]-point2[0])**2 + (point1[1]-point2[1])**2)

ans = 0
per = permutations(xy, n)
persize = factorial(n)
cost = 0
for i in per:
    cpoint = i[0]
    for j in i[1:]:
        cost += distance(cpoint, j)
        cpoint = j
ans = cost/persize
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#include<cstring>
#include <vector>
#include <cmath>
typedef long long int ll;

int main()
{
  ll n;
  cin >> n;
  string s = "";
  for (int i = 1; i < 99; i++)
  {
    if (n <= pow(26, i))
    {
      n--;
      for (int j = 0; j < i; j++)
      {
        char c = 'a' + n % 26;
        s.append(1, c);
        n /= 26;
      }
      break;
    }
    else
      n -= pow(26, i);
  }
  for (int i = s.length() - 1; i >= 0; i--)
    cout << s[i];
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    double m;
    cin>>n>>m;
    double a[n];
    double sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    sort(a,a+n);
    double odd=sum/(4*m);
    for(int i=(n-1);i>=n-m;i--)
    {
        if(a[i]<odd)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

int f(int d, int x) {
  int t = 0;
  while(d * (1 << t) < x) t++;
  return t;
}

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0.0;
  rep(i, n) {
    int dice = i + 1;
    ans += (1.0) / (double)(1LL << f(dice, k));
  }
  ans *= (1.0 / (double)n);
  printf("%.20f\n", ans);
  return 0;
}

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

int main(void) {
    int N, M;
    bool isMatched;
    cin >> N >> M;
    vector<string> A(N), B(N);

    for(int i = 0; i < N; i++)  cin >> A[i];
    for(int i = 0; i < M; i++)  cin >> B[i];

    for(int i = 0; i < N - M + 1; i++) {
        for(int j = 0; j < N - M + 1; j++) {
            isMatched = true;
            for(int k = 0; k < M; k++) {
                for(int l = 0; l < M; l++) {
                    if(A[i+k][j+l] != B[k][l]) {
                        isMatched = false;
                        break;
                    }
                }
            }
            if(isMatched) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

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

int main() {

  /* input Red card data */
  int N;
  cin >> N;
  string Red[N];
  for(int i=0;i<N;i++){
    cin >> Red[i];
  }
  
  /* input data Blue card*/
  int M;
  cin >> M;
  string Blue[M];
  for(int i=0;i<M;i++){
    cin >> Blue[i];
  }
    
  /* card counting */
  vector<int> count(N);
  int count_max =0;
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      if(Red[i]==Red[j])
        count.at(i)++;
    }
    for(int k=0;k<M;k++){
      if(Red[i]==Blue[k])
        count.at(i)--;
    }
    count_max=max(count_max,count.at(i));
  }
    
  /* output data */
  cout << count_max << endl;
}


Measured memory_bytes: 256
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

ll fpow(ll a, ll n)
{
    ll ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

const int M = 1e5 + 10, N = 110;
ll v[N], dp[M][N];
int w[N];

ll solve(int weight, int index)
{
	if (weight < 0 or index < 0)
		return 0;
	if (dp[weight][index] != -1)
		return dp[weight][index];
	if (weight < w[index])
		dp[weight][index] = solve(weight, index-1);
	else
		dp[weight][index] = max(v[index] + solve(weight - w[index], index-1), solve(weight, index-1));
	return dp[weight][index];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, weight;
    cin >> n >> weight;
    FOR(i,0,n)
    {
    	cin >> w[i] >> v[i];
    	FOR(j,0,weight+1)
    		dp[j][i] = -1; 
    }
    cout << solve(weight, n-1) << endl;	
    return 0;
}

Measured memory_bytes: 86272
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  ll N, H, a, b;
  cin >> N >> H;
  vector<pair<ll, ll> > h;

  rep(i, N){
    cin >> a >> b;
    h.push_back(make_pair(a, 0));
    h.push_back(make_pair(b, 1));
  }

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

  ll cnt = 0;
  for(int i = h.size() - 1; i >= 0; i--){
    H -= h[i].first;
    cnt++;
    if(H <= 0) break;
    if(h[i].second == 0){
      if(H%h[i].first != 0) cnt++;
      cnt += H/h[i].first;
      break;
    }
  }

  print(cnt);

}


Measured memory_bytes: 6384
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define floop(i,a,b) for (int i=(a);i<(b);i++)
#define rloop(i,a,b) for (int i=(a);i>=(b);i--)
#define floopeq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}

void solve()
{
	int x1,x2,x3,x4,x5;
	cin>>x1>>x2>>x3>>x4>>x5;
	if(x1==0)
	{
		cout<<1<<endl;return;
	}
	else if(x2==0)
	{
		cout<<2;return;
	}
	else if(x3==0)
	{
		cout<<3;
		return;
	}
	else if(x4==0)
	{
		cout<<4;
		return;
	}
	else
	{
		cout<<5<<endl;return;
	}
}
int main() 
{ 
    
    int t;
    t=1;
    while(t--){
    	solve();
    }
    return 0; 

} 


Measured memory_bytes: 3592
N, K = map(int, input().split())
a = list(map(int, input().split()))

if N == K:
    print(max(sum(a), 0))
    exit()

a_plus = []
a_minus = []
for i in range(N):
    if i == 0:
        if a[i] > 0:
            a_plus.append(a[i])
            a_minus.append(0)
        else:
            a_plus.append(0)
            a_minus.append(a[i])
    else:
        if a[i] > 0:
            a_plus.append(a_plus[i-1] + a[i])
            a_minus.append(a_minus[i-1])
        else:
            a_plus.append(a_plus[i-1])
            a_minus.append(a_minus[i-1] + a[i])

ans = 0
for i in range(N-K):
    ans = max(ans,
              a_plus[N-1] + (a_minus[i+K] - a_minus[i]),
              a_plus[N-1] - (a_plus[i+K] - a_plus[i]))
print(ans)


Measured memory_bytes: 14608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	while(cin >> n >> m, n | m)
	{
		int A[n + 1];
		for(int i = 0; i < n; i++)
			cin >> A[i];
		int ans = -1;
		for(int i = 0; i < n; i++)
		{
			for(int j = i + 1; j < n; j++)
			{
				if(A[i] + A[j] <= m)
					ans = max(A[i] + A[j], ans);
			}
		}
		if(ans == -1)
			cout << "NONE" << endl;
		else
			cout << ans << endl;
	}
	return 0;
}





Measured memory_bytes: 3212
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;
    cin >> n;
    int m = n;
    int f = 0;
    while(m){
        f += m % 10;
        m /= 10;
    }
    cout << (n % f == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import copy
import math

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

S = input().rstrip()
T = input().rstrip()

ans = 0

for i in range(3):
    ans += S[i] == T[i]

print(ans)

Measured memory_bytes: 3444
n,k = map(int, input().split())
pl = [0] + list(map(int, input().split()))
cl = [0] + list(map(int, input().split()))

valsl = []
already = [False]*(n+1)
for i in range(1,n+1):
    if already[i]: continue
    vals = [cl[i]]
    curr_i = i
    already[i] = True
    while True:
        next_i = pl[curr_i]
        if already[next_i]: break
        v = cl[next_i]
        vals.append(v)
        curr_i = next_i
        already[next_i] = True
    valsl.append(vals)


# print(valsl)
ans = -10**18
for vals in valsl:
    curr_sum = sum(vals)
    vlen = len(vals)
    for i in range(len(vals)):
        new_vals = vals[i:] + vals[0:i]
        if curr_sum <= 0:
            vmax = -10**18
            v = 0
            for j in range(min(k,vlen)):
                v += new_vals[j]
                vmax = max(v,vmax)
            ans = max(vmax, ans)
        else:
            loop = k//vlen-1
            rem = k-loop*vlen
            v = loop*curr_sum
            vmax = v
            for j in range(rem):
                v += new_vals[j%vlen]
                vmax = max(v,vmax)
            ans = max(vmax, ans)

print(ans)

Measured memory_bytes: 73344
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lowbit(x) (x)&(-x)
#define ll long long
using namespace std;
const int maxn = 2e5 + 1000;

priority_queue<ll> q1;
priority_queue<ll, vector<ll>, greater<ll>> q2;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T; cin >> T; ll C = 0;
	while (T--)
	{
		int flag; cin >> flag;
		if (flag == 1)
		{
			ll a; ll b; cin >> a >> b; C += b;
			q1.push(a); q2.push(a);
			if (q1.top() > q2.top())
			{
				C += abs(q2.top() - q1.top());
				a = q1.top(); q1.pop();
				q1.push(q2.top());
				q2.pop();
				q2.push(a);
			}
		}
		else cout << q1.top() << ' ' << C << endl;
	}
	return 0;
}

Measured memory_bytes: 4588
#include "bits/stdc++.h"

using namespace std;

int main() {

    string s;
    cin >> s;
    stack <char> store;
    int ans = 0;
    for(int i = 0; i < s.length(); i++) {
        if(store.empty()) store.push(s[i]);
        else if(store.top() != s[i]) {
            store.pop();
            ans += 2;
        }
        else store.push(s[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;


int main() {

	int N;
	cin >> N;
	ll A[MAX], B[MAX];
	for (int i = 1; i <= N + 1; i++) { cin >> A[i]; }
	for (int i = 1; i <= N; i++) { cin >> B[i]; }

	ll ans = 0;

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

		if (A[i+1] >= B[i]) {
			ans += B[i];
			A[i+1] -= B[i];
			B[i] = 0;
		}
		else {
			ans += A[i + 1];
			B[i] -= A[i + 1];

			A[i+1] = 0;
			
		}

	}

	cout << ans;


	system("PAUSE");

}

Measured memory_bytes: 5368
n, m = gets.split.map(&:to_i)
A = Array.new(n)
B = Array.new(m)
result = Array.new(n, 0)
n.times do |i|
  A[i] = gets.split.map(&:to_i)
end

m.times do |i|
  B[i] = gets.to_i
end

n.times do |i|
  m.times do |j|
    result[i] += A[i][j] * B[j]
  end
end
puts result


Measured memory_bytes: 8876
import collections
n = int(input())
d = list(map(int, input().split()))
D = collections.Counter(d)
ans = 1
mod = 998244353
if d[0] != 0:
    print(0)
    exit()
if D[0] != 1:
    print(0)
    exit()
for i in range(1, max(d)):
    ans *= D[i]**D[i + 1]
    ans %= mod
print(ans)


Measured memory_bytes: 19928
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k,a[2000],ans=1000000000;
vector<ll> u,v;
int main(void){
    cin>>n>>m>>k;
    if(k==1){cout<<0<<endl;return 0;}
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        v={};
        u={};
        for(int j=0;j<n;j++){
            if(i==j)continue;
            if(a[i]<=a[j]){
                v.push_back(a[j]);
            }
            else{
                if(v.size()>=m){
                    sort(v.begin(),v.end());
                    for(int i=0;i<min((ll)v.size()-m+1LL,k-1LL);i++)u.push_back(v[i]);
                }
                v={};
            }
        }
        if(v.size()>=m){
            sort(v.begin(),v.end());
            for(int i=0;i<min((ll)v.size()-m+1,k-1);i++)u.push_back(v[i]);
        }
        //cout<<u.size()<<" "<<i<<endl;
        if(u.size()<k-1)continue;
        sort(u.begin(),u.end());
        //cout<<u[0]<<endl;
        ans=min(ans,u[k-2]-a[i]);
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

int main(){
    ll N;
    cin >> N;
    ll a;
    cin >> a;
    for(ll i = 1; i < N; i++){
        // cout << a << endl;
        ll b;
        cin >> b;
        a = gcd(a, b);
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())

W = ["a"]
nW = []

"""
k = len(collections.Counter(Y[0]))
print(k)
"""
for j in range(N-1):
    for w in W:
        k = len(collections.Counter(w))
        for i in range(k+1):
            nW.append(w + chr(i+97))
    W = nW.copy()
    nW.clear()
    
    # print("N=",j+2)
# print(W[-1])

for i in W:
    print(i)

Measured memory_bytes: 14060
d, g = map(int, input().split())

scores = []
sum = []
for i in range(d):
    a, b = map(int, input().split())
    scores.append([a, b])
    sum.append((i + 1) * 100 * a + b)

def ans(goal, p_num):
    if p_num <= 0:
        return float("INF")

    # 一番スコアの高い問題を必要な分か、あるいは限界まで解く。
    n = min(int(goal / (100 * p_num)), scores[p_num - 1][0])

    # できる限りまで高得点問題を解いたときの特典
    s = 100 * p_num * n

    # 全部解いたら、ボーナスを追加した点数を s とする
    if n == scores[p_num - 1][0]:
        s = sum[p_num - 1]

    # まだgoalに達していなかった場合、再帰関数に放り込む
    if goal > s:
        n += ans(goal - s, p_num - 1)

    return min(n, ans(goal, p_num - 1))

print(ans(g, d))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    bool easy = true;
    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
            {
                easy = false;
            } 
        }
        else
        {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
            {
                easy = false;
            } 
        }
    }
    
    cout << (easy ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000
#define MIN -1

typedef struct {
  int p,l,r;
}Node;

Node node[MAX];

int n,height[MAX],depth[MAX];

int Height(int);
int Sibling(int);
void Depth(int,int);
void Print(int);

int Height(int u) {
  int h1 = 0 , h2 = 0;

  if( node[u].l != MIN ) {
    h1 = Height(node[u].l) + 1;
  }
  if( node[u].r != MIN ) {
    h2 = Height(node[u].r) + 1;
  }

  if( h1 > h2 ) return height[u] = h1;
  else return height[u] = h2;
}

int Sibling(int u) {
  if( node[u].p == MIN ) return MIN;
  if( node[node[u].p].r != u && node[node[u].p].r != MIN ) return node[node[u].p].r;
  if( node[node[u].p].l != u && node[node[u].p].l != MIN ) return node[node[u].p].l;

  return MIN;
}

void Depth( int u, int d ) {
  if( u == MIN ) return;
  depth[u] = d;
  Depth( node[u].l, d+1 );
  Depth( node[u].r, d+1 );
}

void Print(int u) {
  int suu = 0;

  printf("node %d: parent = %d, sibling = %d, ",u,node[u].p,Sibling(u));
  if( node[u].l != MIN ) suu++;
  if( node[u].r != MIN ) suu++;

  printf("degree = %d, depth = %d, height = %d, ",suu,depth[u],height[u]);
  if( node[u].p == MIN ) printf("root\n");
  else if( node[u].l == MIN && node[u].r == MIN ) printf("leaf\n");
  else printf("internal node\n");
} 



int main(){
  int i;
  int id,l,r,root = 0;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ) {
    node[i].p = MIN;
  }

  for( i = 0 ; i < n ; i++ ) {
    scanf("%d%d%d",&id,&l,&r);
    node[id].l = l;
    node[id].r = r;
    if( l != MIN ) node[l].p = id;
    if( r != MIN ) node[r].p = id;
  }

  for( i = 0 ; i < n ; i++) {
    if( node[i].p == MIN ) {
      root = i;
    }
  }

  Depth( root,0 );
  Height(root);

  i = 0;
  while( i < n ){
    Print(i);
    i++;
  }

  return 0;
}

Measured memory_bytes: 620
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	auto A=vecin(N);
	ll S=0;
	REP(i,N){
		ll V=i+1;
		if(V%2 && A[i]%2) S++;
	}
	out(S);
	return 0;
}


Measured memory_bytes: 3640
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
  ans += b[i]
  if i <= n - 2:
    if a[i + 1] == a[i] + 1:
      ans += c[a[i] - 1]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int i, j, N, M, Q;
	char S[2002][2002] = {};
	scanf("%d %d %d", &N, &M, &Q);
	for (i = 1; i <= N; i++) scanf("%s", &(S[i][1]));

	short q[4000001][2], par[2002][2002][2] = {};
	int k, l, head, tail;
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= M; j++) {
			if (S[i][j] == '0' || par[i][j][0] != 0) continue;
			par[i][j][0] = i;
			par[i][j][1] = j;
			q[0][0] = i;
			q[0][1] = j;
			for (head = 0, tail = 1; head < tail; head++) {
				k = q[head][0];
				l = q[head][1];
				if (S[k-1][l] == '1' && par[k-1][l][0] == 0) {
					par[k-1][l][0] = k;
					par[k-1][l][1] = l;
					q[tail][0] = k - 1;
					q[tail++][1] = l;
				}
				if (S[k+1][l] == '1' && par[k+1][l][0] == 0) {
					par[k+1][l][0] = k;
					par[k+1][l][1] = l;
					q[tail][0] = k + 1;
					q[tail++][1] = l;
				}
				if (S[k][l-1] == '1' && par[k][l-1][0] == 0) {
					par[k][l-1][0] = k;
					par[k][l-1][1] = l;
					q[tail][0] = k;
					q[tail++][1] = l - 1;
				}
				if (S[k][l+1] == '1' && par[k][l+1][0] == 0) {
					par[k][l+1][0] = k;
					par[k][l+1][1] = l;
					q[tail][0] = k;
					q[tail++][1] = l + 1;
				}
			}
		}
	}
	
	int root[2002][2002], up[2002][2002], down[2002][2002], left[2002][2002], right[2002][2002];
	for (j = 1, root[0][0] = 0; j <= M; j++) {
		root[0][j] = 0;
		for (i = 1, left[0][j] = 0, right[0][j] = 0; i <= N; i++) {
			left[i][j] = left[i-1][j] + ((S[i][j] == '1' && par[i][j][1] == j - 1)? 1: 0);
			right[i][j] = right[i-1][j] + ((S[i][j] == '1' && par[i][j][1] == j + 1)? 1: 0);
		}
	}
	for (i = 1; i <= N; i++) {
		root[i][0] = 0;
		for (j = 1, up[i][0] = 0, down[i][0] = 0; j <= M; j++) {
			root[i][j] = root[i-1][j] + root[i][j-1] - root[i-1][j-1] + ((par[i][j][0] == i && par[i][j][1] == j)? 1: 0);
			up[i][j] = up[i][j-1] + ((S[i][j] == '1' && par[i][j][0] == i - 1)? 1: 0);
			down[i][j] = down[i][j-1] + ((S[i][j] == '1' && par[i][j][0] == i + 1)? 1: 0);
		}
	}
	
	int m, n;
	for (n = 1; n <= Q; n++) {
		scanf("%d %d %d %d", &i, &j, &k, &l);
		printf("%d\n", root[k][l] - root[i-1][l] - root[k][j-1] + root[i-1][j-1] + up[i][l] - up[i][j-1] + down[k][l] - down[k][j-1] + left[k][j] - left[i-1][j] + right[k][l] - right[i-1][l]);
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 108820
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int[] num = {a, b, c};

        int result = 0;
        Arrays.sort(num);
        for (int i=0; i<2; i++) {
            result += num[i];
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define fastIO() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"

int main()
{
    fastIO();

    string s;
    cin>>s;
    int sz=s.size();
    if(s[sz-1]=='s')
        cout<<s+"es"<<endl;
    else
        cout<<s+"s"<<endl;

    return 0;
}



Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
a.sort()
cnt = [0 for _ in range(10**6+5)]
ans = 0
if n == 1:
    print(1)
    exit()
if a[0] == 1:
    if a[1] != 1:
        print(1)
    else:
        print(0)
    exit()
for x in a:
    for i in range(x, 10**6+5, x):
        cnt[i] += 1
for x in a:
    if cnt[x] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 164856
N = int(input())
S = input()
cnt = 0
for i in range(1, N):
	if S[i] == 'W':
		cnt += 1
max = cnt
for i in range(1, N):
	if S[i-1] == 'E':
		cnt += 1
	if S[i] == 'W':
		cnt -= 1
	if max < cnt:
		max = cnt
print(N - max - 1)

Measured memory_bytes: 9728
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)9e18;

int main() {
	int H, W;
	cin >> H >> W;
	int N;
	cin >> N;
	VP a(N);
	REP(i, N) {
		a[i].first = i + 1;
		cin >> a[i].second;
	}
	VVI c(H, VI(W));
	int k = 0;
	REP(i, H) {
		REP(j, W) {
			c[i][j] = a[k].first;
			a[k].second--;
			if (a[k].second == 0) k++;
		}
	}

	REP(i, H) {
		REP(j, W) {
			if (i % 2 == 0) cout << c[i][j] << " ";
			else if (i % 2 == 1) cout << c[i][W - 1 - j] << " ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384