akhauriyash/Code-Regression huggingface dataset:
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.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;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var n,s,a,c = 0;
console.log(main());
function main(){
  n = o.a();
  s = o.r(n,1);
  a = xArray(0,n);
  var f = 0;
  for(var i = 0; i < n; i++){
    for(var j = 0; j < n; j++){
      if(s[i][j] === "1"){
        f = a[i] = 1;
        break;
      }
    }
    if(a[i] === 0)c++;
  }
  if(f === 0)return n;
  return solve();
}

function solve(){
  var ans = 0;
  for(var i = 0; i < n; i++){
    if(a[i] === 0)continue;
    var map = xArray(-1,n);
    map[i] = 0;
    var q = [];
    for(var j = 0; j < n; j++){
      if(s[i][j] === "0")continue;
      map[j] = 1;
      q.push(j);
    }
    var u = 1;
    while(q.length){
      var q2 = [];
      while(q.length){
        var t = q.pop();
        for(var j = 0; j < n; j++){
          if(s[t][j] === "0")continue;
          if(map[j] === -1){
            map[j] = u+1;
            q2.push(j);
          }
          else if(map[j] !== u-1 && map[j] !== u+1)return -1;
        }
      }
      u++;
      q = q2;
    }
    if(ans < u)ans = u;
  }
  return ans+c;
}

Measured memory_bytes: 10372
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 100005

int V,E;
vector<int> G[MAX];

int depth[MAX];
int cnt[MAX];
int visited[MAX];

vector<P> ans;

void dfs(int pos,int prev){
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(!visited[to]){
      depth[to]=depth[pos]+1;
      dfs(to,pos);
      cnt[pos]+=cnt[to];
      if(cnt[to]==0)ans.push_back( P( min(pos,to) , max(pos,to) ) );
    }else if(depth[to]<depth[pos]){
      cnt[pos]++;
      cnt[to]--;
    }
  }
}

