akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, t; cin >> n >> t;
	vi a(n); rep(i, n) cin >> a[i];
	
	int mn = inf, diff = 0, ans = 0;
	set<pi> s;
	rep(i, n){
		s.emplace(a[i], -i);
		mn = min(mn, a[i]);
		diff = max(diff, a[i] - mn);
	}
	for(int i = n - 1; i >= 0; i--){
		s.erase(pi(a[i], -i));
		int k = a[i] - diff;
		auto it = s.lower_bound(pi(k, -inf));
		if(it != s.end() && it->first == k){
			ans++;
			s.erase(it);
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n;
  vector<vector<int> > adj(n * n);
  for (int i = 0; i < n; i++) {
    int prev = -1;
    for (int j = 0; j < n - 1; j++) {
      int x; cin >> x;
      --x;
      int u = min(i, x), v = max(i, x);
      if (prev != -1) adj[prev].push_back(u * n + v);
      prev = u * n + v;
    }
  }
  vector<int> degree(n * n), visited(n * n), len(n * n);
  bool hasCycle = false;
  function<void(int)> dfs = [&](int u) {
    visited[u] = 2;
    len[u] = 1;
    for (auto v: adj[u]) {
      ++degree[v];
      if (visited[v] == 2) hasCycle = true;
      if (!visited[v]) dfs(v);
      len[u] = max(len[u], 1 + len[v]);
    }
    visited[u] = 1;
  };
  for (int i = 0; i < n * n; i++) if (!visited[i]) dfs(i);
  if (hasCycle) {
    cout << -1 << endl;
    return 0;
  }
  cout << *max_element(len.begin(), len.end()) << endl;
  return 0;
}



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

int main(){
    ll l,r; cin >> l >> r;
    int ans = 2019;
    if(r-l>=2019){
        cout << 0 << endl;
        return 0;
    }
    else{
        if((l%2019)>=(r%2019)){
            cout << 0 << endl;
            return 0;
        }
        else{
            for(int i=l;i<r;++i){
                for(int j=i+1;j<=r;++j){
                    ans = min(ans,(i%2019)*(j%2019)%2019);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pii> a(n);
	for(int i = 0; i < n; i ++){
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a.begin(), a.end());
	int temp = a[n - 2].first;
	for(int i = 0; i < n - 1; i ++){
		a[i].first = a.back().first;
	}
	a.back().first = temp;
	sort(a.begin(), a.end(), [](pii A, pii B){return A.second < B.second;});
	for(auto x: a){
		cout << x.first << "\n";
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
string dp[3000][2];
string s,t;
 
int main(){
    cin >> s >> t;
    ll sl = s.size();
    ll tl = t.size();
    if(s[0]==t[0]) dp[0][0] = s[0];
    else dp[0][0] = "";
    for(int i=1;i<sl;i++){
        if(dp[i][0].size() > 0) dp[i][0] = dp[i-1][0];
        else{
            if(s[i] == t[0]) dp[i][0] = s[i];
            else dp[i][0] = "";
        }
    }
    for(int j=1;j<tl;j++){
        for(int i=0;i<sl;i++){
            if(i == 0){
                if(s[0]==t[j]){
                    dp[0][1] = s[0];
                    continue;
                }
                if(dp[0][0].size() > 0){
                    dp[0][1] = dp[0][0];
                    continue;
                }
                dp[0][1] = "";
                continue;
            }
            if(dp[i][0].size() > dp[i-1][1].size()) dp[i][1] = dp[i][0];
            else dp[i][1] = dp[i-1][1]; 
            if(s[i]!=t[j]) continue;
            if(dp[i][1].size() <= dp[i-1][0].size()) dp[i][1] = dp[i-1][0] + s[i];
        }
        for(int i=0;i<sl;i++) dp[i][0] = dp[i][1];
    }
    cout << dp[sl-1][0] << endl;
    return 0;
}

Measured memory_bytes: 7808
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B = MAP()

if A%3== 0 or B%3==0 or (A+B)%3 == 0:
	print("Possible")
else:
	print("Impossible")


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pdi = pair<double, int>;

int N, X;
vector<int> b, l, u;
vector<pli> diff;
vector<ll> sumX;
vector<ll> sum0;

bool is_win(ll A) {
	const int q = (int)(A / X);
	const int r = A % X;

	for (int i = 0; i < N; i++)
	{
		ll ans = 0;

		ans += r > b[i] ? (ll)u[i] * (r - b[i]) : - (ll)l[i] * (b[i] - r);

		if (i < q) {
			ans += sumX[q + 1];
			ans += sum0[q + 1];
			ans -= (ll)u[i] * (X - b[i]);
		}
		else {
			ans += sumX[q];
			ans += sum0[q];
			ans -= - (ll)l[i] * b[i];
		}

		if (ans >= 0)
			return true;
	}

	return false;
}

int main() {
	cin >> N >> X;
	b.assign(N, 0), l.assign(N, 0), u.assign(N, 0);
	for (int i = 0; i < N; i++)
		cin >> b[i] >> l[i] >> u[i];


	for (int i = 0; i < N; i++)
		diff.push_back(pli((ll)u[i] * (X - b[i]) + (ll)l[i] * b[i], i));
	sort(diff.rbegin(), diff.rend());

	{
		vector<int> dummyb, dummyl, dummyu;
		for (int i = 0; i < N; i++)
		{
			int ni = diff[i].second;
			dummyb.push_back(b[ni]);
			dummyl.push_back(l[ni]);
			dummyu.push_back(u[ni]);
		}
		b = dummyb;
		l = dummyl;
		u = dummyu;
	}

	sumX.push_back(0);
	sum0.push_back(0);
	for (int i = 0; i < N; i++) {
		sumX.push_back(sumX[i] + (ll)u[i] * (X - b[i]));
		sum0.push_back(sum0[i] - (ll)l[N - 1 - i] * b[N - 1 - i]);
	}
	reverse(sum0.begin(), sum0.end());

	ll lb = -1, rb = (ll)N * X; // (lb, rb]
	while (rb - lb > 1) {
		ll mid = (lb + rb) / 2;
		if (is_win(mid))
			rb = mid;
		else
			lb = mid;
	}

	cout << rb << endl;
	return 0;
}

Measured memory_bytes: 5976
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <functional>
#include <queue>

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using ll = long long;
using vll = vector<ll>;
using pii = pair<int, int>;
using vb = vector<char>;
using vvb = vector<vb>;

#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define mp(a, b) make_pair(a,b)

#define fi first
#define sn second
#define decpii(p) p.fi--,p.sn--;


#ifdef LOCAL
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#else
#define dump(c) ;
#endif


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

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, (int) a.size())os << (i ? " " : "") << a[i];
    return os << ']';
}


int dxf[] = {1, 0, -1, 0};
int dyf[] = {0, -1, 0, 1};

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

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

inline vi uni(vi &vec) {
    sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct ____ {
    ____() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} ________;

int solve() {
    int R, C;
    cin >> R >> C;

    vvb block(R, vb(C, false));
    int bc = 0;
    rep(r, R) {
        rep(c, C) {
            char t;
            cin >> t;
            if(t == '#') {
                block[r][c] = true;
                bc++;
            }
        }
    }

    vvb passed(R, vb(C, false));

    queue<pair<int, pii>> que;
    pii start = mp(0,0);
    que.push(mp(0, start));
    passed[start.fi][start.sn] = true;

    while (!que.empty()) {
        auto t = que.front();
        que.pop();
        int step = t.fi;
        pii now = t.sn;

        if (now == mp(R - 1, C - 1)) {
            return R*C - step - 1 - bc;
        }

        rep(i, 4) {
            int dr = now.fi + dyf[i];
            int dc = now.sn + dxf[i];

            if (0 <= dr && dr < R && 0 <= dc && dc < C
                && !block[dr][dc] && !passed[dr][dc]) {
                que.push(mp(step + 1, mp(dr, dc)));
                passed[dr][dc] = true;
            }
        }
    }

    return -1;
}

int main() {
    cout << solve() << endl;
    return 0;
}


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

int main() {
  int a,b1,b2;
  cin >> a;
  b1=a/100;
  b2=a%100;
  if(b1>=01 && b1<=12){
    if(b2>=01 && b2<=12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else{
    if(b2>=01 && b2<=12) cout << "YYMM" << endl;
    else cout << "NA" << endl;    
  }
}


Measured memory_bytes: 256
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    return sum([count(ai) for ai in a if ai % 2 == 0])


def count(n):
    ans = 0
    while n % 2 == 0:
        ans += 1
        n /= 2
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 4148
#include<stdio.h>
#include<stdlib.h>

typedef struct{
  int parent;
  int left;
  int right;
}Node;

void print(int);
int sibling(int);
int height(int);
int degree(int);

Node Tree[25];
int H[25];


int main(){

  int n,i,j,id,child,r,depth;
 
  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    Tree[i].parent = -1;
    Tree[i].left = -1;
    Tree[i].right = -1;
  }

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

    for(j = 0 ; j < 2 ; j++){

      scanf("%d",&child);
      Tree[child].parent = id;

      if(j == 0)
	Tree[id].left = child;
      else if(j == 1){
	Tree[id].right = child;
      }
      r = child;
    }
  }
  
  for(j = 0 ; j < n ; j++) print(j);
 
  return 0; 
}


void print(int j){
  
  int depth,i,s,deg,h;

  depth = 0;
  
  i = Tree[j].parent;
  
  while(i != -1){
    i = Tree[i].parent;
    depth++;
  }

  h = height(j);
  s = sibling(j);
  deg = degree(j);

  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", j,Tree[j].parent, s, deg, depth, h);

  if(Tree[j].parent == -1) printf("root\n");
  else if(Tree[j].left==-1 && Tree[j].right==-1) printf("leaf\n");
  else printf("internal node\n");
}


int height(int s){
  int r, l;
  r = l = 0;

  if(Tree[s].left == -1 && Tree[s].right == -1) return 0;

  if(Tree[s].left != -1 && Tree[s].right != -1){
    l = height(Tree[s].left) + 1;
    r = height(Tree[s].right) + 1;
    if(l < r) return r;
    else return l;  
  }
  else if(Tree[s].left == -1 && Tree[s].right != -1) return height(Tree[s].right) +1;
  else if(Tree[s].right == -1 && Tree[s].left != -1) return height(Tree[s].left) +1;

}

int sibling(int s){
  if( Tree[s].parent == -1 )return -1;
  if( Tree[Tree[s].parent].left != -1 && Tree[Tree[s].parent].left != s ){
    return Tree[Tree[s].parent].left;
  }
  if( Tree[Tree[s].parent].right != -1 && Tree[Tree[s].parent].right != s ){
    return Tree[Tree[s].parent].right;
  }
  return -1;
}

int degree(int s){
  int d = 0;

  if(Tree[s].left != -1) d++;
  if(Tree[s].right != -1) d++;

  return d;

}

Measured memory_bytes: 612
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

  ll remain = K;
  string ans = s;
  for (ll i = 0; i < s.size(); i++) {
    const char c = s[i];
    ll n = (ll)('z' - c + 1) % 26;

    if (remain >= n) {
      remain -= n;
      ans[i] = 'a';
    }

    if (i == s.size() - 1 && remain > 0) {
      ans[i] = (char)('a' + (ans[i] + remain - 'a') % 26);
    }
  }

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


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

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

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

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

  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
D = [V[k] - C[k] for k in range(N)]

D = sorted(D)[::-1]

ans = 0
for d in D:
    if d > 0:
        ans += d
print(ans)

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

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

  int n, m; cin >> n >> m;
  vector<int> a(m);
  ll su = 0;
  for(int i=0;i<m;++i) {
    cin >> a[i];
    su += a[i];
  }
  cout << (n - su >= 0 ? n - su : -1) << endl;


  
}


Measured memory_bytes: 3660
//*****************************believer******************************//
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef map<ll,ll> mi;
 
#define f first
#define ss second
#define ins insert
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define pq priority_queue
#define sqr(n) floor(sqrt(n))
#define sz(v) ((ll)(v.size()))
#define trav(a,x) for (auto& a: x)
#define all(v) (v).begin(),(v).end()
#define arl(v) (v).rbegin(),(v).rend()
#define mem(a) memset(a, -1, sizeof (a))
#define ssort(v) sort((v).begin(),(v).end())
#define rsort(v) sort((v).rbegin(),(v).rend())
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define vmn(a) (*min_element(a.begin(),a.end()))
#define vmx(a) (*max_element(a.begin(),a.end()))
#define foo(i,a,b) for (ll i = (a); i < (b); ++i)
#define foor(i,a,b) for (ll i = (a); i >= (b); --i)

const ll N=2e5+100;
ll dp[N][3];
ll a[N][3];

ll solve(ll x,ll used)
{
    if(dp[x][used]!=-1)
    return dp[x][used];
    
    if(used==0)
    return dp[x][0]=a[x][0]+max(solve(x-1,1LL),solve(x-1,2LL));
    else if(used==1)
    return dp[x][1]=a[x][1]+max(solve(x-1,0LL),solve(x-1,2LL));
    else
    return dp[x][2]=a[x][2]+max(solve(x-1,1LL),solve(x-1,0LL));
    
}


int main()
{
    
        ll n;
        cin>>n;
        foo(i,0,n)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
        
        mem(dp);
        ///////initialisation of dp;
        dp[0][0]=a[0][0];
        dp[0][1]=a[0][1];
        dp[0][2]=a[0][2];
        
        ll ans=max({solve(n-1,0),solve(n-1,1),solve(n-1,2)});
        cout<<ans<<endl;
        
    
    return 0;
}


Measured memory_bytes: 15340
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int a, b, c;
	cin >> a >> b >> c;
	vi v;
	v.pb(0);
	rep(i, c) {
		int x=a + i;
		if(x>=a&&x<=b)
			v.pb(x);
	}
	repr(i, c) {
		int x=b - i;
		if (x >= a&&x <= b)
			v.pb(x);
	}
	sort(all(v));
	REP(i,1, v.size()) {
		if (v[i-1] != v[i])
			cout << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	ll n;
	cin >> n;
	ll ans;
	if (n % 11 <= 6 && n % 11 > 0)ans = n / 11 * 2 + 1;
	else ans = ceil(n / 11.0) * 2;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= int(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void chmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

template <typename UnaryPredicate>
int64_t binsearch(int64_t l, int64_t r, UnaryPredicate p) {
    assert (l <= r);
    -- l;
    while (r - l > 1) {
        int64_t m = l + (r - l) / 2;  // avoid overflow
        (p(m) ? r : l) = m;
    }
    return r;
}

ll solve(ll a, ll b) {
cerr << endl;
dump(a);
dump(b);
    ll dense = binsearch(1, a * b + 1, [&](ll i) {
        long double x = (a * b - 1) /(long double) i;
        long double y = (a * b - 1) /(long double) (i + 1);
        return x - y <= 1;
    });
dump(dense);
dump((a * b - 1) / dense);
    ll acc = 0;
    acc += dense - 1;
    acc += (a * b - 1) / dense;
    if (min(a, b) <= dense
            and min(a,b) <= (a * b - 1) / dense) acc -= 1;
dump(acc);
    return acc;
}

int main() {
    int q; cin >> q;
    while (q --) {
        int a, b; cin >> a >> b;
        ll answer = solve(a, b);
        cout << answer << endl;
    }
    return 0;
}


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

int main()
{
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++)
  {
    if (i % k == 0)
    {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define preturn(X) cout<<X<<endl; return 0
typedef long long ll;





int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a && c<=b){
        preturn("Yes");
    }
    preturn("No");
}


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

int main() {
  int x;
  cin >> x;
  vector<bool> dp(x + 105 + 1);
  dp[0] = true;
  for (int i = 0; i < x; i++) {
    for (int k = 100; k <= 105; k++) {
      dp[i + k] = dp[i + k] || dp[i];
    }
  }
  cout << int(dp[x]) << endl;
}


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

using namespace std;

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

int main(){
  int n;
  uint64_t k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i, n){
    cin >> a[i];
  }
  vector<int> j(n, -1);
  vector<int> l(200020, -1);
  REP(i, n){
    int x = a[i];
    if(l[x] >= 0){
      j[l[x]] = i + 1;
    }
    l[x] = i;
  }
  REP(i, n){
    int x = a[i];
    if(l[x] >= 0){
      j[l[x]] = n + i + 1;
      l[x] = -1;
    }
  }
  int p = 0;
  int q = 0;
  do{
    p = j[p];
    q += p / n;
    p %= n;
  }while(p != 0);
  k %= q;
  if(k == 0){
    cout << endl;
    return 0;
  }
  q = 0;
  while(1){
    int np = j[p];
    if(np >= n){
      q += 1;
      if(q == k) break;
      np -= n;
    }
    p = np;
  }
  bool first = true;
  while(p < n){
    if(j[p] <= n){
      p = j[p];
    }else{
      if(!first) putchar(32);
      printf("%d", a[p]);
      first = false;
      ++p;
    }
  }
  puts("");
  return 0;
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int n;
int sum = 0;
int path1, path2;
int ok = 0;
void solve(int n) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int price = 7 * i + 4 * j;
			if (price == n)
				ok = true;
			if (price > n)
				break;
		}

	}
	if (ok)cout << "Yes " << endl;
	else cout << "No " << endl;

}
int main() {
	cin >> n;
	solve(n);
	return 0;
}


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

using namespace std;

#define int long long

typedef long long LL;
typedef pair<int, int> pii;

const int maxn = 100005;

pii aa[maxn];
LL ans[maxn];

signed main()
{
//	freopen("main.in", "r", stdin);
//	freopen("main.out", "w", stdout);
	int n;
	scanf("%lld", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%lld", &aa[i].first);
		aa[i].second = i;
	}
	sort(aa + 1, aa + n + 1, greater<pii>());
	int nowid = n;
	for(int i = 1; i <= n; ++i)
	{
		if(aa[i].first != aa[i + 1].first)
		{
			nowid = min(nowid, aa[i].second);
			ans[nowid] += (aa[i].first - aa[i + 1].first) * i;
		}
	}
	for(int i = 1; i <= n; ++i)
		printf("%lld\n", ans[i]);
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <deque>
#include <string>
#include <stdlib.h>
using namespace std;
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(void) {
  string s;
  cin >> s;
  deque<char> q;
  for (char c : s) q.push_back(c);
  bool filp = false;
  int Q;
  cin >> Q;
  rep(iq, Q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      filp = !filp;
    } else {
      int f; char c;
      cin >> f >> c;
      if (filp) f = 3-f;
      if ( f == 1) {
        q.push_front(c);
      } else {
        q.push_back(c);
      }
    }
  }
  if (filp) reverse(q.begin(), q.end());
  string ans;
  for (char c : q) ans += c;
  cout << ans << endl;
  
  return 0;
}





Measured memory_bytes: 1412
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

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

    int n = int('Z');
    rep(i,S.size()){
        if (int(S[i]) + N > n) S[i] += N - 26;
        else S[i] += N;
    }
    cout << S << endl;
    return 0;
}

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

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

    bool ans = true;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0 && s[i] == 'L')
        {
            ans = false;
            break;
        }
        else if (i % 2 == 1 && s[i] == 'R')
        {
            ans = false;
            break;
        }
    }

    cout << (ans ? "Yes" : "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 < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if(S == U)
    A--;
  else
    B--;
  cout << A << ' ' << B << endl;
}

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

int score2color(int s){
	if(s < 400) return 0;
	else if (s < 800) return 1;
	else if (s < 1200) return 2;
	else if (s < 1600) return 3;
	else if (s < 2000) return 4;
	else if (s < 2400) return 5;
	else if (s < 2800) return 6;
	else if (s < 3200) return 7;
	return 8;
}

int main(){
	int a, n;
	unordered_set<int> s;
	int min = 0, max = 0;
	int color;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a;
		color = score2color(a);
		if(color==8){
			max++;
		} else if(s.count(color) == 0){
			s.insert(color);
			min++;
			max++;
		}
	}
	if(min==0) min=1;
	cout << min << " " << max;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  vector<ll> dp(MAX);
  ll N; cin >> N;
  dp[0] = 1; dp[1] = 1;
  rep(i,N){
    dp[i + 2] = dp[i] + dp[i + 1];
  }
  cout << dp[N] << endl;

}



