akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> sheetInfo = new ArrayList<Integer>();
		for(int i = 0;i < n;i++) {
			sheetInfo.add(sc.nextInt());
		}
		Collections.sort(sheetInfo);
		int answer =0;
		int numberCount = 1;
		int beforeNumber = sheetInfo.get(0);
		for(int i=1;i < n;i++) {
			if(beforeNumber == sheetInfo.get(i)) {
				numberCount++;
				if(i == n-1) {
					if(numberCount %2 ==1) {
						answer++;
					}
				}
			}else {
				if(numberCount %2 ==1) {
					answer++;
				}
				numberCount = 1;
				beforeNumber = sheetInfo.get(i);
				if(i == n-1) {
					answer++;
				}
			}
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 58740
#include<iostream>

using namespace std;

int a,b,mem,o1,o2,o3;

int main(){
	while(1){
	o1=0;
	o2=0;
	o3=0;
	cin>>a>>b;
	if(a==0&&b==0) break;
	mem=b-a;
	if(mem>=1000){
		o3+=mem/1000;
		mem-=1000*o3;
	}
	if(mem>=500){
		o2+=mem/500;
		mem-=500*o2;
	}
	o1=mem/100;
	cout<<o1<<" "<<o2<<" "<<o3<<endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
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 chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void)
{
    string s;
    cin >> s;
    if (s[2] != s[3] || s[4] != s[5]) {
        printf("No");
        return 0;
    }
    
    printf ("Yes");
    
    
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    ll n,m;
    cin>>n>>m; ;
    ll cnt=0;
    if(n>=m/2){
        cnt=m/2;
    }
    else {
        cnt+=n;
        m-=2*n;
        cnt+=m/4;
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int a[N];
bool b[N];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int ta=0;
    for(int x,y,i=0;i<m;i++) {
        scanf("%d%d",&x,&y);
        if(x==1) a[ta++]=y;
        else if(y==n) b[x]=true;
    }
    for(int i=0;i<ta;i++)
        if(b[a[i]]) {
            printf("POSSIBLE\n");
            return 0;
        }
    printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int x,y;
		while(true) {
			int H=scan.nextInt();
			int W=scan.nextInt();
			if(H == 0 && W == 0) break;
			for(y=0;y<H;y++) {
				for(x=0;x<W;x++) {
				if((x+y)%2 == 0) {
					System.out.printf("#");
				}
				else{
						System.out.printf(".");
				}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
		scan.close();
}
}


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

#define FOR(i, s, e) for (int (i) = (s); (i) < (e); (i)++)

int main() {
    int N, K; cin >> N >> K;
    vector<char> S(N); FOR(i, 0, N) cin >> S[i];

    int a[1000100] = {0};
    a[0] = 1;
    int j = 0;
    FOR(i, 1, N) {
        if(S[i] == S[i - 1]) a[j]++;
        else {
            j++;
            a[j]++;
        }
    }

    int ans =0;
    if(S[0] == '0' ) {
        FOR(i, 0, 2*K) ans += a[i];
        int ab=ans-a[0]+a[2*K]+a[2*K+1];
        ans=max(ans, ans-a[0]+a[2*K]+a[2*K+1]);
        FOR(i, 1, j) {
            ab=ab-a[2*i]-a[2*i-1]+a[2*K+2*i+1]+a[2*K+2*i];
            ans=max(ans,ab);
        }
    }
    if(S[0] == '1' ) {
        FOR(i, 0, 2*K+1) ans += a[i];
        int ac=ans-a[0]-a[1]+a[2*K+1]+a[2*K+2];
        ans=max(ans, ans-a[0]-a[1]+a[2*K+1]+a[2*K+2]);
        FOR(i, 1, j) {
            ac=ac-a[2*i]-a[2*i+1]+a[2*K+2*i+1]+a[2*K+2*i+2];
            ans=max(ans,ac);
        }

    }

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


}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int n; cin >> n;
	int x; cin >> x;
	if(x == 1 || x == 2 * n - 1){
		printf("No\n");
	}else{
		printf("Yes\n");
		/*
		int now = 1;
		for (int i = 1; i <= n - 2; ++i){
			if(now == x || now == x - 1 || now == x - 2){
				i--;
				now++;
			}
			else{
				printf("%d\n", now);
				now++;
			}
		}
		*/
		set<int> s;
		s.insert(x - 1);
		s.insert(x);
		s.insert(x + 1);
		int now = 0;
		for (int i = 1; i < 2 * n; ++i)
		{
			if(now == n - 2) break;
			if(s.count(i) == 0){
				printf("%d\n", i);
				now++;
				s.insert(i);
			}
		}

		printf("%d\n", x - 1);
		printf("%d\n", x);
		printf("%d\n", x + 1);
		for (int i = 1; i < 2 * n; ++i)
		{
			if(s.count(i) == 0){
				printf("%d\n", i);
				s.insert(i);
			}
		}
		/*
		for (int i = 1; i <= n - 2; ++i){
			if(now == x || now == x - 1 || now == x - 2){
				now++;
				i--;
			}
			else{
				printf("%d\n", now);
				now++;
			}
		}
		*/
	}
	return 0;
}

Measured memory_bytes: 11008
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		
		if((A <= C && C <= B) || (B <= C && C <= A)) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := newScanner()
	S := sc.next()
	if len(S) < 4 {
		fmt.Println("No")
		return
	}
	if strings.HasPrefix(S, "YAKI") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}
	return result
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int a, b;
    cin >> a >> b;
    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    } else {
        if (b < 0) {
            if ((b - a + 1) % 2 == 0) {
                cout << "Positive" << endl;
            } else {
                cout << "Negative" << endl;
            }
        } else {
            cout << "Positive" << endl;
        }
    }
}

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

Measured memory_bytes: 256
from collections import defaultdict
a = int(input())
dic = defaultdict(int)
l = []
for i in range(a):
    l.append("".join(sorted(list(input()))))
    dic[l[-1]]+=1
s = 0
L = set(l)
for j in L:
    i = dic[j]
    s+=i*(i-1)/2
print(int(s))


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int h, w, n, a, ans[100][100], hi = 0, wi = 0, f = false;
  cin >> h >> w >> n;

  rep(i, 1, n + 1) {
    cin >> a;
    rep(j, 0, a) {
      ans[hi][wi] = i;
      f ? wi-- : wi++;
      if(wi == w || wi == -1) {
        hi++;
        f = !f;
        if(wi == w) wi--;
        else wi++;
      }
    }
  }

  rep(i, 0, h) {
    rep(j, 0, w) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}


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

int main() {
long long k;
cin>>k;
long long ans=0;
if(k%2==0||k%5==0){
    ans=-1;
}
else if(k==7||k==1){
    ans=1;
}
else{
    long long temp=7;
    long long temp2=1;

    for(long long i=1;i<10*k;i++){
        temp2=(temp2*10)%k;
        temp+=(7*temp2)%k;
        temp=temp%k;
        if(temp==0){
            ans=i+1;
            break;
        }
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl '\n';
#define all(v) ((v).begin()), ((v).end())
#define sz(s)               (int)s.size()
#define Ceil(x,y)             ((x+y-1)/y)
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define vi                    vector<int>
#define pii                 pair<int,int>
#define fx(n)           fixed<<setprecision(n)
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define forr(i, n) for (int i = 0; i < int(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e7 + 5, MOD = 1e9 + 7;
using namespace std;
void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); }
int main()
{
	fast();
	ll n;
	cin>>n;
	cout<<(n*(n+1))/2<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n; cin >> n;
  int a[100050];
  for(int i=0;i<n;i++) cin >> a[i];
  int ans=0;
  int count=0;
  for(int i=0;i<n-1;i++){
    if(a[i]>=a[i+1]) count++;
    else{
      if(count>=ans) ans = count; 
      count=0;
    }
  }
  if(count>=ans) ans = count; 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  static int n, k;
  static int[] d;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

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

    int i = n;
    for(;;){
      String str = Integer.toString(i);
      boolean check = true;
      for(int j = 0; j < str.length(); j++){
        for(int l = 0; l < k; l++){
          if(d[l] == str.charAt(j) - '0'){
            check = false;
            break;
          }
        }
        if(!check){
          break;
        }
      }
      if(check){
        break;
      }
      ++i;
    }

    System.out.println(i);
  }
}


Measured memory_bytes: 14868
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

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

using namespace std;
int main(){
  string s;
  int sou=0;
  cin >> s;
  for(char c : s){
	if(c == '+'){
	  sou ++;
	}
	else{
	  sou --;
	}
  }
  cout << sou << endl;
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll n,k;
ll ans=LINF;
void dfs(ll v, ll cnt){
  if(cnt==0) {
    chmin(ans, v);
    return;
  }
  
  dfs(v*2, cnt-1);
  dfs(v+k, cnt-1);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  cin>>n>>k;
  
  dfs(1,n);
  cout<<ans<<endl;
}

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

int main() {
    string s;
    cin >> s;
    vector<bool> b_v(26);

    rep(i, s.size()) {
        b_v.at(s.at(i) - 'a') = true;
    }

    int ans = 0;
    int i;
    for (i = 0; i < b_v.size(); i++) {
        if (b_v.at(i) == false) {
            ans = i;
            break;
        }
    }
    
    if (i == b_v.size())
        cout << "None" << endl;
    else
        cout << (char)('a' + ans) << endl;

    return 0;
}

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

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

  int count = 0;
  for (int i = a; i <= b; i++) {
    int q = i;

    int r1 = q % 10;
    q = q / 10;

    int r2 = q % 10;
    q = q / 10;

    // int r3 = q % 10;
    q = q / 10;

    int r4 = q % 10;
    q = q / 10;

    int r5 = q % 10;
    // q = q / 10;

    if (r1 == r5 && r2 == r4) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#!ruby -n
n = []
x = 0
y = 0
n, s, w, e = false
$_.each_char do |c|
  if c == "N"
    y = y + 1
    n = true
  elsif c == "S"
    y = y - 1
    s = true
  elsif c == "W"
    x = x + 1
    w = true
  elsif c == "E"
    x = x - 1
    e = true
  end
end

xt = (w && e) || (!w && !e)
yt = (n && s) || (!n && !s)

if xt && yt
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll combination(ll, ll);
int main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1)*(b - 1);
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (1<<30);
const int MAX = 55;
int d[MAX][MAX];
char s[MAX][MAX];
int v1[4] = {0, 1, 0, -1};
int v2[4] = {1, 0, -1, 0};

void bfs(pair<int, int> p){
    queue<pair<int, int>> q;
    q.push(p);
    for(int i=0; i<MAX; i++) for(int j=0; j<MAX; j++) d[i][j] = INF;
    d[1][1] = 0;

    while(!q.empty()){
        pair<int, int> u = q.front(); q.pop();
        for(int i=0; i<4; i++){
            if(s[u.first + v1[i]][u.second + v2[i]] == '.' && d[u.first + v1[i]][u.second + v2[i]] == INF){
                d[u.first + v1[i]][u.second + v2[i]] = d[u.first][u.second] + 1;
                q.push({u.first + v1[i], u.second + v2[i]});
            }
        }
    }

}


int main(){
    int H, W; cin >> H >> W;
    int black = 0;

    for(int i=0; i<H+5; i++) for(int j=0; j<W+5; j++) s[i][j] = '#';
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++){
        char c; cin >> c; s[i][j] = c;
        if(c == '#') black++;
    }

    bfs({1, 1});

    if(d[H][W] == INF) cout << -1 << endl;
    else cout << W*H - black - (d[H][W] + 1) << endl;
    
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int ans = __gcd(a[0], a[1]);
    for (int i = 1; i < n; ++i)
    {
        ans = __gcd(ans, a[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())
ans = []
for ss in set(s):
    ans.append(s.count(ss) - t.count(ss))
p = max(ans) if max(ans) > 0 else 0
print(p)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

const int MAX=500;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
int dp[MAX][MAX];

int main(){
    int H,W;
    cin>>H>>W;
    vector<string> s(H);
    rep(i,H) cin>>s[i];
    auto id=[&](int x,int y) {return x*W+y;};

    rep(i,MAX){
        rep(j,MAX) dp[i][j]=INF;
        dp[i][i]=0;
    }

    rep(x,H){
        rep(y,W){
            if(s[x][y]=='#') continue;
            for(int dir=0;dir<4;dir++){
                int nx=x+dx[dir],ny=y+dy[dir];
                if(nx<0 || nx>=H || ny<0 || ny>=W || s[nx][ny]=='#') continue;
                dp[id(x,y)][id(nx,ny)]=1;
                dp[id(nx,ny)][id(x,y)]=1;
            }
        } 
    }

    int V=H*W;
    rep(k,V){
        rep(i,V){
            rep(j,V){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }

    int res=0;
    rep(x,H){
        rep(y,W){
            if(s[x][y]=='#') continue;
            rep(x2,H){
                rep(y2,W){
                    if(s[x2][y2]=='#') continue;
                    res=max(res,dp[id(x,y)][id(x2,y2)]);
                }
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
const int L = 1000006;
ll spf[L+10];
void soe()
{
	ll i,j;

	spf[1]=1;
	for(i=2;i<=L;i++)
	{
		if(spf[i]==0)
		{
			for(j=i;j<=L;j+=i)
			{
				if(spf[j]==0)
					spf[j]=i;
			}
		}
	}
}
unordered_map<ll,ll> factorise(ll x)
{
	unordered_map<ll,ll> mq;
	while(x>1)
	{
		mq[spf[x]]++;
		x=x/spf[x];
	}
	return mq;
} 
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,i;
	soe();
	cin>>n;
	ll a[n+2];
	for(i=0;i<n;i++)
		cin>>a[i];
	ll gcd=a[0];
	for(i=1;i<n;i++)
		gcd = __gcd(gcd, a[i]);
	unordered_map <ll,ll> x;
	for(i=0;i<n;i++)
	{
		unordered_map <ll,ll> sub = factorise(a[i]);
		for(auto y:sub)
		{
			x[y.ff] += y.ss;
		}
	}
	ll ff=0;
	for(i=0;i<n;i++)
	{
		unordered_map <ll,ll> sub = factorise(a[i]);
		ll f=0;
		for(auto y:sub)
		{
			ll p = x[y.ff] - y.ss;
			if(p!=0)
			{
				f=1;
				break;
			}
		}
		if(f==1)
		{
			ff=1;
			break;
		}
	}
	if(ff==0)
		cout<<"pairwise coprime";
	else if(gcd==1)
		cout<<"setwise coprime";
	else
		cout<<"not coprime";
	cout<<nl;
	// unordered_map <ll,ll> x = factorise(35280);
	// for(auto y:x)
	// 	cout<<y.ff<<" "<<y.ss<<nl;

	return 0;
}


Measured memory_bytes: 22256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    T operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class U>
class Input<vector<U>> {
public:
    vector<U> operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    vector<U> operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class T>
T input() {
    Input<T> i{};
    return i();
}

int main() {
    Input<size_t> in{};
    auto a = in();
    auto b = in();
    auto c = in();
    auto x = in();
    auto y = in();
    size_t d = 0;
    if (2 * c < a + b) {
        while (x > 0 && y > 0) {
            --x;
            --y;
            d += 2 * c;
        }
    }
    d += min(a * x + b * y, 2 * c * max(x, y));
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define int long long
using namespace std;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N + 1), B(N);
    for (int i = 0; i < N + 1; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
    
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        A[i] -= B[i];
        cnt += B[i];
        B[i] = 0;
        if (A[i] < 0) {
            B[i] -= A[i];
            cnt += A[i];
            A[i] = 0;
        }
        if (B[i] < 0) continue;
        A[i + 1] -= B[i];
        cnt += B[i];
        B[i] = 0;
        if (A[i + 1] < 0) {
            B[i] -= A[i + 1];
            cnt += A[i + 1];
            A[i + 1] = 0;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
    }
    int min = 100 * (100 * 100);
    for (int p = 1; p < 100; p++) {
        int tmp = 0;
        for (int j = 0; j < N; j++) {
            tmp += (X.at(j) - p) * (X.at(j) - p);
        }
        if (tmp < min) min = tmp;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
dd = int(input())
c = list(list(map(int, input().split())))
s = [[0]*26]*dd
v = [[0]*26]*dd
vs = [[0]*26]*dd
ans = [0]*dd
fdate = [0]*26
for i in range(dd):
    s[i] = list(list(map(int, input().split())))



for i in range(dd):

    for j in range(26):
        v[i][j] = s[i][j] + c[j] *(i-fdate[j])
    maxv = -100000
    for j in range(26):
        if maxv < v[i][j]:
            maxv = v[i][j]
            ans[i]=j+1
            fdate[j]=i+1
for a in ans:
    print(a)
    

Measured memory_bytes: 74168
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        ss: chars,
    };
    let s = ss.iter().map(|c| c.to_digit(10).unwrap() as i64).collect::<Vec<_>>();
    if s.len() == 1 {
        println!("{}", s[0]);
        return;
    }
    let mut ans = 0;
    for i in 0..1 << (s.len() - 1) as u32 {
        let mut sum = 0;
        sum += s[0];
        for k in 0..s.len() - 1 {
            if (i >> k & 1) == 0 {
                sum *= 10;
                sum += s[k + 1];
            } else {
                ans += sum;
                sum = s[k + 1];
            }
        }
        ans += sum;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
fn solve(mut xs: Vec<u64>, ys: &[u64], mut zs: Vec<u64>) -> usize {
    xs.sort();
    zs.sort();
    ys.iter()
        .map(|&y| lower_bounds(&xs, y).len() * upper_bounds(&zs, y).len())
        .sum()
}

fn lower_bounds(xs: &[u64], x: u64) -> &[u64] {
    &xs[0..point(xs, |mid| mid < x)]
}

fn upper_bounds(xs: &[u64], x: u64) -> &[u64] {
    &xs[point(xs, |mid| mid <= x)..xs.len()]
}

fn point<P>(xs: &[u64], predicate: P) -> usize
where
    P: Fn(u64) -> bool,
{
    let mut l = 0;
    let mut r = xs.len();

    while r - l > 0 {
        let mi = (r + l) / 2;

        if predicate(xs[mi]) {
            l = mi + 1;
        } else {
            r = mi;
        }
    }
    l
}

fn main() {
    read_none();
    let xs = read_vec();
    let ys = read_vec();
    let zs = read_vec();

    println!("{}", solve(xs, &ys, zs));
}

// utils

fn read_none() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|c| c.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 5868
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll ans = 700;
    rep(i, S.size()){
        if(S[i] == 'o'){
            ans += 100;
        }
    }

    cout << ans << endl;

    return 0;
}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,k,c;
        cin>>n>>k>>c;
        string s;
        cin>>s;
        vector<int>a,b;
        for(int i=0;i<n;i++){
            if(s[i]=='o'){
                a.push_back(i);
                i+=c;
            }
        }
        for(int i=n-1;i>=0;i--){
            if(s[i]=='o'){
                b.push_back(i);
                i-=c;
            }
        }
        for(int i=0;i<k;i++){
            if(a[i]==b[k-i-1])
                cout<<a[i]+1<<"\n";
        }
        return 0;
    }


Measured memory_bytes: 3468
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=1e5+5;
const ll INF=1e18;

ll Zsum,sum,ans=-INF;
ll ans1[MAXN],ans2[MAXN];
int X,Y,Z;
pll a[MAXN];
map<ll,int> cnt;

bool cmp(pll p,pll q){return p.first-p.second<q.first-q.second;}

int main(){
    scanf("%d%d%d",&X,&Y,&Z);
    int n=X+Y+Z;
    for(int i=1;i<=n;i++){
        ll a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        Zsum+=c;
        a-=c,b-=c;
        ::a[i].first=a,::a[i].second=b;
    }
    sort(a+1,a+n+1,cmp);
    int st,ed;
    sum=0;
    for(st=1;st<=Y;st++){
        cnt[a[st].second]++;
        sum+=a[st].second;
    }
    ans1[Y]=sum;
    for(;st<=n-X;st++){
        if(a[st].second<=cnt.begin()->first){ans1[st]=sum;continue;}
        sum-=cnt.begin()->first;
        if(cnt.begin()->second>1) cnt.begin()->second--;
        else cnt.erase(cnt.begin());
        cnt[a[st].second]++;
        sum+=a[st].second;
        ans1[st]=sum;
    }
    cnt.clear();
    sum=0;
    for(ed=n;ed>n-X;ed--){
        cnt[a[ed].first]++;
        sum+=a[ed].first;
    }
    ans2[n-X+1]=sum;
    for(;ed>=Y;ed--){
        if(a[ed].first<=cnt.begin()->first){ans2[ed]=sum;continue;}
        sum-=cnt.begin()->first;
        if(cnt.begin()->second>1) cnt.begin()->second--;
        else cnt.erase(cnt.begin());
        cnt[a[ed].first]++;
        sum+=a[ed].first;
        ans2[ed]=sum;
    }
    for(int i=Y;i<=n-X;i++)
        ans=max(ans,ans1[i]+ans2[i+1]);
    printf("%lld",ans+Zsum);
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int D, c[27];
int s[366][27];

chrono::steady_clock::time_point program_begin;

double runtime() {
	chrono::steady_clock::time_point program_end = chrono::steady_clock::now();

	return chrono::duration_cast<chrono::microseconds>(program_end - program_begin).count() / 1000000.0;
}

int calc(vector<int> sc) {
	vector<int> last(27, 0);
	int val = 0;
	rep(d, 1, D + 1) {
		val += s[d][sc[d]];
		last[sc[d]] = d;
		rep(i, 1, 27)
			val -= c[i] * (d - last[i]);
	}
	return val;
}

int myrand(int a, int b) {
	return a + rand() % (b - a + 1);
}

void solve() {
	vector<int> ans(366), best_ans(366);
	int best_ans_val = -50000000;

	//while (runtime() <= 0.2) {
		for (int i = 1; i <= 365; i++)
			ans[i] = i % 26 + 1;
	//	int val = calc(ans);
	//	if (val > best_ans_val) {
			
	//	}
	//}

	while (runtime() <= 1.8) {
		int d = myrand(1, 365), n = myrand(1, 26);
		if (ans[d] == n)
			continue;
		vector<int> new_ans = ans;
		new_ans[d] = n;
		int new_val = calc(new_ans);
		double accept_proc = exp(-5.0 * runtime() / 1.8);
		if (chmax(best_ans_val, new_val)) {
			best_ans = new_ans;
		}
	}

	rep(i, 1, D + 1)
		write(best_ans[i]);
}

void test() {}

int main(int argc, char *argv[]) {
	//cin.tie(0)->sync_with_stdio(0);
	//cin.exceptions(cin.failbit);

	srand(time(NULL));

	program_begin = chrono::steady_clock::now();

	read(D);
	rep(i, 1, 27) read(c[i]);
	rep(i, 1, D + 1) rep(j, 1, 27) read(s[i][j]);
	
	solve();
}


Measured memory_bytes: 3760
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

r = []
l = []

for i,j in enumerate(a):
    r.append(i+j)
    l.append(i-j)
    
ans = 0
#Counterで{'要素':'個数'}の連想配列(辞書型)をつくり、そこから取り出す
b = Counter(r)
for i in l:
    ans += b.get(i,0)
    
print(ans)

Measured memory_bytes: 50752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
const int N=1e6;
ll v[N+10];
ll pos[N];
int main()
{

   ll n;

   cin>>n;

   ll ara[n+1],bra[n+1];

   for(ll i=0;i<n;i++)
   {
       cin>>ara[i]>>bra[i];
   }

   ll cnt=0,flag=0;

   for(ll i=0;i<n;i++)
   {
       if(ara[i]==bra[i])
       {

           cnt++;


       }
       else cnt=0;

       if(cnt==3)
       {
           flag=1;
       }

   }

   if(flag==1)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}











Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define f(a,j,k) for(int i = a ; i < j ; i += k)
#define f1(a,j,k) for(int i = a ; i > j ; i -= k)
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
typedef pair<int,int> pri;
typedef pair<long long,long long> prl;
int main() {
	std::ios::sync_with_stdio(false);
  ll n , m;
	cin >> n >> m;
	cout << (1+n-1)*(n-1) / 2 + (1+m-1)*(m-1)/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
            #define ll long long int
            #define ull unsigned long long
            ll power(ll,ll);
            ll ncr(ll,ll);
            ll add(ll a,ll b);
            void fact();
            ll mul(ll a,ll b);
            #define watch(x) cerr<<(#x)<<"is"<<x<<nl;
            #define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
            #define fi(a,b) for(ll i=a; i<b; i++)
            #define fk(a,b) for(ll k=a; k<b; k++)
            #define fri(a,b) for(ll i=a; i>=b; i--)
            #define fj(a,b) for(ll j=a; j<b; j++)
            #define ffi(a,b) for(ll i=a;i*i<=b;i++)
            #define mp make_pair
            #define ff first 
            #define  tc ll t; cin>>t; while(t--)
            #define all(v) (v).begin(),(v).end()
            #define ss second
            #define pb push_back
            #define mem(v,a) memset((v),a,sizeof(v));
            #define pll pair<ll,ll>
            #define mll map<ll,ll>
            #define sll set<ll>
            #define vll vector<ll>
            #define max3(a,b,c) max(a,max(b,c))
            #define min3(a,b,c) min(a,min(b,c))
            #define nl endl
             int mod=1e9+7;
            const ll  N=1000032LL;
            ll fac[N+2];
            ll inv[N+2];
            
           
            
            signed main(){  
        	fast
        	//~ fact();
        	//~ tc
            { ll n;
				cin>>n;
    		  string s;
    		 
    		 cin>>s;
    		ll p=s.length();
    		
    		fi(0,p)cout<<char((s[i]+n-65)%26+65);
    	    
    	     }
                return 0;
            }
             
             
            /******************************************************************************/
             
            ll add(ll a,ll b){
    			a+=b;
    		   if(a>=mod) a-=mod;
    		   if(a<0) a+=mod;
    		   return a;
    		} 
             
            ll mul(ll a,ll b){
                return ((a)*(b))%mod;
            }
             
            ll power(ll a,ll n){
              ll res=1;
              while(n){
                  if(n&1) res= mul(res,a);
                 n>>=1; 
                 a= mul(a,a);
              }
                return res;
            }
            void fact(){
            	inv[0]=fac[0]=1;
            	fi(1,N){
            	 fac[i]=mul(fac[i-1],i);
            	inv[i]=power(fac[i],mod-2);
            }
            }
             
            ll ncr(ll n,ll r){
            	
            	if(r>n) return 0;
            	ll e=fac[n];
            	e=mul(e,inv[r]);
            	e=mul(e,inv[n-r]);
            	return e;
            }


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(2*100)

def main():
    
    N, M, K = map(int, input().split())
    G = {v: deque([]) for v in range(N)}
    G_original = {v: deque([]) for v in range(N)}
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
        G_original[a].append(b)
        G_original[b].append(a)

    Block = {v: deque([]) for v in range(N)}
    for _ in range(K):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        Block[c].append(d)
        Block[d].append(c)

    # seen = [0]*(N)
    stack = []
    color = {v: None for v in range(N)}
    col2v = {col: set() for col in range(N)}
    
    def dfs(j, col):
        if color[j] is not None:
            return
        # seen[j] = 1
        col2v[col] = set()
        stack.append(j)
        color[j] = col
        col2v[col].add(j)
        while stack:
            s = stack[-1]
            if not G[s]:
                stack.pop()
                continue
            g_NO  = G[s].popleft()
            if color[g_NO] is not None:
                continue
            color[g_NO] = col
            col2v[col].add(g_NO)
            # color[g_NO] = 1
            stack.append(g_NO)
    # def dfs(node, co):
    #     if color[node] is not None:
    #         return
        
    #     color[node] = co
    #     col2v[co].add(node)
    #     for n in G[node]:
    #         dfs(n, co)
    #     return
        
    c = 0
    for start in range(N):
        dfs(start, c)
        c += 1
    
    ans = []
    for v in range(N):
        # kouho = col2v[color[v]]
        # # print(kouho)
        # block = Block[v]
        # # print(block)
        # friend = G_original[v]
        # # print(friend)
        # tmp = kouho - set(block + friend)
        tmp = col2v[color[v]]
        tmp2 = tmp & set(Block[v])
        tmp3 = tmp & set(G_original[v])
        print((len(tmp)-len(tmp2)-len(tmp3)-1), end=" ")
        # ans.append(len(col2v[color[v]] - set(Block[v]+G_original[v]))-1)
        
        # print("##############")
    # print(*ans)
main()

Measured memory_bytes: 329592
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int cnt = 0;
  rep(i, S.size()){
    if(S.at(i) != T.at(i)) cnt++;
  }
  cout << cnt << endl; // 標準出力
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;
int vis[N];
vector<vector<int>>adj(N);


bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
void dfs(int x){
    vis[x]=1;
    for(auto i:adj[x]){
        if(!vis[i])
            dfs(i);
    }
}


void fun(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){        
        string s;
        cin>>s;
        int k=stoi(s.substr(0,2));
        int p=stoi(s.substr(2));
        if(p<=12 && k<=12 && (k!=0 && p!=0)){
            cout<<"AMBIGUOUS";
        }
        else if(k<=12 && p<=99 && k!=0){
            cout<<"MMYY";
        }
        else if(p<=12 && k<=99 && p!=0){
            cout<<"YYMM";
        }
        else{
            cout<<"NA";
        }
        
    }
    return 0;
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);


    ll n,m; cin>>n>>m;
    vint edges[n], edges_inv[n];
    rep(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        edges[a].push_back(b);
        edges_inv[b].push_back(a);
    }
    // rep(i,n) printv(edges[i]);

    vint ans(n+2,0);
    rep(i,n){
        queue<ll> q;
        q.push(i);
        vint dist(n,LLONG_MAX);
        dist[i] = 0;

        while(!q.empty()){
            ll now = q.front(); q.pop();

            for(auto to:edges[now]){
                if(dist[to] <= dist[now] + 1) continue;
                dist[to] = dist[now] + 1;
                q.push(to);
            }

        }
        // cout<<"i: "<<i<<endl;
        // printv(dist);
        auto solve = [&](ll now, ll d){// nowに向かってくるもののうちdist == d-1 であるノードの一つを返す。  ないなら-1を返す。
            for(auto to:edges_inv[now]){
                if(dist[to] == d - 1) return to;
            }
            return -1ll;
        };
        ll minval = LLONG_MAX;
        for(auto to:edges_inv[i]){
            chmin(minval, dist[to]);
        }
        if(minval == LLONG_MAX) continue;
        vint tmp;
        ll now = i;
        while(minval>=0){
            now = solve(now, minval+1);
            tmp.push_back(now);
            minval--;
        }
        if(tmp.size() < ans.size()) swap(tmp,ans);
    }
    if(ans.size() < n+2){
        cout<<ans.size()<<endl;
        for(auto e:ans)cout<<e+1<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;

}

Measured memory_bytes: 384
/*
 * author: calgagi
 *         Calvin Gagliano 
 */
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define ar array
#define f first
#define s second
#define dd long double

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (!(n & 1)) {
            a[i] *= 2, b[i] *= 2; 
        }
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    ll mx_mid, mn_mid;
    if ((n & 1)) {
        mx_mid = b[n/2], mn_mid = a[n/2];
    } else {
        mx_mid = (b[n/2]+b[(n-1)/2])/2, mn_mid = (a[n/2]+a[(n-1)/2])/2;
    }

    cout << mx_mid-mn_mid+1 << endl; 
    
    return;
}

int main() {
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);
    srand(chrono::steady_clock::now().time_since_epoch().count()); 
    
    int t = 1;
    /* cin >> t; */
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 6392