akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG

vin dy={-1,0,0,1};
vin dx={0,-1,1,0};
int h=1000;
int w=1000;
vvch a(h,vch(w));
int bfs(){
    queue<pair<int,int>> q;
    queue<pair<int,int>> r;
    int sum=0;
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='#')q.push(mp(i,j));
        }
    }
    while(q.size()){
        while(q.size()){
            auto p=q.front();
            q.pop();
            rep(i,4){
                int ny=p.first+dy[i];
                int nx=p.second+dx[i];
                if(0<=ny&&ny<h&&0<=nx&&nx<w&&a[ny][nx]!='#'){
                    a[ny][nx]='#';
                    r.push(mp(ny,nx));
                }
            }
        }
        if(r.size())sum++;
        while(r.size()){
            q.push(r.front());
            r.pop();
        }
    }
    return sum;
}
int main(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w)cin>>a[i][j];
    }
    cout<<bfs()<<endl;
}

Measured memory_bytes: 9488
#include<iostream>
#include<string>
using namespace std;
bool isPrime(int x)
{
    for(int i=2;i*i<=x;++i)
    {
        if(x%i==0)return false;
    }
    return true;
}
int main()
{
    int x;
    cin>>x;
    for(int i=x;;i++)
    {
        if(isPrime(i))
        {
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c ;
  
  if(a==7 && b==5 && c==5)
    cout << "YES" << endl;
  else if(a==5 && b==7 && c==5)
    cout << "YES" << endl;
  else if(a==5 && b==5 && c==7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}

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

const int N = 5010, M = 210;
int n, m, w[N][M], l[N], r[N], tot;
ll dis[N], tmp[N], s[N];
struct node { int x, l, r, c; } a[N * M << 1];

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline bool mycmp(node a, node b) { return a.x < b.x; }

int main() {
	n = read(), m = read();
	for(int i = 2; i <= n; ++i)	dis[i] = dis[i - 1] + read();
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			w[i][j] = read();
	for(int j = 1; j <= m; ++j) {
		for(int i = 1; i <= n; ++i) {
			l[i] = i - 1;
			while(l[i] && w[l[i]][j] < w[i][j])	l[i] = l[l[i]];
		}
		for(int i = n; i >= 1; --i) {
			r[i] = i + 1;
			while(r[i] <= n && w[r[i]][j] <= w[i][j])	r[i] = r[r[i]];
		}
		for(int i = 1; i <= n; ++i) {
			a[++tot].x = l[i] + 1; a[tot].l = i;
			a[tot].r = r[i] - 1; a[tot].c = w[i][j];
			a[++tot].x = i + 1; a[tot].l = i;
			a[tot].r = r[i] - 1; a[tot].c = -w[i][j];
		}
	}
	sort(a + 1, a + tot + 1, mycmp);
	ll ans = 0;
	int now = 1;
	for(int i = 1; i <= n; ++i) {
		memset(tmp, 0, sizeof(tmp));
		while(now <= tot && a[now].x == i)	tmp[a[now].l] += a[now].c, tmp[a[now].r + 1] -= a[now].c, ++now;
		for (int j = 1; j <= n; ++j) tmp[j] += tmp[j - 1], s[j] += tmp[j], ans = j < i ? ans : max(ans, s[j] - dis[j] + dis[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


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

struct UnionFind{
  vector<long long> par;

  UnionFind(int n){
    par.assign(n,-1);
  }

  void unite(long long x, long long y){
    x=root(x);y=root(y);
    if(x==y) return;

    if(par[x]>par[y]){
      swap(x,y);
    }
    par[x]+=par[y];
    par[y]=x;
  }

  long long root(long long x){
    if(par[x]<0){
      return x;
    }else{
      return par[x]=root(par[x]);
    }
  }

  bool same(long long x, long long y){
    return root(x)==root(y);
  }
};

int main(){
  long long n,m,ans=0;
  cin >> n >> m;
  UnionFind uf(n);
  long long p[n],x[m],y[m];
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i];
    x[i]--;y[i]--;
    uf.unite(x[i],y[i]);
  }
  for(int i=0;i<n;i++){
    if(uf.same(i,p[i])){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

void printarray(int array[],int n){
	int i;
	for(i=0;i<n;++i){
		if(i)printf(" ");
		printf("%d",array[i]);
	}
	printf("\n");
}

int main(void){
	int n,i,j,key;
	int array[100];
	scanf("%d",&n);
	
	for(i=0;i<n;++i)
		scanf("%d",&array[i]);
  printarray(array,n);		
	for(i=1;i<n;++i){
		key = array[i];
		j=i-1;
		while(j>=0&&array[j]>key){
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = key;
		printarray(array,n);
	}
	return 0;
}

Measured memory_bytes: 1800
#include<stdio.h>
#include<string.h>

int main(){
  
  char S[100000];
  int check[27] = {0};
  scanf("%s",S);

  int len = strlen(S);

  for(int i=0; i<len; i++){
    check[S[i]-'a']++;
  }

  for(int j=0; j<26; j++){
    if(check[j] == 0){
      printf("%c",'a'+j);
      return 0;
    }
  }

  printf("None");

  return 0;

}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

bool prime(int x){
	for(int i = 2; i * i <= x; ++i){
		if(x % i == 0){ return false; }
	}
	return true;
}

void mainmain(){
	int x;
	cin >> x;
	for(; !prime(x); ++x);
	cout << x << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    COMinit();
    int S;cin >> S;
    int k = 1;
    ll ans = 0;
    while(true){
        if(S<2*k+1) break;
        ans = (ans + COM(S-2*k-1, k-1)) % MOD;
        k++;
    }

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

Measured memory_bytes: 15600
N, M = map(int, input().split())
S = [tuple(map(int, input().split()))[1:] for _ in range(M)]
P = tuple(map(int, input().split()))

ans = 0
for state in range(2 ** N):
  for m in range(M):
    count = 0
    for s in S[m]:
      if state & (1 << (s - 1)):
        count += 1
    if count % 2 != P[m]:
      break
  else:
    ans += 1
print(ans)

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

template <typename T>
T BinarySearch(T ok, T ng, std::function<bool(T)> pred) {
  while (abs(ok - ng) > 1) {
    T mid = (ok + ng) / 2;
    (pred(mid) ? ok : ng) = mid;
  }
  return ok;
}

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(ll, n, k);
  V<ll> a(n);
  rep(i, n) cin >> a[i];
  wt(BinarySearch<ll>(*max_element(all(a)), 0, [&](ll mid) {
    ll cuts = 0;
    rep(i, n) cuts += (a[i] - 1) / mid;
    return cuts <= k;
  }));
}


Measured memory_bytes: 4736
N = gets.to_i
a_list = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
if a_list.group_by { |a| a }.any? { |k, l| l.size > 2 || k == 0 && l.size > 1 }
  puts 0
  exit 0
end
ans = 2 ** ((N.even? ? N : N - 1) / 2) % MOD
puts ans


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

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

  int ans = 0;

  ans += 1000 * (X / 500);
  X -= 500 * (X / 500);

  ans += 5 * (X / 5);
  X -= 5 * (X / 5);

  cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
#define endl '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define floop(i,a,b) for(int i=a;i<=b;++i)
const ll mod=1e9+7;
const int N = 10000000;
int lp[N+1];
vector<int> pr;
int32_t main(){
	IOS;	
	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
	ll ans=0;
	int n;
	cin>>n;
	floop(i,1,n){
		int curr = 1;
		int x = i;
		while(x>1){
			int temp = 0;
			int flag = lp[x];
			while(x%flag==0){
				x/=flag;
				temp++;
			}
			curr*=(temp+1);
		}
		ans += (ll(i))*(ll(curr));
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const int INF = 1e9;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    char c;
    cin >> c;
    cout << char(c + 1);
}

Measured memory_bytes: 256
let print_array a =
  Array.iteri (fun i s -> Printf.printf (if i = 0 then "%s" else " %s") s) a;
  print_newline ()

let swap i j a = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp

let bubble_sort a n cmp =
  let rec bubble i flag =
    if i = 0 then doit flag
    else if cmp a.(i-1) a.(i) <= 0 then bubble (i - 1) flag
    else (swap i (i - 1) a; bubble (i - 1) true)
  and doit flag =
    if flag then bubble (n - 1) false
  in doit true

let selection_sort a n cmp =
  let rec select j minj =
    if j >= n then minj
    else select (j + 1) (if cmp a.(j) a.(minj) < 0 then j else minj)
  and doit i =
    if i < n then begin
      let j = select i i in
      if j <> i then swap i j a;
      doit (i + 1)
    end in
  doit 0

let cmp_card x y =
  let num_of_char c = Char.code c - Char.code '0' in
  compare (num_of_char x.[1]) (num_of_char y.[1])

let stable_p a b n =
  let rec doit i =
    if i = n then true
    else if a.(i) <> b.(i) then false
    else doit (i + 1)
  in doit 0

let () =
  let n = read_int () in
  let a = Array.of_list (Str.split (Str.regexp " ") (read_line ())) in
  let b = Array.copy a in
  bubble_sort a n cmp_card;
  selection_sort b n cmp_card;
  print_array a;
  print_endline "Stable";
  print_array b;
  print_endline (if stable_p a b n then "Stable" else "Not stable")

Measured memory_bytes: 2172
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include<iterator>
#include<queue>
#include<functional>
using namespace std;

const int MAX_N = 100;
const int INF = INT_MAX / 2;

struct edge { int to, cap, weight, rev; };
typedef vector<edge> Edges;
typedef vector<Edges> Graph;
typedef pair<int, int> P;

Graph G(MAX_N);
vector<int> dist(MAX_N);
vector<int> prevv(MAX_N);
vector<int> preve(MAX_N);


void add_edge(int s, int t, int cap, int weight) {
	edge e = { t,cap,weight,G[t].size() };
	G[s].push_back(e);
	edge f = { s, 0, -weight, G[s].size() - 1 };
	G[t].push_back(f);
}

void Dijkstra(int s) {
	fill(dist.begin(), dist.end(), INF);
	priority_queue< P, vector<P>, greater<P> >  q;

	fill(dist.begin(), dist.end(), INF);
	dist[s] = 0;

	q.push(P(0, s));

	while (!q.empty()) {
		P p = q.top();
		q.pop();
		int v = p.first;
		if (dist[v] < p.second) {
			continue;
		}
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (e.cap > 0 && dist[e.to] > dist[v] + e.weight) {
				dist[e.to] = dist[v] + e.weight;
				prevv[e.to] = v;
				preve[e.to] = i;
				P u = P(e.to, dist[e.to]);
				q.push(u);
			}
		}
	}
}
/*
void WarshallFloyd(int s) {
fill(dist.begin(), dist.end(), INF);
dist[s] = 0;
bool update = true;
while (update) {
update = false;
for (int j = 0; j<MAX_N; j++) {
for (int k = 0; k<G[j].size(); k++) {
edge e = G[j][k];
if (e.cap>0 && dist[e.to]>dist[j] + e.weight) {
dist[e.to] = dist[j] + e.weight;
prevv[e.to] = j;
preve[e.to] = k;
update = true;
}
}
}
}
}
*/

int MinimumCostFlow_wf(int s, int t, int f) {
	int cost = 0;
	while (f>0) {
		Dijkstra(s);
		if (dist[t] == INF) {
			return -1;
		}

		int d = f;
		for (int v = t; v != s; v = prevv[v]) {
			d = min(d, G[prevv[v]][preve[v]].cap);
		}

		f -= d;
		cost += d*dist[t];
		for (int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}

		//?£??????????????????????????????£
		for (int i = 0; i < MAX_N; i++) {
			for (int j = 0; j < G[i].size(); j++) {
				edge ee = G[i][j];
				ee.weight += (dist[ee.to] - dist[i]);
			}
		}
	}
	return cost;
}


int main() {
	int V, E, F, s, t, cap, weight;

	cin >> V >> E >> F;
	for (int i = 0; i<E; i++) {
		cin >> s >> t >> cap >> weight;
		add_edge(s, t, cap, weight);
	}

	cout << MinimumCostFlow_wf(0, V - 1, F) << endl;
}

Measured memory_bytes: 1288
n, k = map(int, input().split())
a = list(map(int, input().split()))

dp = [float('Inf') for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        if i - j >= 0:
            if dp[i] > dp[i - j] + abs(a[i] - a[i - j]):
                dp[i] = dp[i - j] + abs(a[i] - a[i - j])
print(dp[n - 1])

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[N - 1] - a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

const int N = 200010;

int n,x,y;
int a[N],b[N];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		a[i]=x+y;
		b[i]=x-y;
	}
	sort(a,a+n);
	sort(b,b+n);
	printf("%d",max(a[n-1]-a[0],b[n-1]-b[0]));
	return 0;
}

Measured memory_bytes: 3296
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        int count = selectionSort(A, N);
        for(int i = 0; i < N; i++){
            System.out.print(A[i]);
            if(i != N - 1){
                System.out.print(" ");
            }
        }
        System.out.println();
        System.out.println(count);
    }

    public static int selectionSort(int[] A, int N){
        int count = 0;
        for(int i = 0; i < N; i++){
            boolean flag = false;
            int minj = i;
            for(int j = i; j < N; j++){
                if(A[j] < A[minj]){
                    minj = j;
                    flag = true;
                }
            }
            if(flag){
                count++;
            }
            int temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
        }
        return count;
    }
}



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

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a;
  a.push_back(0);
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  int map[100][100] = {0};
  int px=0, py=0;
  int next = 1;
  for (int i=1; i<n+1; i++) {
    for (int j=0; j<a[i]; j++) {
      map[py][px] = i;
      px += next;
      if (px == w) {
        px = w-1;
        py++;
        next = -1;
      } else if (px == -1) {
        px = 0;
        py++;
        next = 1;
      }
    }
  }

  for (int i=0; i<h; i++) {
    for (int j=0; j<w-1; j++) {
      cout << map[i][j] << " ";
    }
    cout << map[i][w-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 384
n,m=map(int,input().split())
h=list(map(int,input().split()))
ll=[]
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]<h[b-1]:
        lose=[a]
    elif h[a-1]>h[b-1]:
        lose=[b]
    else:
        lose=[a,b]
    ll += lose

import collections
c=collections.Counter(ll)
print(n-len(c))

Measured memory_bytes: 22160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a + b == c || a + c == b || b + c == a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}

}

Measured memory_bytes: 35792
package main

import "fmt"

func main() {
	var a, b, c, x int
	count := 0

	fmt.Scan(&a, &b, &c, &x)

	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				total := i*500 + j*100 + k*50
				if total == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


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

int main(){
	int N;
  	int K;
  	int digit=0;
  	cin >> N >> K;
  	while(N>0){
      digit++;
      N = (int)N/K;
    }
  	cout << digit << endl;
  
	return(0);
}


Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string a = ReadLine();
	int n = a.Length;

	const int N = 'z'-'a'+1;
	var ct = new int[N];
	for (int i = 0; i < n; i++)
	{
	    char c = a[i];
	    ct[c-'a']++;
	}

	long ans = (long) n * (n-1) / 2;
	for (int i = 0; i < N; i++)
	{
	    long m = ct[i];
	    ans -= m * (m-1) / 2;
	}

	WriteLine(ans+1);
    }
}


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

int main(void){
  int n, m, i;
  bool lock;
  string u, t, mess;
  map<string, bool> mp;

  cin >> n;
  for(i=0;i<n;i++){
    cin >> u;
    mp[u] = true;
  }
  
  lock = true;
  cin >> m;
  for(i=0;i<m;i++){
    cin >> t;
    if(mp.find(t) == mp.end()){
      cout << "Unknown " << t << endl;
    }else{
      mess = lock ? "Opened by ":"Closed by ";
      lock = not lock;
      cout << mess << t << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

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

    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int h,w;
	int i,j;

	while(scanf("%d %d",&h,&w)!=EOF){

		if(h==0 && w==0)
			break;

		for(j=0;j<w;j++)
			printf("#");
		puts("");

		for(i=1;i<h-1;i++){
			printf("#");
			for(j=1;j<w-1;j++)
				printf(".");
			printf("#");
			puts("");
		}
	
		for(j=0;j<w;j++)
			printf("#");
		puts("");

		
		puts("");

	}

	return 0;

}

Measured memory_bytes: 588
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main() {
	int k,x;
	cin>>k>>x;
	for(int i=k-1; i>=1; i--) {
		if(x-i<-1000000) {
			continue;
		}
		cout<<x-i<<" ";
	}
	cout<<x<<" ";
	int i=0;
	for(i=1; i<k-1; i++) {
		if(x+i>1000000) {
			break;
		}
		cout<<x+i<<" ";
	}
	if(x+i<=1000000&&k>1) {
		cout<<x+i;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

res = []
result = 1
for I in range(2,N+1):
    res += prime_factorize(I)
for J in set(res):
    result *= res.count(J) + 1
print(result % (10**9+7))

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

int main() 
{
    int N;
    cin >> N;
    pair<int, int> A[N];
    for(int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        A[i].first = tmp;
        A[i].second = i;
    }
    sort(A, A + N);
    /*
    for(int i = 0; i < N; ++i) {
        cout << A[i].first << " " << A[i].second << endl;
    }
    */
    int ans[N];
    for(int i = 0; i < N; ++i) {
        if(i < N-1) {
            ans[A[i].second] = A[N-1].first;
        }
        else {
            ans[A[i].second] = A[N-2].first;
        }
    }
    for(int i = 0; i < N; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
void solve(int n, int k, int c, string& s, vector<int>& maxlen, vector<int>& maxindex) {
    for(int i = 0; i < n; i++) {
        if(i == 0) {
            maxlen[i] = s[i] == 'o';
            maxindex[i] = i;
        } else {
            maxlen[i] = maxlen[i - 1];
            maxindex[i] = maxindex[i - 1];
            if(s[i] == 'o' and maxlen[i] < maxlen[i - c - 1] + 1) {
                maxlen[i] = maxlen[i - c - 1] + 1;
                maxindex[i] = i;
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s, t;
    for(int i = 0; i <= c; i++) {
        s += 'x';
    }
    cin >> t;
    s += t;
    for(int i = 0; i <= c; i++) {
        s += 'x';
    }
    n += 2 * (c + 1);
    vector<int> maxL(n), maxLindex(n), maxR(n), maxRindex(n);
    solve(n, k, c, s, maxL, maxLindex);
    reverse(s.begin(), s.end());
    solve(n, k, c, s, maxR, maxRindex);
    reverse(s.begin(), s.end());
    reverse(maxR.begin(), maxR.end());
    reverse(maxRindex.begin(), maxRindex.end());
    for(int i = 0; i < n; i++) {
        if(s[i] == 'o' 
        and maxL[max(0, min(i, maxRindex[i + 1] - c) - 1)] + maxR[i + 1] < k
        and maxL[i - 1] + maxR[min(max(i, maxLindex[i - 1] + c) + 1, n - 1)] < k) {
            cout << i - c << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5140
from collections import deque

s = input()
n = int(input())
ans = deque(s)

div = True
for i in range(n):
    q = input().split(' ')
    if q[0] == '1':
        div = not div
    elif (q[1] == '1' and div) or (q[1] == '2' and not div):
        ans.appendleft(q[2])
    else:
        ans.append(q[2])

if div:
    print(''.join(ans))
else:
    print(''.join(reversed(ans)))


Measured memory_bytes: 8564
ar = list(map(int,input().split(" ")))
br = list(map(int,input().split(" ")))
count = 0
for i in range(ar[0]-1):
    if (br[i+1] - br[i]) * ar[1] < ar[2]:
        count += (br[i+1] - br[i]) * ar[1]
    else:
        count += ar[2]
print(count)

Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <array>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cstdio>

using namespace std;

#define int long long

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

	int a, s, d;

	cin >> a >> s >> d;

	bool ans = std::min(a, s) < d && d < std::max(a, s);

	cout << (ans ? "Yes" : "No") << endl;
}

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);
    cout.tie(NULL);
    string s,t;cin>>s>>t;
    ll n=s.length(),m=t.length();
    ll dp[n+1][m+1];
    for(int i=0;i<=n;++i)
    {
        dp[i][0]=0;
    }
    for(int i=0;i<=m;++i)
    {
        dp[0][i]=0;
    }
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=m;++j)
        {
            dp[i][j]=0;
        }
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(s[i-1]!=t[j-1])
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            else
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
        }
    }
    //cout<<dp[n][m]<<endl;
    if(dp[n][m]==0)
    {
        cout<<" ";
        return 0;
    }
    vector<char>v;
    int ti=n,tj=m;
    while(ti>0 && tj>0)
    {
        
        if(dp[ti][tj-1]==dp[ti][tj])
        {
            tj--;
        }
        else if(dp[ti-1][tj]==dp[ti][tj])
        {
            ti--;
        }
        else if(dp[ti][tj]==dp[ti-1][tj-1]+1)
        {
            v.push_back(s[ti-1]);
            ti--;tj--;
        }
        
    }
    for(int i=(int)v.size()-1;i>=0;--i)
    {
        cout<<v[i];
    }
    cout<<endl;

    
    return 0;
}

Measured memory_bytes: 70656
board = "#."*151
num = []
while True:
    n = list(map(int, input().split()))
    if n[0] == 0 and n[1] == 0:
        break
    else:
        num.append(n)

for i in num:
    h = i[0]
    w =i[1]
    count = 0
    for n in range(1,h+1):
        if n % 2 == 0:
            while count < n:
                print(board[1:w+1])
                count += 1
        else:
            while count < n:
                print(board[:w])
                count += 1
    print('')

Measured memory_bytes: 7616
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int page = n / 2;
		
		if(n % 2 > 0){
			page++;
		}
		
		System.out.println(page);
	}
}

Measured memory_bytes: 21844
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

NUMS = [3, 5, 7]

def countup(nums)
  last = nums.pop
  if last.nil?
    [3]
  elsif last == 3 || last == 5
    nums << last + 2
    nums
  else
    countup(nums) + [3]
  end
end

test = [3]
count = 0

while test.join.to_i <= N
  if test.include?(3) && test.include?(5) && test.include?(7)
    count += 1
  end
  test = countup(test)
end

puts count


Measured memory_bytes: 14416
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1e9+7;
vector<long long> fact, fact_inv, inv;
void init_nCk(ll n){
  fact.resize(n+5);
  fact_inv.resize(n+5);
  inv.resize(n+5);
  fact[0]=fact[1]=1;
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(ll i=2;i<n+5;++i){
    fact[i]=fact[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
ll nCk(ll n,ll k){
  return fact[n]*(fact_inv[k]*fact_inv[n-k]%MOD)%MOD;
}
int main(){
  ll N,K,ans=0;
  cin>>N>>K;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(K==1){cout<<0<<endl;}
  else{
    init_nCk(N);
    for(ll i=K-1;i<N;i++){
      ans+=vec.at(i)*nCk(i,K-1)%MOD;
      ans=(ans+MOD)%MOD;
    }
    for(ll i=N-K;i>=0;i--){
      ans-=vec.at(i)*nCk(N-i-1,K-1)%MOD;
      ans=(ans+MOD)%MOD;
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3328
n,k=map(int,input().split())
x=[0]*n
d=[0]*k
sums=[]
sums2=0
sums3=0
for i in range(k):
    d[i]=int(input())
    a=[0]*d[i]
    a=list(map(int,input().split()))
    sums=sums+a
    sums2=sums2+d[i]
for j in range(n):
    if sums.count(j+1)==0:
        sums3=sums3+1
print(sums3)

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

int par[100001];
int rnk[100001];

void init(int n)
{
  for(int i = 0; i < n; i++){
    par[i] =i;
    rnk[i] = 0;
  }
}

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

void unite(int x, int y)
{
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(rnk[x] < rnk[y]){
    par[x] = y;
  } else {
    par[y] = x;
    if(rnk[x] == rnk[y]) rnk[x]++;
  }
}

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

int main()
{
  int n, m;
  int p[100001];
  int x, y;
  int ans = 0;

  cin >> n >> m;

  init(n);
  for(int i = 1; i <= n; i++)
    cin >> p[i];
  for(int i = 0; i < m; i++){
    cin >> x >> y;
    unite(x, y);
  }

  for(int i = 1; i <= n; i++){
    if(same(i, p[i])) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

def f(x):
    if 1 <= x and x <= 10:
        return 10
    elif 11 <= x and x <= 20:
        return 20
    elif 21 <= x and x <= 30:
        return 30
    elif 31 <= x and x <= 40:
        return 40
    elif 41 <= x and x <= 50:
        return 50
    elif 51 <= x and x <= 60:
        return 60
    elif 61 <= x and x <= 70:
        return 70
    elif 71 <= x and x <= 80:
        return 80
    elif 81 <= x and x <= 90:
        return 90
    elif 91 <= x and x <= 100:
        return 100
    elif 101 <= x and x <= 110:
        return 110
    elif 111 <= x and x <= 120:
        return 120
    else:
        return 130
    
aa = a + f(b) + f(c) + f(d) + f(e)
bb = b + f(c) + f(d) + f(e) + f(a)
cc = c + f(d) + f(e) + f(a) + f(b)
dd = d + f(e) + f(a) + f(b) + f(c)
ee = e + f(a) + f(b) + f(c) + f(d)
print(min(aa, bb, cc, dd, ee))

Measured memory_bytes: 9288
//ABC145-D
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <int MOD = 1000000007>
struct Mint{
    int x;

    Mint() : x(0) {}
    Mint(long long t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(int n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        int a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

template <typename T>
struct Comb{
    vector<T> fac, fin;

    Comb(int sz) : fac(sz + 1), fin(sz + 1){
        fac[0] = fin[sz] = T(1);
        for(int i = 1; i <= sz; i++){
            fac[i] = fac[i - 1] * T(i);
        }
        fin[sz] /= fac[sz];
        for(int i = sz - 1; i >= 0; i--){
            fin[i] = fin[i + 1] * T(i + 1);
        }
    }

    inline T fact(int k) const { return fac[k]; }
    inline T finv(int k) const { return fin[k]; }

    T P(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k];
    }

    T C(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k] * fin[k];
    }

    T H(int n, int k) const {
        if(n < 0 || k < 0) return T(0);
        return k == 0 ? T(1) : C(n + k - 1, k);
    }
};

signed main(){
    ll x,y;
    cin >> x >> y;
    ll sum = x + y;
    if(sum % 3 == 0 && sum / 3 <= x && x <= sum / 3 * 2 && sum / 3 <= y && y <= sum / 3 * 2){
        ll mn = min(x, y);
        Comb<Mint<MOD>> C(1e6);
        cout << C.C(sum / 3, mn - sum / 3) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    sort(A.begin(), A.end());
    vector<ll> B;
    if(N%2==0){
    	REP(i, N/2){
    		B.push_back(2*i+1);
    		B.push_back(2*i+1);
    	}
    }else{
    	B.push_back(0);
    	REP(i, N/2){
    		B.push_back(2*i+2);
    		B.push_back(2*i+2);
    	}
    }

    bool ok = true;
    REP(i, N) if(A[i] != B[i]) ok = false;
    cout << (ok ? powLL(2, N/2) : 0) << endl;
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a;
    ll ans=1,num=1;
    for(int i=0;i<n;i++){
        cin>>a;
        ans*=3;
        if(a%2==0){
            num*=2;
        }
    }
    cout <<ans-num<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
len = n


while len >= 1:
  for i in range(n-len + 1):
    sub = s[i:i+len]    
    for c in sub:
      if c not in ['A','T','G','C']:
      	break
    else:
      print(len)
      exit()
  len-=1
  
print(len)
    
      

Measured memory_bytes: 3064
#include<iostream>
#define r(i,n)for(int i=0;i<n;i++)
using namespace std;main(){int c[10][10],H,W,t,a;cin>>H>>W;r(i,10)r(j,10)cin>>c[i][j];r(k,10)r(i,10)r(j,10)c[i][j]=min(c[i][j],c[i][k]+c[k][j]);r(h,H)r(w,W){cin>>t;if(t>=0)a+=c[t][1];}cout<<a;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll ans=1e9;
	ll a,b;
	cin>>a>>b;
	if(a/2019!=b/2019){
		cout<<0<<endl;
		return 0;
	}
	for(ll i=a;i<=b;i++){
		for(ll j=i+1;j<=b;j++){
			ans=min(ans,i*j%2019);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[][] c = new int[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				c[i][j] = stdIn.nextInt();
			}
		}
		
		/*
		int s1 = c[0][0]-c[1][0];
		int s2 = c[0][1]-c[1][1];
		int s3 = c[0][2]-c[1][2];
		
		int s4 = c[1][0]-c[2][0];
		int s5 = c[1][1]-c[2][1];
		int s6 = c[1][2]-c[2][2];
		
		int s7 = c[0][0]-c[0][1];
		int s8 = c[1][0]-c[1][1];
		int s9 = c[2][0]-c[2][1];
		
		int s10 = c[0][1]-c[0][2];
		int s11 = c[1][1]-c[1][2];
		int s12 = c[2][1]-c[2][2];
		
		if(s1 == s2 && s2 == s3 && s4 == s5 && s5 == s6 && s7 == s8 && s8 == s9 && s10 == s11 && s11 == s12) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		*/
		
		int[] a = new int[3];
		int[] b = new int[3];
		a[0] = 0;
		b[0] = c[0][0];
		b[1] = c[0][1];
		b[2] = c[0][2];
		a[1] = c[1][0]-b[0];
		a[2] = c[2][0]-b[0];
		
		boolean flag = true;
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				if(c[i][j] != a[i] + b[j]) {
					flag = false;
					break;
				}
			}
		}
		
		if(flag) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21972
def ks(n, W, arr):
    dp = [[0 for i in range(W+1)] for j in range(n+1)]
    for i in range(1,n+1):
        for j in range(1,W+1):
            if arr[i-1][0] > j:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-arr[i-1][0]]+arr[i-1][1])
    return dp[n][W]

if __name__ == "__main__":
    n, W = map(int, input().split())
    arr = []
    for i in range(n):
        w,v = map(int, input().split())
        arr.append([w,v])
    arr.sort(key = lambda x:x[0])
    ans = ks(n,W,arr)
    print(ans)


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

#define ll long long
ll dp[200005];
ll fp(ll b, ll e, ll m){
	ll rs = 1ll;
	for(; e > 0; e /= 2, b = (b * 1ll * b) % m)
		if(e % 2 == 1) rs = (rs * 1ll * b) % m;
	return rs;
}

string s;
ll pc1 = 0ll, pcm1 = 0ll;
ll ans[200005];
ll n;

int main(){
	cin >> n >> s;

	dp[0] = 0ll;
	for(int i = 1; i < 200005; i ++){
		int nx = i % __builtin_popcount(i);
		dp[i] = dp[nx] + 1ll;
	}

	ll pc = 0;
	for(ll i = 0; i < n; i ++)
		if(s[i] == '1') pc ++;

	ll pw = 0ll;
	for(ll i = n - 1; i >= 0; i --, pw ++)
		if(s[i] == '1'){
			pc1 = (pc1 + fp(2ll, pw, pc + 1ll)) % (pc + 1ll);
			if(pc > 1) pcm1 = (pcm1 + fp(2ll, pw, pc - 1ll)) % (pc - 1ll);
			else if(pc == 1) pcm1 = 0ll;
		}

	pw = 0ll;
	for(ll i = n - 1; i >= 0; i --, pw ++){
		ll rs;
		if(s[i] == '1'){
			if(pc > 1) rs = (pcm1 - fp(2ll, pw, pc - 1ll)) % (pc - 1ll);
			else{
				ans[i] = 0; continue;
			}
			while(rs < 0ll) rs += pc - 1ll;
		}else{
			rs = (pc1 + fp(2ll, pw, pc + 1ll)) % (pc + 1ll);
		}

		ans[i] = 1ll + dp[rs];
	}

	for(ll i = 0; i < n; i ++)
		cout << ans[i] << endl;
	return 0;
}
/*
2
2
3
2
2
2
3
4
4
3
2
3
3
3
3
2
2
3
3
4
3
2
2
3
1
2
2
3
2
2
*/

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  char X, Y; cin >> X >> Y;
  if (X < Y) cout << "<" << endl;
  else if (X == Y) cout << "=" << endl;
  else cout << ">" << endl;


  return 0;
}


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

long long int x, y;

int main(void) {
	cin >> x >> y;

	long long int ans = 1000000000000;

	//A
	if (y >= x) { ans = min(ans, y - x); }

	//AB
	if (-y >= x) { ans = min(ans, -y - x + 1); }

	//BA
	if (y >= -x) { ans = min(ans, y + x + 1); }

	//BAB
	if (-y >= -x) { ans = min(ans, -y + x + 2); }


	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(str,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))






N=input1()
S,T=input2()
ans=""
for i in range(N):
	ans+=S[i]+T[i]
print(ans)









Measured memory_bytes: 2940
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	s := strconv.Itoa(n)
	if strings.Index(s, "7") != -1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1820
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
INF = float("inf")

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H, W, N = getlist()
	L = []
	for i in range(N):
		x, y = getlist()
		L.append((x, y))
	L = sorted(L)
	damage = 0
	ans = INF
	xval = 0
	for i in range(N):
		x, y = L[i][0], L[i][1]
		if x >= y + 1 + damage:
			ans = x - 1
			break
		if x == y + damage and xval != x:
			damage += 1
		xval = x
	print(min(ans, H))


if __name__ == '__main__':
	main()

Measured memory_bytes: 60544
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc105/editorial.pdf
　　　http://drken1215.hatenablog.com/entry/2018/08/13/125300
　　　https://www.hamayanhamayan.com/entry/2018/08/12/010816
・左端固定で右端動かすループの累積和だけ取れば、
　(右端の累積和)-(左端-1の累積和)で、どこでも分かるようになる。
・B-AがMの倍数 → BとAのmod Mが等しい(やってみれば分かる)
・余りの数を全部集計してから、各余りの数について2つ選ぶ組み合わせを数える。
"""

from collections import defaultdict

N, M = map(int, input().split())
aN = list(map(int, input().split()))

# 累積和を一時的に格納する変数
sm = 0
# 累積和のmod Mを格納するdict
d = defaultdict(int)
# 何もない累積和0の分を足しておく
d[0] = 1
for i in range(N):
    sm += + aN[i]
    d[sm%M] += 1

ans = 0
for k, v in d.items():
    # 各余りの数について、v個から2つ選ぶ組み合わせ(vC2)
    ans += v * (v-1) // 2
print(ans)


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

int main(){
    int N; cin >> N;
    int ans = 0;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin >> a[i];
    sort(a.begin(), a.end());
    for(int i=0;i<N;i++){
        if(i%2 == 0) ans+=a[N-1-i];
        else ans -=a[N-1-i];
    }
    cout << ans << endl;
}

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

#define M_PI       3.14159265358979323846

using namespace std;

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

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

//container util

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

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

int d[100005];
int cnt[100005];

int main() {
	int a,b;
	cin >> a>>b;
	cout << ((b - a) * (b - a + 1)) / 2 - b << endl;
	return 0;
}

Measured memory_bytes: 256