akhauriyash/Code-Regression huggingface dataset:
n = int(input())
p  = list(map(int, input().split()))
counter = 0

for i in range(n):
    minj = i
    for j in range(i+1, n):
        if p[j] < p[minj]:
            minj = j
    t = p[i]
    p[i] = p[minj]
    p[minj] = t
    if i != minj:
        counter += 1

if counter <= 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
from math import atan2,pi
a, b, x = [int(i) for i in input().split()]
x /= a

if x > a * b / 2:
    c = a * b - x
    print(atan2(c * 2 / a, a)*180/pi)
else:
    c = x * 2 / b
    print(atan2(b, c)*180/pi)
    
    


Measured memory_bytes: 38256
n = int(input())
d_count = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for i in range(n):
    w = input()
    d_count[w] = d_count[w] + 1

print('AC x ' + str(d_count['AC']))
print('WA x ' + str(d_count['WA']))
print('TLE x ' + str(d_count['TLE']))
print('RE x ' + str(d_count['RE']))


Measured memory_bytes: 9152
#include <stdio.h>

int Benefit(int,int);

int main() {
  int price;
  int n;
  int max_price = 0;
  int min_price;
  int benefit;
  int max_benefit;
  int i,j;

  scanf("%d",&n);
  //price_array = (int *)malloc(n * sizeof(int));
  scanf("%d",&price);
  min_price = price;
  for(i=1;i<n;i++) {
    scanf("%d",&price);
    benefit = Benefit(min_price,price);
    if(i==1) max_benefit = benefit;
    else if(max_benefit < benefit) {
      max_benefit = benefit;
    }
    if(min_price > price) {
      min_price = price;
    }
    //scanf("%d",&price);
  }

  printf("%d\n",max_benefit);

  return 0;
}

int Benefit(int x,int y) {
  return y-x;
}




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


