akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

int main()
{

    int n,m;
    scanf("%d %d", &n, &m);
    vector<deque<int>> a(n);
    forn(i,0,n) {
        forn(j,0,m) {
            int x;
            scanf("%d", &x);
            x--;
            a[i].pb(x);
        }
    }
    vi ban(m,0);
    int ans = n;
    vi pt(n,0);
    forn(step,0,m) {
        vi cnt(m,0);
        forn(i,0,n) {
            while(ban[a[i][pt[i]]]) pt[i]++;
            cnt[a[i][pt[i]]]++;
        }
        pi cur = mp(0,-1);
        forn(i,0,m) cur = max(cur, mp(cnt[i], i));
        ans = min(ans, cur.first);
        ban[cur.second] = 1;
    }
    cout<<ans;
    
}



Measured memory_bytes: 768
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    bool isYes = true;
    for (int i = n - 1; i > 0; i--) {
        if (v[i - 1] - v[i] >= 2) {
            isYes = false;
            break;
        } else if (v[i - 1] - v[i] == 1) {
            v[i - 1] -= 1;
        } else {
            continue;
        }
    }
    string answer = isYes ? "Yes" : "No";
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define N 501

int main()
{
  int i,j,w,t,l,f,D[N][N];

  scanf("%d",&w);

  for(i=0;i<w;i++){
    for(j=0; j<w; j++){
      D[i][j]=0;
    }
  }
  for(i=0;i<w;i++){
    scanf("%d %d",&t,&l);
    t--;
    for(j=0;j<l;j++){
      scanf("%d",&f);
      f--;
      D[t][f]=1;
    }
  }
  for(i=0;i<w;i++){
    for(j=0; j<w-1; j++){
      printf("%d ",D[i][j]);
    }
    printf("%d\n",D[i][w-1]);
  }
  return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

ll N, X;
ll path = 0;
ll lside, sside;

ll solve(ll a, ll b) {
	if (b == 0) {
		return -a;
	}
	else {
		return 2 * (a / b) * b + solve(b, a % b);
	}
}

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

	if (X == 0) {
		cout << 0 << endl;
		return 0;
	}

	if (X < N - X) { X = N - X; }

	path += N;
	path += solve(X, N - X);

	cout << path << endl;

	return 0;
}

Measured memory_bytes: 256
l=[]
n=int(input())
for _ in range(n):
    a=int(input())
    l.append(a)
maxl=max(l)
a=l.count(maxl)
if a>=2:
    for _ in range(n):
        print(maxl)
else:
    for i in range(n):
        if l[i]!=maxl:
            print(maxl)
        else:
            ll=l.copy()
            l.remove(maxl)
            print(max(l))
            l=ll

Measured memory_bytes: 18460
#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 <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


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

	cout << N * (N - 1) / 2 << endl;
}

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

#define mp make_pair
#define fst first
#define snd second

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const ll M = 1000000007;
//const int MAX_N = 100000;
string t;

int main()
{
  cin >> t;
  ll e = 1, a = 0, ab = 0, abc = 0;
  for (int i = 0; i < (int)t.size(); i++) {
    ll e1 = e, a1 = a, ab1 = ab, abc1 = abc;
    if (t[i] == 'A') a1 = (a + e) % M;
    if (t[i] == 'B') ab1 = (ab + a) % M;
    if (t[i] == 'C') abc1 = (abc + ab) % M;
    if (t[i] == '?') {
      e1 = (3 * e) % M;
      a1 = (3*a + e) % M;
      ab1 = (3*ab + a) % M;
      abc1 = (3*abc + ab) % M;
    }
    e = e1, a = a1, ab = ab1, abc = abc1;
    //printf("a=%lld, ab=%lld, abc=%lld\n",a,ab,abc);
  }

  cout << abc << endl;

  return 0;
}


Measured memory_bytes: 512
info=gets.chomp.split(" ").map(&:to_i)#N A B
x=gets.chomp.split(" ").map(&:to_i)

dp=Array.new(info[0])
dp[0]=0
for i in 1..info[0]-1
	walk=dp[i-1]+info[1]*(x[i]-x[i-1])
	tel=dp[i-1]+info[2]
	if(walk>tel)
		dp[i]=tel
	else
		dp[i]=walk
	end
end
p dp[info[0]-1]

Measured memory_bytes: 10244
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

