akhauriyash/Code-Regression huggingface dataset:
// 未解決

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

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

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

  int n;
  cin >> n;
  int ans = 0;
  REPS(i, n) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
};


Measured memory_bytes: 3652
N=int(input())
L=[1]
for i in range(1,100):
    a=6**i
    if a<=100000:
        L.append(a)
    else:
        break
for i in range(1,100):
    a=9**i
    if a<=100000:
        L.append(a)
    else:
        break
dp=[1000000]*(N+1)
dp[0]=0
for i in range(1,N+1):
    sub=10**5
    for l in L:
        if i-l>=0:
            sub=min(sub, dp[i-l]+1)
    dp[i]=sub

print(dp[N])

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

int main(){
	int n,m,x,k=0,l=0;
  	cin >> n >> m >> x;
  	int a[m];
  	for (int i=0;i<m;i++){
    	cin >> a[i]; 	
    }
  	int o=x;
  	for (;x<n;x++){
      	for (int i=0;i<m;i++){
    		if (x==a[i]) k++;
        }
    }
  	for (;o>0;o--){
      	for (int i=0;i<m;i++){
    		if (o==a[i]) l++;
        }
    }
  	if (k>=l) cout << l << endl;
  	else cout << k << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    int n;
    int s;
    int t;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        out.println((a + b - 1) / b);
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer      tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define rep(i,n) for(int i=0;i<n;i++)

int N;
double x[300],y[300];

int main(){
	while(cin>>N&&N){
		int ans=1;
		rep(i,N)cin>>x[i]>>y[i];
		rep(i,N)for(int j=i+1;j<N;j++){
			double x1=x[i],y1=y[i],x2=x[j],y2=y[j];
			if((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)<4){
				double xm=(x1+x2)/2,ym=(y1+y2)/2,dx=x2-x1,dy=y2-y1,n=sqrt(dx*dx+dy*dy),d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)),dd=sqrt(1-d*d/4);
				double cx=xm-dy/n*dd,cy=ym+dx/n*dd;
				int res=0;
				rep(k,N)if((x[k]-cx)*(x[k]-cx)+(y[k]-cy)*(y[k]-cy)<=1+EPS)res++;
				ans=max(ans,res);
				cx=xm+dy/n*dd;cy=ym-dx/n*dd;
				res=0;
				rep(k,N)if((x[k]-cx)*(x[k]-cx)+(y[k]-cy)*(y[k]-cy)<=1+EPS)res++;
				ans=max(ans,res);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 964
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	int i=0,N=0;	
	scanf("%d", &N);

	long long A[N],ans=1,x=(pow(10,18.0));

	if(2<=N && N<=(pow(10,5.0))){
		for(i=0; i<N; i++){
			scanf("%lld",&A[i]);
		}
		for(i=0; i<N; i++){
			if(A[i]==0){
				printf("0");
				return 0;
			}			
		}	
	}else{
		return 0;
	}

	for(i=0; i<N; i++){
		if(A[i]<=x/ans){
			//printf("hoge\n");
			//printf("%lld\n", ans);
			ans=ans*A[i];
			//printf("%lld\n", ans);
		}else{
			printf("-1\n");
			return 0;
		}
	}

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

	return 0;
}


Measured memory_bytes: 2928
N,K,Q = map(int, input().split())
A = []
for i in range(Q):
    A.append(int(input()))
B = [0 for _ in range(N)]
for j in range(Q):
    B[A[j]-1] += 1
for k in range(N):
    if Q-B[k] >= K:
        print('No')
    elif Q-B[k] < K:
        print('Yes')

Measured memory_bytes: 8672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i;mp)

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;


  double ans;
  double x1,x2,y1,y2;
  double m_rad = -2.0*M_PI/60.0*m + M_PI/2.0;
  double h_rad = -2.0*M_PI/(60.0*12.0)*(h*60.0+m) + M_PI/2.0;
  x1 = b*cos(m_rad);
  y1 = b*sin(m_rad);
  x2 = a*cos(h_rad);
  y2 = a*sin(h_rad);
  ans = sqrt(pow(a, 2) + pow(b, 2) -2.0 * a * b * cos(fabs(h_rad - m_rad)));
  printf("%.20f", ans);
  // cout << fabs(h_rad - m_rad) << '\n';
  // cout << cos(fabs(h_rad - m_rad)) << '\n';
  // cout << ans << '\n';
  // x1 = fabs(b*cos(m_rad));
  // y1 = fabs(b*sin(m_rad));
  // x2 = fabs(a*cos(h_rad));
  // y2 = fabs(a*sin(h_rad));

  // if (m_rad < 0) m_rad += 2.0*M_PI;
  // if (h_rad < 0) h_rad += 2.0*M_PI;
  // cout << m_rad << " "<< h_rad<<endl;
  // if (m_rad <M_PI/2.0) {
  //
  // }
  // else if (m_rad <M_PI) {
  //   x1 *= -1.0;
  // }
  // else if (m_rad <3.0*M_PI/2.0) {
  //   x1 *= -1.0;
  //   y1 *= -1.0;
  //
  // }
  // else if (m_rad <2.0*M_PI) {
  //   y1 *= -1.0;
  // }
  //
  // if (h_rad <M_PI/2.0) {
  //
  // }
  // else if (h_rad <M_PI) {
  //   x2 *= -1.0;
  // }
  // else if (h_rad <3.0*M_PI/2.0) {
  //   x2 *= -1.0;
  //   y2 *= -1.0;
  // }
  // else if (h_rad <2.0*M_PI) {
  //   y2 *= -1.0;
  // }

  // cout << x1 << " "<< y1<< " " <<x2 << " "<<y2 << " "<<endl;
  // ans = sqrt(pow((x2-x1), 2) + pow((y2-y1), 2));
  // cout << ans << endl;
  // printf("%.12f", ans);
  return 0;
}