int main() {
	int n;
	string w[200];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> w[i];
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (i == j)continue;
			if (w[i] == w[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
		if (i != 0 && w[i - 1].back() != w[i].front()) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, K = map(int, input().split())
    A = list(map(lambda x: int(x) - 1, input().split()))

    visited = [False] * N
    route = []
    
    cnt = 0
    v = 0
    while visited[v] == False and cnt < K:
        visited[v] = True
        route.append(v)
        v = A[v]
        cnt += 1

    if cnt < K:
        start = route.index(v)
        loop = cnt - start
        offset = (K - start) % loop
        res = route[start + offset] + 1
        print(res)
        # print(cnt)
        # print(offset)
    else:
        print(v + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 103136
H,W,K = gets.chomp.split.map(&:to_i)
c = H.times.map{gets.chomp.split("").map(&:to_s)}
ans = 0

(0..2**H-1).each do |t|
  (0..2**W-1).each do |y|
    black = 0
    (0..H-1).each do |i|
      (0..W-1).each do |j|
        if t>>i & 1 == 0 && y>>j & 1 == 0 && c[i][j]=="#"
          black += 1
        end
      end
     end
    if black == K
      ans += 1
    end
  end
end

puts ans



Measured memory_bytes: 14264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;
using ll=long long;
 
int main() {
int x,y;
  cin>>x>>y;
  int a,b,c;
    cin>>a>>b>>c;
  vector<int> p(a),q(b),r(c);
  rep(i,a) cin>>p[i];
  rep(i,b) cin>>q[i];
  rep(i,c) cin>>r[i];
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  vector<int> d;
  rep(i,x) d.push_back(p[i]);
  rep(i,y) d.push_back(q[i]);
  rep(i,c) d.push_back(r[i]);
  sort(d.rbegin(),d.rend());
  ll ans=0;
  rep(i,x+y) ans+=d[i];
  cout<<ans<<endl;
  } 

Measured memory_bytes: 3572
/*"Nothing is true."*/
#include<bits/stdc++.h>
using namespace std;
inline int min(int _a, int _b) {return _a < _b ? _a : _b;}
inline int max(int _a, int _b) {return _a > _b ? _a : _b;}
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

template <class _T> inline void rd(_T &_a) {
	int _f=0,_ch=getchar();_a=0;
	while(_ch<'0' || _ch>'9'){if(_ch=='-')_f=1;_ch=getchar();}
	while(_ch>='0' && _ch<='9')_a=(_a<<1)+(_a<<3)+_ch-'0',_ch=getchar();
	if(_f)_a=-_a;
}
const int maxn = 100100;
int a, b;
int main() {
	//freopen("AtCoder_89_C.in","r",stdin);
	//freopen("AtCoder_89_C.out","w",stdout);
	rd(a); rd(b);
	if(a * b % 2 == 0) puts("Even");
	else puts("Odd");
	return 0;
}



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

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

int main(){
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    vector<pair<int, int>> A(M);
    vector<long long> ans;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        A[i].first = a;
        A[i].second = b;
    }
    reverse(A.begin(), A.end());
    
    long long cnt = (long long)N * (N - 1) / 2;
    for(int i = 0; i < M; i++){
        if(uf.findSet(A[i].first, A[i].second)){
            uf.unionSet(A[i].first, A[i].second);
            ans.push_back(cnt);
        }else{
            ans.push_back(cnt);
            cnt -= uf.size(A[i].first) * uf.size(A[i].second);
            uf.unionSet(A[i].first, A[i].second);
        }
    }
    
    reverse(ans.begin(), ans.end());
    for(int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */

struct UnionFind{
  vector<long long> data;
  UnionFind(long long N) : data(vector<long long>(N,-1)){}
  long long root(long long x){
    if(data[x] < 0)return x;
    else return data[x] = root(data[x]);
  }
  bool same(long long x,long long y){
    return root(x) == root(y);
  }
  void unite(long long x,long long y){
    if(!same(x,y)){
      x = root(x);
      y = root(y);
      if(data[x] < data[y]){
        data[x] += data[y];
        data[y] = x;
      }
      else{
        data[y] += data[x];
        data[x] = y;
      }
    }
    return;
  }
  long long getsize(long long x){
    return -data[root(x)];
  }
};

/* main */

signed main(){
	ll N,M;
	cin >> N >> M;
	UnionFind UF(N);
	ll ans[M];
	ll A[M],B[M];
	FOR(i,0,M){
		cin >> A[i] >> B[i];
		A[i]--;B[i]--;
	}
	ans[M-1] = N*(N-1)/2;
	REP(i,0,M-1){
		ans[i] = ans[i+1];
		if(UF.same(A[i+1],B[i+1]))continue;
		int x = UF.getsize(A[i+1]);
		int y = UF.getsize(B[i+1]);
		UF.unite(A[i+1],B[i+1]);
		ans[i] -= x*y;
	}
	for(auto x:ans)cout << x << endl;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rep3(k,n) for(int k = 0; k < (n); ++k)
#define rep4(l,n) for(int l = 0; l < (n); ++l)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int l[3];
  cin >> l[0] >> l[1] >> l[2];
  if(l[0] == l[1] && l[1] == l[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
	typedef complex<double> com;
	const double eps = 1e-11;
	int n;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if ( abs( ( conj( com( x2 - x1, y2 - y1 ) ) * com( x4 - x3, y4 - y3 ) ).imag() ) < eps )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 1228
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt() - 1;
		}
		UnionFindTree uft = new UnionFindTree(n);
		for (int i = 0; i < m; i++) {
			uft.unite(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (uft.same(i, arr[i])) {
				count++;
			}
		}
		System.out.println(count);
	}
	
	static class UnionFindTree {
		int[] parents;
		public UnionFindTree(int size) {
			parents = new int[size];
			for (int i = 0; i < size; i++) {
				parents[i] = i;
			}
		}
		
		public int find(int x) {
			if (parents[x] == x) {
				return x;
			}
			int ans = find(parents[x]);
			parents[x] = ans;
			return ans;
		}
		
		public boolean same(int x, int y) {
			return find(x) == find(y);
		}
		
		public void unite(int x, int y) {
			int xx = find(x);
			int yy = find(y);
			parents[xx] = yy;
		}
	}
}


Measured memory_bytes: 88992
def main():
    n = int(input())
    alph = [[0 for _ in range(n)] for _ in range(26)]
    for i in range(n):
        s = input()
        for c in s:
            alph[ord(c)-97][i] += 1

    ans = ""
    for i in range(26):
        if all(alph[i][j] >0 for j in range(n)):
            k = min(alph[i])
            ans += chr(97+i) * k
    return ans


if __name__ == '__main__':
    print(main())

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   string s,t; cin>>s>>t;
   int res=inf;
   rep(i,0,s.size()-t.size()+1){
      int cnt=0;
      rep(j,0,t.size())if(s[i+j]!=t[j])cnt++;
      chmin(res,cnt);
   }
   cout<<res<<endl;
   return 0;
}

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

int tmp = 0, ans = 0, N, M, C, A[20][20], B[20];

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

  for(int i = 0; i < M; i++){
    cin >> B[i];
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      tmp += A[i][j] * B[j];
    }
    if(tmp + C > 0)
      ans++;
    tmp = 0;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  rep(i, b) {
    int temp = a * (i + 1) % b;
    if (temp == c) {
      cout << "YES" << endl;
      return;
    }
  }
  cout << "NO" << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3628
/* Not my code */
#include <cstdio>
#include <cstring>
#define N 55
int main(void)
{
	const char *tar = "AKIHABARA";
	char str[N];
	scanf("%s", str);
	int len = strlen(str);
	int i, j = 0;
	for (i = 0; tar[i]; ++i) {
		if (j == len || str[j] != tar[i]) {
			if (tar[i] != 'A') return !printf("NO");
		}
		else ++j;
	}
	printf("%s", j != len ? "NO" : "YES");
}

Measured memory_bytes: 128
a = [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]

k = int(input())
print(a[k-1])

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

ll calc( ll a ) {
    if ( a <= 0 ) return 0;
    ++a;

    ll ans = 0;
    rep(i, 50) {
        ll loop = (1LL << (i + 1));
        ll cnt = ( a / loop ) * ( loop / 2 );
        cnt += max(0LL, ( a % loop ) - ( loop / 2 ) );

        if ( cnt % 2 == 1 ) {
            ans += 1LL << i;
        }
    }
    return ans;
}


int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = calc(b) ^ calc(a-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef struct {
  int i;
  std::string s;
  int p;
} restrant_t;

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<restrant_t> r(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> r.at(i).s >> r.at(i).p;
    r.at(i).i = i + 1;
  }

  std::sort(r.begin(), r.end(), [](const auto &a, const auto &b) {
    if (a.s == b.s)
      return a.p > b.p;
    return a.s < b.s;
  });

  for (auto &i : r)
    std::cout << i.i << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, T;
    cin >> A >> B >> T;
    cout << T / A * B << endl;
    return 0;
}


Measured memory_bytes: 764
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var a=[];
function root(x){return a[x]===x?x:a[x]=root(a[x]);}
function same(x,y){return root(x)===root(y);}
function unite(x,y){x=root(x);y=root(y);if(x===y)return;a[x]=y;}

var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a(), m = o.a();
  var p = o.l();
  for(var i = 0; i <= n; i++)a[i] = i;
  for(i = 0; i < m; i++){
    var t = o.l();
    unite(t[0],t[1]);
  }
  var ans = 0;
  for(i = 1; i <= n; i++){
    if(same(p[i-1],i))ans++;
  }
  return ans;
}

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

#define int int64_t

const int maxn = 100000;

int n, m, v, p;
int a[maxn];
int64_t pref[maxn + 1];

signed main () {
    scanf("%d %d %d %d", &n, &m, &v, &p);
	int ans = 0;
	for (int i = 0; i < n; ++i)
		scanf("%lld", &a[i]);
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; ++i)
		pref[i + 1] = pref[i] + a[i];
	ans = p;
	for (int i = p; i < n; ++i) {
		if (a[i] + m < a[p - 1]) 
            break;
		int64_t cur = v - (n - (i - p + 1));
		if (cur <= 0) {
			++ans;
			continue;
		}
		if (cur * m <= (i - p + 1) * (a[i] + m) - (pref[i] - pref[p - 1]))
			++ans;
	}
	printf("%d \n", ans);
}


Measured memory_bytes: 1792
#include<iostream>
int main()
{
	const int MAX=100;
	using namespace std;
	int n,i,j,index,temp,A[MAX],count;
	count=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>A[i];
	for(i=0;i<n;i++)
	{
		index=i;
		for(j=i;j<n;j++)
			if(A[j]<A[index])
				index=j;
		temp=A[index];
		A[index]=A[i];
		A[i]=temp;
		if(index!=i)
			count++;
	}
	for(i=0;i<n;i++)
		if(i<n-1)
			cout<<A[i]<<' ';
		else
			cout<<A[i];
	cout<<endl<<count<<endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4)== S.at(5)){
    cout << "Yes" << endl;
  }
  
  else{
   cout << "No" << endl;
  }

}

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

int main()
{
	int n;
	cin>>n;
	
	int dp[n];
	int height[n];

	for(int i=0;i<n;i++)		cin >>height[i];

		dp[0]=0;
		dp[1]=abs(height[1]-height[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-2]+abs(height[i]-height[i-2]),dp[i-1]+abs(height[i]-height[i-1]));
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 4460
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=1e6+6,K=1001;
vector<int> kok[K];
vector<int> g[N];
int num[K][K];
int order[N],in[N];
pii bun[N];
int u[N];
int pos=0;
int sos[N];
int ban[K],mark[K];
void dfs(int v){
    u[v]=1;
    for(int to:g[v]){
        if(!u[to])
            dfs(to);
    }
    order[pos++]=v;
}

int32_t main(){
    int n;
    cin>>n;
    int z=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<i;++j){
            bun[z]={i,j};
            num[i][j]=num[j][i]=z++;
        }
    }
    for(int i=1;i<=n;++i){
        int pep=-1;
        kok[i].resize(n-1);
        for(int&x:kok[i]){
            cin>>x;
            int cur=num[i][x];
            if(pep!=-1){g[pep].pb(cur);in[cur]++;}
            pep=cur;
        }
    }
    forn(i,z)if(!u[i])dfs(i);
    set<int> s;
    forn(i,z){
        int v=order[i];
        sos[v]=1;
        for(int to:g[v])if(!sos[to]){
            cout<<"-1\n";
            return 0;
        }
        if(!in[v])s.insert(v);
    }
    int ans=0,pl=0;
    while(pl!=z){
        dbg(pl,"============");
        vector<int> era;
        vector<int> ins;
        pos=0;
        for(int i:s){
            int x=bun[i].f;
            int y=bun[i].s;
            dbg(i,x,y);
            if(!ban[x]&&!ban[y]){
                dbg(x,y);
                pl++;
                ban[mark[pos++]=x]=1;
                ban[mark[pos++]=y]=1;
                era.pb(i);
                for(int to:g[i]){
                    dbg(bun[to].f,bun[to].s,in[to]);
                    if((--in[to])==0){
                        ins.pb(to);
                    }
                }
            }
        }
        for(int i:era)s.erase(i);
        for(int i:ins)s.insert(i);
        forn(j,pos)ban[mark[j]]=0;
        ans++;
    }
    cout<<ans<<'\n';


    return 0;
}


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

