akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,mo,ans;
int s[3005][3005];
int c[3005][3005];
int power(int x,int y,int mo){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int C(int x,int y){
	int ans=1;
	for (int i=x-y+1;i<=x;i++)
		ans=1ll*ans*i%mo;
	for (int i=1;i<=y;i++)
		ans=1ll*ans*power(i,mo-2,mo)%mo;
	return ans;
}
int main(){
	scanf("%d%d",&n,&mo);
	s[0][0]=c[0][0]=1;
	for (int i=1;i<=n+1;i++){
		c[i][0]=1;
		for (int j=1;j<=i;j++){
			s[i][j]=(s[i-1][j-1]+1ll*s[i-1][j]*j)%mo;
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mo;
		}
	}
	for (int ij=0;ij<=n;ij++){
		int tmp=0,v=1,del=power(2,n-ij,mo);;
		for (int k=0;k<=ij;k++){
			tmp=(tmp+1ll*s[ij+1][k+1]*v)%mo;
			v=1ll*v*del%mo;
		}
		tmp=1ll*tmp*power(2,power(2,n-ij,mo-1),mo)%mo;
		tmp=1ll*tmp*c[n][ij]%mo;
		ans=(ans+((ij&1)?mo-tmp:tmp))%mo;
	}
	printf("%d\n",ans);
}

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

int main(){
    double i,j;
    while(cin >> i >> j){
        if(i < 35.5 && j < 71.0) cout << "AAA\n";
        else if(i < 37.5 && j < 77.0) cout << "AA\n";
        else if(i < 40.0 && j < 83.0) cout << "A\n";
        else if(i < 43.0 && j < 89.0) cout << "B\n";
        else if(i < 50.0 && j < 105.0) cout << "C\n";
        else if(i < 55.0 && j < 116.0) cout << "D\n";
        else if(i < 70.0 && j < 148.0) cout << "E\n";
        else cout << "NA\n";
    }
}

Measured memory_bytes: 1192
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, a: "List[int]"):
    ans = 0
    c = 1
    n = a[0]
    for i in range(1, N):
        # print(c)
        if a[i] == n:
            c += 1
            continue
        else:
            if c >= 2:
                ans += c//2
                
            n = a[i]
            c = 1

    if c >= 2:
        n = a[i]
        ans += c//2

    
    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    unordered_set<lint> distinct_elements;
    range(i, 0, N) {
        lint e; cin >> e;
        distinct_elements.emplace(e);
    }
    cout << (distinct_elements.size() == N ? "YES" : "NO") << "\n";
}

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

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


Measured memory_bytes: 3548
N, M, X, Y = gets.split.map(&:to_i)
MAX_X = gets.split.map(&:to_i).max
MIN_Y = gets.split.map(&:to_i).min

if MAX_X < MIN_Y && X < Y && X < MIN_Y &&  MAX_X < Y
  puts "No War"
else
  puts "War"
end

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

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

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

using namespace std;

int main() {
    int n, m, a[100][100], b[100], c=0;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; ++i) cin >> b[i];

    for (int i = 0; i < n ; ++i) {
        for (int j = 0; j < m; ++j) {
            c += a[i][j] * b[j];
        }
        cout << c << endl;
        c = 0;
    }
    return 0;
}


Measured memory_bytes: 3140
N, K = map(int, input().split())
A = [i-1 for i in map(int, input().split())]

r = []
f = [-1]*N
now = 0
loop = 0

i = 0


while i < K:
    r.append(now)
    f[now] = i
    now = A[now]
    i += 1
    if f[now] >= 0:
        loop = i-f[now]
        nokori = K-i
        print(r[f[now]+nokori%loop]+1)
        break
else:
    print(now+1)


Measured memory_bytes: 102276
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int N, M;
std::vector<std::pair<int, int> > edge[100004];
bool used[100004];
int dist[100004];

bool dfs(int v){
  bool ok = true;
  for (int i=0; i<edge[v].size(); i++){
    int vv = edge[v][i].first;
    int d = edge[v][i].second;
    if (used[vv]) {
      if (dist[vv]!=dist[v]+d) {
	return false;
      }
    } else {
      dist[vv]=dist[v]+d;
      used[vv]=true;
      ok &= dfs(vv);
    }
  }
  return ok;
}