Measured memory_bytes: 4020
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(x) cout << (x) << "\n";
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n";
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i];
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cins(int, n, as);
    int ans = 0;
    For(i, n){
        while(as[i] % 2 == 0){
            ans ++;
            as[i] /= 2;
        }
    }
    Cout(ans);
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = list(num-1 for num in map(int, input().split()))
loc = 0

arrived = [0]*N
ar = set()
cnt = 0
while not loc in ar:
    arrived[cnt] = loc
    ar.add(loc)
    loc = S[loc]
    cnt += 1

if K < cnt:
    print(arrived[K]+1)
else:
    for i in range(cnt):
        if arrived[i] == loc:
            K -= i
            roop = cnt-i
            K %= roop
            print(arrived[i+K]+1)
            break



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int h, w; std::cin >> h >> w;
  int n; std::cin >> n;
  vi a(n); rep(i, n) std::cin >> a[i];
  vvi grid(h, vi(w));
  bool right = true;
  int cursor = 0;
  rep(i, h) {
    if (right) {
      rep(j, w) {
        if (a[cursor] == 0) cursor++;
        grid[i][j] = cursor+1;
        a[cursor]--;
      }
    } else {
      drep(j, w) {
        if (a[cursor] == 0) cursor++;
        grid[i][j] = cursor+1;
        a[cursor]--;
      }
    }
    right ^= 1;
  }
  rep(i, h) rep(j, w) std::cout << grid[i][j] << (j+1 < w ? " " : "\n");
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int A;
    int B;
    int C;
    cin >> A >> B >> C;
    if (A == 5 && B == 5 && C == 7)
    {
        cout << "YES";

    }
    else if (A == 5 && B == 7 && C == 5)
    {
        cout << "YES";

    }
    else if (A == 7 && B == 5 && C == 5)
    {
        cout << "YES";
    }
    else {
        cout << "NO";
    }

}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll r, D, x;
  cin >> r >> D >> x;
  rep(i, 10){
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	vector<ll> p3(1, 1);
	REP(i, 30) p3.emplace_back(p3.back() * 3);
	
	auto dist = [](ll y1, ll x1, ll y2, ll x2) -> ll {
		return abs(y1 - y2) + abs(x1 - x2);
	};
	
	auto flip = [](ll &a, ll &b, ll &c, ll &d) -> void {
		swap(a, b);
		swap(c, d);
	};
	
	auto dfs1 = [&](auto &&dfs1, auto &&dfs2, int level, ll y1, ll x1, ll y2, ll x2, ll sum) -> ll {
		if (level == 0) return sum;
		
		ll by1 = y1 / p3[level - 1], bx1 = x1 / p3[level - 1], by2 = y2 / p3[level - 1], bx2 = x2 / p3[level - 1];
		if (by1 != by2 && bx1 != bx2) return sum + dist(y1, x1, y2, x2);
		if (bx1 == bx2) { flip(y1, x1, y2, x2); flip(by1, bx1, by2, bx2); }
		// by1 = by2
		if (x1 > x2) { flip(x1, x2, y1, y2); flip(bx1, bx2, by1, by2); }
		// x1 <= x2
		
		if (by1 == 1 && bx1 != bx2) {
			return sum + abs(x1 - x2)
			+ min(abs(p3[level - 1] - 1 - y1) + abs(p3[level - 1] - 1 - y2)
				, abs(p3[level - 1] * 2 - y1) + abs(p3[level - 1] * 2 - y2));
		}
		
		y1 %= p3[level - 1]; by1 = 0;
		y2 %= p3[level - 1]; by2 = 0;
		
		while (bx1 > 0 && bx2 > 0) {
			x1 -= p3[level - 1];
			x2 -= p3[level - 1];
			--bx1; --bx2;
		}
		
		if (bx1 == bx2) return dfs1(dfs1, dfs2, level - 1, y1, x1, y2, x2, sum);
		if (bx1 == 0 && bx2 == 2) {
			return dfs1(dfs1, dfs2, level - 1, y1, 0, y2, p3[level - 1] - 1, sum + (p3[level - 1] - x1) + (x2 - p3[level - 1] * 2 + 1));
		}
		
		// bx1 = 0 and bx2 = 1
		return dfs2(dfs1, dfs2, level - 1, y1, x1, y2, x2, sum);
	};
	
	// 横
	auto dfs2 = [&](auto &&dfs1, auto &&dfs2, int level, ll y1, ll x1, ll y2, ll x2, ll sum) -> ll {
		if (level == 0) return 1 + sum;
		
		ll by1 = y1 / p3[level - 1], bx1 = x1 / p3[level - 1], by2 = y2 / p3[level - 1], bx2 = x2 / p3[level - 1];
		if (by1 != by2) return sum + dist(y1, x1, y2, x2);
		
		if (by1 == 1) {
			if (bx1 == 0) return dfs1(dfs1, dfs2, level, y1, x1, y2, p3[level] - 1, sum + x2 - p3[level] + 1);
			if (bx2 == 5) return dfs1(dfs1, dfs2, level, y1, 0, y2, x2 % p3[level], sum + p3[level] - x1);
		}
		
		y1 %= p3[level - 1]; by1 = 0;
		y2 %= p3[level - 1]; by2 = 0;
		
		if (bx1 < 2) {
			sum += 2 * p3[level - 1] - x1;
			x1 = 0;
		}
		else x1 %= p3[level - 1];
		if (bx2 > 3) {
			sum += x2 - p3[level - 1] * 4 + 1;
			x2 = p3[level - 1] * 2 - 1;
		}
		else x2 = x2 % p3[level - 1] + p3[level - 1];
		
		return dfs2(dfs1, dfs2, level - 1, y1, x1, y2, x2, sum);
	};
	
	int Q;
	cin >> Q;
	while (Q--) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		cout << dfs1(dfs1, dfs2, 30, a - 1, b - 1, c - 1, d - 1, 0) << '\n';
	}
	
	return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  int count = 0;
  for(int i = 0; i < n; i++){
    if(data.at(i) >= k){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
class UnionSet:
    def __init__(self, nmax):
        self.size = [1]*nmax
        self.id = [i for i in range(nmax+1)]
    def root(self, i):
        while i != self.id[i]:
            self.id[i] = self.id[self.id[i]]
            i = self.id[i]
        return i
    def connected(self, p, q): return self.root(p) == self.root(q)
    def unite(self, p, q):
        i, j = self.root(p), self.root(q)
        if i == j: return
        if self.size[i] < self.size[j]:
            self.id[i] = j
            self.size[j] += self.size[i]
        else:
            self.id[j] = i
            self.size[i] += self.size[j]
# UNION-FIND library
 
def id(r, c):
    global w
    return r*w+c
 
mv = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
 
while True:
    w, h = map(int, input().split())
    if w == 0: break
    arr = [[] for r in range(h)]
    u = UnionSet(w*h)
    for r in range(h): arr[r] = list(map(int, input().split()))
    for r in range(h):
        for c in range(w):
            if not arr[r][c]: continue
            for i in range(8):
                r2, c2 = r + mv[i][0], c + mv[i][1]
                if r2 < 0 or r2 >= h or c2 < 0 or c2 >= w or not arr[r2][c2]: continue
                u.unite(id(r, c), id(r2, c2))
    ans = 0
    for r in range(h):
        for c in range(w):
            if arr[r][c] and u.root(id(r, c)) == id(r, c): ans += 1
    print(ans)


Measured memory_bytes: 5884
# coding: utf-8
# Your code here!


N = int(input())

dp = [[0]*3 for _ in range(N+1)]

for i in range(1, N+1):
    a, b, c = map(int, input().split())
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c
    
print(max(dp[N]))

Measured memory_bytes: 22772
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
using namespace std;

int fact(int n) {
	int ret = 1;
	for (int i = 0; i < n; i++) {
		ret *= (i + 1);
	}
	return ret;
}
int main() {
	int N;
	int P[8], Q[8];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> Q[i];
	}

	/*
	P1が1,2,...,Nのうち下から何番目かを調べる。それをcとして、(c-1) * (N-1)!を足す。
	次に、P2が、{1,2,..,N} \setminus P1のうち何番目かを調べる。それをcとして、(c-1) * (N-2)!を足す。
	云々
	*/

	int used[8];

	for (int i = 0; i < N; i++) {
		used[i] = 0;
	}
	int ord_p = 0;
	int ord_q = 0;
	for (int i = 0; i < N;i++) {
		int c = 0;
		/*used[0], ..., used[P[i]-2]のうちいくつが0か？*/
		for (int j = 0; j < P[i] - 1; j++) {
			if (used[j] == 0) {
				c += 1;
			}
		}
		ord_p += c * fact(N - i - 1);
		used[P[i] - 1] ++;
	}

	for (int i = 0; i < N; i++) {
		used[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		int c = 0;
		/*used[0], ..., used[P[i]-2]のうちいくつが0か？*/
		for (int j = 0; j < Q[i] - 1; j++) {
			if (used[j] == 0) {
				c += 1;
			}
		}
		ord_q += c * fact(N - i - 1);
		used[Q[i] - 1] ++;
	}

	int ans = ord_p - ord_q;

	if (ans > 0) {
		cout << ans;
	}
	else {
		cout << -ans;
	}
}

Measured memory_bytes: 256
package main
import "fmt"
func main(){
	var N, M int
	fmt.Scan(&N, &M)
	Balls := make([]int, N)
	for i:=0; i<N; i++{
		Balls[i]=1
	}
	Boxes := make([]bool, N)
	Boxes[0] = true
	for i:=0; i<M; i++{
		var x, y int
		fmt.Scan(&x, &y)
		x--
		y--
		if Balls[x]>1{
			if Boxes[x]{
				Boxes[y] = true
			}
			Balls[x]--
			Balls[y]++
		}else if Balls[x]==1{
			if Boxes[x]{
				Boxes[x] = false
				Boxes[y] = true
			}
			Balls[x]--
			Balls[y]++
		}else{
			panic("ふえぇ〜〜0未満になるなんて制約に書いてないよぉ〜〜><")
		}
	}

	ans := 0
	for _, b := range Boxes{
		if b{
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 6340
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

using namespace std;

const int inf = 1 << 30;

struct edge {
	int src;
	int dst;
	int cost;
};

bool operator<(const edge& a, const edge& b)
{
	return tie(b.cost, a.src, a.dst) < tie(a.cost, b.src, b.dst);
}

int main()
{
	int H, N;
	cin >> H >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}

	vector<int> best(H + 1, inf);
	vector<bool> visited(H + 1, false);

	priority_queue<edge> q;
	edge e0 = { -1, H, 0 };
	q.push(e0);
	while (!q.empty()) {
		edge e = q.top();
		q.pop();

		if (visited[e.dst]) {
			continue;
		}
		visited[e.dst] = true;

		for (int i = 0; i < N; ++i) {
			int h2 = max(0, e.dst - A[i]);
			int m2 = e.cost + B[i];
			if (m2 < best[h2]) {
				best[h2] = m2;
				edge f = { e.dst, h2, m2 };
				q.push(f);
			}
		}
	}
	cout << best[0] << endl;
}


Measured memory_bytes: 7152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    ll maxv=0;
    for(ll x=0;x<n;x++){
        cin>>w[x]>>v[x];
        maxv=max(maxv,v[x]);
    }
    ll sz=n*maxv;
    ll dp[2][sz+1];
    for(ll x=0;x<=sz;x++){
        dp[0][x]=W+1;
    }
    dp[0][v[0]]=w[0];
    for(ll x=0;x<2;x++){
        dp[x][0]=0;
    }
    ll ans=v[0];
    for(ll x=1;x<n;x++){
        for(ll y=1;y<=sz;y++){
            dp[x%2][y]=dp[(x-1)%2][y];
            if(v[x]<=y){
                dp[x%2][y]=min(dp[x%2][y],w[x]+dp[(x-1)%2][y-v[x]]);
            }
            if(dp[x%2][y]>W)dp[x%2][y]=W+1;
            else ans=max(ans,y);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i, s, n) for (int i = s; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, 0, h) {
        rep(j, 0, w) { cin >> s[i][j]; }
    }
    bool f = false;
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (s[i][j] == '.') continue;
            f = false;
            if (i != 0 && s[i - 1][j] == '#') f = true;
            if (i != h - 1 && s[i + 1][j] == '#') f = true;
            if (j != 0 && s[i][j - 1] == '#') f = true;
            if (j != w - 1 && s[i][j + 1] == '#') f = true;
            if (!f) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import numpy as np
h,w = map(int,input().split())
A = np.array([list(map(int,input().split())) for _ in range(h)],dtype = "int")
ans=[]
for p in range(h):
    for q in range(w-1):
            if(A[p][q]%2==1):
                A[p][q+1] +=1
                A[p][q] -=1
                ans.append([p+1,q+1,p+1,q+2])
                
for p in range(h-1):
    if(A[p][w-1]%2==1):
        A[p+1][w-1] += 1
        A[p][w-1] -= 1
        ans.append([p+1,w,p+2,w])
print(len(ans))
for a in ans:
    print(a[0],a[1],a[2],a[3])

Measured memory_bytes: 39528
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

string s;
int p;

int term();
int num();

int expression() {
	int ret = term();
	while (s[p] == '+') {
		p++;
		ret += term();
	}
	return ret;
}

int term() {
	int ret = num();
	while (s[p] == '*') {
		p++;
		ret *= num();
	}
	return ret;
}

int num() {
	int ret = 0;
	while (isdigit(s[p])) {
		ret *= 10;
		ret += (s[p] - '0');
		p++;
	}
	return ret;
}

int expression2() {
	int ret = num();
	while (true) {
		if (s[p] == '+') {
			p++;
			ret += num();
		}
		else if (s[p] == '*') {
			p++;
			ret *= num();
		}
		else {
			break;
		}
	}
	return ret;
}

int main() {
	int n;
	cin >> s >> n;
	p = 0;
	int ans1 = expression();
	p = 0;
	int ans2 = expression2();

	if (n == ans1) {
		if (n == ans2) {
			cout << 'U' << endl;
		}
		else {
			cout << 'M' << endl;
		}
	}
	else if (n == ans2) {
		cout << 'L' << endl;
	}
	else {
		cout << 'I' << endl;
	}
	
	return 0;
}

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

bool is_number(char num) { return 0 <= num - '0' && num - '0' <= 9; }

int main() {
  int A, B;
  scanf("%d%d", &A, &B);
  string S;
  cin >> S;

  bool is_valid = true;
  for (int i = 0; i < A + B + 1; i++) {
    if (i == A) {
      if (S.at(i) != '-') is_valid = false;
    } else {
      if (!is_number(S.at(i))) is_valid = false;
    }
  }

  if (is_valid)
    printf("Yes");
  else
    printf("No");
  return 0;
}


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

#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

bitset<100010> DP;

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	vector<int> v;
	for (int i = 0; i < 6; i++) v.push_back(100 + i);
	int x; cin >> x;
	DP[0] = true;
	for (int i = 1; i < N; i++) for (int j : v) if (i >= j) DP[i] = DP[i] |  DP[i - j];
	cout << DP[x] << endl;

	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  C - Maximum Volume
//
//  Created by Hashizo on 2020/03/22.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {
	double ans = 0.0;

	double l;
	cin >> l;

	ans = powl((double)(l/3.0), (double)3.0);
	printf("%.6lf\n",ans);
	return 0;
}


Measured memory_bytes: 512
N = int(input())
D = {}
for _ in range(N):
    s = input()
    if s not in D: D[s]=0
    D[s] += 1

M = int(input())
for _ in range(M):
    t = input()
    if t not in D: D[t]=0
    D[t] -= 1

print(max(0, max(D.values())))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef int64_t lint;
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

int main() {
	int N;
	cin >> N;
	int a=0, b=0, c=0, d=0;
	string s;
	rep(i, N) {
		std::cin >> s;
		if (s == "AC") {
			a++;
		} else if (s == "WA") {
			b++;
		} else if (s == "TLE") {
			c++;
		} else {
			d++;
		}
	}
	std::cout << "AC x " << a << '\n';
	std::cout << "WA x " << b << '\n';
	std::cout << "TLE x " << c << '\n';
	std::cout << "RE x " << d << '\n';
}


Measured memory_bytes: 3624
fn main() {
    println!("{}", read::<f64>() * 2.0 * std::f64::consts::PI);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2196
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long ll;
struct Range {
    int x, a, b, i;
    int operator*() { return x; }
    Range& operator++() {
        x += i;
        return *this;
    }
    bool operator!=(const Range& v) { return v.a <= x && x < v.b; }
    Range begin() { return {x, a, b, i}; };
    Range end() { return {x, a, b, i}; }
};
Range range(int a) { return {0, 0, a, 1}; }

double ta[310][310][310];
int n;

double d(int i, int j, int k) {
    if (ta[i][j][k] != -1) {
        return ta[i][j][k];
    }
    double a = n;
    if (i > 0) {
        a += i * d(i - 1, j, k);
    }
    if (j > 0) {
        a += j * d(i + 1, j - 1, k);
    }
    if (k > 0) {
        a += k * d(i, j + 1, k - 1);
    }
    a /= i + j + k;
    ta[i][j][k] = a;
    return a;
}

int main() {
    int x=0, y=0, z=0;
    cin >> n;
    for (int i : range(n)) {
        int a;
        cin >> a;
        if (a == 1) {
            x++;
        } else if (a == 2) {
            y++;
        } else {
            z++;
        }
    }


    for (int i : range(310)) {
        for (int j : range(310)) {
            for (int k : range(310)) {
                ta[i][j][k] = -1;
            }
        }
    }
    ta[0][0][0] = 0;
    cout << setprecision(20) << d(x, y, z) << endl;
}

Measured memory_bytes: 233088
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int x;
  cin>>x;
  cout<<a[x-1]<<endl;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
gr1 = [2]
gr2 = [4,6,9,11]
if x in gr1:
  x_gr = 1
elif x in gr2:
  x_gr = 2
else:
  x_gr = 3
if y in gr1:
  y_gr = 1
elif y in gr2:
  y_gr = 2
else:
  y_gr = 3
if x_gr == y_gr:
  print('Yes')
else:
  print('No')

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

typedef long long ll;

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

    int n,k;
    cin >> n >> k;
    ll ans = k;
    for(int i=0;i<n-1;i++) ans *= (k-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    // スペース区切りの整数の入力
    int N = sc.nextInt();
    int M = sc.nextInt();

    List<Boolean> nList = new ArrayList<>();
    List<Integer> hList = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      hList.add(sc.nextInt());
      nList.add(true);
    }

    for (int i = 0; i < M; i++) {
      int Ai = sc.nextInt() - 1;
      int Bi = sc.nextInt() - 1;
      int A = hList.get(Ai);
      int B = hList.get(Bi);
      if (A < B) {
        nList.set(Ai, false);
      } else if (B < A) {
        nList.set(Bi, false);
      } else {
        nList.set(Ai, false);
        nList.set(Bi, false);
      }
    }

    System.out.println(nList.stream().filter(Boolean::booleanValue).count());
  }
}

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

X_axis = [i for i in range(W+1)]
Y_axis = [j for j in range(H+1)]

def CalcSqueare(a,b):
    if len(a)==0 or len(b)==0:
        print(0)
    else:
        print((a[-1]-a[0]) * (b[-1] - b[0]))


for i in range(N):
    x_i,y_i,a_i =map(int,input().split())

    if a_i==1:
        X_axis = [x for x in X_axis if x>=x_i]
    elif a_i==2:
        X_axis = [x for x in X_axis if x<=x_i]
    elif a_i==3:
        Y_axis = [y for y in Y_axis if y>=y_i]
    else:
        Y_axis = [y for y in Y_axis if y<=y_i]

CalcSqueare(X_axis,Y_axis)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000009;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);


struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int cnt[1 << 20];
int ans[1 << 20];
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	rep(i, (1 << 20))ans[i] = n;
	rep1(i, (1 << 20)-1) {
		for (int j = i; j < (1 << 20); j += i) {
			ans[j] -= cnt[i];
		}
	}
	int tmp = 0;
	rep(i, n) {
		if (ans[a[i]] == n - 1)tmp++;
	}
	cout << tmp << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init_f();
	//init();
	//int t; cin >> t;rep(i,t)
	solve();
	stop
		return 0;
}


Measured memory_bytes: 16168
#include<bits/stdc++.h>
using namespace std ;
#define Psi pair<string,int>

main(){
	int n ;
	string s ;
	vector<Psi> V ;
	
	while( cin >> s ){
		if( cin.eof() ) break ;
		cin >> n ;
		
		V.push_back( Psi(s,n) ) ;
	}
	
	sort( V.begin() , V.end() ) ;
	
	string t = "0a" ;
	for( int i=0 ; i<V.size() ; i++ ){
		if( V[i].first != t ){
			if( i ) cout << endl ;
			cout << V[i].first << endl ;
			cout << V[i].second ;
		}
		else cout << " " << V[i].second ;
		
		t = V[i].first ;
	}
	
	cout << endl ;
}

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

int N, M, ans;

vector<int> jobs[100005];
priority_queue<int> pq;

int main() {
  int a, b;

  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;

    jobs[a].push_back(b);
  }

  for (int i = 1; i <= M; i++) {
    for (int job : jobs[i]) {
      pq.push(job);
    }
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 5632
N = int(input())
INF = int(1e13)
A = [list(map(int, input().split())) for _ in range(N)]
X = [[[0, 0] for __ in range(N)] for _ in range(N)]
for i in range(N):
  for j in range(N):
    X[i][j] = [A[i][0]-A[j][0], A[i][1] - A[j][1]]
for i in range(N):
  X[i][i][0], X[i][i][1] = INF + 2*i, INF + 2*i+1
D = {}
for i in range(N):
  for j in range(N):
    if X[i][j][0]*(10*INF)+X[i][j][1] in D:
      D[X[i][j][0]*(10*INF)+X[i][j][1]] += 1
    else:
      D[X[i][j][0]*(10*INF)+X[i][j][1]] = 1
if N == 1:
  print(1)
else:
  print(N-max(D[i] for i in D))


Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int sum= 0;
  for(int i=0; i<N; i++){
    int left,right;
    cin >> left >> right;
    sum += right - left + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
S = {']':'[',')':'('}
while 1:
    l = input()
    if l == '.':break

    lst = []
    flg = True
    for w in list(l):
        if w == '[' or w == '(':
            lst.append(w)
        if w== ']' or w == ')':
            if len(lst) > 0 and S[w] == lst[-1]:
                lst.pop(-1)
            else:
                flg = False
                break
    print('yes' if flg and len(lst) == 0 else 'no')

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

#define int long long

using namespace std;

signed main(void){
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++) cin >> X[i][j];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int d = 0;
            for(int k = 0; k < D; k++) d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            int r = sqrt(d);
            if(d == r * r) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
int main(){
    int n,mx=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        if(a[i]<mx-1){
            cout<<"No"<<endl;
            return 0;
        }
        mx=max(mx,a[i]);
    }
    cout<<"Yes"<<endl;
}

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


int main(){
   while(1){
      int n,x;
      cin >> n >> x;
      if(n==0){
         break;
      }
      int i,j,k,ans;
      ans=0;
      for(i=1;i<n-1;i++){
         for(j=i+1;j<n;j++){
            k=x-i-j;
            if(j<k&&k<=n){
               ans++;
            }
         }
      }
      cout << ans<<endl;
   }
}


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a ; i <= b ; ++ i) 
const int N = 2005, inf = 1e9 + 7 ;
using namespace std ;

int n, L[N], R[N], cnt ;
char A[N], B[N] ;
struct poi { int l, r ; } a[N] ;

bool cmp(poi a, poi b) {
	return a.l < b.l ;
}

int solve(int c) {
	int res = inf, mx = 0 ;
	cnt = 0 ;
	rep(i, 0, n - 1) if (B[(i + c + n) % n] != A[i]) {
		++ cnt ;
		a[cnt].l = L[i], a[cnt].r = R[i] ;
	}
	sort(a + 1, a + cnt + 1, cmp) ;
	rep(i, 1, cnt) {
		if (c < 0) res = min(res, cnt - c + (c - min(a[i].l, c)) * 2 + mx * 2) ; else
			res = min(res, cnt + c + (max(mx, c) - c) * 2 + max(- a[i].l, 0) * 2) ;
		mx = max(mx, a[i].r) ;
	}
	if (c < 0) res = min(res, cnt - c + mx * 2) ; else
		res = min(res, cnt + c + (max(mx, c) - c) * 2) ;
	return res ;
}

int main() {
	scanf("%s%s", A, B) ;
	bool flg = true ;
	n = strlen(A) ;
	rep(i, 0, n - 1) flg &= (B[i] == '0') ;
	if (flg) {
		flg = false ;
		rep(i, 0, n - 1) flg |= (A[i] == '1') ;
		if (flg) { puts("-1") ; return 0 ; }
		puts("0") ;
		return 0 ;
	}
	int ans = inf ;
	rep(i, 0, n - 1) {
		for (int j = 0 ; j >= - n + 1 ; -- j) if (B[(i + j + n) % n] == '1') { L[i] = j ; break ; }
		for (int j = 0 ; j <= n - 1 ; ++ j) if (B[(i + j) % n] == '1') { R[i] = j ; break ; }
	}
	rep(i, - n + 1, n - 1) ans = min(ans, solve(i)) ;
	printf("%d\n", ans) ;
	return 0 ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		set<string> ans;
		string input;
		cin>>input;
		for(int i=0;i<input.length();i++){
			string s1=input.substr(0,i),s2=input.substr(i);
			for(int k=0;k<2;k++){
				for(int l=0;l<2;l++){
					ans.insert(s1+s2);
					ans.insert(s2+s1);
					reverse(s1.begin(),s1.end());
				}
				reverse(s2.begin(),s2.end());
			}
		}
		cout<<ans.size()<<endl;
	}
}