Measured memory_bytes: 6576
#M-SOLUTIONS B
#c>b>aが達成条件
a, b, c = map(int, input().split())
k = int(input())
count = 0
while b <= a:
  b *= 2
  count += 1
while c <= b:
  c *= 2
  count += 1
#print(a,b,c)
#print(count)
if count > k:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9164
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
d = defaultdict(int)
N = int(input())
A = list(map(int,input().split()))
s = 0
ans = []
for i in range(N):
    a = A[i]
    s += a
    d[a] += 1
Q = int(input())
for i in range(Q):
    B,C = map(int,input().split())
    if d[B] == 0:
        ans.append(s)
    else:
        num = d[B]
        d[B] = 0
        d[C] += num
        s += C*num
        s -= B*num
        ans.append(s)
for i in ans:
    print(i)
    


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

using namespace std;


int main()
{
    //freopen("in.txt","r",stdin);
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b && a!=c)
        cout<<"Yes"<<endl;
    else if(a==c && a!=b)
        cout<<"Yes"<<endl;
    else if(b==c && c!=a)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;




    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int f_dir[2][4] = {{-1, 0, 0, 1}, {0, -1, 1, 0}};
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

void solve(int r, int n){
  vector<pair<double, double>> heights(41, pair<double, double>{0, 0});
  for(int i = 0; i < n; i++){
    int xl, xr;
    double h;
    cin >> xl >> xr >> h;
    for(int j = xl+20; j <= xr+20; j++){
      if(j > 0 && j > xl+20) heights[j-1].second = max(heights[j-1].second, h);
      if(j < 40 && j < xr+20) heights[j+1].first = max(heights[j+1].first, h);
    }
  }
  double ans = 20;
  for(int i = 20 - r; i <= r+20; i++){
    double h = sqrt(1.0*r*r - (double(i) - 20)*(double(i) - 20));
    if(i == 20-r){
      ans = min(ans, r + heights[i].second - h);
    }
    else if(i == r+20){
      ans = min(ans, r + heights[i].first - h);
    }
    else{
      ans = min(ans, r + heights[i].second - h);
      ans = min(ans, r + heights[i].first - h);
    }
  }
  cout << fixed << setprecision(16) << ans << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int r, n;
  while(cin >> r >> n && r){
    solve(r, n);
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



Measured memory_bytes: 3268
#include <iostream>
using namespace std;
bool overlap(int a,int b,int c,int d){
    if(d <= a){
        return false;
    }
    if(b <= c){
        return false;
    }
    return true;
}
int main(void){ 
    int a,b,s,f,n;
    cin >> a >> b >> n;
    for(int i=0; i<n; i++){
        cin >> s >> f;
        if(overlap(a,b,s,f)){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N, K;
	cin >> N >> K;

	vector<int> A(N), F(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> F[i];

	sort(A.begin(), A.end());
	sort(F.begin(), F.end(), greater<int>());

	auto judge = [&](lint idx) {
		
		lint sum = 0;
		for (int i = 0; i < N; i++) sum += max(A[i] -(idx / F[i]), 0LL);

		return sum <= K;

	};

	auto biSearch = [&](auto f) {
		lint ok = 1e12;
		lint ng = -1;

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

			if (f(mid)) ok = mid;
			else ng = mid;
		}

		return ok;
	};

	cout << biSearch(judge) << "\n";

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<map>
using namespace std;
typedef long long li;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}


li gcd(li a,li b){
  while(b){
    li r=a%b; a=b; b=r;
  }
  return a;
}


struct frac{ // den>0
  li num;
  li den;

  frac(li a,li b=1){
    if(!a and !b){ num=0; den=0; return; }
    li d=gcd(a,b);
    num=a/d,den=b/d;
    if(den<0) {num*=-1; den*=-1;}
  }
  int operator<(const frac& f) const {
    if(num<f.num) return 1;
    if(num==f.num and den<f.den) return 1;
    return 0;
  }
};

std::ostream& operator<<(std::ostream& os, const frac& f){
  // ここでストリームに obj を書き込みます。
  printf("%ld/%ld",f.num,f.den);
  return os;
}

li pow2(li a){
  li s=1,b=2;
  while(a){
    if(a%2) (s*=b)%=MOD;
    a/=2; (b*=b)%=MOD;
  }
  return s;
}

int main(){
  int n; cin >>n;
  map<frac,li> mp;
  rep(i,n){
    li a,b; cin >>a >>b;
    mp[{a,b}]++;
  }
  if(df)print(mp);
  li cnt=1,cn0=0;
  
  auto x=mp.find({0,0});
  if(x!=mp.end()){
    cn0=x->second;
    mp.erase({0,0});
  }
  
  for(auto& x:mp){
    frac f=x.first; li c=x.second;
    auto y=mp.find({-f.den,f.num});
    if(y==mp.end()){
      if(df)print("*2^",c);
      (cnt*=pow2(c))%=MOD;
    }else{
      if(df)print("*(2^",c,"+2^",y->second,"-1)");
      li t=pow2(c);
      (t+=pow2(y->second)-1)%=MOD;
      (cnt*=t)%=MOD;
      mp.erase(y);
    }
  }
  print((cnt+MOD-1+cn0)%MOD);
  
}


Measured memory_bytes: 16060
x, y = map(int, input().split())

result = 0
if x == 1:
    result += 300000
elif x == 2:
    result += 200000
elif x == 3:
    result += 100000
if y == 1:
    result += 300000
elif y == 2:
    result += 200000
elif y == 3:
    result += 100000

if x == 1 and y == 1:
    result += 400000

print(result)

Measured memory_bytes: 3064
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll ,string> Tlls;
#define PI 3.141592

int main()
{

  long double R;
  cin >> R;
  double a = PI;
  //小数点以下を指定したい場合　https://marycore.jp/prog/cpp/stream-format-float/
  cout << fixed;
  cout << setprecision(20) << 2 * R * a << endl;

  return 0;
}


Measured memory_bytes: 3804
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int w = in.nextInt();
		int h = in.nextInt();
		if (w + h == 0) return false;

		int sy = -1, sx = -1;

		char[][] table = new char[h][w];
		for (int i=0; i<h; i++) {
			table[i] = in.next().toCharArray();
			for (int j=0; j<w; j++) {
				if (table[i][j] == '@') {
					sy = i; sx = j;
				}
			}
		}

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

		ArrayDeque<Integer> que = new ArrayDeque<>();
		int cnt = 0;
		que.add(sy*w+sx);

		boolean[][] visited = new boolean[h][w];
		visited[sy][sx] = true;

		while (que.size() > 0) {
			int c = que.pollFirst();
			cnt++;
			int cy = c/w, cx = c%w;
			for (int k=0; k<4; k++) {
				int ny = cy + dy[k], nx = cx + dx[k];
				if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
				if (table[ny][nx] == '#' || visited[ny][nx]) continue;
				visited[ny][nx] = true;
				que.add(ny*w+nx);
			}
		}

		out.println(cnt);


		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n,a[200001];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int> b;
    for(int i = 0; i < n; i++){
        if(i % 2) b.push_back(a[i]);
        else b.insert(b.begin(),a[i]);
    }

    if(n % 2){
        for(int i = 0; i < n; i++) cout << b[i] << ' ';
    }else{
        for(int i = n-1; i >= 0; i--) cout << b[i] << ' ';
    }

    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    vector<int> l(3);
    rep(i, 3) cin >> l[i];
    cout << l[0] * l[1]/2 << endl;
}


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

int main()
{
    char c[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
using namespace std;
//	int x=atoi(s.c_str()); s_to_in;
int dx[] = { -1,0,0,1 };
int dy[] = { 0,1,-1 ,0};
#define endl '\n'
long long mo = 1e9;
const long double P = 3.141592653589793238L;
void trust_yourself()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y, long long mo)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mo;
		y = (y >> 1); //y/=2
		x = (x*x) % mo;
	}

	return p;
}
long long convert_to_num(string x) {
	long long  num = 0;
	for (int i = 0; i < x.size(); i++) {
		num *= 2;
		num += x[i] - '0';
	}
	return num;
}

long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = p * i;
		p /= p1;
		p1++;
	}
	return p;
}



