akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

class MinCostFlow {
public:
  struct edge { int to, cap, cost, rev; };

private:
  const int INF = 1 << 28;
  int N;
  vector<vector<edge>> E;
  vector<int> h, dist, prevv, preve;

public:
  MinCostFlow(int N): N(N), E(N), h(N, 0), dist(N), prevv(N), preve(N) {}

  void add_directed_edge(int from, int to, int cap, int cost) {
    E[from].push_back((edge) { to, cap, cost, (int) E[to].size() });
    E[to].push_back((edge) { from, 0, -cost, (int) E[from].size() - 1 });
  }

  int min_cost_flow(int s, int t, int f) {
    int ret = 0;
    while (f > 0) {
      priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
      for (int i = 0; i < N; i++) dist[i] = INF;
      dist[s] = 0;
      q.push(make_pair(0, s));
      while (!q.empty()) {
        pair<int, int> p = q.top();
        q.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0; i < E[v].size(); i++) {
          edge &e = E[v][i];
          if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
            dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
            prevv[e.to] = v;
            preve[e.to] = i;
            q.push(make_pair(dist[e.to], e.to));
          }
        }
      }
      if (dist[t] == INF) return -1;
      for (int v = 0; v < N; v++) h[v] += dist[v];
      int d = f;
      for (int v = t; v != s; v = prevv[v]) d = min(d, E[prevv[v]][preve[v]].cap);
      f -= d;
      ret += d * h[t];
      for (int v = t; v != s; v = prevv[v]) {
        edge &e = E[prevv[v]][preve[v]];
        e.cap -= d;
        E[v][e.rev].cap += d;
      }
    }
    return ret;
  }
};

ll volume(vector<ll> &b) {
  return b[0] * b[1] * b[2];
}

bool contain(vector<ll> &b1, vector<ll> &b2) {
  bool ret = false;
  do {
    bool ok = true;
    REP(i, 0, 3) ok = ok && b1[i] < b2[i];
    ret = ret || ok;
  } while (next_permutation(b1.begin(), b1.end()));
  sort(b1.begin(), b1.end());
  return ret;
}

int main(void) {
  for (ll N; cin >> N, N;) {
    vector<vector<ll>> B(N, vector<ll>(3));
    REP(i, 0, N) cin >> B[i][0] >> B[i][1] >> B[i][2];

    REP(i, 0, N) sort(B[i].begin(), B[i].end());

    MinCostFlow mcf(N * 2 + 2);
    ll s = N * 2, t = N * 2 + 1;
    vector<ll> p(N), q(N);
    REP(i, 0, N) p[i] = i;
    REP(i, 0, N) q[i] = N + i;

    REP(i, 0, N) mcf.add_directed_edge(s, p[i], 1, 0);
    REP(i, 0, N) mcf.add_directed_edge(p[i], t, 1, volume(B[i]));
    REP(i, 0, N) mcf.add_directed_edge(q[i], t, 1, 0);

    REP(i, 0, N) {
      REP(j, 0, N) if (j != i) {
        if (contain(B[i], B[j])) {
          mcf.add_directed_edge(p[i], q[j], 1, 0);
        }
      }
    }

    cout << mcf.min_cost_flow(s, t, N) << endl;
  }
}


