akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;
int is(char c)
{
    if(c == 'a' ||c == 'e'|| c == 'i'|| c =='o' || c =='u'||c == 'y')
        return 1;
    return 0;
}

int f[105];

int main()
{
    int n;

    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&f[i]);
    sort(f,f+n);
    int cnt1 = 0,cnt2 = 0;
    for(int i=0;i<n;i+=2)
    {
        cnt1 += f[i];
        cnt2 += f[i+1];
    }
    printf("%d\n",abs(cnt1-cnt2));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // sqrt()

double ax, ay, ar;
double bx, by, br;

int
solve()
{
	double dx = ax - bx, dy = ay - by;
	double d = sqrt(dx * dx + dy * dy);
	if (d + br < ar)
		return 2;

	if (d + ar < br)
		return -2;

	if (ar + br < d)
		return 0;

	return 1;
}

int
main(int argc, char** argv)
{
	int n;

	scanf("%d", &n);
	while (n--)
	{
		scanf("%lf %lf %lf %lf %lf %lf", &ax, &ay, &ar, &bx, &by, &br);
		printf("%d\n", solve());
	}

	return 0;
}

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

int main(){
  string s;
  cin>>s;
  string h = "";
  for (int i=0;i<5;++i){
    h+="hi";
    if (h==s){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}

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

using namespace std;

const int N = 2e5 + 5, L = 300;

int n;
char s[N];
bool all[L][N];
int nxt[N][26];
int dp[N];
int len;
void solve(int pos) {
	cout << s[pos];
	len --;
	for(int j = 0; j < 26; ++j) {
		int to = nxt[pos + 1][j];
		if(!to) {
			for(; len; --len)cout << char(j + 'a');
			exit(0);
		}
		if(to != 0 && dp[to] == dp[pos] - 1) {
			solve(to);
			return;
		}
	}
}
int main() {
	//freopen("ghiozdan.in", "r", stdin);
	cin >> (s + 1);
	n = strlen(s + 1);
	for(int i = n; i; --i) {
		for(int j = 0; j < 26; ++j) {
			if(s[i] - 'a' == j) nxt[i][j] = i;
			else nxt[i][j] = nxt[i + 1][j];
		}
	}

	for(int i = n; i; --i) {
		dp[i] = n - i + 1;
		for(int j = 0; j < 26; ++j) {
			int to = nxt[i + 1][j];
			dp[i] = min(dp[i], dp[to] + 1);
		}
	}

	int pos = 0;
	for(int j = 0; j < 26; ++j)
    {
        if(!nxt[1][j])
        {
            cout << char(j+'a');exit(0);
        }
    }
	for(int i = 1; i <= n; ++i) {
		if(i != nxt[1][s[i] - 'a'])
			continue;
		if(pos == 0) pos = i;
		else if(dp[i] < dp[pos])pos = i;
		else {
			if(dp[i] == dp[pos] && s[i] < s[pos])pos = i;
		}
	}
	len = dp[pos]+1;
	solve(pos);
}


Measured memory_bytes: 25216
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int r, c;
    cin >> r >> c;
    vector <vector <int> > matrix(r+1, vector<int>(c+1));
    for(int i = 0; i<r; i++){
        for(int j=0; j<c; j++){
            cin >> matrix.at(i).at(j);
            matrix.at(i).at(c) += matrix.at(i).at(j);
            matrix.at(r).at(j) += matrix.at(i).at(j);
            matrix.at(r).at(c) += matrix.at(i).at(j);
        }
    }
    for(int i = 0; i<=r; i++){
        for(int j=0; j<=c; j++){
            cout << matrix.at(i).at(j);
            if(j != c) cout << " ";
        }
        cout << endl;
    }

    // for(int i=0; i<r; i++){
    //     for(int j=0; j<c; j++){
    //         matrix.at(i).at(c) += matrix.at(i).at(j);
    //         matrix.at(r).at(j) += matrix.at(i).at(j);
    //         matrix.at(r).at(c) += matrix.at(i).at(j);
    //     }
    // }

    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,r,g,b;
int main(){
	r=read();
	g=read();
	b=read();
	n=read();
	int ans=0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(i*r+j*g>n)continue;
			int k=n-i*r-j*g;
			if(k%b)continue;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define INF 1000000007

int main(){
  ll n;
  cin >> n;
  ll d[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
  }

  ll count[n+1];
  for(int i=0;i<n+1;i++){
    count[i] = 0;
  }
  if(d[0] != 0){
    cout << 0 << endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    if(d[i] == 0){
      cout << 0 << endl;
      return 0;
    }
    count[d[i]] += 1;
  }

  ll ans = 1;
  int edge = 0;
  for(int i=n-1;i>0;i--){
    if(count[i]!=0){
      edge = i;
      break;
    }
  }

  for(int i=2;i<edge+1;i++){
    for(int c=0;c<count[i];c++){
      ans *= count[i-1];
      ans %= 998244353;
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1792
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	vector<ll> v(n);
	ll sum=0;
	ll tsum=0;
	ll mod=(ll)1e9+7;
	for(int i=0;i<n;++i)
	{
		cin >> v[i];
		sum+=v[i];
		sum%=mod;
		tsum+=v[i]*v[i];
		tsum%=mod;
	}
	sum%=mod;
	sum=(sum*sum)%mod;
	tsum%=mod;
	cout << (((sum-tsum)%mod+mod)%mod*power(2,mod-2,mod))%mod << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


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

using namespace std;

typedef long double ld;
typedef long long ll;

const int M = 100100;

int n, a[M];
int sum = 0;
int b[M];

void read() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum ^= a[i];
    b[i] = a[i] ^ (a[i] - 1);
  }
}

void kill() {
  //cout << ((1 << 31) - 1) << endl;
  int ans = 0;
  for (int i = 30; i >= 0; --i)
    if ((sum >> i) & 1) {
      bool found = false;
      for (int j = 0; j < n; ++j)
        if (b[j] == (1 << (i + 1)) - 1) {
          sum ^= b[j];
          ++ans;
          found = true;
          break;
        }

      if (!found) {
        cout << "-1" << endl;
        exit(0);
      }
    }

  assert(sum == 0);

  cout << ans << endl;
}

int main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();

}



Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int D,c[26],i,j;
	scanf("%d",&D);
	for(i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	int s[D][26];
	for(i=0;i<D;i++){
		for(j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	
	int v[D],t[D],score=0,day[26];
	for(i=0;i<D;i++){
		scanf("%d",&t[i]);
		t[i]--;
	}
	for(i=0;i<26;i++){
	day[i]=-1;
	}
	
	for(i=0;i<D;i++){
		score += s[i][t[i]];
		day[t[i]] = i;;
		for(j=0;j<26;j++){
			score -= c[j]*(i - day[j]);
		}
		v[i]=score;
		printf("%d\n",v[i]);
	}
	return 0;
}

Measured memory_bytes: 1732
s = input()
n = len(s)
table = [0 for _ in range(n + 1)]
for i in range(n):
    table[-2 - i] = (int(s[-1 - i]) * pow(10, i, 2019) + table[-1 - i]) % 2019
count = [0 for _ in range(2019)]
ans = 0
for t in table:
    if count[t] != 0:
        ans += count[t]
    count[t] += 1
print(ans)

Measured memory_bytes: 16480
package main

import (
  "fmt"
  "sort"
)

type data struct {
  s string 
  v, id int
}

type datas []data

func (d datas) Len() int {return len(d)}
func (d datas) Less(i, j int) bool {
  if d[i].s == d[j].s {
    return d[i].v > d[j].v
  }
  return d[i].s < d[j].s
}
func (d datas) Swap(i, j int) {d[i], d[j] = d[j], d[i]}

func main() {
  var n int 
  fmt.Scan(&n)
  d := make(datas, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&d[i].s, &d[i].v)
    d[i].id = i + 1

  }
  sort.Sort(d)
  for i := 0; i < n; i++ {
    fmt.Println(d[i].id)
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    ll ans = 1;
    for (ll x = 1; x * x <= M; x++) {
        if (M % x == 0 && x * N <= M) {
            ans = max(ans, x);
        }
        ll y = M / x;
        if (M % y == 0 && y * N <= M) {
            ans = max(ans, y);
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<ll, ll>;

vector<P> runLength(const vector<ll>& A) {
    vector<P> res;
    ll now = A.front();
    ll cnt = 1;
    rep(i, 1, A.size()) {
        if (A[i] == now) {
            ++cnt;
        } else {
            res.emplace_back(now, cnt);
            now = A[i];
            cnt = 1;
        }
    }
    res.emplace_back(now, cnt);
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    sort(all(A));
    reverse(all(A));
    vector<P> v = runLength(A);
    ll ans = v.front().first * (v.front().second - 1);
    priority_queue<ll> que;
    rep(i, 0, v.front().second) {
        que.push(v.front().first);
    }
    rep(i, 1, v.size()) {
        ll now = v[i].first;
        ll cnt = v[i].second;
        while (cnt && !que.empty()) {
            ll val = que.top();
            que.pop();
            ans += val;
            --cnt;
            que.push(now);
            que.push(now);
        }
    }
    cout << ans << endl;
    return 0;
}

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

signed main(){
	int n,m1,m2,p1,p2;
	cin>>n;
	vector<int>a(n+2),w(n+2);
	a[0]=0;
	a[n+1]=0;
	w[0]=0;
	for(int i=1;i<n+2;i++){
		cin>>a[i];
		w[i]=w[i-1]+abs(a[i]-a[i-1]);
	}
	for(int i=1;i<=n;i++){
		cout<<w[n+1]-(w[i+1]-w[i-1])+abs(a[i+1]-a[i-1])<<endl;
	}
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> T1 pow_(T1 a, T2 b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

vector<int> a;
vector<vector<int> > G;
vector<int> ans;
vector<int> lis;

void dfs(int v, int p) {
  for (int nv : G[v]) {
    if (nv == p) continue;
    int it = lb(lis, a[nv]);
    int i = -1, j = -1;
    if (it == sz(lis)) {
      lis.eb(a[nv]);
      i = sz(lis);
    } else {
      i = it;
      j = lis[it];
      lis[it] = a[nv];
    }
    // cout << v << " " << nv << "  " << lis << endl;
    dfs(nv, v);
    ans[nv] = sz(lis);
    if (i == sz(lis)) {
      lis.pop_back();
    } else {
      lis[i] = j;
    }
  }
}

void solve() {
  int n;
  cin >> n;
  a.resize(n);
  cin >> a;
  G.resize(n);
  ans.resize(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].eb(b);
    G[b].eb(a);
  }
  lis.eb(a[0]);
  dfs(0, -1);
  ans[0] = 1;
  rep(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 30036
#include<bits/stdc++.h>
#define ld long double
using namespace std;


const int N = 105;


int n;
ld x[N], y[N], z[N];
ld ans_x, ans_y, ans_z, ans = 9e18;

ld dist(ld x1, ld y1, ld z1, ld x2, ld y2, ld z2){
    return (x1 - x2) * (x1 - x2) +
           (y1 - y2) * (y1 - y2) +
           (z1 - z2) * (z1 - z2);
}
ld rec(int cur = 0, ld cur_x = 0, ld cur_y = 0, ld cur_z = 0){
    if(cur == 3){
        ld res = 0;
        for(int i = 1; i <= n; i++){
            res = max(res, dist(x[i], y[i], z[i], cur_x, cur_y, cur_z));
        }
        if(res < ans){
            ans = res;
            ans_x = cur_x;
            ans_y = cur_y;
            ans_z = cur_z;
        }
        return res;
    }
    if(cur == 0){
        ld l = -1e4, r = 1e4;
        for(int it = 1; it <= 60; it++){
            ld m1 = l + (r - l) / 3,
               m2 = r - (r - l) / 3;
            if(rec(cur + 1, m1) > rec(cur + 1, m2)){
                l = m1;
            }
            else{
                r = m2;
            }
        }
    }
    else if(cur == 1){
        ld l = -1e4, r = 1e4;
        for(int it = 1; it <= 60; it++){
            ld m1 = l + (r - l) / 3,
               m2 = r - (r - l) / 3;
            if(rec(cur + 1, cur_x, m1) > rec(cur + 1, cur_x, m2)){
                l = m1;
            }
            else{
                r = m2;
            }
        }
        return rec(cur + 1, cur_x, l);
    }
    else if(cur == 2){
        return rec(cur + 1, cur_x, cur_y, 0);
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cout << fixed << setprecision(6);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        z[i] = 0;
    }
    rec();
    cout << sqrtl(ans);
    return 0;
    cout << ans_x << " " << ans_y;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    maps=[]
    n = int(input())
    maps=[list(map(int,input().split())) for _ in range(2)]
    dp=[]
    for i in range(n):
        total=sum(maps[0][:i+1])+sum(maps[1][i:])
        dp.append(total)
    print(max(dp))

if __name__=="__main__":
    main()

Measured memory_bytes: 9136
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

class Point {
	int x;
	int y;

	Point(int a, int b) {
		this.x = a;
		this.y = b;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] map = new char[h][w];
		boolean[][] memo = new boolean[h][w];
		for (int i = 0; i < h; i++) {
			map[i] = sc.next().toCharArray();
		}
		solve(map, memo);
	}

	private static void solve(char[][] map, boolean[][] memo) {
		int cnt = -1;
		int[] dx = { 0, 1, 0, -1 };
		int[] dy = { -1, 0, 1, 0 };
		int w = map[0].length;
		int h = map.length;
		Queue<Point> queue = new ArrayDeque<>();
		for (int i = 0; i < map.length; i++) {
			for (int j = 0; j < map[0].length; j++) {
				if (map[i][j] == '#') {
					queue.add(new Point(j, i));
					memo[i][j] = true;
				}
			}
		}

		while (!queue.isEmpty()) {
			int stop = queue.size();
			for (int k = 0; k < stop; k++) {
				Point p = queue.poll(); //先頭の座標を取得後、削除
				for (int i = 0; i < 4; i++) { //forループで、上下左右に分岐させる
					int x = p.x + dx[i];
					int y = p.y + dy[i];

					//分岐先の座標が、2つのif文の条件を満たすなら先頭に追加
					if (x >= 0 && x < w && y >= 0 && y < h) {
						if (map[y][x] != '#' && !memo[y][x]) {
							queue.add(new Point(x, y));
							memo[y][x] = true; //追加した座標を探索済みにする
						}
					}
				}
			}
			cnt++;
		}
		System.out.println(cnt);
	}
}

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

int n;
int p[112345];
bool f[112345];

int main() {
	cin >> n;
	REP(i, n) scanf("%d", p + i);
	
	REP(i, n) {
		p[i]--;
		if (i == p[i]) f[i] = true;
	}
	
	int ans = 0;
	REP(i, n + 1) {
		if (f[i] && f[i - 1]) { ans++; f[i] = f[i - 1] = false; }
		if (f[i - 1]) { ans++; f[i - 1] = false; }
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


class DisjointSet{
	public:
		vector<int> rank,p;
		DisjointSet(){};
		DisjointSet(int size){
			p.resize(size,0);
			rank.resize(size,0);
			for(int i=0;i<size;i++)makeSet(i);
		}

		void makeSet(int i){
			p[i] = i;
			rank[i] = 0;
		}

		int findSet(int i){
			if(p[i]!=i)p[i]=findSet(p[i]);
			return p[i];
		}

		void unite(int x,int y){
			link(findSet(x),findSet(y));
		}

		void link(int x,int y){
			if(rank[x]>rank[y]){
				p[y]=x;
			}else{
				p[x]=y;
				if(rank[x]==rank[y])rank[y]++;
			}
		}

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



int main()
{
	int n,a,b,q,t;
	scanf("%d %d",&n,&q);
	DisjointSet ds = DisjointSet(n);
	for(int i=0;i<q;i++){
		scanf("%d %d %d",&t,&a,&b);
		if(t==0)ds.unite(a,b);
		else{
			if(ds.same(a,b))printf("1\n");
			else printf("0\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2780
n,a,b,c,d=map(int,input().split())
s=input()
f=0;F=0
for i in range(a,max(c,d)-1):
  if s[i:i+2]=='##':f=1
for i in range(b-2,min(c,d)-1):
  if s[i:i+3]=='...':F=1
if F==0 and c>d:f=1
print('YNeos'[f::2])

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(){
 long a,b;
 cin >> a >> b;
 long c = 1;
 bool B = true;
 vector<int> v(a);
 for(int i=0;i<a;i++)cin >> v[i];
 vector<int> v2(a,-1);
 v2[0] = 0;
    for(long i=0;i<b;i++){
        c = v[c-1];
        if(B){
            if(v2[c-1] == -1)v2[c-1] = i+1;
            else{
            long e = i+1 - v2[c-1];
            long f = (b-i-1)/e;
            i += e*f;
            B = false;
            }
        }
    }
    cout << c << endl;
 }

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a, b; cin >> a >> b;
    for(int i = 1; i < 10000; i++){
        double c = double(i) * 0.08;
        double d = double(i) * 0.10;
        if(a == int(c) && b == int(d)){
            cout << i << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, m;
  cin >> n >> m;
  int a[2010], b[2010];
  vector<int> E[1010], E_rev[1010];
  rep(i, m)
  {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    E[a[i]].push_back(b[i]);
    E_rev[b[i]].push_back(a[i]);
  }

  ll Min = LINF;
  int ans[1010];
  rep(i, m)
  {
    ll d[1010];
    fill(d, d + n, LINF);
    d[b[i]] = 0;
    queue<int> que;
    que.push(b[i]);
    while (!que.empty())
    {
      int q = que.front();
      que.pop();
      for (auto to : E[q])
      {
        if (q == a[i] && to == b[i])
          continue;
        if (d[to] == LINF)
        {
          d[to] = d[q] + 1;
          que.push(to);
        }
      }
    }

    if (d[a[i]] == LINF)
      continue;
    if (Min <= d[a[i]] + 1)
      continue;

    Min = d[a[i]] + 1;
    int v = a[i];
    ans[Min - 1] = a[i] + 1;
    int index = Min - 1 - 1;
    while (v != b[i])
    {
      for (auto to : E_rev[v])
      {
        if (d[v] == d[to] + 1)
        {
          v = to;
          ans[index] = to + 1;
          index--;
          break;
        }
      }
    }
  }
  if (Min == LINF)
  {
    cout << -1 << "\n";
  }
  else
  {
    cout << Min << "\n";
    rep(i, Min) cout << ans[i] << "\n";
  }

  return 0;
}

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

int main(void){
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> v(m);
	vector<pair<int,int>> range(n);
	rep(i,n)range[i]={i,i};
	rep(i,m)cin>>v[i].first>>v[i].second;
	sort(v.begin(),v.end());
	rep(i,m){
		int y=v[i].second;
		range[y-1].second=range[y].second;
		range[y].first=range[y-1].first;
	}
	cout<<range[0].second-range[0].first+1;
	rep1(i,n-1)cout<<" "<<range[i].second-range[i].first+1;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5184
#include <queue>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int dir[] = { 0, 1, 0, -1 };
int H, W, dist[25][25]; string s[25], t;
int main() {
	while (cin >> H >> W, H) {
		int ax = -1, ay = -1, bx = -1, by = -1;
		for (int i = 0; i < H; i++) {
			cin >> s[i];
			for (int j = 0; j < W; j++) {
				if (s[i][j] == 'A') ax = i, ay = j;
				if (s[i][j] == 'B') bx = i, by = j;
			}
		}
		cin >> t;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				dist[i][j] = 999999999;
			}
		}
		queue<pair<int, int> > que; que.push(make_pair(ax, ay)); dist[ax][ay] = 0;
		while (!que.empty()) {
			pair<int, int> u = que.front(); que.pop();
			for (int i = 0; i < 4; i++) {
				int tx = u.first + dir[i], ty = u.second + dir[i ^ 1];
				if (0 <= tx && tx < H && 0 <= ty && ty < W && s[tx][ty] != '#' && dist[tx][ty] == 999999999) {
					dist[tx][ty] = dist[u.first][u.second] + 1;
					que.push(make_pair(tx, ty));
				}
			}
		}
		bool flag = false;
		for (int i = 0; i < 10000; i++) {
			if (dist[bx][by] <= i) {
				cout << i << ' ' << bx << ' ' << by << endl;
				flag = true; break;
			}
			int tx = bx, ty = by;
			if (t[i % t.size()] == '2') tx++;
			if (t[i % t.size()] == '4') ty--;
			if (t[i % t.size()] == '6') ty++;
			if (t[i % t.size()] == '8') tx--;
			if (0 <= tx && tx < H && 0 <= ty && ty < W) bx = tx, by = ty;
		}
		if (!flag) cout << "impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
#define LL long long
LL A[110];
LL gcd(LL a,LL b){
    return b==0?a:gcd(b,a%b);
}
LL lcm(LL a,LL b){
    if(a<b)swap(a,b);
    return a/gcd(a,b)*b;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)cin>>A[i];
    LL ans=1;
    for(int i=1;i<=n;i++)ans=lcm(ans,A[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	long long sum=0;
	while(n--)
	{
		long long x,y;
		scanf("%lld%lld",&x,&y);
		sum=sum+y-x+1;
	}
	printf("%lld\n",sum);

	return 0;
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vector<ll>arr(n);
    for(int i=0; i<n; i++)
     cin>>arr[i];
    sort(arr.begin(),arr.end());
    ll ans=0;
    for(int i=n-k-1; i>=0; i--){
    	ans+=arr[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007

ll a,b,c;

ll solve(vector<ll> &v, ll tmp){
    ll i,j,k;
    ll n=v.size();
    ll s=1e10;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            for(k=0;k<n;k++){
                if(i==j||j==k||k==i) continue;
                s=min(s,tmp+abs(a-v[i])+abs(b-v[j])+abs(c-v[k]));
            }
        }
    }
    return s;
}

int main(){
    ll i,j;
    ll n;
    cin>>n>>a>>b>>c;

    ll l[n];
    for(i=0;i<n;i++) cin>>l[i];

    ll c[n];
    ll ans=1e10;

    for(i=0;i< (1<<(2*n));i++){
        ll ii=i;
        for(j=0;j<n;j++){
            c[j]=ii%4;
            ii=ii/4;
        }
        vector<ll> v;
        ll p=0,q=0,r=0;
        ll tmp=0;

        for(j=0;j<n;j++){
            if(c[j]==0) v.pb(l[j]);
            else if(c[j]==1) {
                if(p>0) tmp+=10;
                p+=l[j];
            }
            else if(c[j]==2) {
                if(q>0)  tmp+=10;
                q+=l[j];
            }
            else {
                if(r>0) tmp+=10;
                r+=l[j];
            }
        }
        if(p>0) v.pb(p);
        if(q>0) v.pb(q);
        if(r>0) v.pb(r);

        
        ans=min(ans,solve(v,tmp));


    }

    cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 256
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

A, B = MAP()
print(A*B)

Measured memory_bytes: 72808
X = int(input())
if 400 <= X and X <= 599:
    print(8)
elif 600<=X and X<=799:
    print(7)
elif 800<=X and X<=999:
    print(6)
elif 1000<=X and X<=1199:
    print(5)
elif 1200<=X and X<=1399:
    print(4)
elif 1400<=X and X<=1599:
    print(3)
elif 1600<=X and X<=1799:
    print(2)
elif 1800<=X and X<=1999:
    print(1)


Measured memory_bytes: 9184
n,a = map(int,input().split())
#
ans = []
for x in range(n + 1):
    for y in range(n + 1 - x):
        z = n - x - y
        if a == 10000*x + 5000*y + 1000*z:
            ans.append([x,y,z])

if len(ans)!=0:
    print(*ans[0])
else:
    print(-1,-1,-1)


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

int main(){
  int n;
  cin >> n;
  vector<pair<string, int>> playlist(n);
  for (int i = 0; i < n; i++) {
    string s;
    int t;
    cin >> s >> t;
    playlist.at(i).first = s;
    playlist.at(i).second = t;
  }

  string playing;
  cin >> playing;
  bool flag = false;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (playlist.at(i).first == playing) {
      flag = true;
      continue;
    }
    if (flag == true) ans += playlist.at(i).second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
W=list(map(int, input().split()))
ans=99999999999

for T in range(0,N):
  S1=W[0:T]
  S2=W[T:N]
  A=sum(S1)
  B=sum(S2)
  ans=min(ans,abs(A-B))

print(ans)

Measured memory_bytes: 3060
def judge(strs)
	strs.length.times do |i|
		next if strs[i] == "U" || strs[i] == "D"
		if i % 2 == 0
			if strs[i] != "R"
				return "No"
			end
		else
			if strs[i] != "L"
				return "No"
			end
		end
	end
	"Yes"
end

strs = gets.chomp.split("")
puts judge(strs)


Measured memory_bytes: 3836
#include<stdio.h>

int map[12][12];

int fill(int i, int j){
    if(!map[i][j]) return 0;
    map[i][j] = 0;
    if(0 <= i-1 && i-1 < 12) fill(i-1, j);
    if(0 <= i+1 && i+1 < 12) fill(i+1, j);
    if(0 <= j-1 && j-1 < 12) fill(i, j-1);
    if(0 <= j+1 && j+1 < 12) fill(i, j+1);
    return 1;
}

int main(void){
    while(1){
        int ans = 0;
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < 12; j++)
                map[i][j] = getchar() == '1';
            getchar();
        }
        for(int i = 0; i < 12; i++)
            for(int j = 0; j < 12; j++)
                if(fill(i, j)) { ans++; }
        printf("%d\n", ans);
        if(getchar() == EOF) return 0;
    }
}


Measured memory_bytes: 2100
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
E = [-1] * 26
for i in range(D):
    ans = -1
    max_v = -float("inf")
    for j in range(26):
        tmp = S[i][j] - (C[j] * (i-E[j]))
        if tmp > max_v:
            ans = j + 1
            max_v = tmp
    E[ans-1] = i
    print(ans)

Measured memory_bytes: 9400
import Data.List

main = do
  getLine
  as <- map read . words <$> getLine :: IO [Integer]
  print $ rect as

rect = calc . group . reverse . sort

calc gs = max (product (map head gs2)) ((head gs4)^2)
  where
    gs2 = headhead1 $ filter ((>=2) . length) gs
    gs4 = head1 $ filter ((>=4) . length) gs

head1 xs = if null xs then [0] else head xs
headhead1 xs = if length xs < 2 then [[0]] else take 2 xs

Measured memory_bytes: 40060
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F3F3F3F3F
#define N 100005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define db double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int dir[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}
int n, a[10000], b[1000][100];
int bit[10000], x;
int main(){

   // IN;
    for(int i = 1; i <= 1024; ++i){
        bit[i] = bit[i & (i - 1)] + 1;
    }
    SC(n);
    FF(i, 1, n){
        int p = 0;
        FF(j, 1, 10){
            SC(x);
            p = (p << 1) + x;
        }
        a[i] = p;
    }
    FF(i, 1, n){
        FF(j, 0, 10) SC(b[i][j]);
    }
    LL ans = -INF;
    for(int s = 1; s < 1 << 10; ++s){
        LL t = 0;
        FF(j, 1, n){
            int x = a[j] & s;
            t += b[j][bit[x]];
        }
        if(t > ans) ans = t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {
  val nums = readLine.split(" ").map(_.toLong)
  val eightTax = nums(0)
  val tenTax = nums(1)

  val ans = Range.inclusive(0, 1300).find ( orig =>
    Math.floor(orig.toDouble * 0.08) == eightTax && Math.floor(orig.toDouble * 0.1) == tenTax
  )

  println(ans.getOrElse(-1))
}



Measured memory_bytes: 27052
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    int n,m;
    cin >> n >> m;
    long long int sum = (n*(n-1))/2 + (m*(m-1))/2;
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int vis[2001],dist[2001][2001];
vector<int> tree[2001];
void bfs(int n)
{
     queue<int> nodes;
     nodes.push(n);
     vis[n]=1;
     while(!nodes.empty()){
        int centr=nodes.front();
        nodes.pop();
        for(int i=0;i<tree[centr].size();i++){
            int v=tree[centr][i];
            if(vis[v]==0){
                vis[v]=1;
                dist[n][v]=1+dist[n][centr];
                nodes.push(v);
            }
        }
     }
}
int cnt[2001];
int main()
{
    int i,j,k;
    int n,x,y;
    scanf("%d %d %d",&n,&x,&y);
    for(i=1;i<n;i++){
        tree[i].pb(i+1);
        tree[i+1].pb(i);
    }
    if(x+1!=y){
        tree[x].pb(y);
        tree[y].pb(x);
    }
    for(i=1;i<=n;i++){
        memset(vis,0,sizeof vis);
        bfs(i);
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            cnt[dist[i][j]]++;
    }
    }
    for(i=1;i<n;i++)
        printf("%d\n",cnt[i]/2);
}


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

#define ll  long long int
#define ld  long double
#define MAX 1000001
#define MOD 1000000007
#define pi  3.14159265358979323846264338
#define mp  make_pair
#define pb  push_back
#define pll pair<ll,ll>
#define vl  vector<ll>
#define vi  vector<int>
#define vs  vector<string>
#define vc  vector<char>
#define fst first
#define sec second
#define foi(i, a, b)   for(ll i = a; i<b;i++)
#define fod(i, a, b)   for(ll i = a;i>=b;i--)
#define all(v)         (v).begin(), (v).end()
#define max3(a, b, c)  max(max(a,b), c)
#define min3(a, b, c)  min(min(a,b), c)
#define ump  unordered_map<ll,ll>
#define us   unordered_set<ll>
#define nl  "\n"
#define INF  (ll)1e18
#define s(v) (ll)(v).size()
#define e(v) (v).empty

using namespace std;

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

ll power(ll x, ll y) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = (power(x, y/2)%MOD); 
    if (y%2 == 0) 
        return ((temp)*(temp))%MOD; 
    else
        return ((x)*(temp)*(temp))%MOD; 
}

void dfs(vector<vector<int>>& adj,vector<int>& visited,vector<int>& dp,int i){
    visited[i] = 1;
    
    for(int child : adj[i]){
        if(!visited[child]){
            dfs(adj,visited,dp,child);
        }
        dp[i] = max(dp[i],1 + dp[child]);
    }

}

void solve(){   
    int n,m;
    cin>>n>>m;

    vector<vector<int>> adj(n+1);
    int x,y;

    foi(i,0,m){
        cin>>x>>y;
        adj[x].pb(y);
    }
    vector<int> dp(n+1,0);
    vector<int> visited(n+1,0);
    foi(i,1,n+1){
        if(!visited[i]){
            //cout<<i<<"\n";
            dfs(adj,visited,dp,i);
        }
    }
    int ans = 0;
    foi(i,0,n+1){
        ans = max(ans,dp[i]);
    }
    cout<<ans<<"\n";

}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12940
//#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

#include <iostream>
using namespace std;

const int MAX  = 2e5 + 10;

int main() {
	char a[MAX], b[MAX];
	int count = 0;
	cin >> a >> b;
	for(int i = 0; i < strlen(b); i++) {
		if (a[i] != b[i]) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4020
import queue
K = int(input())
q = queue.Queue()

for i in range(1, 10):
  q.put(i)

# print(list(q.queue))

for i in range(1, K):
  x = q.get()
  modx10 = x % 10
  if modx10 != 0:
    q.put(10 * x + modx10 - 1)
  q.put(10 * x + modx10)
  if modx10 != 9:
    q.put(10 * x + modx10 + 1)
  
  #print(i, x, list(q.queue)[len(q.queue)-10:])
print(q.get())

Measured memory_bytes: 12480
local n, m = io.read("*n", "*n")
local parent = {}
for i = 1, n do
  parent[i] = i
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

for i = 1, m do
  local a, b = io.read("*n", "*n")
  local ra, rb = uf_findroot(a), uf_findroot(b)
  parent[rb], parent[b] = ra, ra
end
local g = {}
for i = 1, n do
  local r = uf_findroot(i)
  g[r] = true
end
local ret = -1
for k, v in pairs(g) do ret = ret + 1 end
print(ret)


Measured memory_bytes: 4428
import sys
input = sys.stdin.readline
N,K,Q = map(int,input().split())
A = [0] * Q
for i in range(Q):
    A[i] = int(input())
    
judge = [K-Q] * N
for j in A:
    judge[j-1] += 1

for k in judge:
    if k > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 48092
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <climits>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  stack<char> stack;
  string S; cin >> S;
  int ans = S.size();
  for (char c : S) {
    if (stack.empty()) {
      stack.push(c);
    } else if (stack.top() != c) {
      stack.pop();
    } else {
      stack.push(c);
    }
  }
  ans -= stack.size();
  while (!stack.empty()) {
    // cout << stack.top() << endl;
    stack.pop();
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
import heapq


class TwoDimPriorityQueue():
    def __init__(self, num_queues):
        self.queues = [[] for i in range(0, num_queues, 1)]

    def insert(self, t, x):
        heapq.heappush(self.queues[t], (-1) * x)
        return self

    def getMax(self, t):
        if len(self.queues[t]) > 0:
            return (-1) * self.queues[t][0]
        return None

    def deleteMax(self, t):
        if len(self.queues[t]) > 0:
            heapq.heappop(self.queues[t])
        return self


num_queues, num_op = map(int, input().split(' '))
queues = TwoDimPriorityQueue(num_queues)

for op in range(0, num_op):
    op = tuple(map(int, input().split(' ')))
    if op[0] == 0:
        queues.insert(op[1], op[2])
    elif op[0] == 1:
        max_number = queues.getMax(op[1])
        if max_number != None:
            print(f'{max_number}')
    elif op[0] == 2:
        queues.deleteMax(op[1])


Measured memory_bytes: 13656
import collections

n,m=map(int,input().split())
a,b,c=[],[],[]
for i in range(m):
    A=list(map(int,input().split()))
    a.append(A)
for i in range(m):
    if a[i][1]==n:
        b.append(a[i][0])
    elif a[i][0]==1:
        c.append(a[i][1])
if len(set(b)&set(c))>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 54780
#include "bits/stdc++.h"
using namespace std;

int main() {

	string s, t;
	cin >> s;
	cin >> t;

	sort(s.begin(), s.end());
	
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N,a,b,c;
    scanf("%d",&N);
    for (int i=0; i<N; i++) {
        scanf("%d %d %d",&a,&b,&c);
        int max=a;
        if (max<b) {
            max=b;
        }
        if (c>max) {
            max=c;
        }
        if (max*max ==(a*a) + (b*b) + (c*c) - (max * max)) {
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
        
    }
    return 0;
}


Measured memory_bytes: 2040
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		if (s.equals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");

		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<bool> toll(N+1, false);
  for(int i=0;i<M;i++) {
    int a;
    cin >> a;
    toll[a] = true;
  }

  int cost1 = 0;
  int cost2 = 0;
  for(int i=X;i>=0;i--) {
    if(toll[i]) {
      cost1++;
    }
  }
  for(int i=X;i<N+1;i++) {
    if(toll[i]) {
      cost2++;
    }
  }

  if(cost1 < cost2) {
    cout << cost1 << endl;
  } else {
    cout << cost2 << endl;
  }
}

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

int main() {
  int N, cnt = 0;
  cin >> N;
  for (int i = 1; i <= N; i += 2) {
    vector<int> inprime(6);
    int tmp = i;
    while (tmp % 3 == 0) {
      inprime.at(0)++;
      tmp /= 3;
    }
    while (tmp % 5 == 0) {
      inprime.at(1)++;
      tmp /= 5;
    }
    while (tmp % 7 == 0) {
      inprime.at(2)++;
      tmp /= 7;
    }
    while (tmp % 11 == 0) {
      inprime.at(3)++;
      tmp /= 11;
    }
    while (tmp % 13 == 0) {
      inprime.at(4)++;
      tmp /= 13;
    }
    if (tmp != 1) {
      inprime.at(5)++;
    }
    int yaku_num = 1;
    for (int j = 0; j < 6; j++) {
      yaku_num *= inprime.at(j) + 1;
    }
    if (yaku_num == 8) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
// finish date: 2018/04/10

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    vi val(3);
    rep(i, 3) cin >> val[i];
    sort(val.begin(), val.end(), greater<int>());
    int ma, x, y;
    ma = val[0];
    x = val[1];
    y = val[2];
    int ans = 0;
    ans += (ma - x) / 2;
    x += ((ma - x) / 2) * 2;
    ans += (ma - y) / 2;
    y += ((ma - y) / 2) * 2;
    if (x == ma && y == ma) cout << ans << endl;
    else if (ma > x && ma > y) cout << ans + 1 << endl;
    else cout << ans + 2 << endl;


    return 0;
}

Measured memory_bytes: 256
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;
const int MOD = 1e9 + 7;


int main() {
    int n, m; cin >> n >> m;

    vector<int> a(m);
    for (int i=0; i<m; i++) {
        cin >> a[i];
    }

    int t = 0;
    vector<int> b(n+1, 0);

    for (int cur=0; cur<=n; cur++) {
        // cout << "if1" << endl;
        if (m != 0 and a[t] == cur) {
            t++;
            continue;
        }

        // cout << "if2" << endl;
        if (m == 0 or (t <= m and a[t] != cur+1)) {
            if (cur == 0 and cur+1 <= n) b[cur+1] = 1;
            if (cur+1 <= n and b[cur] != 0) {
                b[cur+1] += b[cur];
                b[cur+1] %= MOD;
            }
        }

        // cout << "if3" << endl;
        if (m == 0 or (t <= m and a[t] != cur+2)) {
            if (cur == 0 and cur+2 <= n) b[cur+2] = 1;
            if (cur+2 <= n and b[cur] != 0) {
                b[cur+2] += b[cur];
                b[cur+2] %= MOD;
            }
        }
    }

    b[n] %= MOD;
    cout << b[n] << endl;
    return 0;
}



Measured memory_bytes: 1024