int main(){
int N,ans;
  cin>>N;
  ans=10000;
  vector<int>a(N),b(N);
  cin>>a[0];
  b[0]=a[0];
  for(int i=1;i<N;i++){
    cin>>a[i];
  b[i]=a[i]+b[i-1];
  }
    for(int i=0;i<N;i++){
  ans=min(abs(b[N-1]-2*b[i]),ans);
  }
   
      cout<<ans<<endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc150/tasks/abc150_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> P(N), Q(N), A(N);
    REP(i, N) cin >> P[i];
    REP(i, N) cin >> Q[i];
    iota(ALL(A), 1);
    int cnt = 0, cntP = 0, cntQ = 0;
    do {
        if (A == P)
            cntP = cnt;
        if (A == Q)
            cntQ = cnt;
        cnt++;

    } while (next_permutation(ALL(A)));
    cout << abs(cntP - cntQ) << endl;

    return 0;
}


Measured memory_bytes: 3592
n = int(input())

result = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

for i in make_divisors(n):
    x = n//i - 1
    if x!=0:
        if n%x == n//x:
            result+=x

print(result)


Measured memory_bytes: 3264
n=int(input())
ans=[i&-i for i in range(1,n+1)]
def position_zip(a,flag):
  j=1
  d={}
  for i in sorted(a):
    if i in d:continue
    d[i]=j
    j+=1
  if flag==1:return d
  return [d[i] for i in a]