int main(){
  scanf("%d", &N);
  scanf("%d", &M);
  int l, r, d;
  for (int i=0; i<M; i++){
    scanf("%d", &l);
    scanf("%d", &r);
    scanf("%d", &d);
    l--;
    r--;
    edge[l].push_back(std::make_pair(r, d));
    edge[r].push_back(std::make_pair(l, -d));
  }
  for (int i=0; i<100004; i++){
    used[i]=false;
  }

  for (int i=0; i<N; i++){
    if (!used[i]) {
      dist[i]=0;
      bool ok = dfs(i);
      if (!ok) {
	std::cout << "No" << std::endl;
	return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;

// 時点 start から 時点 per おきに起こる事象がある，
// 現在の時点が now の時，次にその事象が起こる時点はいくつか．
Int NextPoint(Int start, Int per, Int now) {
    now = max(start, now);
    if (now % per != 0) {
        now += (per - (now % per));
    }
    return now;
}

int main(void) {
    Int n;
    cin >> n;
    vector<Int> c(n);
    vector<Int> s(n);
    vector<Int> f(n);
    for (Int i = 0; i < n; ++i) {
        cin >> c[i] >> s[i] >> f[i];
    }
    Int t;
    for (Int i = 0; i < n; ++i) {
        t = 0;
        for (Int j = i; j < n - 1; ++j) {
            t = NextPoint(s[j], f[j], t);
            t += c[j];
        }
        cout << t << endl;
    }
    return 0;
}



Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c[]=new int[a];
		int max=0;
		if(a==1) {
			int d=scan.nextInt();
			System.out.println(Math.abs(b-d));
		}
		else {
		for(int i=0;i!=a;i++) {
			int d=scan.nextInt();
			if(d>max) {
				max=d;
			}
			c[i]=Math.abs(b-d);
		}
		int ans=0;
		for(int i=max;;) {
			for(int j=0;j!=a+1;j++) {
				if(j==a) {
					ans=i;
					break;
				}
				if(c[j]%i!=0) {
					i=c[j]%i;
					break;
				}
			}
			if(ans!=0) {
				break;
			}
		}
		System.out.println(ans);
		}
		}
}

Measured memory_bytes: 50788
from itertools import combinations_with_replacement

n,m,q =map(int,input().split())
A,B,C,D=[],[],[],[]
res=[]
for i in range(q):
    a,b,c,d=map(int,input().split())
    A.append(a-1)
    B.append(b-1)
    C.append(c)
    D.append(d)
    
for p in combinations_with_replacement(list(range(1,m+1)),n):
    cnt=0
    for a,b,c,d in zip(A,B,C,D):
            if p[b] - p[a] ==c:
                cnt+=d
    res.append(cnt)
    
print(max(res))

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

typedef long long ll;

ll N;
string X;
vector<ll> M;
vector<ll> W;
const ll MOD = 998244353;
ll R;

ll count(ll m) {
  ll x = 0;
  for (ll i = 0; i < m; ++i) {
    (x = 2 * x + (X[i] - '0')) %= MOD;
  }
  string y;
  for (ll i = 0; i < N; ++i) {
    char c = X[i % m];
    if ((i / m) % 2 == 1) c = c == '0' ? '1' : '0';
    y += c;
  }
  return y <= X ? (x + 1) % MOD : x;
}
int main() {
  cin >> N >> X;
  for (ll d = 1; d <= N; d += 2)
    if (N % d == 0) M.push_back(N / d);
  W.resize(M.size());
  for (ll i = 0; i < M.size(); ++i) {
    W[i] = 2 * M[i] % MOD;
    for (ll j = 0; j < i; ++j) {
      if (M[j] % M[i] == 0) (W[i] += MOD - W[j]) %= MOD;
    }
    (R += W[i] * count(M[i]) % MOD) %= MOD;
  }
  cout << R << endl;
  return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  vector<int> va(3);
  for (int i = 0; i < 3; ++i) {
    cin >> va[i];
  }

  sort(va.begin(), va.end());

  int fst = va.front();
  int ans = 0;
  ans += abs(va[1] - fst);
  ans += abs(va[2] - va[1]);

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
 	int k, N;
  	cin >> k >> N;
  	int *A, *dis;
  	A = new int[N];
	dis = new int[N];  	
  	for(int i=0; i<N; i++){
     	cin >> A[i]; 
    	if(i!=0) dis[i] = A[i]-A[i-1];
    }
  	dis[0] = k - A[N-1] + A[0];
  	int max;
  	max=dis[0];
  	for(int i=0; i<N; i++){
      if(dis[i]>max) max = dis[i];
    }
  	cout << k - max << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 500;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

int main()
{
	int p, q;
	while (cin >> p >> q){
		map<int, int> db;
		string ans;
		int idx = -1, c = 0;

		db[p] = c++;

		p *= 10;
		while (1){
			//商を計算.
			ans.push_back(p / q + '0');

			//割り切れてたら終了.
			if (!(p % q)) break;

			//余りを見て循環しているか判定.
			if (db.count(p % q)){
				idx = db[p % q];
				break;
			}

			//余りとその桁数を登録.
			db[p % q] = c++;

			//余りから次の割られる値を計算.
			p = ( p % q ) * 10;
		}

		cout << ans << endl;

		if (idx != -1){
			FOR(i, ans.size()){
				if (i >= idx)	cout << "^";
				else			cout << " ";
			}
			cout << endl;
		}

		if (cin.eof()) break;
 	}

	return 0;
}

Measured memory_bytes: 1200
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	t := getNextString(scanner)

	fmt.Fprintln(writer, solve(s, t))
	writer.Flush()
}

func solve(s, t string) string {
	sl := len(s)
	tl := len(t)

	for i := 0; i <= sl-tl; i++ {
		valid := true
		for ti := 0; ti < tl; ti++ {
			si := sl - tl - i + ti
			if s[si] == '?' {
				continue
			}
			if s[si] != t[ti] {
				valid = false
				break
			}
		}
		if valid {
			ans := make([]string, sl)
			for ii := 0; ii < sl; ii++ {
				if s[ii] == '?' {
					ans[ii] = "a"
					continue
				}
				ans[ii] = fmt.Sprintf("%c", s[ii])
			}
			for ii := 0; ii < tl; ii++ {
				ans[sl-tl-i+ii] = fmt.Sprintf("%c", t[ii])
			}
			return strings.Join(ans, "")
		}
	}

	return "UNRESTORABLE"
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 #include <math.h>
using namespace std;
#define ll long long
#define pi 3.14159265359

int main(){
  int n,r;
  cin>>n>>r;
  if(n>=10){
    cout<<r<<endl;
    return 0;
  }
  cout<<r+100*(10-n)<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    string S;
    cin >> N >> S;
    ll res = 0;
    REP(i, 10)REP(j, 10)REP(k, 10){
    	string T = "";
    	T += char(i+'0');
    	T += char(j+'0');
    	T += char(k+'0');
    	ll idx = 0;
    	REP(t, S.size()){
    		if(T[idx] == S[t]) idx++;
    		if(idx==3) break;
    	}
    	res += (idx==3);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    X = LMIIS()
    for i,x in enumerate(X):
        if x == 0:
            print(i+1)
            return
    
main()

Measured memory_bytes: 65128
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var c = new int[3][];
        for (int i = 0; i < 3; i++)
        {
            c[i] = Console.ReadLine().Split().Select(t => int.Parse(t)).ToArray();
        }
        var a = new int[3];
        var b = new int[3];

        bool flag = false;
        for (int i = 0; i <= 100; i++)
        {
            a[0] = i;
            b[0] = c[0][0] - a[0];
            b[1] = c[0][1] - a[0];
            b[2] = c[0][2] - a[0];
            a[1] = c[1][0] - b[0];
            a[2] = c[2][0] - b[0];
            if (c[1][1] == a[1] + b[1] && c[1][2] == a[1] + b[2] && c[2][1] == a[2] + b[1] && c[2][2] == a[2] + b[2])
            {
                flag = true;
                break;
            }
        }
        if (flag) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
using ll=long long int;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };




int main() {

	int h, w;
	cin >> w >> h;

	char s[55][55];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}



	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			bool ans = false;
			if (s[i][j] == '#') {

				for (int k = 0; k < 4; k++) {
					int ny = i + dy[k];
					int nx = j + dx[k];

					if (s[ny][nx] == '#' && 0 <= ny && ny < h && 0 <= nx && nx < w) {
						ans = true;
					}

				}
				if (!ans) {
					cout << "No" << endl;
					return 0;
				}
			}




		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

int main(){
    ll n, x, y;
    vector<pair<ll, ll>> v;
    scanf("%lld", &n);
    for(ll i = 0; i< n; i++){
        scanf("%lld %lld", &x, &y);
        v.push_back(make_pair(x, y));
    }
    sort(v.begin(), v.end());
    for(auto i = v.begin(); i != v.end(); i++){
        printf("%lld %lld\n", i->first, i->second);
    }
    return 0;
}


Measured memory_bytes: 4928
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

// n: 回答者数
// k: 初期ポイント
// q: 問題数
int n, k, q;
// 回答者の正解数
vector<int> A;

// あとでまとめて処理する
int main() {
  cin >> n >> k >> q;
  A.resize(n);
  rep(i, q) {
    // i: 問題
    // A_i: 正解した人
    int a;
    cin >> a;
    // to 0-index
    a--;
    A[a]++;
  }

  rep(i, n) {
    int p = k - (q - A[i]);
    bool yes = p > 0;
    string ans = yes ? "Yes" : "No";
    cout << ans << endl;
  }
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int a[200000];
int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int brick_no = 1;
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(brick_no == a[i]){
      brick_no ++;
    } else {
      ans ++;
    }
  }
  if(ans < N){
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;

int main() {
  map<string, int> si;
  int n; cin >> n;
  string s[n];
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    si[s[i]]++;
  }
  int m; cin >> m;
  string t[m];
  for(int i = 0; i < m; i++) {
    cin >> t[i];
    si[t[i]]--;
  }
  int maxv = 0;
  for(int i = 0; i < n; i++) maxv = max(maxv, si[s[i]]);
  cout << maxv << endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	int l[n], r[n];
	l[0]=0, r[n-1]=0;
	for(int i=1; i<n; i++) l[i]=max(l[i-1], a[i-1]);
	for(int i=n-2; i>=0; i--) r[i]=max(r[i+1], a[i+1]);

	for(int i=0; i<n; i++) cout << max(l[i], r[i]) << endl;
	return 0;
}

Measured memory_bytes: 3968
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
if N % 2:
    print(N // 2)
else:
    print(N // 2 - 1)


Measured memory_bytes: 3064
using CompLib.Util;
using System;
using System.Collections.Generic;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] a = sc.IntArray();

        var hs = new HashSet<int>();

        foreach (var i in a)
        {
            if (!hs.Add(i))
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine("YES");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 35920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n, t;
    cin >> n >> t;
    ll sum = 0, end = 0;
    rep(i, n) {
        ll k;
        cin >> k;
        if (k > end) {
            end = k;
        }
        if (k + t > end) {
            sum += k + t - end;
            end = k + t;
        }
    }
    cout << sum << endl;
}




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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int a,b,x;
  cin>>a>>b>>x;
  if(a%x==0){
    cout<<(b/x)-(a/x)+1<<endl;
  }else{
    cout<<(b/x)-(a/x)<<endl;
  }
  
}
///////////////////////////



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (q, h, s, d) = readLine()!!.split(' ').map(String::toLong)
    val n = readLine()!!.toLong() * 4L
    println((n / 8) * longArrayOf(q * 8, h * 4, s * 2, d).min()!! +
            (n % 8 / 4) * longArrayOf(q * 4, h * 2, s).min()!! +
            (n % 4 / 2) * longArrayOf(q * 2, h).min()!! + (n % 2) * h)

}


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

signed main(void)
{
	int d, n, m, ans;
	cin >> d >> n;
	ans = 1;
	rep(i, d)
	{
		ans *= 100;
	}
	m = ans * (n / 100);
	ans *= n;
	ans += m;
	cout << ans << endl;
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);



    ll res = 0;
    ll n; cin>>n;


    for (ll i=1; i<=n; i++) {
	ll cnt=n/i;
	ll cur=i*(cnt*(cnt+1)/2);
	res += cur;
    }

    cout<<res<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3644
N = int(input())
a = list(map(int,input().split()))

x1 = [abs(a[0])] + [abs(a[i]-a[i+1]) for i in range(N-1)] + [abs(a[-1])] 
x2 = [abs(a[1])] + [abs(a[i]-a[i+2]) for i in range(N-2)] + [abs(a[-2])] 

res0 = sum(x1)

for i in range(N):
    print(res0 - x1[i] - x1[i+1] + x2[i])

Measured memory_bytes: 18396
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int wrong_num = 0;
    for(int i=0; i<n; i++){
        if(p[i] != i+1){
            wrong_num++;
        }
    }
    if(wrong_num == 0 || wrong_num == 2){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

#define maxs(x,y) (x=std::max(x,y))
#define mins(x,y) (x=std::min(x,y))

int main() {
  int A, B;
  std::cin >> A >> B;
  int cnt {};
  --B;
  for (cnt = 0;B > 0;++cnt) {
    B -= (A-1);
  }
  std::cout << cnt << '\n';
}


Measured memory_bytes: 256
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
m1,d1=map(int,input().split())
m2,d2=map(int,input().split())
if m1==m2:
    print(0)
else:
    print(1)

Measured memory_bytes: 2940
///BISMILLAH'IR  RO'HMANIR  ROH'IM
///RIFAT SHARIAR SAKIL
///SOFTWARE ENGINEERING(SUST)

#include<stdio.h>
int main()
{
    char S[10];
    scanf("%s",S);
    if(strcmp(S,"SAT")==0)printf("1");
    if(strcmp(S,"SUN")==0)printf("7");
    if(strcmp(S,"MON")==0)printf("6");
    if(strcmp(S,"TUE")==0)printf("5");
    if(strcmp(S,"WED")==0)printf("4");
    if(strcmp(S,"THU")==0)printf("3");
    if(strcmp(S,"FRI")==0)printf("2");
    return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};


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

    mint a = k;
    mint ans = a.pow(n);
    cout << ans.x << endl;
}





Measured memory_bytes: 3112
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define INT long long
#define MOD 1000000007
using namespace std;
map<INT, INT> a;
INT n, b[100010], cnt;
bool cmp(INT x, INT y){ return x > y; }
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0, x ; i < n ; i++ )
    {
        cin>>x;
        a[x]++;
    }
    for(auto x : a)
        if( x.second > 3 ) b[cnt++] = x.first, b[cnt++] = x.first;
        else if( x.second > 1 ) b[cnt++] = x.first;
    sort(b, b+cnt, cmp);
    if( cnt < 2 ) cout<<0<<endl;
    else cout<<b[0]*b[1]<<endl;
    return 0;
}


Measured memory_bytes: 6528
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    string s = readln.chomp;
    string[][] sentences = [[]];
    void Split() {
        string[] words;
        while (!s.empty) {
            if (s.startsWith("egg")) {
                words ~= "egg";
                s = s["egg".length .. $];
            } else {
                assert(s.startsWith("chicken"));
                words ~= "chicken";
                s = s["chicken".length .. $];
            }
        }
        string prev;
        foreach (word; words) {
            if (word == prev) {
                sentences ~= [[word]];
            } else {
                sentences.back ~= word;
            }
            prev = word;
        }
    }

    Split;

    ulong max_len = sentences.map!"a.length".reduce!max;
    sentences.filter!((a) => a.length == max_len).array[0].back.writeln;

    //writeln(sentences);
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
#define print(Target) cout << Target << '\n';
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;

bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

signed main()
{
  ios::sync_with_stdio(false);
  string s;

  while (cin >> s){
    while (s.find('@') != -1){
      string t;
      int key = s.find('@');
      REP(i, s[key + 1] - '0'){
        t += s[key + 2];
      }
      s.erase(key, 3);
      s.insert(key, t);
    }
    print(s);
  }

  return (0);
}

Measured memory_bytes: 1188
w, h, n = map(int, input().split())
left = 0
right = w
down = 0
up = h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        down = max(down, y)
    elif a == 4:
        up = min(up, y)

    if right - left <= 0 or up - down <= 0:
        print(0)
        exit()

ans = (right - left) * (up - down)
print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var M = cin.ReadInt;
			var A = cin.ReadIntArray(M);
			var res = N-A.Sum();
			if(res<0) res=-1;
			Console.WriteLine(res);
		}

	}
	static class ExtendClass {
		public static void Swap<T>(this T[] A, int x, int y) {
			var tmp = A[x];
			A[x]=A[y];
			A[y]=tmp;
		}
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		public static IEnumerable<int> Indices<T>(this T[] X) => Enumerable.Range(0, X.Length);
		public static IEnumerable<int> Indices<T>(this T[,] X, int dim)
			=> Enumerable.Range(0, X.GetLength(dim));
		public static string Join<T>(this T[,] X, string separatorD2 = ",", string separatorD1 = "\n")
			=> X.Indices(0).Select(
				i => X.Indices(1).Select(j => X[i, j]).Join(separatorD2)
			).Join(separatorD1);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}