int main(){
  scanf("%d %d",&V,&E);
  for(int i=0;i<E;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0,-1);
  cout<<ans.size()<<endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define vec vector

int main(void)
{
	while(1) {
		int n, m;
		cin >> n >> m;
		if (n == 0) break;
		vec<int> h(n + 1), w(m + 1);
		h[0] = 0;
		w[0] = 0;
		rep(i, n) {
			int l;
			cin >> l;
			h[i + 1] = h[i] + l;
		}
		rep(i, m) {
			int l;
			cin >> l;
			w[i + 1] = w[i] + l;
		}

		int K = 1500 * 1000;
		vec<int> x(K + 1, 0);
		vec<int> y(K + 1, 0);
		rep(i, n) {
			for (int j = i + 1; j <= n; j++) {
				x[h[j] - h[i]]++;
			}
		}
		rep(i, m) {
			for (int j = i + 1; j <= m; j++) {
				y[w[j] - w[i]]++;
			}
		}
		int ans = 0;
		rep(i, K) {
			ans += x[i + 1] * y[i + 1];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 14492
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];

  long long sum = 0;
  for (int i = 0; i < n; i++) sum += A[i];
  
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] >= (float)sum / (4 * m)) count++; 
  }

  if (count >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
          `-.____`.___ \_____/___.-`___.-'
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    ADITI GOEL IS LOVE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// while(scanf("%d",&n)!=EOF)

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <bits/stdc++.h>
#define ii int64_t
#define lli long long int
#define li long int
#define vi vector<int64_t>
#define mii unordered_map<int64_t,int64_t>
#define nl cout<<"\n"
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
ii n,t,i,j,k,l,x,y,z,cnt=0,sum=0,mx=-INFINITY,mn=INFINITY;
bool f,f1,f2;
using namespace std;
int main()
{fio;
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
    else
        cout<<"No";

    
    
    
    
}



Measured memory_bytes: 256
import numpy as np
from copy import deepcopy

N = int(input())
A = []
A.append(list(map(int, input().split())))
a = deepcopy(A[0])
a.sort()
A.append(a)
A_t = np.array(A).T.tolist()
A_t.sort()

out = []
for i in range(N):
    out.append(str(A_t[i][1]))
print(" ".join(out))


Measured memory_bytes: 55248
<?php
$n = (int)trim(fgets(STDIN));

$list = [];
for ($i=0; $i < $n; $i++) { 
	$node = new TreeNode($i);
	$list[$node->getId()] = $node;
}
for ($i=0; $i < $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$id = (int)$input[0];
	$k = (int)$input[1];
	for ($j=0; $j < $k; $j++) { 
		$list[$id]->addChild((int)$input[$j+2]);
		$list[(int)$input[$j+2]]->setParentId($id);
	}
}
for ($i=0; $i < $n; $i++) { 
	if ($list[$i]->getParentId() === -1) {
		// root
		$curId = $i;
		break;
	}
}
dfs($curId, 0);
$list[$curId]->setType('root');

foreach ($list as $v) {
	echo 'node ' . $v->getId() . ': parent = ' . $v->getParentId() . ', depth = ' . $v->getDepth() . ', '  . $v->getType() . ', [' . implode(', ', $v->getChildren()) . ']' . PHP_EOL;
}




function dfs($id, $depth){
	global $list;
	$list[$id]->setDepth($depth);
	++$depth;
	if($list[$id]->hasChild()){
		$list[$id]->setType('internal node');
		$children = $list[$id]->getChildren();
		foreach ($children as $c) {
			dfs($c, $depth);
		}
	}
}

/**
 * 
 */
class TreeNode
{
	private $id;
	private $parent_id = -1;
	private $children = [];
	private $depth = 0;
	private $type = 'leaf';

	function __construct($id)
	{
		$this->id = $id;
	}

	function setParentId($p_id){
		$this->parent_id = $p_id;
	}
	function addChild($c_id){
		$this->children[] = $c_id;
	}
	function hasChild(){
		return count($this->children) > 0;
	}
	function getId(){
		return $this->id;
	}
	function getParentId(){
		return $this->parent_id;
	}
	function getChildren(){
		return $this->children;
	}
	function setDepth($d){
		$this->depth = $d;
	}
	function addDepth(){
		$this->depth += 1;
	}
	function getDepth(){
		return $this->depth;
	}
	function setType($t){
		$this->type = $t;
	}
	function getType(){
		return $this->type;
	}
}


Measured memory_bytes: 79036
#include <string>
#include <iostream>
using namespace std;
int n, m, a[10], b[2], c[10], dp[10][100]; string s;
int r[10] = { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 };
int main() {
	cin >> n >> s >> m;
	for (int i = 0; i < m; i++) cin >> a[i];
	int v = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '*') b[(n - i - 1) & 1]++;
		else v += (((n - i - 1) & 1) ? r[s[i] - 48] : (s[i] - 48));
	}
	v = (n * 10 - v) % 10; dp[0][0] = 1;
	for (int i = 0; i < b[0] + b[1]; i++) {
		for (int j = 0; j < 100; j++) {
			for (int k = 0; k < m; k++) {
				if (i < b[0]) dp[i + 1][j] += (j >= a[k] ? dp[i][j - a[k]] : 0);
				else dp[i + 1][j] += (j >= r[a[k]] ? dp[i][j - r[a[k]]] : 0);
			}
		}
	}
	int ret = 0;
	for (int i = v; i < 100; i += 10) ret += dp[b[0] + b[1]][i];
	cout << ret << endl;
	return 0;
}

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

using namespace std;

void __start__() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MY
    freopen("/home/ainur/CLionProjects/wow/input.txt", "r", stdin);
    freopen("/home/ainur/CLionProjects/wow/output.txt", "w", stdout);
#else
    //freopen("search.in", "r", stdin);
   // freopen("search.out", "w", stdout);
#endif
}

#define sz(x) (int)x.size()
#define yes cout<<"Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ft first
#define sd second
#define read(a) for(auto &qwqw:a)cin >> qwqw;
#define print(a) for(auto qwqw:a)cout<<qwqw<<' ';
#define print_plus(a) for(auto qwqw:a)cout<<qwqw+1<<' ';
//#define FOR(i, b, n) for(int i=b;i<n;i++) #define FOR(i, n) FOR(i, 0, n) #define FOR(n) FOR(i, 0, n)
mt19937_64 rnd(time(0));
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vb = vector<bool>;
using pii = pair<int, int>;
using vd = vector<long double>;


int log2(int q) {
    int c = 0;
    while (q) {
        q >>= 1;
        c++;
    }
    return c;
}

void test_case() {
    int n;
    cin >> n;
    if (n >= 30)
        yes;
    else
        no;

}

signed main() {
    __start__();
    int Q = 1;
    //cin >> Q;

    while (Q--) {
        test_case();
    }
}





Measured memory_bytes: 3588
//0 と 1 のみから成る 3 桁の番号 s が与えられます。1 が何個含まれるかを求めてください。
#include <iostream>

using namespace std;

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

    int counter = 0;

    for (int i = 0; i < 3; ++i){
        if(s[i] == '1') ++counter;
    }

    cout << counter << endl;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var intN = cin.ReadInt;
          	var intA = cin.ReadInt;
          	var intB = cin.ReadInt;
          
          	var intAllSum = 0 ;
          
          	for(int i = 0 ; i <= intN ; i ++ )
            {
            	var intSepSum = 0 ;
            	foreach(var chrNum in i.ToString()) intSepSum += (int)(chrNum - '0');
              	if ( intA <= intSepSum && intSepSum <= intB ) intAllSum += i ;
            }
          
            WriteLine(intAllSum);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 28088
#include<cstdio>
char s[200001];
int a[200001];
int main(){
    int n;
    scanf("%d%s",&n,s);
    for(int i=0;i<n;i++)a[i]=(s[i]=='.')?1:0;
    for(int i=1;i<n;i++)a[i]+=a[i-1];
    //白い石をすべて黒にする場合
    int ans=a[n-1];
    //0番目からi番目まで白、そのあと黒にする場合
    for(int i=0;i<n;i++){
        int tmp=(i+1-a[i])+(a[n-1]-a[i]);
        if(tmp<ans)ans=tmp;
    }
    printf("%d\n",ans);
    return 0;
}

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define fill(a,p) memset(a,p,sizeof(a))
#define pb push_back
#define mod 1000000007
#define N 100005
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>
#define endl "\n"

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =2005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll minim(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;      
     x = x % p;    
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
            y = y>>1;  
            x = (x*x) % p;   
    } 
    return res; 
}

ll modInverse(ll n,ll p) 
{ 
    return power(n, p-2, p); 
} 


ll lcm(ll a,ll b){
  return (a*b)/__gcd(a,b);
}

bool comp(const point &p1,const point &p2){
	if(p1.first!=p2.first)return p1.first<p2.first;
	else return p1.second<p2.second;
}

string to(char x){
	string s(1,x);
	return s;
}

ll dp[N];

ll rec(ll s,vector<vector<ll>> &graph){
	if(graph[s].size()==0)return 0;
	else if(dp[s]!=-1)return dp[s];
	else{
		ll &ans=dp[s];
		for(ll i=0;i<graph[s].size();i++){
			ans=max(ans,1+rec(graph[s][i],graph));
		}
		return ans;
	}
}

int main()
{
	fio;
	ll n;cin>>n;
	ll m;cin>>m;
	vector<vector<ll>> graph(n);
	f(m){
		ll x,y;cin>>x>>y;
		x--;y--;graph[x].pb(y);
	}
	fill(dp,-1);
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans=max(ans,rec(i,graph));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8576
import java.util.*;

/**
 * A
 */
public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int flag = 0, count = 0;

        int n = sc.nextInt();
        int[] S = new int[n];

        for(int i=0; i<n; i++) {
            S[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int[] T = new int[q];

        for (int i = 0; i<q; i++) {
            T[i] = sc.nextInt();
        }

        sc.close();

        for(int j=0; j<q; j++) {
            flag = 0;
            for(int i=0; i<n; i++) {
                if(S[i] == T[j]) {
                    flag++;
                    break;
                }
            }
            if(flag >= 1) {
                count++;
            } 
        }

        System.out.println(count);

    }
}


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

using namespace std;

int main(void)
{
	char c; cin>>c;
	if(c == 'a') cout<<"vowel"<<endl;
	else if(c == 'i') cout<<"vowel"<<endl;
	else if(c == 'u') cout<<"vowel"<<endl;
	else if(c == 'e') cout<<"vowel"<<endl;
	else if(c == 'o') cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a,b,c,x,y,ans,m,n;
int main(){
	cin>>a>>b>>c>>x>>y;
	if(a+b>2*c){
		if(x>=y){
			m=y*c*2+(x-y)*a;
			n=x*c*2;
			if(m>n) ans=n;
			else ans=m;
		}
		else{
			m=x*c*2+(y-x)*b;
			n=y*c*2;
			if(m>n) ans=n;
			else ans=m;
		}
	}
	else ans=x*a+y*b;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import random

random.seed(0)

def calc_point(point_list, interval, choice):
    point = 0

    for i, day in enumerate(interval):
        point -= c[i] * day

    point += point_list[choice - 1]

    return point

d = int(input())

c = list(map(int,input().split()))

s = []

for _ in range(d):
    temp = list(map(int,input().split()))

    s.append(temp)

choices = [(i % 26) + 1 for i in range(d)]

interval = [0] * 26
result = 0

for i in range(d):
    choice = choices[i]

    interval = [x + 1 for x in interval]

    interval[choice - 1] = 0

    result += calc_point(s[i], interval, choice)

for _ in range(10000):
    temp_choices = choices.copy()
    temp_result = 0

    temp_choices[random.randint(0, d - 1)] = random.randint(1, 26)

    interval = [0] * 26
    
    for i in range(d):
        choice = temp_choices[i]

        interval = [x + 1 for x in interval]

        interval[choice - 1] = 0

        temp_result += calc_point(s[i], interval, choice)

    if temp_result > result:
        choices = temp_choices
        result = temp_result

for choice in choices:
    print(choice)

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

int main() {
  int N,K;
  cin >> N >> K;
  int distance = 0;
  for (int i = 0;i < N;i++){
    int x;
    cin >> x;
    distance += min(x,K - x);
  }
  cout << distance * 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, m, en, d[105][10], s[15];
ll g(ll p) {
	if (p < 1) return 1;
	else return s[p];
}
ll f(ll p, ll q) {
	ll r = 0;
	if (d[p][q] != -1) return d[p][q];
	if (p == n) return (q == en);
	r = (f(p + 1, q) * g(q - 2) * g(m - q - 1)) % M;
	if (q > 1) r = (r + f(p + 1, q - 1) * g(q - 3) * g(m - q - 1)) % M;
	if (q < m) r = (r + f(p + 1, q + 1) * g(q - 2) * g(m - q - 2)) % M;
	return d[p][q] = r;
}
int main()
{
	ll i;
	cin >> n >> m >> en;
	s[0] = 1;
	s[1] = 2;
	for (i = 2; i <= 10; i++) s[i] = s[i - 1] + s[i - 2];
	memset(d, -1, sizeof(d));
	cout << f(0, 1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e16
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    string s;
    while(cin>>s)
    {
        string t1,t2;
        for(int i=0;i<s.size();i++)
        {
            if(i%2==0)t1+='0';
            else t1+='1';

            if(i%2==0)t2+='1';
            else t2+='0';
        }

        int cnt1=0,cnt2=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]!=t1[i])cnt1++;
            if(s[i]!=t2[i])cnt2++;
        }
        pf("%d\n",min(cnt1,cnt2));
    }   
    return 0;
}
 









 




























Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
 
 
int main() {
    int N;
    cin >> N;
    if (N & 1) {
        // Odd
        cout << 2 * N << endl;
    } else {
        cout << N << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from math import factorial
def cmb(n,r):
  return factorial(n) // factorial(r) // factorial(n-r)

def nPr(n, r):
    num = 1
    for i in range(n, n-r, -1):
        num *= i
    return num

n=int(input())
A=list(map(int,input().split()))
num = [0]*(n+1)
base = 0
ans = []
for i in range(n):
  num[A[i]] += 1
for a in num:
  if a > 1:
    base += cmb(a,2)
for a in A:
  ans.append(base-(num[a]-1))
for a in ans:
  print(a)

Measured memory_bytes: 26140
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		String S=sc.next();
		int[] A=new int[4];
		
		for(int i=0;i<4;i++) {
			A[i]=S.charAt(i);
		}
		
		Arrays.sort(A);
		
		if(A[0]==A[1]&&A[2]==A[3]&&A[0]!=A[2]) {
		
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		sc.close();
		
	}
}


Measured memory_bytes: 25044
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AApplePie {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt();
            int p = s.nextInt();
            out.println((a * 3 + p) / 2);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22996
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    int n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    bool ok=1;
    rep(i,n){
        if(a[i]%2!=0) ok=0;
    }
    if(ok) cout<<"second"<<endl;
    else cout<<"first"<<endl;
}

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


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define eps 1.0E-14

ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main()
{
    init();
    //cout << fixed << setprecision(20);
    ld a,b,c; in a>>b>>c;
    if (sqrt(a) + sqrt(b) +eps < sqrt(c)) cout << "Yes";
    else cout << "No";

}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  sort(A.begin(),A.end());
  vector<ll> cum(N+1,0); rep(i,N) cum[i+1]=cum[i]+A[i];
  
  ll ans=1;
  for(int i=N-2;i>=0;i--){
    if(cum[i+1]*2>=A[i+1]) ans++;
    else break;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 

const ll MAX=1e5+1L;
const ll inf=1e18L;
int main()
{
    fastio;
    ll n,w,i,j;
    cin>>n>>w;
    vector<ll>value(n),weight(n);
    for(i=0;i<n;i++) cin>>weight[i]>>value[i];
    vector<vector<ll>>dp(n,vector<ll>(MAX,inf));
    dp[0][0]=0;
    dp[0][value[0]]=weight[0];
    for(i=1;i<n;i++)
        for(j=0;j<MAX;j++)
        {
            if(j>=value[i])
                dp[i][j]=min(dp[i-1][j-value[i]]+weight[i] , dp[i-1][j]);
            else 
                dp[i][j]=dp[i-1][j];
        }
    ll ans=0;
    for(i=MAX-1;i>=0;i--) if(dp[n-1][i]<=w) {ans=i; break;}
    cout<<ans; 
    



    

    
}

Measured memory_bytes: 79488
#include<stdio.h>

int main(void)
{
  int L, R, d;
  scanf("%d %d %d", &L, &R, &d);

  int nL, nR;
  nL = (L-1) / d;
  nR = R / d;

  printf("%d\n", nR-nL);

  return 0;
}


Measured memory_bytes: 1688
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=2e5+1, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,k,q;
	cin>>n>>k>>q;
	vector<ll> v(n+1,k-q);
	while(q--){
		int x;
		cin>>x;
		v[x]++;
	}
	for(int i=1;i<=n;i++){
		cout<<(v[i]>0?"Yes":"No")<<"\n";
	}
	
}


Measured memory_bytes: 1408
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function f(A,B,x)
    return div(A * x , B) - A * (div(x , B))
end

function main()
    A,B,N = parseMap(split(readline()))
    x = min(N,B-1)
    println(max(f(A,B,x),f(A,B,x)))
end




main()

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

int main() {

    int a, b;
    cin >> a >> b;

    if ((a*b)%2 == 1) cout << "Odd" << endl;
    else cout << "Even" << endl;

    return 0;
}

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

bool isPrime(int x){
	if(x == 2)return true;

	if(x % 2 == 0)return false;

	int i = 3;
	while(i <= sqrt(x)){
		if(x % i == 0)return false;
		i++;
	}

	return true;
}

int main(){
	int i,N;
	int Num = 0;

	cin >> N;
	for(i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		if(isPrime(tmp))Num++;
	}

	cout << Num << endl;

	return 0;
}


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


using namespace std;

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double ans;
    if ((a * a * b) / 2. >= x) {
        double tmp = atan((2 * x) / (a * b * b));
        ans = 90 - tmp * (180. / M_PI);
    } else {
        double c, phi;
        c = (2 * (a * a * b - x)) / (a * a * a);
        phi = atan(c);
        ans = phi * (180. / M_PI);
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

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

  int ans = 0;
  REP(i, N){
    int j = A[i];
    if(A[j] == i) ans++;
  }

  cout << ans/2 << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int x,y;
  cin >> x >> y;
  if(x==2||y==2)
  {
    cout << "No" << endl;
    return 0;
  }
  vector<int> vec(4);
  vec = {4,6,9,11};
  int count = 0;
  rep(i,4)
  {
    if(x==vec[i])
    {
      count ++;
    }
    if(y==vec[i])
    {
      count ++;
    }
  }
  if(count == 1)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string side[4],Longitudinal[5];
int mox[2][4]={{0,1,0,-1},{0,0,0,-1}},moy[2][4]={{-1,0,1,0},{-1,0,0,0}};
char str[5]="URDL";
void serch(int x,int y,int then)
{
    if(then==-1)then=3;
    if(x==0&&y==0){
        cout<<endl;
        exit(0);
    }
    for(int i=0;i<4;i++){
        int now=(then+i)%4;
        if(now%2==0){
            if(y+moy[0][now]<5&&y+moy[0][now]>-1&&side[y+moy[1][now]][x]=='1'){
                cout<<str[now];
                serch(x,y+moy[0][now],now-1);
            }
        }
        else{
            if(x+mox[0][now]<5&&x+mox[0][now]>-1&&Longitudinal[y][x+mox[1][now]]=='1'){
                cout<<str[now];
                serch(x+mox[0][now],y,now-1);
            }
        }
    }
}int main()
{
    for(int i=0;i<4;i++)cin>>Longitudinal[i]>>side[i];
    cin>>Longitudinal[4];
    cout<<"R";
    serch(1,0,0);
}

Measured memory_bytes: 1180
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
    ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47500
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

const int INF = 1e9;


// code
// ------------------------------------------------
int main() {
  int n,l;
  cin >> n >> l;

  vector<string> s(n);
  rep(i,n) 
  {
    string b;
    cin >> b;
    s[i] = b;
  }

  sort(all(s));

  rep(i,n) cout << s[i];


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

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



int main()
{
    ll X, Y;
    cin >> X >> Y;
    if(X%Y==0) { cout << -1 << endl; return 0;}
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
ll a,b,c,x,y,i,j,k,cnt,l;
ll ar[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    ll test;
    cin>>test;
    double z=3.1428571428*test*2.0;
    cout<<fixed<<setprecision(20)<<z<<endl;
    return 0;
}



Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,x,m;cin>>n>>m>>x;
  int R=0,L=0;
  for(int i=0;i<m;i++)
  {
    int A[i];cin>>A[i];
    if(A[i]>x){ R++; }
    else if(A[i]<x){ L++; }
  }
  cout<<min(L,R)<<endl;
}
    


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

int main() {
	long long n, sum = 1;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		sum = sum*i%1000000007;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int coin[6]={500,100,50,10,5,1};
  int price;
  int ans;
  int i;
  int f=0;

  while(f==0){
    scanf("%d",&price);

    if(price==0){
      f=1;
    }
    else{
      ans=0;
      price=1000-price;
      for(i=0;i<6;i++){
	ans=ans+price/coin[i];
	price=price%coin[i];
      }
      printf("%d\n",ans);
    }
  }

  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n=0;//カードの枚数読み込み
    char m;
    char M[5]={'S','H','C','D'};
    
    int i,j,x;//アクセス用
    int a[4][13];
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%c",&m);
        scanf("%c %d",&m,&j);
        if(m=='S'){
            a[0][j-1]=14;
        }else if(m=='H'){
            a[1][j-1]=14;
        }else if(m=='C'){
            a[2][j-1]=14;
        }else{
            a[3][j-1]=14;
        }
    }
    
    for(x=0;x<4;x++){
        for(i=0;i<13;i++){
            if(a[x][i]!=14){
                printf("%c %d\n",M[x],i+1);
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2052
def fact(n)
  i = 2
  res = Hash.new(0)
  while i * i <= n
    while n % i == 0
      n /= i
      res[i] += 1
    end
    i += 1
  end
  res[n] = 1 if n != 1
  res
end

def comb(n, k)
  res = 1
  i = n
  while i >= n-k+1
    res *= i
    i -= 1
  end
  while k > 0
    res /= k
    k -= 1
  end
  res
end
MOD = 10**9+7
n, m = gets.split.map(&:to_i)
f = fact(m)
ans = 1
f.each do |k,v|
  ans *= comb(n+v-1, v)
  ans %= MOD
end
p ans


Measured memory_bytes: 3836
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;

int digit_sum(int x) {
  int res = 0;
  while (x != 0) {
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main() {
  cin >> N;
  cout << (N % digit_sum(N) == 0 ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

int n, m;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2;

    return 0;
}


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

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

using namespace std;

typedef pair<int,int> Paint;

bool Pairsecond(const Paint& pf,Paint&ps){//sortCompare
  return pf.second < ps.second;
}

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007


/*
確認ポイント
cout<< (char)数値 //数値にあった文字に置き換えられる
cout<< (double)int型/(2など)//小数になる
length(),size()に括弧をつけ忘れてないか;
sort()が使える型//vector,string...
YesNo大文字小文字間違えてないか
cout << fixed << 小数計算//正しい小数表記になる(基本6桁)(e記法回避にも使える)
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
sqrt(数値型)でrootが取れる
vector.unique()は隣接した同じ要素を削除するので先にソートをする
*/
int main(){
  string s,d;cin>>s>>d;
  int ans = 0;
  for(int i = 0; 3 > i; i++){
    ans +=(s[i]==d[i]?1:0);
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
static const int MAX =100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r,int c){
    stack<int> S;
    S.push(r);
    color[r] = c;
    while( !S.empty() ){
        int u=S.top();S.pop();
        for (int  i = 0;  i < G[u].size() ; ++i) {
            int v=G[u][i];
            if( color[v]==NIL){
                color[v] = c;
                S.push(v);
            }

        }
    }
}

void assignColor(){
    int id=1;
    for (int i = 0; i < n; ++i)  color[i] = NIL;
    for (int u = 0; u < n; ++u)
        if(color[u] == NIL)
            dfs(u,id++);
}

int main(){
    int s,t,m,q;

    cin>>n>>m;

    for (int i = 0; i < m; ++i) {
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin>>q;

    for (int i = 0; i < q; ++i) {
        cin >> s >> t;
        if(color[s]==color[t])  cout<<"yes"<<endl;
        else  cout<<"no"<<endl;


    }
    return 0;
}


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

using namespace std;

int main() {
  string s;cin>>s;
  int n=s.size();
  int ans=0,cnt=0;
  rep(i,n){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      cnt++;
    }
      else cnt=0;
      ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
c = input()[:-1]

n = ord(c)

if 97 <= n:
    print("a")
else:
    print("A")

Measured memory_bytes: 10416
from math import sqrt
N, P = map(int, input().split())
def prime_factorize(n):
    a = []
    N = n
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= N:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

lis = prime_factorize(P)
#print(lis)
if N == 1:
    print(P)
    exit()

else:
    d = [0] * (10 ** 7)
    sq = sqrt(P) + 1
    for i in lis:
        if i < sq:
            d[i] += 1
    #print(d[:24])
    #print(d[103])
    lis2 = []
    for i in reversed(range(10 ** 6 + 5)):
        if d[i] >= N:
            val = d[i] // N
            lis2.append(pow(i,val))
    ans = 1
    for i in lis2:
        ans *= i
    print(ans)


Measured memory_bytes: 118380
#include <iostream>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

bool isBig(int aw, int as, int bw, int bs){
	return as*(bw + bs) < bs*(aw + as);
}

int main(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	map<int,int> wat, sug;
	a *= 100, b *= 100;
	for(int i = 0; i <= 2000; i++){
		if(a*i > f)break;
		for(int j = 0; j <= 2000; j++){
			if(a*i + b*j > f)break;
			wat[a*i + b*j]; 
		}
	}
	for(int i = 0; i < 5000; i++){
		if(c*i > f)break;
		for(int j = 0; j < 5000; j++){
			if(d*j + c*i > f)break;
			sug[c*i + d*j];
		}
	}
	int water = a, sugar = 0;
	for(map<int,int>::iterator i = wat.begin(); i != wat.end(); i++){
		for(map<int,int>::iterator j = sug.begin(); j != sug.end(); j++){
			if(i->first + j->first > f)break;
			if(i->first*e < j->first*100)break;
			if(isBig(water, sugar, i->first, j->first)){
				water = i->first;
				sugar = j->first;
			}
		}
	}
	cout<<water+sugar<<" "<<sugar<<endl;
}



Measured memory_bytes: 384
import java.util.*;
class Main
{
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong();
        long ans=0;
        while(x>4) {
            if (x / 500 > 0) {
                ans += 1000;
                x -= 500;
                continue;
            }
            if (x / 5> 0) {
                ans += 5;
                x -= 5;
                continue;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {

  int n;
  string s;
  cin >> n >> s;
  int cnt = 1;

  REP(i,n-1){
    if(s[i] != s[i+1]) cnt++;
  }

  cout << cnt << endl;
  return 0;

}

Measured memory_bytes: 3736
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   int n,q,p;
   cin >> n;
   int sum=0;
   vector<int> a(n);
   for(int i=0; i<n; i++){
       cin >> a[i] ;
   }
   for(int i=0; i<n; i++){
       cin >> p ;
       if(p<a[i]){
            sum+=-p+a[i];
       }
   }
   cout << sum << 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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll ans = 0;
    rep(i,N){
        cin >> a[i];
        if(i%2==0 && a[i]%2==1){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3568
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);


    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3608