ans=position_zip(ans,0)
for i in range(n-1,-1,-1):print(*ans[:i])

Measured memory_bytes: 3952
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
Edg
int dep[SZ];
void dfs(int x)
{
	vector<int> rs;
	for esb(x,e,b)
		dfs(b),rs.pb(dep[b]);
	sort(rs.begin(),rs.end());
	reverse(rs.begin(),rs.end());
	for(int i=0;i<rs.size();++i)
		dep[x]=max(dep[x],rs[i]+i+1);
}
int main()
{
	int n; scanf("%d",&n);
	for(int i=2;i<=n;++i)
	{
		int x; scanf("%d",&x);
		ad_de(x,i);
	}
	dfs(1); printf("%d\n",dep[1]);
}



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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> s( H );
	for( int i = 0; i < H; i++ ) {
		cin >> s[i];
	}

	if( s[0][0] == '#' || s[H - 1][W - 1] == '#' ) {
		cout << -1 << endl;
		return 0;
	}
	vector<vector<int>> visit( H, vector<int>( W ) );
	typedef pair<int, int> P;
	vector<vector<P>> from( H, vector<P>( W ) );
	int dy[4] = { 1, -1, 0, 0 };
	int dx[4] = { 0, 0, 1, -1 };
	queue<P> que;
	que.push( P( 0, 0 ) );
	visit[0][0] = 1;
	int flag = 0;
	while( !que.empty() ) {
		int y, x;
		tie( y, x ) = que.front();
		que.pop();
		if( y == H - 1 && x == W - 1 ) {
			flag = 1;
			break;
		}
		for( int i = 0; i < 4; i++ ) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if( ny < 0 || ny >= H || nx < 0 || nx >= W ) continue;
			if( s[ny][nx] == '#' ) continue;
			if( visit[ny][nx] ) continue;
			que.push( P( ny, nx ) );
			visit[ny][nx] = 1;
			from[ny][nx] = P( y, x );
		}
	}
	if( flag == 0 ) {
		cout << -1 << endl;
		return 0;
	}
	set<P> st;
	int y = H - 1;
	int x = W - 1;
	while( 1 ) {
		st.insert( P( y, x ) );
		if( y == 0 && x == 0 ) break;
		int ny, nx;
		tie( ny, nx ) = from[y][x];
		y = ny;
		x = nx;
	}
	int ans = 0;
	for( int i = 0; i < H; i ++ ) {
		for( int j = 0; j < W; j++ ) {
			if( s[i][j] == '#' ) continue;
			if( st.count( P( i, j ) ) ) continue;
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    Yes(a == b && b == c);
}

Measured memory_bytes: 256
#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<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
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 Per(i,sta,n) for(int i=n-1;i>=sta;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++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
int cnt[200010];

void solve(){
    cin >> n;
    rep(i,n-1){
        int a;cin >> a;
        cnt[a-1]+=1;
    }
    rep(i,n){
        cout << cnt[i] << endl;
    }
}

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

Measured memory_bytes: 4424
import re,sys
for e in sys.stdin:
 s=any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',e.strip())])
 for i in '0123456789'[s:]:
  if eval(e.replace('X',i).replace('=','==')):print(i);break
 else:print('NA')


Measured memory_bytes: 6568
n, m = map(int, input().split())
h = list(map(int, input().split()))
g = [1]*n
for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] <= h[b-1]:
    g[a-1] = 0
  if h[a-1] >= h[b-1]:
    g[b-1] = 0
print(g.count(1))

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

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

  int i=0;
  int j=0;
  int k=0;

  for (i = 0; i <= S.size()-1; i++) {
    if(S[i]=='A'||S[i]=='T'||S[i]=='C'||S[i]=='G'){
      j +=1;
    }
    else{
      k=max(k,j);
      j=0;
    }


    }

    cout << max(k,j) <<endl;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if (s[2] == s[3] && s[4] == s[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main () {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());
    int alice = 0, bob = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) alice += a[i];
        else bob += a[i];
    }

    cout << alice - bob << endl;
}