Measured memory_bytes: 29528
# include <bits/stdc++.h>
using namespace std;
# define int long long
const int N = 2e5 + 10, mod = 1e9 + 7, INF = 8e18;
main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s, t; 
	cin >> s >> t;
	cout << t << s << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#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 MOD 1e9+7
#define INF 1e9
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;


int main(void){
    string s;
    cin>>s;
    REP(i,19){
        if(i==5||i==13)cout<<" ";
        else cout<<s[i];
    }
    cout<<endl;
}




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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0, pos = 0;
    rep(i, N){
        if(S[i] == 'I') pos++;
        else pos--;
        ans = max(ans, pos);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int x,y,a;
  scanf("%d %d",&x,&y);
  if(x>=y){
    a=x%y;
    while(a!=0){
      x = y;
      y = a;
      a = x % y;
    }
    printf("%d\n",y);
  }else if(y>=x){
    a=y%x;
    while(a!=0){
      y = x;
      x = a;
      a = y % x;
    }
    printf("%d\n",x);
  }
}
    



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

int main() {
  int n;
  cin >> n;
  int a[n+5];
  int b[n+5];
  int check =0;
 for(int i=1;i<=n;i++){
     cin >> a[i];
 }

 for(int i=n;i>(n/2);i--){
     if(a[i]==1){
         b[i]=1;
         check++;
     }
     else{
         b[i]=0;
     }
 }

 for(int i=(n/2);i>=1;i--){
     int ch =0;
     for(int j=2;i*j<=n;j++){
          ch += b[i*j];
     }
     if(a[i]==1 && ch%2==1){
           b[i]=0;
           
     }
     else if(a[i]==0 && ch%2==1){
         b[i]=1;
         check++;
         
         
     }
     else if(a[i]==1 && ch%2==0){
         b[i]=1;
         check++;
         
     }
     else if(a[i]==0 && ch%2==0){
         b[i]=0;
         
     }
 }

 cout << check << endl;

 for(int i=1;i<=n;i++){
     if(b[i]==1) cout << i << " " ;
 }




}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
 
        int N=sc.nextInt();
        int a[]=new int[N];
        
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
        }
        
        for(int i=0;i<N;i++){
            System.out.print(a[N-1-i]);
            if(!(i==N-1)){
                System.out.print(" ");
            }
        }
         System.out.println("");
        
    }
}


