akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(d + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        last[t[i]] = i;

        for (int j = 1; j <= 26; j++)
        {
            ans -= c[j] * (i - last[j]);
        }
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    // printf("%lld\n", scoring(BestT));

    double BestScore = scoring(BestT);

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1);

    double T0 = 1e6;
    double T1 = 1e3;
    double TL = 1950;

    while (1)
    {
        auto end = chrono::system_clock::now(); // 計測終了時刻を保存
        auto dur = end - start;                 // 要した時間を計算
        auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();

        if (msec >= 1950)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        double score = scoring(t);

        if (exp((score - BestScore) / T) > 0.5)
        {
            BestT = t;
            BestScore = score;
        }
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }

    // printf("%lld\n", scoring(BestT));
}


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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0){
    cout<<1<<endl;
  }
  else if(b==0){
    cout<<2<<endl;
  }
  else if(c==0){
    cout<<3<<endl;
  }
  else if(d==0){
    cout<<4<<endl;
  }
  else if(e==0){
    cout<<5<<endl;
  }




}


Measured memory_bytes: 3552
using System;

class Program {
    static void Main() {
        string line;
        while ((line = Console.ReadLine()) != null) {
            var l = line.Split(' ');
            var sum = int.Parse(l[0]) + int.Parse(l[1]);
            var n = Math.Truncate(Math.Log10(Math.Max(sum, 1))) + 1;
            Console.WriteLine(n);
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    int N, K;
    cin >> N >> K;
    vector<int> price(N);
    rep(i, N) cin >> price.at(i);

    sort(all(price));
    int ans=0;
    rep(i, K){
        ans += price.at(i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  int i,j,cnt=0;
  string s;
  cin>>s;
  if(s.size()==2)cout<<s;
  else{
    for(i=0;i<3;i++)cout<<s[2-i];
  }
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum, a[310000], b[310000];
string str;
bool f[11000];
char c[1100][1100];
int main() {
	cin >> n >> m;
	ans++;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
		if (sum <= m)ans++;
	}

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

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

struct Union_Find {
    std::vector<int> par;
    std::vector<int> rank;
    
    //初期化
    void init( int n ) {
        par.resize( n );
        rank.resize( n );
        for ( int i = 0; i < n; ++i ) {
            par[ i ] = i;
            rank[ i ] = 0;
        }
    }
    
    //木の根を探す
    int find( int s ) {
        if ( par[ s ] == s ) {
            return s;
        }
        return par[ s ] = find( par[ s ] );
    }
    
    //結合
    void unite( int x, int y ) {
        int a = find( x ), b = find( y );
        if ( a == b ) {
            return;
        }
        if ( rank[ a ] < rank[ b ] ) {
            par[ a ] = b;
        }
        else {
            par[ a ] = b;
            if ( rank[ a ] == rank[ b ] ) {
                ++rank[ b ];
            }
        }
    }
    
    //二つの数の根が同じかどうか
    bool same( int x, int y ) {
        return find( x ) == find( y );
    }
    
    //サイズを返す
    unsigned int size() {
        return par.size();
    }
};

using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    Union_Find uf;
    uf.init(n);
    while(q--){
        int com, x, y;
        cin >> com >> x >> y;
        if(com){
            cout << uf.same(x, y) << "\n";
        }else{
            uf.unite(x, y);
        }
    }
}


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

int main() {
  int a, b, c, p;
  cin >> a >> b >> c;
  p = max(max(a, b), c);
  if(p == a + b + c - p)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
  int n;
  std::cin >> n;
  if(n==0)std::cout << "1" << '\n';
  else std::cout << "0" << '\n';
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int rec( int i, int j, const vector<vector<int>>& abc, vector<vector<long long>>* memo )
{
    if ( i == 0 ) return 0;

    if ( ( *memo )[ i ][ j ] != -1 ) return ( *memo )[ i ][ j ];

    long long maxValue = 0;
    for ( int k = 0; k < 3; ++k )
    {
        if ( k == j ) continue;
        int temp = rec( i - 1, k, abc, memo ) + abc[ i - 1 ][ k ];
        if ( temp > maxValue ) maxValue = temp;
    }

    return ( *memo )[ i ][ j ] = maxValue;
}

long long rec( int i, int j, const vector<int>& weights, const vector<int>& values, vector<vector<long long>>* memo )
{
    if ( i == 0 ) return 0;
    if ( ( *memo )[ i ][ j ] != -1 ) return ( *memo )[ i ][ j ];

    return ( *memo )[ i ][ j ] = j >= weights[ i - 1 ] ?
        max( rec( i - 1, j, weights, values, memo ), rec( i - 1, j - weights[ i - 1 ], weights, values, memo ) + values[ i - 1 ] ) :
        rec( i - 1, j, weights, values, memo );
}

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

    int W;
    cin >> W;

    vector<int> weights( N );
    vector<int> values( N );
    for ( int i = 0; i < N; ++i ) cin >> weights[ i ] >> values[ i ];

    vector<vector<long long>> memo( N + 1, vector<long long>( W + 1, -1 ) );
    cout << rec( N, W, weights, values, &memo ) << endl;
}

Measured memory_bytes: 80256
#include <stdio.h>      
int main() {
  
	int H;
	int A;
	scanf("%d %d", &H, &A);
	
	int M = H/A;
	int N = H%A;
	
	N==0?printf("%d\n", M):printf("%d\n", M+1);
	
  return 0;
}


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

#define MAX_N 1005
#define MAX_V 10005

int n;
int A[MAX_N],B[MAX_N];
vector<int> vec;
map<int,int> mp,mp2;

typedef pair<ll,ll> P;
struct edge{ll to,cap,cost,rev; };
int V;
vector<edge> G[MAX_V];
ll h[MAX_V];
ll dist[MAX_V];
ll prevv[MAX_V],preve[MAX_V];
ll tax=1e9;

void add_edge(ll from,ll to,ll cap,ll cost){
  G[from].push_back((edge){to,cap,cost,(ll)G[to].size()});
  G[to].push_back((edge){from,0,-cost,(ll)G[from].size()-1});
}

ll min_cost_flow(int s,int t){
  ll INF = (1LL<<50);
  ll res=0,mini=INF,cnt=0;
  fill(h,h+MAX_V,0);
  while(1){
    cnt++;
    priority_queue<P, vector<P> , greater<P> > que;
    fill(dist,dist+MAX_V,INF);
    dist[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
      P p=que.top();que.pop();
      ll v=p.second;
      if(dist[v]<p.first)continue;
      for(int i=0;i<(int)G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
          dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
          prevv[e.to]=v;
          preve[e.to]=i;
          que.push(P(dist[e.to],e.to));
        }
      }
    }
    if(dist[t]==INF)break;
    for(int v=0;v<MAX_V;v++)h[v]+=dist[v];
    res+=h[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap--;
      G[v][e.rev].cap++;
    }
    mini=min(mini,res-tax*cnt);
  }
  return mini;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i]>>B[i];
    vec.push_back(A[i]);
    vec.push_back(B[i]);
  }
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  V=n+vec.size()+2;
  for(int i=0;i<(int)vec.size();i++){
    mp[vec[i]]=n+i;
    mp2[n+i]=vec[i];
    add_edge(n+i , V-1 , 1 , 0);
  }

  for(int i=0;i<n;i++){
    add_edge(V-2,i,1,0);
    add_edge(i,mp[A[i]],1,tax-B[i]);
    add_edge(i,mp[B[i]],1,tax-A[i]);
  }
  cout<<-min_cost_flow(V-2,V-1)<<endl;
  return 0;
}

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

typedef long long ll;
using namespace std;

ll stages[51];
ll pattys[51];

ll search(ll level, ll X) {
  if (level == 0) {
    return X == 1 ? 1 : 0;
  }

  if (X <= 1 + stages[level - 1]) {
    return search(level - 1, X - 1);
  } else if (1 + stages[level - 1] < X) {
    return pattys[level - 1] + 1 + search(level - 1, X - 2 - stages[level - 1]);
  }
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

int main() {
  ll n;
  ll x;
  cin >> n >> x;
  stages[0] = 1;
  pattys[0] = 1;

  FOR(i, 1, n + 1) {
    pattys[i] = pattys[i - 1] * 2 + 1;
    stages[i] = stages[i - 1] * 2 + 3;
  }

  ll ans = 0;
  FORR(i, 0, n + 1) {
    if (x == 0) break;

    if (x == stages[i]) {  // eat all
      ans += pattys[i];
      break;
    }

    if (x == 1) {
      // B
      break;
    }

    assert(i > 0);

    if (x <= 1ll + stages[i - 1]) {  // Pを含まない下半分よりxが小さかったら
      x--; //xとiが減った次のループへ
    } else { //パティ以上の場合
      ans += 1ll + pattys[i - 1];
      x -= 1ll + stages[i - 1] + 1ll;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin >> n >> x;
    vll a(n);
    REP(i,n) cin >> a[i];
    ll ans = 0;
    REP(i,n-1){
        ll sum = a[i] + a[i+1];
        ll t = min(a[i+1], max(0LL, sum-x));
        ans += t;
        a[i+1] -= t;
        sum -= t;
        t = min(a[i], max(0LL,sum-x));
        ans += t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  ll A, B, C, D;
  std::cin >> A >> B >> C >> D;
  ll N = B - (A - 1);
  ll GCD = gcd(C, D);
  ll LCM = C * D / GCD;
  ll AC = (A - 1) / C;
  ll AD = (A - 1) / D;
  ll ACD = (A - 1) / LCM;
  ll BC = B / C;
  ll BD = B / D;
  ll BCD = B / LCM;
  ll ans = N - ((BC - AC) + (BD - AD) - (BCD - ACD));
  cout << ans << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rep(i,x) for(int i=0;i<(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct SegTree { // ??????min,max
	int n;
	vector<int> Max;
	vector<int> Min;

	void init(int n_)
	{
		n = 1;
		while (n < n_) n *= 2;

		Max.resize(2 * n);
		Min.resize(2 * n);

		for (int i = 0; i < 2 * n - 1; ++i) {
			Max[i] = -inf;
			Min[i] = inf;
		}
	}

	void update(int idx, int val)
	{
		idx += n - 1;
		Min[idx] = val;
		Max[idx] = val;

		while (idx > 0) {
			idx = (idx - 1) / 2;
			Min[idx] = min(Min[idx * 2 + 1], Min[idx * 2 + 2]);
			Max[idx] = max(Max[idx * 2 + 1], Max[idx * 2 + 2]);
		}
	}

	int get_min(int a, int b, int k = 0, int l = 0, int r = -1) // [a, b)???min
	{
		if (r == -1) r = n;
		if (r <= a || b <= l) return inf;
		if (a <= l && r <= b) return Min[k];

		int vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);

		return min(vl, vr);
	}

	int get_max(int a, int b, int k = 0, int l = 0, int r = -1) // [a, b)???max
	{
		if (r == -1) r = n;
		if (r <= a || b <= l) return -inf;
		if (a <= l && r <= b) return Max[k];

		int vl = get_max(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_max(a, b, k * 2 + 2, (l + r) / 2, r);

		return max(vl, vr);
	}
};

int X[200020], Y[200020];

signed main()
{
	int N, d; scanf("%d%d", &N, &d);

	SegTree x_seg, y_seg;

	x_seg.init(N), y_seg.init(N);

	vpii hoge;

	rep(i, N) {
		int x, y, b; scanf("%d%d%d", &x, &y, &b);
		X[i] = x, Y[i] = y;

		hoge.PB(pii(b, i));
	}

	sort(all(hoge));

	rep(i, N) {
		x_seg.update(i, X[hoge[i].scd]);
		y_seg.update(i, Y[hoge[i].scd]);
	}

	ll ans = -inf;

	rep(i, N) {
		if (i > 0 && hoge[i].fst == hoge[i - 1].fst) continue;

		int b = hoge[i].fst;

		int idx = upper_bound(all(hoge), pii(b + d, inf)) - hoge.begin();

		int min_x = x_seg.get_min(i, idx);
		int max_x = x_seg.get_max(i, idx);

		int min_y = y_seg.get_min(i, idx);
		int max_y = y_seg.get_max(i, idx);

		ans = max(ans, 1ll * (max_x - min_x) * (max_y - min_y));
	}

	printf("%lld\n", ans);
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  bool x = true;
  while(true){
    C -= B;
    if(C<1)
      break;
    A -= D;
    if(A<1){
      x = false;
      break;
    }
  }
  if(x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if(a[a[i]-1] == i+1) {
            cnt++;
        }
    }
    cout << cnt/2 << endl;
}

Measured memory_bytes: 640
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int H, W, K;
	cin >> H >> W >> K;
	int c[7][7] = { 0 };
	int brack = 0;
	rep(i, H) {
		rep(j, W) {
			char car;
			cin >> car;
			if (car == '#') {
				c[i][j] = 1;
			}
		}
	}

	int ans = 0;
	rep(y, 1 << H) {
		rep(x, 1 << W) {
			int cnt = 0;
			rep(i, H) {
				rep(j, W) {
					if ((y & (1 << i)) && x & (1 << j)) {
						if (c[i][j] == 1) cnt++;
					}
				}
			}
			if (cnt == K) ans++;
		}
	}

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


Measured memory_bytes: 3600
from collections import deque
from sys import stdin


def main():
    height, width = map(int, stdin.readline().split())
    q = deque([])
    grid = [stdin.readline() for _ in range(height)]
    distance = [[-1 for _ in range(width)] for _ in range(height)]
    for i in range(height):
        for j in range(width):
            if grid[i][j] == "#":
                q.append((i, j))
                distance[i][j] = 0
    answer = 0
    delta = ((0, 1), (1, 0), (0, -1), (-1, 0))
    while q:
        y, x = q.popleft()
        answer = distance[y][x]
        for dy, dx in delta:
            new_y = y + dy
            new_x = x + dx
            if 0 <= new_y < height and 0 <= new_x < width and distance[new_y][new_x] < 0:
                distance[new_y][new_x] = answer + 1
                q.append((new_y, new_x))
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 87132
#include <stdio.h>
#include <math.h>

int main(){
    

    int W, H;

    while(1){
        scanf("%d %d", &H, &W);
        if((H==0)&&(W==0)){
            break;
        }

        for(int h=0; h<H; h++){
            for(int w=0; w<W; w++){
                if((w>0)&&(w<W-1)&&(h>0)&&(h<H-1)){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = unsigned long long;
const long long INF = 1LL << 60;
 
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;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    ll A,B; cin >> A >> B;
    if((A+B)%2==0) cout << (A+B)/2;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
N = int(input())
C = sorted(list(map(int,input().split())))


ans = 0
for i in range(N):
    ans = (ans + pow(2,2*i,MOD)*C[i]*(N-i+1)*pow(2,(N-i-1),MOD) * (pow(2,(N-i-1),MOD))) % MOD

print(ans % MOD)




Measured memory_bytes: 89164
n,k = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)

m = []

(0..n - 1).each do |i|
    sum = 0.0
    sum += p[i] * (p[i] + 1) / 2
    sum /= p[i]
    m << sum.to_f
end
l = 0.0
(0..k - 1).each do |i|
    l += m[i]
end

ans = l
(k..n - 1).each do |i|
    l -= m[i - k]
    l += m[i]
    ans = ans > l ? ans : l
end
puts ans.to_f
    

Measured memory_bytes: 16644
#!/usr/bin/python

t = input().split()
n = int(t[0])
m = int(t[1])

a = 0
if n < 0:
    a += 0
else:
    a += (n * (n-1) // 2)

if m < 0:
    a += 0
else:
    a += (m * (m-1)//2)

print(a)

Measured memory_bytes: 38256
"""
ある街にN人のすぬけ君(すぬけ君1、すぬけ君2、 ...、 すぬけ君N)が住んでいます。

"""
n, k = map(int, input().split())
n_list = list(range(1, n+1))
input_map = {}
for i in range(k):
    d = int(input())
    d_list = [ int(ai) for ai in input().split()]
    for h in d_list:
        if n_list.count(h) == 1:
            n_list.remove(h)

print(len(n_list))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int>cusr(n,0);
    int a;
    rep(i, q) {
        cin >> a;
        cusr[a - 1]++;
    }
    int succsess = q - k + 1;
    bool ans = false;
    for (auto s : cusr) {
        if (s >= succsess)ans = true;
        else ans = false;
        if (ans) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


int h, w;

pair<int, int> nextxy(int x, int y){
    int nx, ny;
    if (y % 2 == 0){
        if (x < w - 1) nx = x + 1, ny = y;
        else nx = x, ny = y + 1;
    }
    else {
        if (0 < x) nx = x - 1, ny = y;
        else nx = x, ny = y + 1;    
    }
    return make_pair(nx, ny);
}

int a[505][505];

int main(){
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> a[i][j];

    vector<pair<int,int>> from;
    vector<pair<int,int>> to;

    int x = 0, y = 0;
    while(true){
        pair<int, int> p = nextxy(x, y);
        int nx = p.first;
        int ny = p.second;
        if (ny == h) break;

        if (a[y][x] % 2 != 0){
            a[y][x]--;
            a[ny][nx]++;
            from.push_back(make_pair(y, x));
            to.push_back(make_pair(ny, nx));
        }
        x = nx, y = ny;
    }
    
    cout << from.size() << endl;
    rep(i, from.size()){
        cout << from[i].first + 1 << " " << from[i].second + 1 << " ";
        cout << to[i].first  + 1 << " " << to[i].second + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 5228
#include<iostream>
#include<string>
#include<math.h>
#include<sstream>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k)
		cout << "Yay!" << endl;
	else
		cout  <<":(" << endl;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getLine >>= print

solve :: String -> Int
solve = sum . zipWith f "CODEFESTIVAL2016"
  where
    f x y
      | x == y = 0
      | otherwise = 1


Measured memory_bytes: 380
#include <iostream>

using namespace std;

int main(void) {
  int X;
  cin >> X;
  if (X == 25) cout << "Christmas" << endl;
  if (X == 24) cout << "Christmas Eve" << endl;
  if (X == 23) cout << "Christmas Eve Eve" << endl;
  if (X == 22) cout << "Christmas Eve Eve Eve" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;
int main() {
	int N, i, j;
	int min = 0;
	int max = 0;
	int b[9] = {};
	int c[9] = { 1,400,800,1200,1600,2000,2400,2800,3200};
	cin >> N;
	vector<int> a(N);
	for (i = 0; i < N; i++) { 
		cin >> a[i];
		for (j = 0; j < 8; j++) {
			if ((c[j] <= a[i]) && (a[i] < c[j + 1])) b[j] = 1;
		}
		if (c[8] <= a[i]) b[8]++;
	}
	for (i = 0; i < 8; i++) {
		min += b[i];
	}
	max = min + b[8];
	if (min == 0) min = 1;
	cout << min << " " << max << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    while True:
        h, w = map(int, input().split())
        if h == 0 and w == 0: break
        
        if w % 2 == 0:
            odd_panel = '#.' * (w // 2)
            even_panel = '.#' * (w // 2)
        else:
            odd_panel = '#.' * (w // 2) + '#'
            even_panel = '.#' * (w // 2) + '.'
            
        for item in range(h):
            if item % 2 == 0:
                print(odd_panel)
            else:
                print(even_panel)

        print('')
        

main()

Measured memory_bytes: 7788
n = int(input())
s1, s2, s3, s4 = 0, 0, 0, 0
for i in range(1, n+1):
  s1 += i
  if i % 3 == 0:
    s2 += i
  if i % 5 == 0:
    s3 += i
  if i % 15 == 0:
    s4 += i
print(s1 - (s2 + s3 - s4))
  

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


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


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, X[110];

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", X+i );

  int ans = 1<<30;

  repi( x, 1, 100 )
  {
    int sum = 0;
    rep( i, N )
      sum += (x-X[i])*(x-X[i]);

    ans = std::min( ans, sum );
  }

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

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
const int N=110;
int a[N];
int main()
{
    int n,m;
    cin>>n>>m;
    int sum=0;
    for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];
    sum=(sum+4*m-1)/(4*m);
    int cnt=0;
    for(int i=1;i<=n;i++)if(a[i]>=sum)cnt++;
    if(cnt>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> A;
int main()
{
	int cnt = 0;
	int n,q,a;
	cin >> n;
	for(int i = 0; i<n;i++)
	{
		cin >> a;
		A.push_back(a);
	}
	
	cin >> q;
	for(int i = 0; i<q;i++)
		{
		cin >> a;
		if(*lower_bound(A.begin(),A.end(),a) == a)
			cnt++;
		}
	cout <<cnt<<endl;
}

Measured memory_bytes: 3528
package main

import (
	"fmt"
)

func main() {
	var in string
	fmt.Scan(&in)
	fmt.Println(op(in))
}

func op(in string) string {
	ii := make([]int, 4)
	for i, v := range in {
		ii[i] = int(v - '0')
	}
	var s string
	if ii[0]+ii[1]+ii[2]+ii[3] == 7 {
		s = fmt.Sprintf("%v+%v+%v+%v=7", ii[0], ii[1], ii[2], ii[3])
	} else if ii[0]+ii[1]+ii[2]-ii[3] == 7 {
		s = fmt.Sprintf("%v+%v+%v-%v=7", ii[0], ii[1], ii[2], ii[3])
	} else if ii[0]+ii[1]-ii[2]+ii[3] == 7 {
		s = fmt.Sprintf("%v+%v-%v+%v=7", ii[0], ii[1], ii[2], ii[3])
	} else if ii[0]-ii[1]+ii[2]+ii[3] == 7 {
		s = fmt.Sprintf("%v-%v+%v+%v=7", ii[0], ii[1], ii[2], ii[3])
	} else if ii[0]-ii[1]-ii[2]+ii[3] == 7 {
		s = fmt.Sprintf("%v-%v-%v+%v=7", ii[0], ii[1], ii[2], ii[3])
	} else if ii[0]+ii[1]-ii[2]-ii[3] == 7 {
		s = fmt.Sprintf("%v+%v-%v-%v=7", ii[0], ii[1], ii[2], ii[3])
	} else if ii[0]-ii[1]+ii[2]-ii[3] == 7 {
		s = fmt.Sprintf("%v-%v+%v-%v=7", ii[0], ii[1], ii[2], ii[3])
	} else if ii[0]-ii[1]-ii[2]-ii[3] == 7 {
		s = fmt.Sprintf("%v-%v-%v-%v=7", ii[0], ii[1], ii[2], ii[3])
	}
	return s
}


Measured memory_bytes: 512
#include<iostream>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<cmath>
    using namespace std;
    int main() {
    	long long a[3];
    	for (int i = 0; i < 3; i++) {
    		cin >> a[i];
    		if (a[i] % 2 == 0) {
    			cout << 0 << endl;
    			return 0;
    		}
    	}
    	sort(a, a + 3);
    	int x = a[2] / 2;
    	long long s, t;
    	s = a[0] * a[1];
    	t = a[0] * a[1] * x;
    	cout << s  << endl;
     
     
    	return 0;
    }

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	int n, k, x,y;
	int ret = 0;
	cin >> n >>k>>x>>y;
	REP(i, n)ret += (i < k) ? x : y;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
using P = pair <int, int>;
 
 
int main() {
    int a,b,c;
    cin >> a>>b>>c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout<< s.size() <<endl;

}

Measured memory_bytes: 256
n = int(input())
ketasuu = 1
keta=[]
for i in range(1,100):
         if n - (26 ** i) > 0:
                  ketasuu += 1
                  n -= 26 ** i
n = n -1
for i in range(ketasuu):
         keta.append(n % 26)
         n = n // 26
keta = list(reversed(keta))
alphaketa=[]
for i in range(len(keta)):
         alphaketa.append(chr(keta[i] + 97))
ans = "".join(alphaketa)
print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>


using namespace std;


using ll = long long;


class ball {
    public:
        ll num;
        ll cnt;
        ball(ll num, ll cnt);
        ball();
};


ball::ball(ll num, ll cnt)
    : num(num), cnt(cnt)
{
}


int main()
{
    map<ll, ll> ball_cnt;
    ll N, K;
    cin >> N >> K;
    for (ll i = 0; i <= N; i++)
        ball_cnt[i] = 0;

    for (ll i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        ball_cnt[tmp]++;
    }

    vector<ball*> balls;
    for (auto c : ball_cnt) {
        balls.push_back(new ball(c.first, c.second));
    }

    sort(balls.begin(), balls.end(),
            [](ball* l, ball* r) { return l->cnt < r->cnt; });

    ll i = 0;
    ll ans = 0;
    while ((balls.size() - i) > K) {
        ans += balls[i++]->cnt;
    }

    for (auto b : balls)
        delete b;
    cout << ans << endl;
}


Measured memory_bytes: 20592
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        int i, j, k;
        int N, X[1000], Y[1000], S[1000];
        cin >> N;
        for(i=0; i<N; i++){
            cin >> X[i] >> Y[i];
            S[i] = X[i] + Y[i];
            if((S[i] - S[0]) % 2 != 0){
                cout << -1 << endl;
                return 0;
            }
        }
     
        vector<int> values;
        for(i=30; i>=0; i--) values.push_back(1<<i);
        if(S[0] % 2 == 0) values.push_back(1);
        int M = values.size();
        cout << M << endl;
        for(i=0; i<M; i++) cout << values[i] << " \n"[i==M-1];
     
        for(i=0; i<N; i++){
            int xpy = X[i] + Y[i], xmy = X[i] - Y[i];
            for(auto&& v : values){
                if(xpy >= 0){
                    if(xmy >= 0){
                        cout << "R";
                        xpy -= v;
                        xmy -= v;
                    }else{
                        cout << "U";
                        xpy -= v;
                        xmy += v;
                    }
                }else{
                    if(xmy >= 0){
                        cout << "D";
                        xpy += v;
                        xmy -= v;
                    }else{
                        cout << "L";
                        xpy += v;
                        xmy += v;
                    }
                }
            }
            cout << endl;
        }
        return 0;
    }

Measured memory_bytes: 256
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))

ans = 0

for i in range(N):
    tmp = np.dot(np.array(list(map(int, input().split()))), B)
    if (tmp.sum() + C) > 0:
        ans += 1

print(ans)

Measured memory_bytes: 21388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		boolean possible = false;

		for (int i = 0; i < S.length(); i++) {
			S = S.substring(1) + S.substring(0, 1);
			if (S.equals(T)) possible = true;
		}

		if (possible) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int D[N], h[N];
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    D[0] = 0;
    D[1] = fabs(h[1]-h[0]);
    for (int i = 2; i < N; i++)
    {
        D[i] = min(D[i-2]+fabs(h[i-2]-h[i]),D[i-1]+fabs(h[i-1]-h[i]));
    }
    cout << D[N-1];
    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
N, K = map(int, input().split())
mod = 10**9 + 7
A = list(map(int, input().split()))
l = []
for i in range(N):
    tmp = [0, 0]
    for j in range(N):
        if j < i:
            if A[i] < A[j]:
                tmp[0] += 1
        else:
            if A[i] < A[j]:
                tmp[1] += 1
    l.append(tmp[:])
ans = 0
for i in range(N):
    ans += K * ((l[i][0] * (K+1)) + (l[i][1]*(K-1))) // 2
    ans %= mod
print(ans % mod)

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

int main(){
  int a;
  cin >> a;
  if (a%2!=0){
    cout << "No" << endl;
    return 0;
  }else{
    char s[a];
    cin >> s;
    for(int i=0; i<a/2; i++){
      if(s[i]!=s[a/2+i]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;
int main()
{
	int A = 0, B = 0, T = 0;
	cin >> A >> B >> T;
	int sample = 0;
	sample = T + 0.5;
	int count = 0;
	for (int i = A;i <= sample; i = i + A)
	{
		count++;
	}
	cout << count*B << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

/*
vll v;
vll times;
ll const MAX = 200005;
ll a[MAX];
ll tbl[MAX][12];


void pd(ll k) {
	for (ll i = 2; i*i <= k; i++) {
		if (k%i == 0) {
			v.push_back(i);
			k /= i;
			ll cnt = 1;
			while (k%i == 0) {
				cnt++;
				k /= i;
			}
			times.push_back(cnt);
		}
	}
	if (k != 1) {
		v.push_back(k);
		times.push_back(1);
	}
}

ll pow_minus(ll k) {
	if (k % 2 == 1) {
		return 1;
	}
	else {
		return -1;
	}
}
ll bit_cnt(ll k) {
	ll ans = 0;
	while (k > 0) {
		ans += (k & 1);
		k >>= 1;
	}
}


ll f(ll bit) {

}

int main() {
	ll n, k;
	cin >> n >> k;
	pd(k);
	ll ans = 0;
	ll max_bit = (1 << v.size());
	for (ll bit = 0; bit < max_bit; bit++) {
		ans += pow_minus(bit_cnt(bit)) * f(bit);
	}
}
*/

ll a[500];
int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	ll max_v = a[1];
	ll cnt = 1;
	ll bef = a[1];
	bool evenflag = (max_v % 2 == 0);
	REP(i, 2, n) {
		ll cur = a[i];
		
		if (cur == bef) {
			cnt++;
			if (cur == max_v / 2 && evenflag && cnt >= 2) {
				cout << "Impossible" << endl;
				return 0;
			}
			else if (cur == max_v / 2 + 1 && !evenflag && cnt >= 3) {
				cout << "Impossible" << endl;
				return 0;
			}
		}
		else {
			if (bef - cur != 1 || cnt == 1 || cur < (1 + max_v) / 2) {
				cout << "Impossible" << endl;	
				return 0;
			}
			cnt = 1;
		}
		bef = cur;
	}
	cout << "Possible" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] l = new int[n];
    int d = 0;
    for(int i = 0;i<n;i++){
      l[i] = sc.nextInt();
    }
    Arrays.sort(l);
    for(int i = n-1;i>=2;i--){
      for(int j = i-1;j>=1;j--){
        for(int k = j-1;k>=0;k--){
          if(l[i]<(l[k]+l[j])){
            d++;
          }
        }
      }
    }
    System.out.println(d);
  }
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s;
  cin >> s;
  if (s.size() % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (ll i=0; i<s.size(); i+=2) {
    if (s[i] != 'h' || s[i+1] != 'i') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    ll ans = 0;
    rep(i,60) {
        ll x = 0;
        rep(j,n) if ((a[j]>>i)&1) x++;
        ll now = (x*(n-x))%mod;
        rep(j,i) now = (now*2)%mod;
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
k()=readline()|>chomp
s()=[parse(Int,x)for x=k()|>split]
n,q=s()
t=k()
a=zeros(Int,n)
[a[j]=a[j-1]+(t[j-1:j]=="AC")for j=2:n]
for i=1:q
l,r=s()
println(a[r]-a[l])
end

Measured memory_bytes: 155324
import sys
# A,B = [int(n) for n in input().split()]
# N = int(input())
A = [0]*3
ptr = [[0,1,2],[0,2,1],[1,2,0],[1,0,2] ,[2,1,0], [2,0,1]]
for i in range(3):
    A[i] = [int(n) for n in input().split()]


for l in ptr:
    tmp = A[l[0]][0]
    ok = True
    for i in l:
        if not (tmp in A[i]):
            ok = False
            break
        elif(tmp == A[i][0]):
            tmp = A[i][1]
        else:
            tmp = A[i][0]
    if(ok):
        print("YES")
        sys.exit()
    tmp = A[l[0]][1]
    ok = True
    for i in l:
        if not (tmp in A[i]):
            ok = False
            break
        elif(tmp == A[i][0]):
            tmp = A[i][1]
        else:
            tmp = A[i][0]
    if(ok):
        print("YES")
        sys.exit()
print("NO")


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

#define             ll  long long
#define             vi  vector<int>
#define             vl  vector<ll>
#define             PI  acos(-1.0)
#define            vii  vector<pair<int, int> >
#define            vll  vector<pair<ll, ll> >
#define            ull  unsigned long long
#define            pii  pair<int, int>
#define            pll  pair<ll, ll>
#define            P_B  push_back
#define            M_P  make_pair
#define         DBG(x)  printf("%s %d\n", #x, x)
#define         SCI(x)  scanf("%d",&x)
#define         SCD(x)  scanf("%lf",&x)
#define         SCS(x)  scanf("%s",x)
#define         CLR(x)  memset(x, 0, sizeof(x))
#define        CLRN(x)  memset(x, -1, sizeof(x))
#define        SCLL(x)  scanf("%lld", &x)
#define       DBGLL(x)  printf("%s %lld\n", #x, x)
#define      FOR(i, n)  for(int i = 0; i < n; i++)
#define     SCI2(m, n)  scanf("%d%d", &m, &n)
#define     SCD2(m, n)  scanf("%lf%lf",&m,&n)
#define    SCLL2(m, n)  scanf("%lld%lld", &m, &n)
#define  FORR(i, m, n)  for(int i = m; i < n; i++)
#define  SCI3(m, n, o)  scanf("%d%d%d",&m, &n, &o)
#define  SCD3(m, n, o)  scanf("%lf%lf%lf",&m,&n,&o)
#define SCLL3(m, n, o)  scanf("%lld%lld%lld",&m, &n, &o)

#define            MOD  1000000007
#define            INF  1000000000


int main()
{
	string s;
	cin >> s;
	int len = s.size();
	FOR(i, len)
		if(s[i] == '?') s[i] = 'D';
	cout << s << endl;
}


Measured memory_bytes: 3720
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll a,b;
    cin>>a>>b;
    if(a*500>=b)
    cout<<"Yes";
    else
    cout<<"No";}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 300001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(9);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n;
    cin >> n;
    int x;
    cin >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No";
        return 0;
    }
    cout << "Yes\n";
    vector<int> ans(2 * n);
    set<int> used;
    ans[n] = x;
    ans[n + 1] = x - 1;
    ans[n - 1] = x + 1;
    used.insert(x);
    used.insert(x + 1);
    used.insert(x - 1);
    if (n > 2) {
        if (x + 2 < 2 * n) {
            ans[n + 2] = x + 2;
            used.insert(x + 2);
        } else {
            ans[n - 2] = x - 2;
            used.insert(x - 2);
        }

    }
    set<int> unused;

    for (int i = 1; i <= 2 * n - 1; ++i) {
        if (!used.count(i)) {
            unused.insert(i);
        }
    }
    for (int i = 1; i < ans.size(); ++i) {
        if (!ans[i]) {
            int el = *unused.begin();
            unused.erase(el);
            ans[i] = el;
        }
    }
    for (int i = 1; i < ans.size(); ++i) {
        cout << ans[i] << "\n";
    }
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 11776
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int x;
    cin >> x;
    x -= 400;
    x /= 200;
    cout << 8 - x;
}


Measured memory_bytes: 3648