Measured memory_bytes: 3292
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] x = new int[n];
    int x_max = 0;
    int x_min = 100;
    int ans = 1000000000;
    for(int i=0; i<n; i++) {
      x[i] = Integer.parseInt(str[i]);
      x_max = Math.max(x_max,x[i]);
      x_min = Math.min(x_min,x[i]);
    }
    for(int i=x_min; i<=x_max; i++) {
      int sum = 0;
      for(int j=0; j<n; j++) {
        sum += Math.pow((x[j]-i),2);
      }
      ans = Math.min(sum,ans);
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(n);
  vector<pair<int, int>> b(m);
  for(int i = 0; i < n; i++){
    cin >> a[i].first >> a[i].second;
  }
  for(int i = 0; i < m; i++){
    cin >> b[i].first >> b[i].second;
  }
  for(int i = 0; i < n; i++){
    long long record, ans = 1000000000000000;
    for(int j = 0; j < m; j++){
      long long count = 0;
      count += abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second);
      if(ans > count) {
        record = j + 1; 
        ans = count;
      }
    }
    cout << record << endl;
  }
}

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


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  double a,b;
  cin >> a >> b;

  if(a > b){
      cout << "GREATER" << endl;
    }else if(b > a){
      cout << "LESS" << endl;
    }else{
      cout << "EQUAL" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int szs=s.size(),szt=t.size();
	int ans=100000;
	for(int i=0;i<=szs-szt;i++)
	{
		int cnt=szt;
		for(int c=0;c<szt;c++)
			if(s[i+c]==t[c])
				cnt--;
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
n,k=map(int,input().split())

p=list(map(int,input().split()))
l=[0]*k
ans=0
for i in range(k):
    aa=1+0.5*(p[i]-1)
    ans+=aa
th=ans
for j in range(k,n):
    a=1+0.5*(p[j-k]-1)
    b=1+0.5*(p[j]-1)

    if ans-a+b>th:
        th=ans-a+b
    ans=ans-a+b

print(th)
"""
1=>1
2=>1.5
3=>2
4=>2.5
5=>3
6=>3.5
7=>4
8=>4.5
9=>5
10=>5.5
11=>6

1+0.5*(n-1)

1+0.5*10"""

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

int main() {
    string S;
    cin >> S;
    if(S == "SUN")
        cout << 7 << endl;
    else if(S == "MON")
        cout << 6 << endl;
    else if(S == "TUE")
        cout << 5 << endl;
    else if(S == "WED")
        cout << 4 << endl;
    else if(S == "THU")
        cout << 3 << endl;
    else if(S == "FRI")
        cout << 2 << endl;
    else if(S == "SAT")
        cout << 1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

bool cmp(pii a,pii b){
	return a.S<b.S;
}

int fac(int n){
	int ans=1;
	For(i,2,n) ans=(ans*i)%MOD;
	return ans;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	string s; cin>>s;
	vector<bool> v(n*2);
	v[0]=true;
	int t=1;
	For(i,1,n*2-1){
		if(s[i]!=s[i-1]) v[i]=v[i-1];
		else v[i]=!v[i-1];
		if(v[i]) t++;
	}
	if(s[0]=='W' || s[n*2-1]=='W' || t!=n){
		cout<<"0\n";
		return 0;
	}
	int l=0;
	int ans=1;
	for(auto i:v){
		if(i) l++;
		else{
			ans=(ans*l)%MOD;
			l--;
		}
	}
	cout<<(ans*fac(n))%MOD<<"\n";
	return 0;
}





























Measured memory_bytes: 720
from collections import deque
def LI():return [int(i) for i in input().split()]

ans=0
inf=1<<65
n,m=LI()
X=[0,inf,-inf]
Y=[0,inf,-inf]
V=[]
H=[]
for i in range(n):
    a,b,c=LI()
    V.append(((a,b),c))
    Y.append(c)
    X.append(a)
    X.append(b)
 
n+=2
V.append(((-inf,inf),inf))
V.append(((-inf,inf),-inf))
 
for i in range(m):
    a,b,c=LI()
    H.append((a,(b,c)))
    X.append(a)
    Y.append(b)
    Y.append(c)
 
m+=2
H.append((inf,(-inf,inf)))
H.append((-inf,(-inf,inf)))

X.sort()
xdc={}
c=1
for j in sorted(set(X)):
    xdc[c]=j
    c+=1
nx=c-1
 
Y.sort()
ydc={}
c=1
for j in sorted(set(Y)):
    ydc[c]=j
    c+=1
ny=c-1
 
xdcr=dict(zip(xdc.values(),xdc.keys()))
ydcr=dict(zip(ydc.values(),ydc.keys()))
 
mpy=[[0]*(nx+1+1) for i in range(ny+1+1)]
mpx=[i[:]for i in mpy]

for (a,b),c in V:
    mpx[ydcr[c]][xdcr[a]]+=1
    mpx[ydcr[c]][xdcr[b]]+=-1
for i in range(ny+1):
    for j in range(nx):
        mpx[i][j+1]+=mpx[i][j]
        
for d,(e,f) in H:
    mpy[ydcr[e]][xdcr[d]]+=1
    mpy[ydcr[f]][xdcr[d]]+=-1
for j in range(nx+1):
    for i in range(ny):
        mpy[i+1][j]+=mpy[i][j]

v=[[0]*(nx+1) for i in range(ny+1)]
q=deque([(xdcr[0],ydcr[0])])
v[ydcr[0]][xdcr[0]]=1

while q:
    cx,cy=q.popleft()
    ans+=(xdc[cx]-xdc[cx+1])*(ydc[cy]-ydc[cy+1])
    for dx,dy in [(-1,0),(1,0),(0,1),(0,-1)]:
        nbx=cx+dx
        nby=cy+dy
        if (0>nbx>=nx)or(0>nby>=ny)or v[nby][nbx]==1:
            continue
        if dy!=0:
            if mpx[-~dy//2+cy][cx]==0:
                q.append((nbx,nby))
                v[nby][nbx]=1
        else:
            if mpy[cy][-~dx//2+cx]==0:
                q.append((nbx,nby))
                v[nby][nbx]=1
if ans>=inf:
    ans='INF'
print(ans)


Measured memory_bytes: 363560
// https://atcoder.jp/contests/abc165/tasks/abc165_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
    [[nodiscard]]
#elif defined(__GNUC__) && \
    (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
    __attribute__((warn_unused_result))
#endif
    FixPoint : private F {
 public:
  explicit constexpr FixPoint(F && f) noexcept : F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
      noexcept(noexcept(
          F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) makeFixPoint(F&& f) noexcept {
  return FixPoint<F>{std::forward<F>(f)};
}

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  VVL edge_list(N, VL(0));

  rep(i, N - 1) {
    ll u, v;
    cin >> u >> v;
    --u, --v;
    edge_list[u].push_back(v);
    edge_list[v].push_back(u);
  }

  VL lis(N, INF);
  VL res(N, 0);

  auto dfs = makeFixPoint([&](auto f, ll u, ll p) -> void {
    auto it = lower_bound(all(lis), as[u]);
    ll i = it - lis.begin();
    ll prev = *it;
    lis[i] = as[u];
    res[u] = lower_bound(all(lis), INF) - lis.begin();

    for (auto v : edge_list[u]) {
      if (v == p) continue;
      f(v, u);
    }

    lis[i] = prev;
  });

  dfs(0, -1);

  rep(i, N) { cout << res[i] << "\n"; }
}


Measured memory_bytes: 38820
#include <iostream>
#include <algorithm>
using namespace std;
 struct job
{int c;
 int d;
};
bool cmp(job a,job b)
{return a.d<b.d;
}
int main()
{int n,now=0,ans=1;
job jb[200000];
while(cin>>n)
{for(int i=0;i<n;i++)
{cin>>jb[i].c>>jb[i].d;
}
sort(jb,jb+n,cmp);
for(int j=0;j<n;j++)
{if((now+jb[j].c)<=jb[j].d)
 {now+=jb[j].c;
  ans=1;
 }
 else {ans=0;
 break;
 }
}
if(ans==1)
{cout<<"Yes"<<endl;
}
if(ans==0)
{cout<<"No"<<endl;
}
}
return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using Long = long long;
template<typename W>
using Edge = pair<int, W>;
template<typename W>
using WeightedGraph = vector<vector<Edge<W>>>;
using UnWeightedGraph = vector< vector<int>>;

void bfs(int s,const UnWeightedGraph &g, vector<int> &indeg, vector<int> &used, vector<int> &order) {
    queue<int> q;
    q.push(s);
    used[s] = true;
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        order.push_back(u);
        for(auto &v: g[u]) {
            indeg[v]--;
            if(indeg[v] == 0 && !used[v]) {
                used[v] = true;
                q.push(v);
            }
        }
    }
}

void tpsort(const UnWeightedGraph &g, vector<int> &order){
    vector<int> indeg(g.size(), 0);
    vector<int> used(g.size(), false);
    order.clear();
    for(int u = 0;u < g.size(); u++)
        for(int v: g[u])
            indeg[v]++;
    for(int u = 0;u < g.size(); u++)
        if(indeg[u] == 0 && !used[u])
            bfs(u, g, indeg, used, order);
}

template<typename W>
void tpsort(const WeightedGraph<W> &g, vector<int> &order) {
    UnWeightedGraph g2(g.size());
    for (int i = 0; i < g.size();i++) {
        for(auto &e : g[i]) {
            g2[i].emplace_back(e.first);
        }
    }
    tpsort(g2, order);
}

int main() {
    int V,E;
    cin >> V >> E;
    UnWeightedGraph g(V);
    for(int i = 0;i < E;i++) {
        int s, t;
        cin >> s >> t;
        g[s].emplace_back(t);
    }

    vector<int> order;
    tpsort(g, order);
    for (auto &e : order) {
        cout << e << endl;
    }
}




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

using namespace std;

bool ok(int x) {
    int q=x%10;
    while(x>0) {
        if(q!=x%10)
            return 0;
        x/=10;
    }
    return 1;
}

int main () {
    long long int n;
    cin >> n;
    while(1) {
        if(ok(n)) {
            cout << n;
            break;
        }
        n++;
    }
}


Measured memory_bytes: 256
// ワーシャル フロイド法
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

const int MAX_V = 100;
const int MAX_E = 9900;
const int INF = 0x7FFFFFFF;

int main(void)
{

    int V, E;
    int first, second, weight;
    bool b_negativeLoop = false;

    // 辺の重みを格納する配列
    int edgeWeight[MAX_V + 1][MAX_V + 1];

    for(int i = 0; i < MAX_V; i++)
    {
        for(int j = 0; j < MAX_V; j++)
        {
            if( i == j )
            {
                edgeWeight[i][j] = 0;
            }
            else
            {
                // 初期値として, 無効値を代入
                edgeWeight[i][j] = INF;
            }

        }
    }

    cin >> V >> E;

    for(int i = 0; i < E; i++)
    {
        cin >> first >> second >> weight;

        edgeWeight[first][second] = weight;
    }

    // ワーシャル フロイド法の実施
    for(int k = 0; k < V; k++)          // 経由する頂点
    {
        for(int i = 0; i < V; i++)      // 開始頂点
        {
            for(int j = 0; j < V; j++)  // 終了頂点
            {
                if( edgeWeight[i][k] != INF && edgeWeight[k][j] != INF )
                {
                    // 最短経路の探索
                    edgeWeight[i][j]
                        = min(edgeWeight[i][j], edgeWeight[i][k] + edgeWeight[k][j]);
                }
            }
        }
    }

    // 負の閉路の探索
    for(int p = 0; p < V; p++)
    {
        if( edgeWeight[p][p] < 0 )
        {
            // 負の閉路が存在する
            b_negativeLoop = true;
            printf("NEGATIVE CYCLE\n");
            break;
        }
    }

    if( b_negativeLoop == false )
    {
        // 結果の表示
        for(int i = 0; i < V; i++)
        {
            for(int j = 0; j < V; j++)
            {
                if( j != 0 )
                {
                    printf(" ");
                }

                if( edgeWeight[i][j] >= INF )
                {
                    printf("INF");
                }
                else
                {
                    printf("%d", edgeWeight[i][j]);
                }
            }

            printf("\n");
        }
    }

    return 0;
}



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

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
    
    int a,b;
    cin>>a>>b;

    cout<<ceil(((b-1)*1.0)/(a-1));

    return 0;
}

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

const ll INI = -1;
int n;
vector<vector<P>> tree(101010, vector<P>(0));
vector<ll> dist(101010, INI);

void dfs(int pos)
{
    for(auto x : tree[pos])
    {
        if(dist[x.first] != INI) continue;
        dist[x.first] = dist[pos] + x.second;
        dfs(x.first);
    }
    return;
}

int main()
{
    cin >> n;
    rep(i, n - 1)
    {
        int a, b, c;
        cin >> a >> b >> c;
        tree[a].emplace_back(P(b, c));
        tree[b].emplace_back(P(a, c));
    }

    int q, k;
    cin >> q >> k;
    dist[k] = 0;
    dfs(k);

    rep(i, q)
    {
        int x, y;
        cin >> x >> y;
        cout << dist[x] + dist[y] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 11264
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[1000100];

int main(){
  clr(d,0);
  ll n;
  cin>>n;
  map<ll,ll> ma;
  set<ll> se;
  rep(i,0,n){
    ll a;
    cin>>a;
    se.insert(a);
    ma[a]++;
  }
  vector<ll> v1(all(se));
  ll ans = 0;
  rep(i,0,v1.sz){
    if(ma[v1[i]]>1){}
    else if(d[v1[i]]==0)ans++;
    rep(j,1,1000100){
      if(v1[i]*j>=1000100)break;
      d[v1[i]*j]=1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 34340
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_166
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] array = ReadLongs();
            var dict = new Dictionary<long, int>();
            long res = 0;
            for(int i = n - 1; i >= 0; i--)
            {
                if (dict.ContainsKey(i + array[i]))
                {
                    res += dict[i + array[i]];
                }

                long minus = i - array[i];
                if (dict.ContainsKey(minus))
                {
                    dict[minus]++;
                }
                else
                {
                    dict[minus] = 1;
                }
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 57068
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRVI(N, X) VI X(N); for (int ___I=0; ___I<n; ___I++) scanf("%d", &(X[___I]))  
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    VI t(2019,0);
    t[0]=1;
    int n=SZ(s);
    LL res=0;
    REP(j,n){
        VI nt(2019,0);
        REP(i,2019){
            if (t[i]){
                int inti=s[j]-'0';
                nt[(i*10+inti)%2019]+=t[i];
                //cout<<inti<<" "<<(i*10+inti)%2019<<" "<<nt[(i*10+inti)%2019]<<endl;
            }
        }
        //cout<<"ok"<<j<<" "<<s[j]<<" "<<nt[0]<<endl;
        res+=nt[0];
        nt[0]+=1;
        t=nt;
    }
    cout<<res<<"\n";
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);
    ll a, b;
    cin >> a >> b;
    ll result = -1;
    for(ll i = 0; i < 30000; i++){
        if(floor(i * 0.08) == a && floor(i * 0.1) == b){
            result = i;
            break;
        }
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


const int MAX = 1e6;
int dp[MAX+1], s[3] = {2, 3, 5};
signed main(){
  dp[1] = 1;
  repi(i,2,MAX+1){
    rep(j,3)if(i%s[j] == 0){
      chmax(dp[i], dp[i/s[j]]);
    }
  }
  rrep(i,MAX)dp[i] += dp[i-1];
  while(1){
    int l, r;
    scanf("%lld", &l);
    if(l == 0)break;
    scanf("%lld", &r);
    printf("%lld\n", dp[r]-dp[l-1]);
  }
	return 0;
}











Measured memory_bytes: 11040
#include <bits/stdc++.h>
using namespace std;
long long n, p, ans = 1;
vector<pair<long long, int> > v;
long long power(long long a, long long b) {
	if (b == 0)
		return 1;
	long long rtr = power(a, b / 2);
	rtr *= rtr;
	if (b % 2)
		rtr *= a;
	return rtr;
}
int main() {
	cin >> n >> p;
	for (long long i = 2; i * i <= p; i++) {
		if (!(p % i)) {
			v.push_back({i, 0});
			while (!(p % i)) 
				p /= i, v.back().second++;
		}
	}
	if (p != 1)
		v.push_back({p, 1});
	for (int i = 0; i < v.size(); i++)
		ans *= power(v[i].first, 1ll * v[i].second / n);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
vector<long long int>xs;
vector<int>islefts;
vector<long long int>anss;
vector<int>oks;

long long int N, T, Q;
long long int getans(const int q) {
	if (oks[q])return anss[q];
	else {
		oks[q] = true;
		if (islefts[q]) {
			if (q == 0) {
				return anss[q] = xs[q] - T;
			}
			else {
				long long int leftx = getans(q - 1);
				return anss[q] = max(leftx, xs[q] - T);
			}
		}
		else {
			if (q == N - 1) {
				return anss[q] = xs[q] + T;
			}
			else {
				long long int rightx = getans(q + 1);
				return anss[q] = min(rightx, xs[q] + T);
			}
		}
	}
}

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

	anss.resize(N);
	for (int i = 0; i < N; ++i) {
		long long int a,isleft; cin >> a >> isleft;
		isleft--;
		xs.push_back(a); islefts.push_back(isleft);
		oks.push_back(false);
	}
	for (int i = 0; i < N-1; ++i) {
		if (!islefts[i] && islefts[i + 1]) {
			long long int dis = xs[i + 1] - xs[i];
			oks[i] = true; oks[i + 1] = true;
			if (dis < 2 * T) {
				anss[i] = xs[i] + dis / 2;
				anss[i + 1] = xs[i + 1] - dis / 2;
			}
			else {
				anss[i] = xs[i] + T;
				anss[i + 1] = xs[i + 1] - T;
			}
		}
	}
	while (Q--) {
		int q; cin >> q; q--;
		long long int ans = getans(q);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6212
#include <iostream>
#include<string>

 
using namespace std;
 
int main(void) {
    int N,Q;
    cin>>N>>Q;
    string S;
    cin>>S;
    
    int A[N+1];
    
   
    int l,r;
    
    for(int i=0;i<=N;i++){
        A[i]=0;
       
    }
    
    for(int i=0;i<N-1;i++){
        A[i+1]=A[i];
        if(S[i]=='A' && S[i+1]=='C'){
            A[i+1]=A[i]+1;
        }
    }
    for(int j=0;j<Q;j++){
        cin>>l>>r;
        int ans;
        ans=A[r-1]-A[l-1];
        cout<<ans<<endl;
                
               
    }          
        
    
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	int ans = 0;
	REP(i, N) {
		cin >> A[i];
	}
	FOR(i, 1, N - 1) {
		if (A[i - 1] < A[i] && A[i] < A[i + 1])ans++;
		else if (A[i - 1] > A[i] && A[i] > A[i + 1])ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input().strip())
s = '_' + input().strip()
s += ''.join(['_'] * 10 ** 5)
r = []
g = []
b = []
for i in range(1, n + 1):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    elif s[i] == 'B':
        b.append(i)

le = len(b)
ans = len(r) * len(g) * le
for x in r:
    for y in g:
        if (x + y) % 2 == 0 and s[(x + y) // 2] == 'B':
            ans -= 1
        if (1 <= (2 * x - y) and s[2 * x - y] == 'B'):
            ans -= 1
        if (1 <= (2 * y - x) and s[2 * y - x] == 'B'):
            ans -= 1
print(ans)


Measured memory_bytes: 68840
#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
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100100;
ll gcd(ll a,ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
	ll x;
	cin >> x;
	ll num = x % 11;
	if (num == 0)cout << x / 11 * 2 << endl;
	else if (num <= 6) cout << x / 11 * 2 + 1 << endl;
	else cout << x / 11 * 2 + 2 << endl;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
# x, y, z = map(int, input().split())
arr = list(map(int, input().split()))
# sm = sum(arr)
# m = max(arr)
# s = input()
b = 1000
p = -1
if n == 0:
	print(x)
else:
	for i in range(-101,102):
		if abs(x-i) < b and i not in arr:
			p = i
			b = abs(x-i)
	print(p)


Measured memory_bytes: 9184
#include<iostream>

using namespace std;

int main()
{
	int N,M,L[100000],R[100000],i,preL = -1,preR = 100001,ans;
	cin >> N >> M;
	for (i = 0; i < M; i++)cin >> L[i] >> R[i];
	for (i = 0; i < M; i++)
	{
		if (preL < L[i])preL = L[i];
		if (R[i] < preR)preR = R[i];
	}
	if (preL > preR)ans = 0;
	else ans = preR - preL + 1;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const ll INF=1000000000000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	static ll n,m;
	static ll a[300010],b[300010],c[300010];
	
	cin >> n ;
	rep(i,n){
		cin >> a[i];
	}
	cin >> m;
	rep(i,m){
		cin >> b[i];
	}
	rep(i,m){
		cin >> c[i];
	}
	
	vector<ll> vec;
	rep(i,n){
		vec.pb(a[i]);
	}
	sor(vec);
	
	vector<ll> sco;
	ll sum = 0;
	rep(i,n){
		sum += vec[i];
		sco.pb(sum);
	}
	
	rep(i,m){
		ll score;
		if(vec[0] <= b[i])score = sco[--ub(vec,b[i])-vec.begin()];
		else score = 0;
		if(score >= c[i])puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 19204
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int[] cards;
    int score;
    String s;
    int one;

    void run(){
	while(sc.hasNext()){
	    score = 0;
	    one = 0;
	    s = sc.nextLine();
	    if(s.equals("0")) break;
	    String[] ss = s.split(" ");
	    cards = new int[ss.length];
	    for(int i=0; i<cards.length; i++)
		cards[i] = Integer.parseInt(ss[i]);

	    Arrays.sort(cards);
	    //System.out.println(cards[0]);
	    

	    for(int k=0; k<cards.length; k++)
		if(cards[k]==1){
		    score += 11;
		    one++;
		}
		else if(cards[k]>=10) score += 10;
		else score += cards[k];	    

	    while(one>0 && score>21){
		score -= 10;
		one--;
	    }
	    
	    System.out.println(score<=21 ? score:0);
	}
    }
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int cnt = 0, sum = 1;
    while(sum < b){
        sum--;
        sum += a;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
  s.append(input())
  
print('AC x {}'.format(s.count('AC')))
print('WA x {}'.format(s.count('WA')))
print('TLE x {}'.format(s.count('TLE')))
print('RE x {}'.format(s.count('RE')))

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	bool a[n][n];
	for (int i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;
		for (int j = 0; j < n; j++) a[i][j] = s[j] == '#';
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cnt += a[i][j];
	if (!cnt) {
		std::cout << -1 << std::endl;
		return 0;
	} else if (cnt == n * n) {
		std::cout << 0 << std::endl;
		return 0;
	} else {
		// pre
		bool can[n];
		for (int i = 0; i < n; i++) {
			can[i] = false;
			for (int j = 0; j < n; j++) if (a[j][i]) can[i] = true;
		}
		int base = n;
		for (int i = 0; i < n; i++) {
			int cnt = 0;
			for (int j = 0; j < n; j++) if (a[j][i]) cnt++;
			if (cnt == n) base--;
		}
		
		// soro
		int res = 1000000000;
		for (int i = 0; i < n; i++) {
			int cost = 0;
			if (!can[i]) {
				cost++;
				if (a[i][i]) cost++;
			}
			for (int j = 0; j < n; j++) {
				if (!a[i][j]) cost++;
			}
			cost += base;
			res = std::min(res, cost);
		}
		assert(res != 1000000000);
		std::cout << res << std::endl;
		return 0;
	}
	
	
	return 0;
}


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

int main()
{
    int a, b, Count = 1;
    cin>>a>>b;
    int x = a;
    if(b == 1)
        cout<<"0";
    else if(b <= a)
        cout<<"1";
    else
    {
        while(a < b)
        {
            a = (a + x) - 1;
            Count++;
        }
        cout<<Count;
    }
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

a = [input() for _ in range(H)]

row = [False] * H
col = [False] * W

for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j], end='')
        print()

Measured memory_bytes: 4468
#include<bits/stdc++.h>
#define M1 1000000007
#define M2 998244353
#define ll long long int
#define N (int)1e5+3
#define test(t) while(t--)
#define PI acos(-1.0)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,b,a) for(ll i=b-1;i>=a;i--)
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define V(a) vector<a>
#define M(a,b) map<a,b>
#define endl '\n'
#define all(x) begin(x),end(x)
#define allr(x) rbegin(x),rend(x)
#define pr(a) cout<<a<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = { 0, -1, 0, 1 };
const int dy[4] = { -1, 0, 1, 0 };
using namespace std;

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    map<ll,bool> m;
    rep(i,0,n) cin >> a[i];
    rep(i,0,n){
        if (m[a[i]]){
            cout  << "NO" << endl;
            return;
        }
        m[a[i]] = 1;
    }
    cout << "YES" << endl;
    return;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int dp[100009];
int fun(int a[],int n,int k){
	dp[0]=0;
  for(int i=1;i<=n;i++){
  	if(i<=k){
     	dp[i]=abs(a[i]-a[0]);
    }
    else{
    	int m;
      int mini=INT_MAX;
      for(int j=1;j<=k;j++){
      	m=dp[i-j]+abs(a[i]-a[i-j]);
      	if(m<mini)
      	mini=m;
      }
      dp[i]=mini;
    }
  }
  return dp[n];
}
int main(){
	int n,k;
    cin>>n>>k;
  	int a[n];
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  cout<<fun(a,n-1,k)<<endl;
}

Measured memory_bytes: 1024
/* B */

#include <iostream>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int* like = new int[m];

    for(int i = 0; i < m; i++){
        like[i] = 0;
    }
    
    for(int t = 0; t < n; t++){
        int k;
        int tmp;
        cin >> k;

        for(int j = 0; j < k; j++){
            cin >> tmp;
            like[tmp - 1]++;
        }    
    }
    
    int cnt = 0;

    for (int i = 0; i < m; ++i)
    {
        if(like[i]==n){
            cnt++;
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
<?php
  
$x = trim(fgets(STDIN));
$get9 = function($x) {
	if ($x <= 599) return 8;
	if ($x <= 799) return 7;
	if ($x <= 999) return 6;
	if ($x <= 1199) return 5;
	if ($x <= 1399) return 4;
	if ($x <= 1599) return 3;
	if ($x <= 1799) return 2;
	if ($x <= 1999) return 1;
};
 
echo $get9($x);

Measured memory_bytes: 16200
# B - Good Distance

import numpy as np
from itertools import combinations

N, D = map(int, input().split())
X = np.array([list(map(int, input().split())) for i in range(N)])
cnt = 0
for p1, p2 in combinations(X, 2):
    d = sum((p1-p2)**2)**.5
    if d.is_integer():
        cnt+= 1
print(cnt)

Measured memory_bytes: 12520
#include <iostream>
using namespace std;
int main()
{
	int a,b,c;
	char op; 
	while(cin>>a>>op>>b)
	{
		if(op=='?')
			break;
		else if (op=='+')
		{
			c=a+b;
			cout<<c<<endl;
		}
		else if(op=='-')
		{
			c=a-b;
			cout<<c<<endl;
		}
		else if(op=='*')
		{
			c=a*b;
			cout<<c<<endl;
		}
		else
		{
			c=a/b;
			cout<<c<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define rep2(i,a,b) for(lint i=a;i<(lint)(b);i++)
#define PICK(N,m,p) (N/(int)(pow(p,m-1))-(N/(int)(pow(p,m)))*p)
using lint = long long;
using ld = long double;
using namespace std;

int main(){
    lint N, a[100];
    cin >> N;
    rep(i,N) cin >> a[i];
    int c=0;
    rep(i,N) if(((i+1)*a[i])%2==1) c++;
    cout << c << endl;
	return 0;
}

Measured memory_bytes: 3556
<?php
$kisuj = array('R', 'U', 'D');
$gusuj = array('L', 'U', 'D');

$arrays = str_split(trim(fgets(STDIN)));

$count = 0;
foreach ($arrays as $array) {
  $count++;
  if ($count % 2 == 0) {
    if (!in_array($array, $gusuj)) {
      echo 'No';
      exit;
    }
  } else {
    if (!in_array($array, $kisuj)) {
      echo 'No';
      exit;
    }
  }
}

echo 'Yes';

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  stack <char> s;
  string str;
  cin >> str;
  rep(i, str.size()) {
    if (str.at(i) == 'B') {
      if (!s.empty()) s.pop();
    } else {
      s.push(str.at(i));
    }
  }
  vector <char> v;
  while (!s.empty()) {
    v.push_back(s.top()); s.pop();
  }
  reverse(v.begin(), v.end());
  rep(i, v.size()) cout << v.at(i);
  cout << endl;
}

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

int main(int argc, char const *argv[])
{
	int A, B;
	int ans =1;
	cin>>A>>B;
	int a=A;
   if(B==1)
     cout<<0;
  else{
	while(A < B){
		A+= (a-1);
		ans++;
	}
	cout<<ans;
    }
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
	if a==0:
		return b
	else:
		return gcd(b%a, a)

X = int(input())
LCM = X*360/gcd(360, X)
print(int(LCM/X))


#a, b = map(int, input().split())
#print(gcd(a, b))



Measured memory_bytes: 9156
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<int, int> P;
#define fs first
#define sc second

int main(){
    int N, M;
    cin >> N >> M;
    int a[N][M];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++) cin >> a[i][j];
    }

    bool use[M + 1];
    fill(use, use + M + 1, true);

    int ans = 100000;
    for(int k = 0; k < M; k++){
        vector<int> b[N];
        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                if(use[a[i][j]]) b[i].push_back(a[i][j]);
            }
        }

        map<int, int> mp;
        for(int i = 0; i < N; i++){
            mp[b[i][0]]++;
        }

        int mx_num = -1, mx = 0;
        for(auto it = mp.begin(); it != mp.end(); it++){
            if(mx < it -> sc){
                mx = it -> sc;
                mx_num = it -> fs;
            }
        }

        /*for(int i = 0; i < N; i++){
            for(int j = 0; j < b[i].size(); j++){
                cout << b[i][j] << " ";
            }
            cout << endl;
        }*/

        //printf("mx = %d, mx_num = %d\n\n", mx, mx_num);

        ans = min(ans, mx);
        use[mx_num] = false;
    }

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


Measured memory_bytes: 1272
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,k;
    cin >> n >> k;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ok = INF, ng = 0;
    while(ok - ng > 1){
        int mid = (ok + ng)/2;
        int cnt = 0;
        rep(i,n)cnt += (a[i]-1)/mid;
        if(cnt <= k)ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


Measured memory_bytes: 4836
use std::io::Read;

fn main() {
    let (p, q, r) = {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let p: usize = iter.next().unwrap().parse().unwrap();
        let q: usize = iter.next().unwrap().parse().unwrap();
        let r: usize = iter.next().unwrap().parse().unwrap();
        (p, q, r)
    };
    let mut v = vec![p, q, r];
    v.sort();
    print!("{}", v[0] + v[1]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n,m;
    cin>>n>>m;
    if(n==1&&m==1){
        cout<<1<<endl;
    }
    else if(n==1){
        cout<<m-2<<endl;
    }
    else if(m==1){
        cout<<n-2<<endl;
    }
    else{
        cout<<(n-2)*(m-2)<<endl;
    }
}


Measured memory_bytes: 256