struct Elem {
    int cur, vel, f; ll cost;
    Elem(int cu, int v, int f_, ll co) : cur(cu), vel(v), f(f_), cost(co) {}
    bool operator<(const Elem &e) const {
        return cost > e.cost;
    }
};

ll dist[510][55][2];
int main() {
    int N, M; scanf("%d%d", &N, &M);
    vector< vector< pair<ll, ll> > > G(N);
    for(int i=0; i<M; i++) {
        int u, v, t; scanf("%d%d%d", &u, &v, &t);
        u--; v--;
        G[u].emplace_back(v, t);
        G[v].emplace_back(u, t);
    }

    int v0; scanf("%d", &v0);
    int A, B, C; scanf("%d%d%d", &A, &B, &C);
    fill(dist[0][0], dist[N][0], LONGINF);
    dist[0][v0][0] = 0;
    priority_queue<Elem> que;
    que.emplace(0, v0, 0, 0);
    while(que.size()) {
        Elem elem = que.top(); que.pop();
        int cur = elem.cur, v = elem.vel, f = elem.f;
        ll cost = elem.cost;
        if(dist[cur][v][f] < cost) continue;
        for(auto e : G[cur]) {
            ll to, t; tie(to, t) = e;
            ll n_cost = cost + v * t;
            ll n_v = (A*v + B) % C;
            ll n_f = f | (to == N-1);
            if(dist[to][n_v][n_f] > n_cost) {
                dist[to][n_v][n_f] = n_cost;
                que.emplace(to, n_v, n_f, n_cost);
            }
        }
    }

    ll ans = LONGINF;
    for(int i=0; i<C; i++) chmin(ans, dist[0][i][1]);
    printf("%lld\n", ans);
    return 0;
}



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

using namespace std;