Measured memory_bytes: 26232
n,m,c = gets.split.map {|x| x.to_i}
b = gets.split.map {|x| x.to_i}
res = 0
n.times {
  a = gets.split.map {|x| x.to_i}
  sum = 0
  a.each_index { |i|
    sum += a[i]*b[i]
  }
  if (sum + c > 0)
    res += 1
  end
}
puts res


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

class UnionFind {
    vector<int> parent;

    public:
        UnionFind(int size) {
            parent = vector<int>(size, -1);
        }

        int find(int x) {
            if (parent[x] < 0) {
                // parent itself
                return x;
            } else {
                return parent[x] = find(parent[x]);
            }
        }

        bool unite(int x, int y) {
            int rX, rY;
            if ((rX = find(x)) == (rY = find(y))) {
                // already united
                return false;
            }
            if (size(rX) < size(rY)) {
                int tmp = rX;
                rX = rY;
                rY = tmp;
            }
            parent[rX] += parent[rY];
            parent[rY] = rX;
            return true;
        }

        int size(int x) {
            return -parent[find(x)];
        }

        bool isSame(int x, int y) {
            return find(x) == find (y);
        }
};

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

    vector<vector<int>> v(m, vector<int>(2));
    for (int i = 0; i < m; i++) {
        cin >> v[i][0] >> v[i][1];
    }

    int c = 0;
    for (int i = 0; i < m; i++) {
        UnionFind uf(n);
        for (int j = 0; j < m; j++) {
            if (i == j) {
                continue;
            }
            uf.unite(v[j][0] - 1, v[j][1] - 1);
        }
        if (uf.size(0) != n) {
            c++;
        }
    }
    cout << c << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define rep(i,a) for(int i = 0;i < (a); i++)
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