Measured memory_bytes: 1292
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
using namespace std;
int gcm(int a, int b) {
	if (!a || !b)return -1;
	if (a < b) {
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
	}
	if (!(a%b)) return b;
	return gcm(a%b, b);
}
long long gcm(long long a, long long b) {
	if (!a || !b)return -1;
	if (a < b) {
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
	}
	if (!(a%b)) return b;
	return gcm(a%b, b);
}
long long a,b,c,d;
string s;

int main() {
	cin >> a >> b >> c >> d;
	long long e = c * d / gcm(c, d);
	cout << b-a+1-(b / c + b / d - b / e - ((a-1) / c + (a - 1) / d - (a - 1)/ e)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string S,T; cin >> S >> T;
  map<char,int> s,t;
  rep(i,S.size()){
    s[S[i]]++;
    t[T[i]]++;
  }
  vi cnt_s,cnt_t;
  for(auto x : s) cnt_s.push_back(x.second);
  for(auto x : t) cnt_t.push_back(x.second);
  sort(all(cnt_s));
  sort(all(cnt_t));
  if(cnt_s.size() != cnt_t.size()){
    cout << "No";
    return 0;
  }else{
    rep(i,cnt_t.size()){
      if(cnt_s[i] != cnt_t[i]){
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define mod 998244353
#define INF 0x3f3f3f
#define fi first
#define se second
#define it iterator
#define ins insert
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false)
#define gcd __gcd
ll lgcd(ll a,ll b){return b == 0? a:lgcd(b, a % b);}

#define T int t;scanf("%d",&t);while(t--)
#define CE cout << endl
#define C(n) cout << n << endl
#define CY cout << "YES" << endl
#define CN cout << "NO" << endl
#define Cy cout << "Yes" << endl
#define Cn cout << "No" << endl
ull s[100010];
int main()
{
    long double a, b;
    cin >> a >> b;
    ull c = a*b;
    C(c);
    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <cstdio>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
const int INF = 1e9 + 7;
/*
void init(int x, int l, int r) {
    if (l == r) {
        tree[x] = INF;
    } else {
        int mid = (l + r) / 2;
        init(x + x, l, mid);
        init(x+x+1, mid + 1, r);
        tree[x] = min(tree[x + x], tree[x + x + 1]);
    }
}
int get(int x, int l, int r, int tl, int tr) {
    if (r < tl || tr < l) {
        return INF;
    }
    if (tl <= l && r <= tr) {
        return tree[x];
    }
    int mid = (l + r) / 2;
    return min(get(x + x, l, mid, tl, tr), get(x+x+1, mid + 1, r, tl, tr));
}
void upd(int x, int l, int r, int pos, int val) {
    if (l == r) {
        tree[x] = min(tree[x], val);
    } else {
        int mid = (l + r) / 2;
        if (pos <= mid) {
            upd(x + x, l, mid, pos, val);
        } else {
            upd(x+x+1, mid + 1, r, pos, val);
        }
        tree[x ] =min(tree[x + x], tree[x + x +1]);
    }
}

*/
int main() {
    int n;
    scanf("%d", &n);
    vector<int> v;
    for (int i = 1; i<= n; i++) {
        int x;
        scanf("%d", &x);
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    long long ans = 0;
    for (int i = 1; i < v.size(); i++) {
        ans += 1ll * (v[i] - v[i - 1]);
    }
    cout << ans;
    
    return 0;
}


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

using namespace std;

#define ll long long

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x, k, d;
    cin>>x>>k>>d;
    x = abs(x);
    ll mul = x/d, mod = x%d;
    if(mul < k){
        x = mod;
        k -= mul;
        if(k&1) x = d-x;
    }
    else{
        x -= k*d;
    }
    cout<<x<<"\n";
    return 0;
}


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

int main(){

  int n, b, f, r, v;

  int bild[5][4][11] = {};

  cin >> n;

  for( int i = 0; i < n; i++){
    cin >> b >> f >> r >> v;

    bild[b][f][r] += v;
  }

  for( int i = 1; i < 5; i++){
    if( i > 1) cout << "####################\n";
    for( int j = 1; j < 4; j++){
      for( int k = 1; k < 11; k++){
	cout << " " << bild[i][j][k];
      }
      cout << endl;
    }
  }

return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int a;
    cin >> a;
    cout << (a + 110) / 111 * 111 << endl;
}

Measured memory_bytes: 256