akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();
    let mut ans = s.len();
    for i in 0..s.len() {
        if s[i] == t[i] {
            ans -= 1;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  rep(i, N) {
    int x;
    cin >> x;
    ans += x;
  }
  cout << ans - N << endl;
  return 0;
}

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

#define ll long long int
#define pb push_back


int main(){
ll h,a;
  cin>>h>>a;
  ll val=h/a;
  
  if(val*a==h)
    cout<<val<<endl;
  
  else
    cout<<val+1<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    while True:
        W,H=map(int,input().split())
        if W==H==0:
            break
        edge=[[[] for _ in range(W)] for _ in range(H)]
        for i in range(2*H-1):
            l=list(map(int,input().split()))
            for j,x in enumerate(l):
                if x==0:
                    if i%2==0:
                        edge[i//2][j].append((i//2,j+1))
                        edge[i//2][j+1].append((i//2,j))
                    else:
                        edge[i//2][j].append((i//2+1,j))
                        edge[i//2+1][j].append((i//2,j))
        d=[[INF]*W for _ in range(H)]
        d[0][0]=1
        que=deque()
        que.append((0,0))
        ans=INF
        while que:
            y,x=que.popleft()
            for ny,nx in edge[y][x]:
                if d[ny][nx]>d[y][x]+1:
                    d[ny][nx]=d[y][x]+1
                    que.append((ny,nx))
                    if ny==H-1 and nx==W-1:
                        ans=min(ans,d[ny][nx])
        print(ans if ans!=INF else 0)
                        
        
        

if __name__ == '__main__':
    main()



Measured memory_bytes: 6316
using System;
public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    string[] DX = Console.ReadLine().Split(' ');
    int D = int.Parse(DX[0]);
    int X = int.Parse(DX[1]);
    int sum = X;
    int A = 0;
    for (int i = 0; i < N; i++) {
      A = int.Parse(Console.ReadLine());
      for (int j = 0; j*A+1 <= D; j++) {
        sum++;
      }
    }
    Console.WriteLine(sum);
  }
}


Measured memory_bytes: 13140
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, m ; 
    cin >> n >> m ; 
    vi  a(m),b(m) ; 
    vector <vi>  key(m+1, vi(15, 0)) ; 
    for (int i=0;i<m;i++){
    	cin >> a[i] >> b[i] ; 
    	for (int j=0;j<b[i];j++) {
    		cin >> key[i][j] ; 
    		key[i][j]-- ; 
    	}
    }
    vi  dp( 1<<n, 1e9 ) ; 
    dp[0] = 0 ; 
    for (int i=0;i<m;i++){ 
    	int now = 0 ; 
    	for (int j=0;j<b[i];j++){ 
    		now |= (1 << (key[i][j]) ) ; 
    	} 
    	if (i == 0) dp[now] = a[i] ; 
    	for (int  bit = 0; bit < (1<<n) && i>0 ; bit++ ) { 
    		dp[bit | now] = min(dp[bit | now], dp[bit]+a[i]) ; 
    	} 
    } 
    if (dp[ (1<<n) - 1 ] == 1e9) dp[(1<<n)-1] = -1 ; 
    co (dp[(1<<n)-1]) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main(void) {
    int N; cin >> N;
    vector<ll> L;
    int ans = 0;
    for(int i=0; i<N; i++) {
        ll x; cin >> x;
        L.push_back(x);
    }
    for(int i=0; i<N-2; i++) {
        for(int j=i+1; j<N-1; j++) {
            for(int l=j+1; l<N; l++) {
                if(L[i] != L[j] && L[j] != L[l] && L[i] != L[l]) {
                    if(L[i]+L[j]>L[l] && L[i]+L[l]>L[j] && L[j]+L[l] > L[i]) {
                        //cout << L[i] << " " << L[j] << " " << L[l] << endl;
                        ans++;
                        }
                } 
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    string t;
    cin>>s;
    cin>>t;
    string r = t;
    sort(all(s));
    sort(all(t));
    sort(rall(r));

    //cout<<s<<endl;
    //cout<<t<<endl;
    //cout<<r<<endl;

    if(s<t || s<r)  cout<<"Yes\n";
    else            cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <unordered_map>
#include <algorithm>

bool isPrime(int32_t n) {
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  int32_t i = 3;
  while (i * i <= n) {
    if (n % i == 0) return false;
    i += 2;
  }
  return true;
}

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


  std::unordered_map<int32_t, int32_t> primes;
  constexpr int32_t MAXN = 100000;
  for (int32_t n = 2; n <= MAXN; n++) {
    if (isPrime(n)) {
      primes[n] = 1;
    }
  }

  int32_t accum2017[MAXN+1] = {};
  for (int32_t i = 2; i <= MAXN; i++) {
    if (primes[i] == 1 && primes[(i+1)/2] == 1) {
      accum2017[i] = accum2017[i-1] + 1;
    }
    else {
      accum2017[i] = accum2017[i - 1];
    }
  }

  int32_t Q;
  int32_t l,r;
  std::cin >> Q;
  while (Q--) {
    std::cin >> l >> r;
    std::cout << accum2017[r] - accum2017[l - 1] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 5156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[][][] list = new int[4][3][10];
        for (int i = 0; i < n; i++) {
            String[] lines = br.readLine().split(" ");
            int[] nList = new int[4];
            for (int j = 0; j < 4; j++) {
                nList[j] = Integer.parseInt(lines[j]) - 1;
            }
            list[nList[0]][nList[1]][nList[2]] += nList[3] + 1;
        }
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 3; k++) {
                for (int l = 0; l < 10; l++) {
                    System.out.print(" " + list[j][k][l]);
                }
                System.out.println();
            }
            if (j != 3) {
                System.out.println("####################");
            }
        }
    }
}

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

int main()
{
    int a, b;
    while(cin >> a >> b)
    {
        if(a >= 10) cout << -1 << endl;
        else if(b >= 10) cout << -1 << endl;
        else cout << a*b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List
import Data.Function (on)

main :: IO ()
main = solve <$> f >>= print
  where f = map read <$> words <$> getLine

solve :: [Integer] -> Integer
solve [r, c, a1, a2, b1, b2] = flip mod 100000007 . sum . map (comb <$> sum <*> (!!1)) $ filter ((==mv).sum) ps
  where ps = map (map abs . zipWith (-) [a1, a2]) [[b1, b2],
                                                   [b1+r, b2],
                                                   [b1-r, b2],
                                                   [b1, b2+c],
                                                   [b1, b2-c],
                                                   [b1+r, b2+c],
                                                   [b1-r, b2+c],
                                                   [b1+r, b2-c],
                                                   [b1-r, b2-c]]
        mv = sum . minimumBy (compare `on` sum) $ ps

comb :: Integer -> Integer -> Integer
comb n m | n < m = 0
         | m == 0 = 1
         | n > 2 * m = comb n (n-m)
         | otherwise = flip mod 100000007 . foldl' f 1 $ zip [n-m+1 .. n] [1 .. m]
  where f a (i,j) = a * i `div` j



Measured memory_bytes: 4260
s=input()
#a,b,c,d=int(s[0]),int(s[1]),int(s[2]),int(s[3]))
for i in range(8):
	ans=int(s[0])
	p=s[0]
	for j in range(3):
		if (i>>j)&1:
			ans+=int(s[j+1])
			p+='+'+s[j+1]
		else:
			ans-=int(s[j+1])
			p+='-'+s[j+1]
	#print(ans)
	if ans==7:
		print(p+'=7')
		exit()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;
int main()
{
    long long N, M;
    cin >> N >> M;

    if(N == 1 && M == 1){
        cout << 1 << endl;
        return 0;
    }
    else if(N == 1){
        cout << M - 2 << endl;
        return 0;
    }
    else if(M == 1){
        cout << N - 2 << endl;
        return 0;
    }

    cout << (N-2) * (M-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(){
  bool flg=true;
  string input;
  cin>>input;
  int num[26]={};
  for(int i=0;i<input.length();i++){
num[input[i]-'a']++;
  }
  for(int i=0;i<26;i++){
    if(num[i]%2==1){
      flg=false;
    }
  }
  if(flg==true){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
const int INF = (int)1e9 + 7;

vector<vector<int>> bfs(vector<string> &grid, int si, int sj) {
    int h = grid.size(), w = grid[0].size();
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<pair<int, int>> que; que.emplace(si, sj); dist[si][sj] = 0;
    while (!que.empty()) {
        int i, j; tie(i, j) = que.front(); que.pop();
        for (int di: {-1, 0, 1}) for (int dj: {-1, 0, 1}) {
            if (di * di + dj * dj != 1) continue;
            int ni = i + di, nj = j + dj;
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (grid[ni][nj] == '#' || dist[ni][nj] != INF) continue;
            dist[ni][nj] = dist[i][j] + 1; que.emplace(ni, nj);
        }
    }
    return dist;
}

int main() {
    int h, w; cin >> h >> w;
    vector<string> field(h);
    for (auto &s: field) cin >> s;
    int dist = bfs(field, 0, 0).back().back();
    if (dist == INF) return !(cout << -1 << endl);
    int bk = 0;
    for (auto &s: field) bk += count(begin(s), end(s), '#');
    cout << (h * w - bk) - (dist + 1) << 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)
using ll = long long;
using P = pair<int, int>;

ll n, sum, t;

int main() {
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  rep (i, n+1) {
    cin >> a[i];
  }
  sum = 0;
  rep (i, n) {
    cin >> b[i];
    sum += b[i];
  }
  rep (i, n) {
    b[i] -= a[i];
    if (b[i] < 0) b[i] = 0;
    if (b[i] > 0) {
      t = min(a[i+1], b[i]);
      a[i+1] -= t;
      b[i] -= t;
    }
  }
  rep (i, n) {
    sum -= b[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;

int mod10(int n){
    if(n % 10 != 0){
        return  n + 10 - n % 10;
    }
    else{
        return n;
    }
}

int main(){
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int ans = 0;
    ans += mod10(A) + mod10(B) + mod10(C) + mod10(D) + mod10(E);
    ans -= max({mod10(A) - A, mod10(B) - B, mod10(C) - C, mod10(D) - D, mod10(E) - E});
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;

int main(){
    ll n , k , ans = 1; cin >> n >> k;
    vector <ll> v(n);
    ll arr[n+5];
    for(int i = 0; i < n; i++){
        cin >> v[i];
        arr[i] = v[i];
    }
    for(int i = 1; i < n; i++){v[i]+=v[i-1];}
    
    for(int i =0; i < n; i++){
        if(v[i]<=k){
            ans++;
        }
    }
    
    cout << ans << '\n';
}

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

int main() {
  int N,ans=0;
  cin >> N;
  vector<string>V(N);
  for(int i=0 ; i<N ; i++)
    cin >> V.at(i);
  sort(V.begin(),V.end());
  V.erase(unique(V.begin(),V.end()),V.end());
  cout << V.size() << endl;
}


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

int pi[233333];

int main()
{
	int k,n; scanf("%d%d",&k,&n);
	for(int i=1; i<=n; i++) scanf("%d",&pi[i]);
	int sum=pi[1]+k-pi[n];
	for(int i=1; i<n; i++) sum=max(sum,pi[i+1]-pi[i]);
	printf("%d",k-sum);
	return 0;
}

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

int main(){
  int h,w;
  while(true){
    cin>>h>>w;
    if(h==0&&w==0)break;
    rep(i,h){
      if(i==0 || i==h-1){
        rep(j,w){
          cout<<'#';
        }
      }else{
        rep(j,w){
          if(j==0 || j==w-1)cout<<'#';
          else cout<<'.';
        }
      }
      cout<<endl;
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    ll ma=0;
    rep(i,n)cin>>a[i],ma=max(ma,a[i]),b[i]=a[i];
    rep(i,n){
        if(a[i]==ma)cnt++;
    }
    if(cnt>=2){
        rep(i,n)Cout(ma);
    }
    else{
        sort(b,b+n);
        rep(i,n){
            if(a[i]==ma)Cout(b[n-2]);
            else Cout(ma);
        }
    }
    return 0;
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MAX = 2000000;
const ll MOD = 1000000007;
ll n;

int main() {
    cin >> n;
    ll cursor = 1;
    ll breaked = 0;
    for(ll i=0; i<n; i++){
        ll a=0;
        cin >> a;
        if(a == cursor){
            cursor++;
        }else{
            breaked++;
        }
    }
    cout << ((breaked == n) ? -1 : breaked) << endl;
    return 0;
}

Measured memory_bytes: 384
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const array = (input.trim()).split('\n').map(Number)
array.shift()

var maxV = array[1] - array[0]
var minV = array[0]

array.shift()

array.forEach(curV => {
    maxV = Math.max(maxV, curV - minV)
    minV = Math.min(minV, curV)
})

console.log(maxV)



Measured memory_bytes: 51488
#include <stdio.h>
#include <stdlib.h>

typedef struct person {
	int id;
	int potato;
	int alive;
} Person;

Person* new_person(int id) {
	Person* p = malloc(sizeof (Person));
	p->id = id;
	p->potato = 0;
	p->alive = 1;

	return p;
}

Person* init(int n) {
	int i;
	Person* p = malloc(sizeof (Person) * n);
	for (i = 0; i < n; i++) {
		p[i].id = i + 1;
		p[i].potato = 0;
		p[i].alive = 1;
	}
	p[n - 1].potato = 1;
	return p;
}

// ポインタを生きている人一人分進める

int pass(Person* head, Person** p, int n) {
	int i = 0;
	while (1) {
		// いま末尾にいるなら先頭へ、そうでなければ次へ
		*p = (*p - head == n - 1) ? head : *p + 1;
		if ((*p)->alive) {
			// 生きている人を見つけた。
			return 1;
		}
		i++;
		if (i >= n) {
			printf("全員死んでいる\n");
			return 0;
		}
	}
}

void dump(Person* head, int n) {
	int i;
	for (i = 0; i < n; i++) {
		printf("%d", head[i].potato);
	}
	printf("\n");
	for (i = 0; i < n; i++) {
		printf("%d", head[i].alive);
	}
	printf("\n");
}

void print_winner(Person* head, int n) {
	int i;
	for (i = 0; i < n; i++) {
		if (head[i].alive) {
			printf("%d\n", head[i].id);
			break;
		}
	}
}

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

	int n = 0;
	int m = 3;

	int i;

	while (1) {
		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0) {
			break;
		}

		int dead = 0;

		Person* p;
		Person* head = init(n);

		p = head + (n - 1); // スタート地点は n 番目の人

		// 生き残っている人がいる間、芋をわたし続ける
		int first = 1;
		while (dead < n - 1) {
			//dump(head, n);
			if (first) {
				first = 0;
			} else {
				p->alive = 0;
				dead++;
			}
			p->potato = 0;
			// 指定人数分pass
			for (i = 0; i < m; i++) {
				if (!pass(head, &p, n)) {
					return (EXIT_FAILURE);
				}
			}
			p->potato = 1;
		}
		print_winner(head, n);
	}

	return (EXIT_SUCCESS);
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int[] x = new int[4];
        for(int i=0;i<4;i++){
            x[i] =0;
        }
        for(int i=0;i<6;i++){
            int n= sc.nextInt();
            x[n-1]++;
            if(x[n-1] >2){
                System.out.println("NO");
                System.exit(0);
            }
        }
        System.out.println("YES");

    }
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

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

    return gcd(b, a % b);
}

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

    int gcdFront[N], gcdBack[N];
    gcdFront[0] = A[0];
    gcdBack[0] = A[N - 1]; 
    for (int i = 1; i < N; ++i)
    {
        gcdFront[i] = gcd(gcdFront[i - 1], A[i]);
        gcdBack[i] = gcd(gcdBack[i - 1], A[N - (i + 1)]);
    }

    int gcdMax = 1;
    REP(i, N)
    {
        if (i == 0) 
        {
            gcdMax = max(gcdMax, gcdBack[N - 2]);
        }
        else if (i == N - 1)
        {
            gcdMax = max(gcdMax, gcdFront[N - 2]);
        }
        else
        {
            gcdMax = max(gcdMax, gcd(gcdFront[i - 1], gcdBack[N - (i + 2)]));
        }
        
    }

    cout << gcdMax << endl;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
using namespace std;
char p[101000];
int n, w[101000], cnt;
int main() {
	int i, j;
	scanf("%s", p+1);
	for (i = 1; p[i]; i++);
	n = i - 1;
	if (p[n] == '1' || p[1]=='0') {
		puts("-1");
		return 0;
	}
	for (i = 1; i < n; i++)if (p[i] != p[n - i ]) {
		puts("-1");
		return 0;
	}
	int bef = 0, bn = 0;
	for (i = 1; i <= n; i++) {
		if ((p[i] == '1' && i<=n/2)||i==n) {
			cnt++;
			if (bn)printf("%d %d\n", bn, cnt);
			int pv = cnt;
			for (j = 1; j < i - bef; j++) {
				printf("%d %d\n", pv, ++cnt);
			}
			bn = pv;
			bef = i;
		}
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>

#define N 11

using namespace std;

class Solver {
    private:
        bool eval(int begin, int end, bool vars[]) {
            if (s[begin] == 'T') {
                return true;
            } else if (s[begin] == 'F') {
                return false;
            } else if ('a' <= s[begin] && s[begin] <= 'k') {
                return vars[s[begin] - 'a'];
            } else if (s[begin] == '-') {
                int count = 0;
                while (s[begin] == '-') {
                    ++count;
                    ++begin;
                }
                if (count % 2 == 0) {
                    return eval(begin, end, vars);
                } else {
                    return !eval(begin, end, vars);
                }
            } else {
                int nest = 0;
                for (int i = begin + 1; true; ++i) {
                    if (s[i] == '(') {
                        ++nest;
                    } else if (s[i] == ')') {
                        --nest;
                    }
                    if (nest > 0) {
                        continue;
                    }
                    if (s[i] == '*') {
                        return eval(begin + 1, i, vars) && eval(i + 1, end - 1, vars);
                    } else if (s[i] == '+') {
                        return eval(begin + 1, i, vars) || eval(i + 1, end - 1, vars);
                    } else if (s[i] == '-' && s[i + 1] == '>') {
                        return (!eval(begin + 1, i, vars)) || eval(i + 2, end - 1, vars);
                    }
                }
            }
        }
    public:
        string s;
        bool is_identity() {
            bool vars[N];
            for (int i = 0; true; ++i) {
                if (s[i] == '=') {
                    for (int j = 0; j < (1 << N); ++j) {
                        for (int k = 0; k < N; ++k) {
                            vars[k] = j & (1 << k);
                        }
                        if (eval(0, i, vars) != eval(i + 1, s.length(), vars)) {
                            return false;
                        }
                    }
                    return true;
                }
            }
        }
};

int main() {
    Solver s;
    while (true) {
        cin >> s.s;
        if (s.s == "#") {
            return 0;
        }
        if (s.is_identity()) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 1184
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn, mm;
	cin >> nn >> mm;
	cout << ((nn - 1) * (mm - 1)) << endl;
	return 0;
}

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

// 補グラフ上の二部マッチング

using Graph = vector<vector<int>>;
// 補グラフ, 0-indexed を前提にしているので注意
Graph inverse(Graph &g) {
    vector<vector<int>>table(g.size(), vector<int>(g.size(), 0));
    for (int i = 0; i < g.size(); ++i) {
        for (auto x: g[i]) {
            table[i][x] = 1;
        }
    }
    Graph res(g.size());
    for (int i = 0; i < g.size(); ++i) {
        for (int j = 0; j < g.size(); ++j) {
            if (i != j && table[i][j] == 0) {
                res[i].push_back(j);
            }
        }
    }
    return res;
}

ll nC2(ll n) {
    return n * (n-1) / 2;
}

int main() {
    int N, M;
    cin >> N >> M;
    Graph g1(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        g1[A].push_back(B);
        g1[B].push_back(A);
    }

    Graph graph = inverse(g1);
    vector<int>flag(N, -1);
    vector<int>block;
    int scale = N, bt = 0;
    for (int i = 0; i < N; ++i) {
        if (flag[i] != -1) continue;
        flag[i] = 0;
        int cnt0 = 1, cnt1 = 0;
        stack<int>st;
        st.push(i);
        while (! st.empty()) {
            auto t = st.top(); st.pop();
            for (auto x: graph[t]) {
                if (flag[x] == -1) {
                    flag[x] = flag[t] ^ 1;
                    if (flag[x]) cnt1++;
                    else cnt0++;
                    st.push(x);
                } else {
                    if (flag[t] == flag[x]) {
                        cout << -1 << "\n";
                        return 0;
                    }
                }
            }
        }
        scale -= cnt0 + cnt1;
        block.push_back(abs(cnt0 - cnt1));
        bt += min(cnt0, cnt1);
    }
    
    bitset<705> dp;
    dp[bt] = 1;
    for (int i = 1; i <= scale; ++i) {
        dp[bt+i] = 1;
    }
    for (auto x: block) {
        dp |= dp << x;
    }
    ll ans = INT_MAX;
    for (int i = 0; i <= N; ++i) {
        if (! dp[i]) continue;
        ll temp = nC2(i) + nC2(N - i);
        ans = min(ans, temp);
    }
    cout << ans << "\n";
    return 0;
}

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

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


Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))
res = 100
for i in range(n):
    for j in range(100):
        if a[i] % 2 == 1:
            break
        a[i] //= 2
    res = min(res, j)
    if res == 0:
        break
print(res)


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    string march = "MARCH";
    vector<ll> stat(5, 0);
    rep(i, 5) {
        rep(j, n) {
            if (s[j][0] == march[i]) stat[i]++;
        }
    }
    // for (auto elem : stat) cout << elem << " "; cout << endl;

    ll count = 0;
    for (size_t i = 0; i < 3; i++)
    {
        for (size_t j = i+1; j < 4; j++)
        {
            for (size_t k = j+1; k < 5; k++)
            {
                count += stat[i] * stat[j] * stat[k];
            }
            
        }
    }
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	string s;
	cin>>s;
	if(s[s.length()-1]=='3')cout<<"bon"<<endl;
	else if(s[s.length()-1]=='0'||s[s.length()-1]=='1'||s[s.length()-1]=='6'||s[s.length()-1]=='8')cout<<"pon"<<endl;
	else cout<<"hon"<<endl;
	return 0;
}


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

int main() {
  int n, c = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = 0; i < n; i++) {
    if(a.at(i) == c + 1)
      c++;
  }
  if(!c)
    cout << -1 << endl;
  else
    cout << a.size() - c << endl;
}

Measured memory_bytes: 1024
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,m; 
    cin>>n>>m; 
    string a[n],b[m];
    for (int i=0;i<n;i++) cin>>a[i];
    for (int i=0;i<m;i++) cin>>b[i];
    for (int i=0;i<=n-m;i++){
    	for (int j=0;j<=n-m;j++){
    		bool ok=true;
    		for (int k=i,ii=0;k<n and ii<m;k++,ii++){
    			for (int l=j,jj=0;l<n and jj<m;l++,jj++){
    				if(b[ii][jj] != a[k][l]) ok=false;
    			}
    			if(!ok) break;
    		}
    		if (ok){
    			printf("Yes\n");
    			return;
    		}
    	}
    }
    printf("No\n");
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3620
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m = LI()
    uf = UnionFind(n)
    for i in range(m):
        a, b = LI()
        uf.unite(a - 1, b - 1)
    ans = 0

    for i in range(n):
        ans = max(uf.size(i), ans)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

string ans[1111];
map<ii,char> ma;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	vector<ii> vec;
	ll sum = 0; 
	for(int i=0;i<n;i++)
	{
		ll x,y; cin>>x>>y; vec.pb(mp(x,y)); sum=(x+y)%2;
		if(sum<0) sum+=2;
	}
	for(int i=0;i<n;i++)
	{
		ll s2 = (vec[i].fi+vec[i].se)%2;
		if(s2<0) s2+=2;
		if(s2!=sum){cout<<-1<<'\n'; return 0;}
	}
	vector<ll> res;
	ma[mp(1,0)] = 'L'; ma[mp(-1,0)] = 'R';
	ma[mp(0,1)] = 'D'; ma[mp(0,-1)] = 'U';
	if(sum==0)
	{
		res.pb(1);
		for(int i=0;i<n;i++)
		{
			vec[i].fi++;
			ans[i]+='L';
		}
	}
	for(int bit=31;bit>=0;bit--)
	{
		ll mod = (1LL<<bit);
		res.pb(mod);
		for(int i=0;i<n;i++)
		{
			ll x = vec[i].fi; ll y = vec[i].se;
			for(auto d:ma)
			{
				if(ans[i].length()==res.size()) break;
				ll x2 = x+d.fi.fi*mod; ll y2 = y+d.fi.se*mod;
				ll M = mod-1;
				if(abs(x2+y2)<=M&&abs(x2-y2)<=M)
				{
					ans[i]+=d.se; vec[i].fi=x2; vec[i].se=y2;
				}
			}
		}
	}
	cout<<res.size()<<'\n';
	for(int i=0;i<res.size();i++)
	{
		cout<<res[i];
		if(i+1<res.size()) cout<<' ';
	}
	cout<<'\n';
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<'\n';
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	cout<<(H-h)*(W-w)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT; while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN

    int n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0){
        cout << "Alice\n";
    } else {
        cout << "Borys\n";
    }


    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N;
    cin >> N;
    V<PLL> ak(N);
    for(auto &&ele : ak) {
        ll a, b;
        cin >> a >> b;
        ele = PLL(a, b);
    }
    ll sum = 0;
    for(auto &&ele : ak) {
        ll a, k;
        tie(a, k) = ele;
        while(a % k && k <= a) {
            ll dec = a / k + 1;
            if(a < dec) break;
            ll aim = a / k * k;
            ll diff = a - aim;
            ll cnt = diff / dec + !!(diff % dec);
            a -= dec * cnt;
        }
        sum ^= a / k;
    }
    cout << (sum ? "Takahashi" : "Aoki") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#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 <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
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) << endl
#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)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -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;

struct UnionFind {  
vector<int> par,rank; 
UnionFind(int n) : par(n),rank(n,1)  {
 for(int i=0; i<n; i++){ par[i]=i; }
}
int find(int x) { 
if(par[x]==x){ return x; }
return par[x] = find(par[x]);
}
void unite(int x, int y) {
int rx = find(x); 
int ry = find(y);
if(rx == ry){ return; }
if(rank[rx]<rank[ry]){ swap(rx, ry); }
par[ry] = rx;
rank[rx] += rank[ry];
}
bool isSame(int x, int y) { 
return find(x) == find(y);
}
int size(int x){
return rank[find(x)];
}
};


int main(void) {
    int N,M;
    cin >> N >> M;

    vpii E(M);

    rep(i,M){
        //a.bも１スタートなので0-indexにする
        cin >> E[i].first >> E[i].second;
        E[i].first--;
        E[i].second--;
    }
    
    int ans=0;
    
    rep(i,M){
        UnionFind uf(N);

        rep(j,M){
            if(i != j && !uf.isSame(E[j].first,E[j].second)){
                  uf.unite(E[j].first,E[j].second);
            }
        }

        set<int> s;
        rep(j,N){
            if(uf.par[j] == j) s.insert(uf.par[j]);//自分自身が親の時、そこは一つの連結成分
        }
        if(s.size() > 1) ans++;
    }

    fin(ans);
    



}

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

int main(){
    while(1){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i == 0 || i == H - 1) || (j == 0 || j == W - 1)){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
# require "prime"
n = gets.chomp.to_i
# zenbu = 0
# (1..n-1).each do |c|
#     ans = n - c
#     count = 1
#     if ans >= 2
#     all = ans.prime_division
#         all.each do |i|
#             count *= (i[1]+1)
#         end
#     else
#         count = 1
#     end
#     zenbu += count
# end
# puts zenbu
count = 0
ans = 0
(1..n).each do |a|
    kizyun = n - 1
    kosuu = kizyun / a
    ans += kosuu
end
puts ans

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

l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
standard = list([] for i in range(n))

for i in range(n):
    if i == 0:
        standard[0].append(['a', 0])
    else:
        for w in standard[i-1]:
            for j in range(w[1]+1):
                standard[i].append([w[0]+l[j], w[1]])
            standard[i].append([w[0]+l[w[1]+1], w[1]+1])

for w in standard[n-1]:
    print(w[0])

Measured memory_bytes: 28012
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int main(void){
  int col;
  char c;
  while(cin>>c>>hex>>col){
    if(c=='0') break;
    int data[3];
    REP(i,3){
      data[i] = col%256;
      col/=256;
    }
    bool judge[3];
    REP(i,3){
      if(255-data[2-i]<data[2-i]){
        judge[i] = false;
      }else{
        judge[i] = true;
      }
    }
    if(judge[0]){
      if(judge[1]){
        if(judge[2]){
          cout<<"black"<<endl;
        }else{
          cout<<"blue"<<endl;
        }
      }else{
        if(judge[2]){
          cout<<"lime"<<endl;
        }else{
          cout<<"aqua"<<endl;
        }
      }
    }else{
      if(judge[1]){
        if(judge[2]){
          cout<<"red"<<endl;
        }else{
          cout<<"fuchsia"<<endl;
        }
      }else{
        if(judge[2]){
          cout<<"yellow"<<endl;
        }else{
          cout<<"white"<<endl;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll x;
  cin >> x;
  ll yen = 100;
  ll ans = 0;
  while(yen < x){
    yen *= 1.01;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n,m;
    cin>>n>>m;
    vector<long long int> dp(n+10,0),koware(m);
    REP(i,m){
        cin >> koware[i];
    }
    dp[0] = 1;
    REP(i,n+1){
        if(lower_bound(koware.begin(),koware.end(),i)!=koware.end()){
            if(*lower_bound(koware.begin(),koware.end(),i)==i){
                dp[i] = 0;
            }else{
            dp[i + 2] += dp[i];
            dp[i + 1] += dp[i];
            dp[i + 2] %= mod;
            dp[i + 1] %= mod;
            
            }
            
        }else{
            dp[i + 2] += dp[i];
            dp[i + 1] += dp[i];
            dp[i + 2] %= mod;
            dp[i + 1] %= mod;
            
        }
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  string s,t;cin>>s>>t;
  int ans = 0;
  REP(i,3){
    if(s[i]==t[i])ans++;
  }

  cout<<ans<<endl;

 

  return 0;
}

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

int main() {
  int n,k,ans=0;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)a[i]=0;
  for(int i=0;i<k;i++){
    int l;
    cin>>l;
    for(int j=0;j<l;j++){
      int t;
      cin>>t;
      a[t-1]++;
    }
  }
  for(int i=0;i<n;i++){
    if(a[i]==0)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3624