ll fact[300000];

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

ll mod_inverse(ll a, ll m){
    ll x, y;
    if(extgcd(a, m, x, y) == 1) return (x + m) % m;
    return 0;  // unsolvable
}

ll mod_comb(ll n, ll k, ll m){
    if(n < 0 || k < 0 || n < k) return 0;
    return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    fact[0] = 1;
    rep(i,300000-1) fact[i+1] = (i+1)*fact[i] % MOD;
    ll ans = 0;
    rep(i,k+1){
        ll j = k-i;
        ll r = (mod_comb(n+2*i, i, MOD) - mod_comb(n+2*i, i-1 ,MOD) + MOD) % MOD;
        ll d = (mod_comb(m+2*j, j, MOD) - mod_comb(m+2*j, j-1, MOD) + MOD) % MOD;
        ans = (ans+r*d % MOD * mod_comb(n+m+2*k, n+2*i, MOD)) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3504
z[1010000];
main(N,a,b,i){for(;scanf("%d%d%d",&N,&a,&b),N;printf("%d\n",a)){
	for(memset(z,0,4040000),*z=1,i=0;i<=N;i++)if(z[i])z[a+i]=a+i<=N,z[b+i]=b+i<=N;
	for(a=i=0;i<=N;i++)a+=!z[i];
}exit(0);}

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

int main(){
  int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    cout << (m <= 4 ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n;
vector<int> a;
int r[100100];

signed main() {

    cin >> n;
    a.resize(n);
    for(auto&&i:a) cin >> i;
    ll ans = 1;
    for(int i = 0; i < n; i++) {
        if(a[i]) 
            ans *= (r[a[i]-1] - r[a[i]]);
        else
            ans *= (3 - r[0]);
        ans %= SMOD;
        r[a[i]]++;
    }

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



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

int main() {
	long long int n = 0 ;
	cin >> n ;
	long long int row = 0 ;
	long long int col =0  ;
	long long int min = 1e20;
	long long int ans = 0 ; 
	for(long long int i=1; i<=sqrt(n) ; i++)
	{
		if(n%i==0)
		{
		row = i ; 
		col  = n / i ;
		ans = (row-1) + (col-1) ;
	//	cout << row << " " << col << endl;
		if(ans < min)
			min = ans ;
		}
	}
	cout << min << endl;
}
	

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

int main(){
   int n;
   cin >> n;
   vector<int> p(n);
   for (int i=0; i<n; i++)
      cin >> p.at(i);

   int ans= 0;
   for (int i=1; i<n-1; i++)
      if (p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1))
         ans++;
      else if (p.at(i-1) > p.at(i) && p.at(i) > p.at(i+1))
         ans++;

   cout <<ans << endl;
}



Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	K := sc.NextInt()

	fmt.Println([]int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}[K-1])
}

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) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	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) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	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, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

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