int main()
{
	trust_yourself();
	//freopen("hussien.in", "r", stdin);
	
	string s;
	cin >> s;
	if (s.find('7') != -1)
		cout << "Yes";
	else
		cout << "No";
	
	
	return 0;

}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> L(N);
	for (Int i = 0; i < N; i++) {
		cin >> L[i];
	}

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

	Int ans = 0;
	Int temp;
	for (Int i = N - 1; i >= 0; i--) {//最大辺
		for (Int j = 0; j < i - 1; j++) {
			/*for (Int k = j + 1; k < i; k++) {
				if (L[i] < L[j] + L[k]) {
					ans += i - k;
					break;
				}
			}*/
			temp = lower_bound(L.begin(), L.end(), L[i] - L[j] + 1) - L.begin();
			temp = max(temp, j+1);
			ans += max(0LL, i-temp);
		}
	}

	cout << ans << "\n";
}


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


int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    rep(i, N) {
        cin >> P[i];
    }
    rep(i, N) { 
        cin >> Q[i];
    }
    vector<int> sorted;
    xrep(i, 1, N+1) {
        sorted.push_back(i);
    }
    map<vector<int>, int> mp;
    do {
        mp[sorted] = mp.size();
    } while(next_permutation(sorted.begin(), sorted.end()));

    int ans = abs(mp[P]-mp[Q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
	{
	    cout<<3<<"\n";
	}
	else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
	{
	  cout<<2<<"\n";
	}
	else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
	{
	   cout<<1<<"\n";
	}
	else
	{
	    cout<<0<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3588
import numpy as np
from numba import njit

@njit #処理の並列化_これがない場合は'TLE'
def imos(n, a):
    l=np.zeros((n+1), dtype = np.int64)

    for i, x in enumerate(a):# x_光の強さ_これで照射範囲が決まる
        left = max(0, i - x) #StartIndex_照らせる範囲
        right = min(n, i + x + 1) #EndIndex + 1_照らせる範囲
        l[left] += 1 # 各々を'+1'と'-1'で表し...
        l[right] -= 1

    return np.cumsum(l)[:n] # 累積和をとる_cumulative sum

n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    a = imos(n, a)
    if a.min() == n: # すべての要素が最大値'n'になるとbreak
        break

print(*a)


Measured memory_bytes: 123976
#include<bits/stdc++.h>
#include <iostream>
#include<cstdlib>
#include <numeric>
using namespace std;

const int MAX_N = 100000;

int main(){
    string n;
    cin >> n;
    int fx=0;
    
    for(int i=0;i<n.size();i++){
        fx += n[i] - '0';
    }
    
    int x = atoi(n.c_str());
    
    if(x%fx==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s;
  string  t;
  cin >> s >>t;

  if(t.size()>=4){
    for(ll i=0;i<s.size();i++){
      if(s[i]!='1'){
        cout << s[i] << endl;
        return 0;
      }
    }
  }
  ll k=stoi(t);
  if(k<=s.size()){
    for(ll i=0;i<k;i++){
      if(s[i]!='1'){
        cout << s[i] << endl;
        return 0;
      }
    }
    cout << 1 << endl;;
  }
  else{
    for(ll i=0;i<s.size();i++){
      if(s[i]!='1'){
        cout << s[i] << endl;
        return 0;
      }
    }
  }


}

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

using namespace std;

const int INF = 1000000007;

int getOverlap(string s, string t){
	int n = min(s.size(), t.size());
	for(int i=n;i>0;i--)
		if(s.substr(s.size()-i) == t.substr(0,i)) return i;
	return 0;
}

int main(){
	int n;
	string str[14];
	int cost[14][14];
	int dp[14][1<<14];
	while(cin >> n, n){
		for(int i=0;i<n;i++) cin >> str[i];
		int notuse = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j) continue;
				if(str[i].find(str[j])!=string::npos) notuse |= 1<<j;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j) continue;
				cost[i][j] = getOverlap(str[i], str[j]);
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<(1<<n);j++) dp[i][j] = INF;
		}
		for(int i=0;i<n;i++){
			if(notuse&(1<<i)) continue;
			dp[i][1<<i] = str[i].size();
		}
		for(int i=0;i<(1<<n);i++){
			if(i&notuse) continue;
			for(int j=0;j<n;j++){
				if(dp[j][i]==INF) continue;
				for(int k=0;k<n;k++){
					if(notuse&(1<<k)) continue;
					if(i&(1<<k))      continue;
					dp[k][i|(1<<k)] = min(dp[k][i|(1<<k)], dp[j][i]+(int)str[k].size()-cost[j][k]);
				}
			}
		}
		int res = INF;
		for(int i=0;i<n;i++) res = min(res, dp[i][((1<<n)-1)^notuse]);
		cout << res << endl;
	}
}

Measured memory_bytes: 1820