Measured memory_bytes: 256
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) {
	   if(B == C) {
		   System.out.print("No");
	   }else {
		   System.out.print("Yes");
	   }
   }else if(A == C) {
	       System.out.print("Yes");
   }else if(B == C) {
           System.out.print("Yes");
   }else {
	   System.out.print("No");

   }

   }

   }



Measured memory_bytes: 21972
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            out.println(n % 500 <= k ? "Yes" : "No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
#define RALL(v) std::rbegin(v), std::rend(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Aug 15 22:15:43 JST 2020
 **/

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

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

template <class Dist, class Key, class Delta>  // Delta: Key from, (Key to, Dist d -> void) update -> void
std::map<Key, Dist> dijkstra(Key s, Delta delta) {
    std::map<Key, Dist> dist;
    using P = std::pair<Dist, Key>;
    std::priority_queue<P, std::vector<P>, std::greater<P>> q;
    q.push({dist[s] = Dist(), s});
    while (!q.empty()) {
        std::pair<Dist, Key> p = q.top();
        q.pop();
        if (dist[p.second] < p.first) continue;
        delta(p.second, [&](Key to, Dist d) -> void {
            if (dist.count(to) && dist[to] <= p.first + d) return;
            q.push({dist[to] = p.first + d, to});
        });
    }
    return dist;
}

bool is_palindrome(const std::string& s) { return s == std::string(s.rbegin(), s.rend()); }
const Int INF = 1e18;
const std::string dummy = "01";
signed main() {
    Int n;
    std::cin >> n;
    auto ss = make_vec<std::string>(2, n, "");
    std::vector<Int> c(n);
    REP(i, n) std::cin >> ss[0][i] >> c[i], ss[1][i] = std::string(RALL(ss[0][i]));
    using Key = std::pair<std::string, bool>;
    auto delta = [&](Key from, auto update) -> void {
        REP(i, n) {
            std::string s = from.first == dummy ? "" : from.first;
            std::string t = ss[!from.second][i];
            bool nxt_b = from.second ^ (s.size() < t.size());
            if (s > t) std::swap(s, t);
            if (s != t.substr(0, s.size())) continue;
            std::string nxt_s = t.substr(s.size(), t.size() - s.size());
            update(Key{nxt_s, nxt_b}, c[i]);
        }
    };
    Key s = {dummy, 0};
    auto res = dijkstra<Int>(s, delta);
    Int ans = INF;
    for (auto& p : res) {
        if (is_palindrome(p.first.first)) chmin(ans, p.second);
    }
    std::cout << (ans == INF ? -1 : ans) << std::endl;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-7
#define endl "\n"
/*ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b%a,a);}
ll modexp(ll x,ll y,ll p)
{ll res=1;x%=p;while(y){if(y&1){res=(res*x)%p;}y=y>>1;x=(x*x)%p;}return res;}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k,x;cin>>k>>x;
    int m=max(-1000000,x-k+1);
    int n=min(1000000,x+k-1);
    rep(i,m,n)
    {
        cout<<i<<" ";
    }

    return 0;

    /*check for long long or int*/
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

    vector<int> A(N);
    rep(i,0,N){
        cin >> A[i];
    }

    i64 ans=0,l=0,b=0;
    vector<int> cnt(30);
    rep(r,0,N){
        while(true){
            bool f=false;
            rep(i,0,20) if((A[r]&(1<<i)) and cnt[i]){
                f=true;
                break;
            }
            if(!f) break;
            rep(i,0,20) if((A[l]&(1<<i))) --cnt[i];
            ++l;
        }
        rep(i,0,20) if(A[r]&(1<<i)) ++cnt[i];
        ans+=r-l+1;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1024
a, b, c = map(int, input().split())
# 最終的にa,b,c全てがなるべき値
# 2ずつ増えるから、(3X-(a+b+c)) / 2が答え
X = 0
# Xは必ずM以上になる
M = max(a, max(b, c))
if (3*M)%2 == (a+b+c)%2:
    X = M
else:
    X = M + 1

print(int((3*X - (a+b+c)) / 2))


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

int main(){
  int N, d;
  int sum = 0;
  cin >> N;

  vector<int> V(N);
  vector<int> C(N);

  for(int i = 0; i<N; i++){
    cin >> V.at(i);
  }
  for(int i = 0; i<N; i++){
    cin >> C.at(i);
    d = V.at(i) - C.at(i);
    if(d>0) sum += d;
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
map< string , int > mp;
int main()
{
	dhoom;
	string s, t; cin >> s >> t;
  int n = s.size();
  vector< vector< int >  > a(26) , b(26);
    for (int i = 0; i < n; i++) {
    a[s[i] - 'a'].push_back(i);
    b[t[i] - 'a'].push_back(i);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  cout << (a == b ? "Yes" : "No") << '\n';
	return 0;
} 



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

int main() {
	int n, k;
	cin >> n >> k;
	int x[100];

	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];

		sum += min(abs(x[i]) * 2, abs(x[i] - k) * 2);
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i, a[5][3], min = 999, minsoe;
	int sum = 0;

	for (i = 0; i < 5; i++) {
		scanf("%d", &a[i][0]);
		a[i][1] = a[i][0] % 10;
		if (a[i][1] != 0 && a[i][1] <= min) {
			min = a[i][1];
			minsoe = i;
		}
	}

	for (i = 0; i < 5; i++) if(i != minsoe) sum = sum + (a[i][0] + 9) / 10 * 10;
	
	sum += a[minsoe][0];

	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
N, M = map( int, input().split())
X = [(0,0,0)]*M
Y = [1]*(N+1)
for i in range(M):
    p,y = map( int, input().split())
    X[i] = (y,p,i)
X.sort()
ANS = ['']*M
for i in range(M):
    y, p, j = X[i]
    ans = '%06d'%p + '%06d'%Y[p]
    ANS[j] = ans
    Y[p] += 1
for i in range(M):
    print(ANS[i])

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

int N, Y;

int main() {
    cin >> N >> Y;
    Y /= 1000;  // So the bills are (10000, 5000, 1000) -> (10, 5, 1).
    int gap = Y - N;

    if (gap < 0) {
        cout << "-1 -1 -1" << endl;
        return 0;
    }

    for (int a = -gap - 1; a <= gap + 1; ++a) {
        int x = 4 * a + gap;
        int y = -9 * a - 2 * gap;
        int z = N - x - y;

        if (x >= 0 && y >= 0 && z >= 0) {
            cout << x << " " << y << " " << z << endl;
            return 0;
        }
    }

    cout << "-1 -1 -1" << endl;
}


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

int main() {
   int N,M;
   cin >> N >> M;
   vector<int> K(M);
   vector<vector<int>> S(M);
   vector<int> P(M);
   for (int i=0; i<M; i++) {
       cin >> K.at(i);
       for (int j=0; j<K.at(i); j++) {
           int s;
           cin >> s;
           S.at(i).push_back(s);
       }
   }
   for (int i=0; i<M; i++) {
       cin >> P.at(i);
   }
   int total=0;
   for (int tmp=0; tmp<(1<<10); tmp++) {
       bitset<10> s(tmp);
       for (int i=0; i<M; i++) {
           int coun=0;
           for (int j=0; j<K.at(i); j++) {
               if (s.test(S.at(i).at(j)-1)) coun++;
           }
           if (coun%2!=P.at(i)) break;
           if (i==M-1) total++;
       }
   }
   for (int i=0; i<10-N; i++) {
       total/=2;
   }
   cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll X, Y;
	cin >> X >> Y;
	for(ll n = 1; ; n++) {
		X *= 2;
		if(X > Y) {
			cout << n << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if (a[0] + a[1] == a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dp[1001][1001];
int path(int i,int j,vector<string> &v)
{
	if(v[i][j]=='#')
	{
		return 0;
	}
  if(i+1==v.size() && j+1==v[0].size())
    return 1;
  else if(i+1==v.size())
  {
    if(dp[i][j+1]==-1)
      dp[i][j+1]=path(i,j+1,v);
    dp[i][j]=dp[i][j+1];
  }
  else if(j+1==v[0].size())
  {
    if(dp[i+1][j]==-1)
      dp[i+1][j]=path(i+1,j,v);
    dp[i][j]=dp[i+1][j];
  }
  else
  {
    if(dp[i+1][j]==-1)
      dp[i+1][j]=path(i+1,j,v);
    if(dp[i][j+1]==-1)
      dp[i][j+1]=path(i,j+1,v);
    dp[i][j]=((long long int)dp[i+1][j]+dp[i][j+1])%mod;
  }
  return dp[i][j];
}
int main()
{
  for(int i=0;i<=1000;i++)
    for(int j=0;j<=1000;j++)
      dp[i][j]=-1;
  int h,w;cin>>h>>w;
  vector<string> v(h);
  for(int i=0;i<h;i++)
    cin>>v[i];
  cout<<path(0,0,v)<<endl;
  return 0;
}
  

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)
#define mod 998244353

map<ll,ll>m;
map<ll,ll>:: iterator it;

int main(void)
{
    fastio;

    ll n,a,ans=0;
    cin >> n;
    while(n--)
    {
        cin >> a;
        m[a]++;
    }
    for(it=m.begin();it!=m.end();it++)
    {
        if((it->second)%2)ans++;
    }
    cout << ans ;

    return 0;
}


Measured memory_bytes: 9752
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
struct edge { int to,w,nxt; } e[N<<1];
int tot=1,h[N];
void adde(int u,int v) {
    e[++tot]=(edge){v,1,h[u]};h[u]=tot;
    e[++tot]=(edge){u,-1,h[v]};h[v]=tot;
}
int n,m,V,E,col[N],cnt[3];
bool vis[N],vise[N];
ll ans=0;
bool flag=0;
void dfs(int u) {
    V++;vis[u]=1;
    cnt[col[u]]++;
    for(int i=h[u];i;i=e[i].nxt) {
        if(vise[i>>1]) continue; vise[i>>1]=1,E++;
        int v=e[i].to;
        if(!vis[v]) col[v]=(col[u]+e[i].w+3)%3,dfs(v);
        else if(col[v]!=(col[u]+e[i].w+3)%3) flag=1;
    }
}
int main() {
	//freopen("flower.in","r",stdin);
	//freopen("flower.out","w",stdout);
    cin>>n>>m;
    for(int i=1,u,v;i<=m;i++) u=gi(),v=gi(),adde(u,v);
    for(int i=1;i<=n;i++)
        if(!vis[i]) {
            V=E=cnt[0]=cnt[1]=cnt[2]=0;flag=0;dfs(i);
            if(flag) ans+=1ll*V*V;
            else if(!cnt[0]||!cnt[1]||!cnt[2]) ans+=E;
            else ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[0];
        }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 8576
n, m = map(int, input().split())
mod = 10**9 + 7
if abs(n-m) > 1:
    ans = 0
elif n == m:
    ans = 2
    for i in range(2, n+1):
        ans = ans*i % mod
    for i in range(2, m+1):
        ans = ans*i % mod
else:
    ans = 1
    for i in range(2, n+1):
        ans = ans*i % mod
    for i in range(2, m+1):
        ans = ans*i % mod
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdint>

int main() {
	std::int64_t n;
	std::cin >> n;

	std::int64_t ans = 1;
	for (std::int64_t i = 1; i <= n; ++i)
		ans = (ans * i) % 1000000007;

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256