int main(){
  int N;
  cin >> N;
    
 priority_queue<long, std::vector<long>, greater<long>> q;
  q.push(1);
  q.push(2);
  q.push(3);
  q.push(4);
  q.push(5);
  q.push(6);
  q.push(7);
  q.push(8);
  q.push(9);

  for(int i=0; i<N-1; i++){
    long cur = q.top();
    q.pop();
    long nextBase = (long)10*cur;
    long lastDig = cur % 10;
    if(cur % 10 != 0) q.push(nextBase + lastDig - 1);
    q.push(nextBase + lastDig);
    if(cur % 10 != 9) q.push(nextBase + lastDig + 1);
  }
  
  cout << q.top();
  return 0; 
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int f[50][50];

int dfs(vector<vector<int>> &m, int h, int w, vector<vector<char>> as) {
    if (h < 0 || w < 0 || h >= m.size() || w >= m[h].size()) {
        return 0;
    }
    if (as[h][w] == 'B') return 1;
    if (as[h][w] == 'W') return 2;
    if (f[h][w]) return m[h][w];
    f[h][w] = 1;
    int t=0;
    t |= dfs(m, h-1, w, as);
    t |= dfs(m, h+1, w, as);
    t |= dfs(m, h, w+1, as);
    t |= dfs(m, h, w-1, as);
    m[h][w] = t;
    return t;
}

int siage(vector<vector<int>> &m, int h, int w, vector<vector<char>> as, int max_num) {
    if (h < 0 || w < 0 || h >= m.size() || w >= m[h].size()) {
        return 0;
    }
    if (as[h][w] == 'B') return 0;
    if (as[h][w] == 'W') return 0;
    if (f[h][w]) return m[h][w];
    f[h][w] = 1;
    int t=0;
    max_num = max(max_num, m[h][w]);
    max_num = max(max_num, siage(m, h-1, w, as, max_num));
    max_num = max(max_num, siage(m, h+1, w, as, max_num));
    max_num = max(max_num, siage(m, h, w-1, as, max_num));
    max_num = max(max_num, siage(m, h, w+1, as, max_num));
    m[h][w] = max_num;
    return max_num;
}

int main()
{
    int w, h;
    while (cin >> w >> h, w) {
        loop(50,i) loop(50,j) f[i][j] = 0;
        vector<vector<char>> as;
        as.resize(h);
        loop(h,i) {
            string s;
            cin >> s;
            for (char c:s) as[i].push_back(c);
        }
       // for(auto mm:as) {
       //     for (auto m:mm) cout << m << ' ';
       //     cout << endl;
       // }

        vector<vector<int>> mat(h, vector<int>(w,0));
        loop(h,i){
            loop(w,j){
                if (as[i][j] == '.') {
                    dfs(mat, i, j, as);
                }
            }
        }
        loop(50,i) loop(50,j) f[i][j] = 0;

        loop(h,i){
            loop(w,j){
                if (as[i][j] == '.') {
                    siage(mat, i, j, as, 0);
                }
            }
        }
        int ans_w = 0, ans_b = 0;
        for(auto mm:mat) {
            for (auto m:mm) {
                if (m == 1) ans_b++;
                if (m == 2) ans_w++;
                //cout << m << ' ';
            }
            //cout << endl;
        }
        cout << ans_b << ' ' << ans_w << endl;

    }
}

Measured memory_bytes: 14356
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  string s;
  cin >> s;
  
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
  
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  map<LL,LL> mp;
  int a,b,c;
  rep(i,n){
    cin >> a;
    mp[a]++;
  }
  rep(i,m){
    cin >> c >> b;
    for(auto &p:mp){
      if(p.first>=b) break;
      if(p.second>=c){
        mp[b]+=c;
        p.second-=c;
        break;
      }
      mp[b]+=p.second;
      c-=p.second;
      p.second=0;
    }
    for(auto itr=mp.begin();1;){
      if(itr->second!=0) break;
      itr = mp.erase(itr);
    }
  }
  LL ans=0;
  for(auto &p:mp){
    ans+=p.first*p.second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	
	map<int, int> mp;
	mp[a]++; mp[b]++; mp[c]++;
	
	if( mp[5] > 1 ) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3544
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10 , P = 1e9 + 7;
int n , a[N] , need[N];

int main(){
  cin >> n;
  rep(i,0,n) need[abs(i-(n-1-i))]++;
  int ans=1;
  rep(i,0,n) if(need[i]) (ans*=need[i])%=P;
  rep(i,0,n) scanf("%d",a+i),need[a[i]]--;
  rep(i,0,n) if(need[i]!=0) {
    cout << 0 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
long long MOD; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} ;
// } fio;

int N;
string S;
vector<int> P;
vector<vector<int>> dp;

int solve(int d, int e, int c){
	int D = d%MOD;
	int E = e%MOD;
	
	int a = P[d];
	int b = P[e];
	
	if(a > b) swap(a, b);
	
	if(c == 1) {
		if(S[b - a - 1] == '1') {
			return b;
		} else {
			return a;
		}
	}

	if(dp[c][D]){
		return dp[c][D];
	}
	
	int f = solve(d, d + (1<<(c-2)), c-1);
	int g = solve(e, e + (1<<(c-2)), c-1);
	
	if(f > g) swap(f, g);
	
	if(S[g - f - 1] == '1')  dp[c][D] = g;
	else dp[c][D] = f;
	
	return dp[c][D];
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	
	cin>>N;
	
	cin>>S;
	
	MOD = (1<<N);
	
	P.resize(1<<(N+1));
	dp.resize(N+1, vector<int>(1<<N));
	
	for(int i = 0; i < 1<<N; i++){
		cin>>P[i];
		P[i + (1<<N)] = P[i];
	}
	
	for(int i = 0; i < 1<<N; i++){
		cout<<solve(i, i + (1<<(N-1)), N)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 48612
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,k;
  cin>>n>>k;
  long long ans=0;
  int q,r;
  for(int b=1;b<=n;b++){
    q = n/b;
    r = n%b;
    ans += q*max(0,b-k)+max(0,r-k+1);
    if(k==0){
      ans--;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(input() for i in range(N))
M = int(input())
T = list(input() for i in range(M))

Li = []
for i in set(L):
    if i not in T:
        K = 0
    else:
        K = T.count(i)
    Li.append(L.count(i) - K)

print(max(Li) if max(Li)>0 else 0)


Measured memory_bytes: 62568
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-14 10:16
# @url:https://atcoder.jp/contests/abc043/tasks/arc059_a
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n=int(input())
    a=list(map(int,input().split()))
    mn,mx=min(a),max(a)
    ans=10**9
    for i in range(mn,mx+1):
        temp=0
        for j in a:
            temp+=(j-i)*(j-i)
        ans=min(ans,temp)
    print (ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 77168
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	int n,a[100];

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = n-1; i > 0; --i) {
		cout << a[i] << " ";
	}
	cout << a[0] << endl;;

}



Measured memory_bytes: 3056
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
#include<map>
#include<set>

using namespace std;

int main()
{
    int n,r;
    cin>>n>>r;
    if(n<10)
    cout<<r+100*(10-n)<<endl;
    else
        cout<<r<<endl;
    return 0;
    
}


Measured memory_bytes: 888
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

ll c[256];

int main(int argc, char **argv) {
	CLEAR(c);
	string s;
	cin >> s;
	int n = s.length();
	REP(i, n) ++c[s[i]];
	ll res = 0;
	REP(i, 256) res += c[i] * (n - c[i]);
	cout << (res / 2 + 1) << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

class union_find {
public:
vector<int> par,rank,lsize;
union_find(int n): par(n),rank(n),lsize(n){
   for (int i=0;i < n;i++){
      par[i]=i;
      rank[i]=0;
      lsize[i]=1;
   }
}

int find(int x){
   if (par[x]==x){
      return x;
   }
   else{
      return par[x] = find(par[x]); 
   }
}

void unite(int x ,int y){
   x=find(x);
   y=find(y);
   if (x==y) return;
   if (rank[x] < rank[y]){
      lsize[y] += lsize[x];
      lsize[x] = -1;
      par[x] = y;
   }else{
      lsize[x] += lsize[y];
      lsize[y] = -1;
      par[y]=x;
      if (rank[x]==rank[y]) rank[x]++;
   }   
}

bool same(int x, int y){
   return find(x) == find(y);
}

int size(int x){
   if (lsize[x] == -1){
      x=find(x);
   }
   return lsize[x];
}
};

struct edge{int u,v,cost;};

bool comp(const edge &e1, const edge &e2){
    return e1.cost < e2.cost;
}

edge es[100001];
int V,E;

int kruskal(){
    sort(es,es+E,comp);
    union_find tree(V);
    int res = 0;
    for (int i = 0;i < E;i++){
        edge e = es[i];
        if (!tree.same(e.u,e.v)){
            tree.unite(e.u,e.v);
            res += e.cost;
        }
    }
    return res;

}

int main(){
    cin >> V >> E;
    rep(i,E){
        ll a,b,c;
        cin >> a >> b >> c;
        es[i].u = a;
        es[i].v = b;
        es[i].cost = c;
    }
    cout << kruskal() << endl;


   return 0;

}


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

int main() {
  int n, l;
  cin >> n >> l;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    vec.at(i) = l + i;
  }
  
  if(vec.at(0)>0){
    int count=0;
    for(int i=1; i<n; i++){
      count += vec.at(i);
    }
    cout << count <<endl;
  }
  else if(vec.at(n-1)<0){
    int count=0;
    for(int i=0; i<n-1; i++){
      count += vec.at(i);
    }
    cout << count << endl;
  }
  else{
    int count=0;
    for(int i=0; i<n; i++){
      count += vec.at(i);
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

#include <vector>
#include <queue>
#include <cstdint>
#include <cassert>
#include <tuple>

template<typename t> t inf() { assert(0); return t(); }
template<> double inf() { return (1LL << 50); }
template<> long inf() { return (1LL << 50); }
template<> int inf() { return (1LL << 31)-1; }

namespace Graph {
  template<typename tEdge>
  struct Graph {
    Graph() : v(0) {}
    std::vector<tEdge> edges;
    uint32_t v;
  };
  template<typename tEdge>
  void addEdge(Graph<tEdge>& graph, tEdge edge) {
    assert( edge.from < graph.v );
    assert( edge.to   < graph.v );
    graph.edges.push_back(edge);
  }
  template<typename tEdge>
  void setV(Graph<tEdge>& graph, uint32_t v) {
    graph.v = v;
  }
};

namespace Graph {
  namespace Dijkstra {
    template<typename tEdge>
    struct DijkstraInfo {
      std::vector<typename tEdge::wType> dists;
    };
    template<typename tEdge>
    static DijkstraInfo<tEdge> dijkstra(const Graph<tEdge>& graph, uint32_t start) {
      std::vector< std::pair<uint32_t, typename tEdge::wType> > *adj = new std::vector< std::pair<uint32_t, typename tEdge::wType> >[graph.v];
      int n = graph.edges.size();
      for(int i = 0; i < n; ++i) {
        adj[graph.edges[i].from].push_back(std::make_pair(graph.edges[i].to, graph.edges[i].w));
      }
      DijkstraInfo<tEdge> info;
      info.dists.resize(graph.v);
      for(auto &x : info.dists) x = inf<typename tEdge::wType>();
      info.dists[start] = 0;
      std::priority_queue< std::pair<typename tEdge::wType, uint32_t> > q;
      q.push(std::make_pair(0, start));
      while( not q.empty() ) {
        typename tEdge::wType w;
        uint32_t id;
        std::tie(w, id) = q.top(); q.pop(); w = -w;
        for(auto I : adj[id]) {
          uint32_t next;
          typename tEdge::wType nw;
          std::tie(next, nw) = I; nw += w;
          if( info.dists[next] <= nw ) continue;
          info.dists[next] = nw;
          q.push(std::make_pair(-nw, next));
        }
      }
      delete [] adj;
      return info;
    }
  };
};


struct Edge {
  uint32_t from;
  uint32_t to;
  typedef int wType;
  wType w;
};

int main() {
  Graph::Graph<Edge> graph;
  int v, e, r;
  scanf("%d %d %d", &v, &e, &r);
  setV(graph, v);
  for(int i = 0; i < e; ++i) {
    Edge edge;
    scanf("%u %u %d", &edge.from, &edge.to, &edge.w);
    addEdge(graph, edge);
  }
  auto res = Graph::Dijkstra::dijkstra(graph, r);
  int n = res.dists.size();
  for(int i = 0; i < n; ++i) {
    printf("%s\n", res.dists[i] == inf<int>() ? "INF" : std::to_string(res.dists[i]).c_str());
  }
  
  return 0;
}

Measured memory_bytes: 18800
from collections import defaultdict

_ = input()
ns = list(map(int, input().split()))

# ns = [4, 1, 3, 2]

xs = ns[0::2]
ys = ns[1::2]

ans = 0
counts = defaultdict(int)
for x in xs:
    counts[x] += 1

max_numx = -1
max_x = -1
for key in counts.keys():
    if counts[key] > max_numx:
        max_numx = counts[key]
        max_x = key

del counts[max_x]
if counts:
    max_numx2 = max(counts.values())
else:
    max_numx2 = 0

counts = defaultdict(int)
for y in ys:
    counts[y] += 1
max_numy = -1
max_y = -1
for key in counts.keys():
    if counts[key] > max_numy:
        max_numy = counts[key]
        max_y = key

del counts[max_y]
if counts:
    max_numy2 = max(counts.values())
else:
    max_numy2 = 0

if max_x != max_y:
    print(len(ns) - max_numx - max_numy)
else:
    print(min(len(ns) - max_numx - max_numy2, len(ns) - max_numx2 - max_numy))


Measured memory_bytes: 15964
input = gets.chomp
n = input.count("N")
s = input.count("S")
e = input.count("E")
w = input.count("W")

if n == 0
  unless s == 0
    puts "No"
    exit
  end
else # n > 0
  unless s <= n && s > 0
    puts "No"
    exit
  end
end

if e == 0
  unless w == 0
    puts "No"
    exit
  end
else # n > 0
  unless w <= e && w > 0
    puts "No"
    exit
  end
end

puts "Yes"

Measured memory_bytes: 1788
import sys
A, B = sys.stdin.readline().rstrip().split()
import math
A = int(A)
B = B.split(".")
B_y = int(B[0] + B[1])
ans = str(A * B_y)

if len(ans) > len(B[1]):
    print(ans[:-len(B[1])])
else:
    print(0)

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

typedef long long ll; 

int main(){
        ll n,a,b;  cin>>n>>a>>b; 
        ll ar[n]; for(int i=0;i<n;i++) cin>>ar[i];
        ll ans =0; 
        for(int i=0;i<n-1;i++) {
                if((ar[i+1]-ar[i])*a<b) { ans+=(ar[i+1]-ar[i])*a; }
                else ans+=b; 
        }
        cout<<ans; 
	return 0; 
}



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

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    sort(h.begin(),h.end());
    double ans = h[0];
    for(int i =1;i<N;i++){
      ans = (ans +h[i])/2.0;
    }
 
    cout<<setprecision(10)<<ans<<endl;
    return 0;    
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;

    int n;  cin >> n;
    int a[n];
    int ans = 0;
    for(int x=0;x<n;x++)    cin >> a[x];

    for(int x=1;x<n-1;x++){
        int num = a[x] , num1 = a[x-1] , num2 = a[x+1];

        int f[] = {num , num1 , num2};
        sort(f , f+3);
        if(f[1] == num) ans++;

    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i,t,small,dif,mv,flag=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&t);
        if(i==0) small = t;
        if(i>flag) dif = t-small;
        if(small>t)
        {
            small = t;
            flag = i;
        }
        if(i==1) mv = dif;
        if(i>1)
        {
            if(mv<dif) mv = dif;
        }
    }
    printf("%d\n",mv);
}



Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n;
  cin >> h >> n;
  int num = 0;
  while(n--){
  	int tmp;
    cin >> tmp;
    num+=tmp;
  }
  if(num>=h) cout << "Yes" << endl;
  else cout << "No" << 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 debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  ll n;
  cin >> n;
  map<ll, ll> m;
  ll input;
  rep(i, n){
    cin >> input;
    m[input] += 1;
  }

  for (auto p = m.begin(); p != m.end(); p++){
    // debug(p->first);
    // debug(p->second);
    if (p->second > 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int a[100010];
signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n,k,q;
    int ac;
    cin >> n >> k >> q;
    for(int i=0;i<q;i++){
        cin >> ac;
        a[ac]++;
    }
    for(int i=1;i<=n;i++){
        if(k + a[i] > q){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
    return 0;
}



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

int main(){
  int N;
  scanf("%d",&N);
  
  vector<int64_t> L(90);
  L.at(0)=2LL;
  L.at(1)=1LL;
  for(int i=2;i<=N;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  printf("%lld\n",L.at(N));
}

Measured memory_bytes: 3812
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	count := 0
LOOP:
	for {
		for i := 0; i < n; i++ {
			if a[i]%2 == 0 {
				a[i] = a[i] / 2
			} else {
				break LOOP
			}
		}
		count++
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >>H>>W;
  string field[H];
  int ans[H][W];
  
  for(int i=0 ; i < H ; i++)cin >>field[i];
  
  for(int i=0 ; i < H ; i++){
    for(int j=0 ; j < W ; j++){
      ans[i][j]=-1;
    }
  }
  
  for(int i=0 ; i < H ; i++){
    for(int j=0 ; j < W ; j++){
      if(field[i][j] == 'c'){
	for(int k=j ; k < W ; k++){
	  ans[i][k]=k-j;
	}
      }
    }
  }
  
  for(int i=0 ; i < H ; i++){
    for(int j=0 ; j < W ; j++){
      cout <<ans[i][j];
      if(j != W-1)cout <<" ";
    }
    cout <<endl;
  }

  return 0;  
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<char> a(n, ' ');
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int counter = 0;
	for (int i = 0; i < n-1; i++) {
		if ((a[i] == 'O' && a[i+1] == 'X') || (a[i] == 'X' && a[i+1] == 'O')) {
			counter++;
			i++;
		}
	}
	cout << counter << endl;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> a(N), b(N);
	ll cur=0,val=0;
	for (int i=0; i<N; i++)
		cin>>a[i], cur-=a[i];
	for (int i=0; i<N; i++)
		cin>>b[i], cur+=b[i];
	for (int i=0; i<N; i++)
		if(a[i]<b[i])
			cur-=(b[i]-a[i]+1)/2;
	cout<<((cur<0)?"No":"Yes")<<"\n";
	return 0;
}

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

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long t = n / (a + b);
    long long last = n % (a + b);
    long long exb = last;
    if (exb > a) exb = a;
    cout << t * a + exb << endl;

}

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

int main(){
    int n, a[102]; cin>>n; long long sum=0;
    for( int i =0; i<n; i++){
        cin>>a[i];
        sum+=a[i];
    }

    long long avr = round(double(sum)/n);int answer=0;
    for( int i=0; i<n; i++){
        answer += (a[i]-avr)*(a[i]-avr);
    }
    cout<<answer;
    return 0;
}

Measured memory_bytes: 256
// bit_xor example
#include<bits/stdc++.h>
using namespace std;
#define int long long

int32_t main () {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    while(k--){
        if(a>0){
            sum+=1;
            a--;
        }else if(b>0){
            sum+=0;
            b--;
        }else{
            sum-=1;
            c--;
        }
    }
    cout<<sum<<endl;
  
    

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    map<string, int> map;
    rep(0, i, N)
    {
        string s;
        cin >> s;
        map[s]++;
    }
    cout << map.size() << endl;
}

Measured memory_bytes: 19048
#include <stdio.h>
int main(void){
    char data[25]={'\0'};
    scanf("%s",data);
    int loop1;
    for(loop1=0;loop1<5;loop1++){
        printf("%c",data[loop1]);
    }
    printf(" ");
    for(loop1=6;loop1<13;loop1++){
        printf("%c",data[loop1]);
    }
    printf(" ");
    for(loop1=14;loop1<19;loop1++){
        printf("%c",data[loop1]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#[allow(dead_code)]
fn read_line(n: usize) -> String {
    let mut ss = String::new();
    for _i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        ss.push_str(&s);
    }
    ss
}

macro_rules! parse {
    ($s:expr => $($r:tt)*) => {
        let s = $s;
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        parse!{s => $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    parse!{
        n: usize,
    }
    let mut ans = 0;
    for i in 1..n {
        let a = i;
        let b = n - i;
        if a >= b {
            break;
        }
        ans += 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<queue>
#include<map>
#include<cstring>
using namespace std;

struct node 
{
  int step;
  int tx,ty;
  int kx,ky;
  node(int s,int ttx,int tty,int kkx,int kky):
    step(s),tx(ttx),ty(tty),kx(kkx),ky(kky){} 
};
  
int main()
{
  int x,y;
  for(;cin>>x>>y,x;)
    {
      bool data[60][60];
      int tx,ty,kx,ky;
      cin>>tx>>ty>>kx>>ky;
      memset(data,false,sizeof(data));
      for(int i=1;i<=y;i++)
	for(int j=1;j<=x;j++)
	  {
	    char tmp;
	    cin>>tmp;
	    data[j][i]=(tmp=='0');
	  }
      queue<node> qu;
      qu.push(node(0,tx,ty,kx,ky));
      map< pair<pair<int,int>,pair<int,int> > ,bool >hash;
      int ans=-1;
      int dx[]={0,0,1,-1};
      int dy[]={1,-1,0,0};
      while(!qu.empty())
	{
	  node tmp=qu.front();
	  qu.pop();
	  //	  cout<<tmp.step<<" "<<tmp.tx<<" "<<tmp.ty<<" "<<tmp.kx<<" "<<tmp.ky<<endl;
	  if(hash[make_pair(make_pair(tmp.tx,tmp.ty),make_pair(tmp.kx,tmp.ky))])
	    continue;
	  if(tmp.tx==tmp.kx && tmp.ty==tmp.ky)
	    {
	      ans=tmp.step;
	      break;
	    }
	  if(tmp.step>=99)
	    continue;
	  hash[make_pair(make_pair(tmp.tx,tmp.ty),make_pair(tmp.kx,tmp.ky))]=true;
	  for(int i=0;i<4;i++)
	    {
	      int ttx=tmp.tx,tty=tmp.ty,tkx=tmp.kx,tky=tmp.ky;
	      if(data[ttx+dx[i]][tty+dy[i]])
		{
		  ttx+=dx[i];
		  tty+=dy[i];
		}
	      if(data[tkx-dx[i]][tky-dy[i]])
		{
		  tkx-=dx[i];
		  tky-=dy[i];
		}
	      //cout<<"make"<<ttx<<" "<<tkx<<" "<<tty<<" "<<tty<<endl;
	      if(!hash[make_pair(make_pair(ttx,tty),make_pair(tkx,tky))])
		qu.push(node(tmp.step+1,ttx,tty,tkx,tky));
	    }
	}
      if(ans==-1)
	cout<<"NA"<<endl;
      else
	cout<<ans<<endl;

    }
}

Measured memory_bytes: 12264
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int m = scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			int i = 0;
			int ret = 0;
			while (i < m) {
				if (s[i] == 'O') {
					i++;
					continue;
				}
				int cnt = 0;
				i++;
				while (i + 1 < m && s[i] == 'O' && s[i + 1] == 'I') {
					cnt++;
					i += 2;
				}
				ret += Math.max(0, cnt - n + 1);
			}
			System.out.println(ret);
		}
	}
}

Measured memory_bytes: 32696
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (a < b ? 0 : 10) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    double ans = 0;
    rep(i,n){
        ans += 1/v[i];
    }
    cout << 1/ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int a, b;
void solve() {  
    cin >> a >> b;
    cout << a * b;
}       
    

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

int main() {
  string S; cin >> S;
  
  int w_cnt = 0;
  char former_color;
  // 白黒　1010...
  for (int i = 0; i < S.size(); ++i) {
    if (i == 0) {
      if (S[i] != '1') {
        ++w_cnt;
      }
      former_color = '1';
    }
    else {
      if (S[i] == former_color) {
        ++w_cnt;
      }
      if (former_color == '1') former_color = '0';
      else former_color = '1';
    }
  }
  
  int b_cnt = 0;
  // 黒白　0101...
  for (int i = 0; i < S.size(); ++i) {
    if (i == 0) {
      if (S[i] != '0') {
        ++b_cnt;
      }
      former_color = '0';
    }
    else {
      if (S[i] == former_color) {
        ++b_cnt;
      }
      if (former_color == '1') former_color = '0';
      else former_color = '1';
    }
  }
  
  cout << min(w_cnt, b_cnt) << endl;
   
  return 0;
}

Measured memory_bytes: 512
def resolve():
  a, b = map(int, input().split())
  if a > b:
    a, b = b, a
  ans = (b + a) // 2
  if abs(a-ans) == abs(b-ans):
    print(ans)
  else:
    print("IMPOSSIBLE")
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
n, m = map(int,input().split())
sc = []
for i in range(m):
    sc.append([int(i) for i in input().split()])

for i in range(0, 1000):
    i = str(i)
    if len(i) != n:
        continue
    flag = True
    for j in range(m):
        #print(i, i[sc[j][0] - 1], sc[j][1])
        if i[sc[j][0] - 1] != str(sc[j][1]):
            flag = False
    if flag:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 3060
n = int(input())
strings = input()
r_array, g_array, b_array = list(), list(), list()

sums = [0, 0, 0]


def counter(s):
    if s == "R":
        sums[0] += 1
    elif s == "G":
        sums[1] += 1
    else:
        sums[2] += 1
    r_array.append(sums[0])
    g_array.append(sums[1])
    b_array.append(sums[2])


for s in strings:
    counter(s)

ret = 0
for i in range(n):
    s = strings[i]
    _r, _g, _b = r_array[i], g_array[i], b_array[i]
    r_, g_, b_ = sums[0] - _r, sums[1] - _g, sums[2] - _b
    if s == "R":
        ret += _g * b_ + _b * g_
    elif s == "G":
        ret += _r * b_ + _b * r_
    else:
        ret += _r * g_ + _g * r_

    for j in range(min(i + 1, n - i)):
        if (strings[i - j] != s) and (strings[i + j] != s) and (strings[i - j] != strings[i + j]):
            ret -= 1
print(ret)

Measured memory_bytes: 69100
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;cin>>n;
    int m = n / 4;
    bool can = false;
    for(int i = 0; i <= m; i++){
        if((n - i*4 )%7 == 0) can = true;
    }
    
    cout << (can ? "Yes" : "No") << endl;
    return 0;
    
}

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

int main(){
  string s;
  int k;
  cin>>s>>k;
  int n=s.size();
  set<string> a;
  rep(i,0,k)
  rep(j,0,n-i){
    string t="";
    rep(l,j,j+i+1){
      t+=s[l];
    }
    a.insert(t);
  }
  int i=0;
  for(auto p:a){
    if(i==k-1){
      cout<<p<<endl;
      break;
    }
    i++;
  }
}

Measured memory_bytes: 1664
import java.util.Scanner;

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

    long X = scanner.nextLong();
    long Y = scanner.nextLong();
    long z = Y / X;
    int k = 0;
    while (z > 0) {
      k++;
      z >>= 1;
    }
    System.out.println(k);
  }
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#pragma GCC optimize("O2")
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1e9+7
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
const int MAXN = 2e5+ 10;
const ll inf = 1e18;

int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
int32_t main() {
    fio
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int x = a[0];
    int ans = 0;
    for (int j = 1; j < n; ++j) {
        ans+=max(0ll,x - a[j]);
        x = max(x,a[j]);
    }
    cout << ans << endl;

}






Measured memory_bytes: 4796