akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin>>n;
    int a[20],x[20][20];
    bool y[20][20];
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    int ans=-1;
    for(int bit=0;bit<(1<<n);bit++){
        int count=0;
        bool OK=true;
        bool p[20];
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                p[i]=true;
                count++;
            }
            else p[i]=false;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<a[i];j++){
                if(p[i]&&p[x[i][j]]!=y[i][j]){
                    OK=false;
                    break;
                }
            }
            if(!OK) break;
        }
        if(OK) ans=max(ans,count);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

// 14:01



using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}

int main() {
    int task = 1;
//    cin >> task;
    while (task--) {
        ll n, m;
        cin >> n >> m;
        if (abs(n - m) > 1) {
            cout << 0 << "\n";
            exit(0);
        }
        ll mod = 1e9 + 7;
        ll res = (fact(n, mod) * fact(m, mod)) % mod;
        if (n == m) {
            cout << (2 * res) % mod << "\n";
        } else {
            cout << res << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        mp[a]++;
        mp[b]++;
    }

    rep(i,n){
        if (mp[i] % 2 != 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

int main()
{
    int n, result = 0;

    cin >> n;

    vector<int> l(n);

    for(int i = 0; i < l.size();i++)
    {
        cin >> l.at(i) ;
    }
    sort(l.begin(),l.end());

    for(int i = 0; i < (n - 2) ; i++)
    {
        for (int j = i + 1  ; j < (n-1) ;  j++)
        {
            for(int t = j + 1 ; t < n; t++)
            {
                if((l.at(t) != l.at(j)) and (l.at(t) != l.at(i))and (l.at(j) != l.at(i)) and (l.at(t) < l.at(i) + l.at(j)))
                {
                    result++;   
                }
            }
        }

    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, n = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (n < K) {
      n *= 2;
    }
    else {
      n += K;
    } 
  }
  cout << n << endl;
}


Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*/


#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#define ll long long int
#define dd double
using namespace std;

int main()
{
  
	ll a,i,sum=0;
	
	cin >> a;
  for(i=1;i<=a;i++)
  {
    if(i%3==0 || i%5==0)
    continue;
    sum+=i;
  }
  cout<<sum<<endl;



  
}
//Apna Time Aayega :)

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

typedef std::pair<int, int> P;

int N;
std::string str;
int i;

bool solve(char prev) {
  for(;;) {
    while( str[i] != '(' and str[i] != ')' and str[i] != '[' and str[i] != ']' and i != N ) i += 1;
    if( i == N ) return (prev == '\0');
    
    if( str[i] == '(' ) {
      i += 1;
      if( not solve('(') ) return false;
      i += 1;
      continue;
    }
    if( str[i] == '[' ) {
      i += 1;
      if( not solve('[') ) return false;
      i += 1;
      continue;
    }
    if( prev == '(' and str[i] == ')' ) {
      return true;
    }
    if( prev == '[' and str[i] == ']' ) {
      return true;
    }
    return false;
  }
  return false;
}

int main() {

  for(;;) {
    std::getline(std::cin, str);
    if( str == "." ) break;
    N = str.size();
    i = 0;
    std::cout << (solve('\0') ? "yes" : "no") << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int N = 2e5 + 5;

void solve_test_case(){
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(auto &i: v){
		cin>>i;
	}
	ll s=0,mx = -1;
	for(int i = 0;i < n;++i){
		mx = max(mx,v[i]);
		//cout<<mx<<"\n";
		s += abs(max(0ll,(mx - v[i])));
	}
	//puts("");
	cout<<s<<"\n";
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin>>t;
	for(int i = 1;i <= t;++i){
		solve_test_case();
	}
}


Measured memory_bytes: 4728
//ex 7 5 3 1 1 3 5 7 -> 同じ数は入れ替え可能 2^(N/2)
// 奇数のとき N=7だと 6 4 2 0 2 4 6 2^((N-1)/2)
package main
import "fmt"
func main(){
	var  N int
	MOD := int(1e9)+7
	fmt.Scan(&N)
	M := make(map[int]int)
	for i:=0; i<N; i++{
		var V int
		fmt.Scan(&V)
		M[V]++
	}
	if N%2==0{
		for i:=1; i<=N-1; i+=2{
			if M[i]!=2{
				fmt.Println(0)
				return
			}
		}
		if len(M)*2 !=N{
			fmt.Println(0)
			return
		}
		fmt.Println(powMod(2, N/2, MOD))
	}else{
		for i:=2; i<=N-1; i+=2{
			if M[i]!=2{
				fmt.Println(0)
				return
			}
		}
		if M[0]!=1{
			fmt.Println(0)
			return
		}
		if len(M)*2-1 !=N{
			fmt.Println(0)
			return
		}
		fmt.Println(powMod(2, (N-1)/2, MOD))
	}
}

func powMod(a, x, mod int)int{
	if x == 0{
		return 1
	}
	ret := 1
	for x > 0{
		ret *= a
		ret %= mod
		x--
	}
	return ret
}

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

#define mod 1000000007

long long *fac_table, *rev_table;

void ini_table(long long);
long long combi(long long, long long);

int main()
{
    int n, delta{};
    scanf("%d", &n);
    int *table = new int[n];
    std::fill(table, table + n, -1);
    for (int i = 0; i < n + 1; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        tmp--;
        if (table[tmp] >= 0)
        {
            delta = i - table[tmp];
            break;
        }
        else
            table[tmp] = i;
    }
    delete[] table;

    fac_table = new long long[n + 2];
    rev_table = new long long[n + 2];
    ini_table(n);
    for (int i = 1; i <= n + 1; i++)
    {
        printf("%lld\n", (combi(n + 1, i) - combi(n - delta, i - 1) + mod) % mod);
    }

    delete[] fac_table;
    delete[] rev_table;

    return 0;
}

long long combi(long long n, long long r)
{
    if (n < r || n < 0 || r < 0) return 0;
    return fac_table[n] * rev_table[r] % mod * rev_table[n - r] % mod;
}

void ini_table(long long n)
{
    long long *tmp = new long long[n + 2];
    fac_table[0] = fac_table[1] = rev_table[0] = rev_table[1] = 1;
    tmp[1] = 1;
    for (int i = 2; i <= n + 1; i++)
    {
        fac_table[i] = fac_table[i - 1] * i % mod;
        tmp[i] = mod - tmp[mod % i] * (mod / i) % mod;
        rev_table[i] = rev_table[i - 1] * tmp[i] % mod;
    }

    delete[] tmp;
    return;
}

Measured memory_bytes: 2792
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

int main()
{
	int N;
	scanf("%d", &N); N--;

	vector<int> A;

	int res = 0;
	REP(i, N)
	{
		int B;
		scanf("%d", &B);

		if (A.empty())
		{
			A.push_back(B);
			A.push_back(B);
		}
		else
		{
			A.back() = min(A.back(), B);
			A.push_back(B);
		}
	}

	for (int a : A)
		res += a;

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

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 256
import java.util.Scanner;

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

		// 入力値の取得
		long N = sc.nextLong();
		int K = sc.nextInt();
		
		int digits = 0;
		while (N >= Math.pow(K, digits)) {
			digits++;
		}

		// 結果の出力
		System.out.println(digits);

		sc.close();
	}
}


Measured memory_bytes: 21972
n,m=map(int,input().split())
g=[list(map(int,input().split())) for i in range(n)] 
c=[list(map(int,input().split())) for i in range(m)] 

for i in g:
    tmp=10**9
    
    for j in range(m):
        t2=abs(i[0]-c[j][0]) + abs(i[1]-c[j][1])
        if t2 <tmp:
            no=j+1
            tmp=t2
            
    print(no)



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

#define fur(i,n,m,k) for (int i = (n) ; i < (m) ; i += k)
#define fr(i,n,m,k) for (int i = (n - 1) ; i >= (m) ; i -= k)
#define pub push_back
#define pob pop_back
#define Sz size()
#define F first
#define S second

typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const int maxn=1e6+20;
ll n,t,b,a,sum,d;
bool bo;
int main(){
	cin>>n;
	fur(i,1,n+1,1){
		fur(j,1,n+1,1){
			fur(k,1,n+1,1){
				sum+=__gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ctr=1;
    int si=s.size();
    rp(i,si-1){
        if(s.at(i+1)!=s.at(i)) ctr++;
    }
    cout << n-max(1,ctr-k-k) << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((n | m) == 0)
				break;
			Edge[] es = new Edge[m];
			for (int i = 0; i < m; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int d = sc.nextInt();
				es[i] = new Edge(a, b, d);
			}
			Arrays.sort(es, new Comparator<Edge>() {
				public int compare(Edge x, Edge y) {
					return x.d - y.d;
				}
			});
			int ans = Integer.MAX_VALUE;
			for (int i = 0; i < m; i++) {
				int min = Integer.MAX_VALUE;
				int max = 0;
				UnionFind uf = new UnionFind(n);
				for (int j = i; j < m; j++) {
					int a = es[j].a;
					int b = es[j].b;
					int d = es[j].d;
					if (!uf.same(a, b)) {
						uf.unite(a, b);
						min = Math.min(min, d);
						max = Math.max(max, d);
						//System.out.println(max + " " + min);
					}
				}
				if (uf.all())
					ans = Math.min(ans, max - min);
			}
			System.out.println(ans != Integer.MAX_VALUE ? ans : -1);
		}
	}
}

class Edge {
	public int a;
	public int b;
	public int d;

	Edge(int a, int b, int d) {
		this.a = a;
		this.b = b;
		this.d = d;
	}

	public String toString() {
		return this.a + " " + this.b + " " + this.d;
	}
}

class UnionFind {
	public int par[];
	public int rank[];

	UnionFind(int n) {
		par = new int[n + 1];
		rank = new int[n + 1];
		for (int i = 0; i < n + 1; i++) {
			par[i] = i;
		}
	}

	public int find(int x) {
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}

	public void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)
			return;
		if (rank[x] > rank[y]) {
			par[y] = x;
		} else {
			par[x] = y;
			if (rank[x] == rank[y])
				rank[y]++;
		}
	}

	public boolean same(int x, int y) {
		return find(x) == find(y);
	}

	public boolean all() {
		boolean flag = true;
		int a = find(1);
		for (int i = 1; i < par.length; i++) {
			if (find(i) != a) {
				flag = false;
				break;
			}
		}
		return flag;
	}
}

Measured memory_bytes: 13000
#include <stdio.h>

int main(void) {
  char c[3];
  int r[3];
  int a = 0;
  int re = 1;
  int i;
  for(i = 0; i < 3; i++) r[i] = 0;
  scanf("%c%c%c", &c[0], &c[1], &c[2]);
  for(i = 0; i < 3; i++) {
    if(c[i] == 'a') r[0] = 1;
    if(c[i] == 'b') r[1] = 1;
    if(c[i] == 'c') r[2] = 1;
  }
  for(i = 0; i < 3; i++) if(r[i] == 0) re = 0;
  if(re == 1) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

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



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

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



int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	int H, W;
	cin >> H >> W ;
	int A[100][100];
	int B[100][100];
	int Visited[100][100];
	rep(i, 0, H) {
		rep(j, 0, W) {
			char a;
			cin >> a;
			A[i][j] = (a == '#' ? 0 : 1);
			B[i][j] = 99999999;
			Visited[i][j] = 0;
		}
	}
	queue<pair<int, int>> Q;

	B[0][0] = 0;
	if (A[0][0] == 0)
		B[0][0] = 1;
	Q.push(make_pair(0, 0));
	while (!Q.empty()) {
		pair<int, int> x = Q.front();
		Q.pop();
		Visited[x.first][x.second] = 1;
		int color = A[x.first][x.second];

		queue<pair<int, int>> R;
		R.push(make_pair(x.first, x.second));
		while (!R.empty()) {
			pair<int, int> y = R.front();
			R.pop();
			int h = y.first + 1;
			int w = y.second;
			if (h < H && w < W) {
				if (A[h][w] == color && Visited[h][w] == 0) {
					R.push(make_pair(h, w));
					B[h][w] = B[x.first][x.second];
					Visited[h][w] = 1;
				}
				else if (B[h][w] > B[x.first][x.second] + 1 - A[h][w]) {
						Q.push(make_pair(h, w));
						B[h][w] = B[x.first][x.second] + 1 - A[h][w];
					
				}
			}
			h = y.first;
			w = y.second + 1;
			if (h < H && w < W) {
				if (A[h][w] == color && Visited[h][w] == 0) {
					R.push(make_pair(h, w));
					B[h][w] = B[x.first][x.second];
					Visited[h][w] = 1;
				}
				else if (B[h][w] > B[x.first][x.second] + 1 - A[h][w]) {
					Q.push(make_pair(h, w));
					B[h][w] = B[x.first][x.second] + 1 - A[h][w];

				}
			}

		}




	}
	cout << B[H - 1][W - 1];

	return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

queue<ll> Q;
vector<vector<ll>> V;
map<ll, ll> Ans;
vector<ll> A;

void bfs(){

    if(!Q.empty()){

        ll x = Q.front();

        Q.pop();

        rep(i, 0, V[x].size()){

            if(A[V[x][i]] != -1)continue;
            
            Q.push(V[x][i]);

            A[V[x][i]] = A[x] + 1;Ans[A[x]]++;

        }

        bfs();

        
    }
}

int main(){
ll N, X, Y;cin >> N >> X >> Y;

V.resize(N);
A.resize(N);

rep(i, 0, N){

    if(i != 0)V[i].push_back(i - 1);

    if(i != N - 1)V[i].push_back(i + 1);

}

V[X - 1].push_back(Y - 1);V[Y - 1].push_back(X - 1);

rep(i, 0, N){

    rep(j, 0, N){

        A[j] = -1;

    }

    Q.push(i);A[i]++;

    bfs();

}

rep(i, 0, N - 1){
  
  cout << Ans[i]/2 << endl;
  
}

}


Measured memory_bytes: 3836
from heapq import heappush, heappop

INF = 10 ** 18

sum_B = 0
L, R = [INF], [INF]
sum_L = sum_R = 0
L_size = R_size = 0

A = map(int, open(0).read().split())

Q = next(A)
for _ in range(Q):
    q = next(A)
    if q == 1:
        a, b = next(A), next(A)

        sum_B += b

        max_L = -heappop(L)
        min_R = heappop(R)

        sum_L -= max_L
        sum_R -= min_R

        l, m, r = sorted((max_L, a, min_R))
        if L_size == R_size:
            heappush(L, -l)
            heappush(L, -m)
            heappush(R, r)
            L_size += 1
            sum_L += l + m
            sum_R += r
        else:
            heappush(L, -l)
            heappush(R, m)
            heappush(R, r)
            R_size += 1
            sum_L += l
            sum_R += m + r
    else:
        median = -L[0]
        min_value = sum_B + sum_R - sum_L
        if L_size != R_size:
            min_value += median
        print(median, min_value)


Measured memory_bytes: 43972
#include<iostream>
using namespace std;
int main() {
	int x[10000],a; 
	for (int i = 1; i <= 10000;i++) {
		cin >> x[i];
		if (x[i] == 0) {
			a = i;
			break;
		}
		
	}
	for (int i = 1; i <= a - 1; i++) {
		cout << "Case " << i << ": " << x[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[55];
int cnt;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int j = 0; j < 100000; j++) {
		int ma = 0;
		int s = 0;
		for (int i = 0; i < n; i++) {
			if (n <= a[i] && ma < a[i]) {
				ma = a[i];
				s = i;
			}
		}
		if (!ma)break;
		int x = a[s] / n;
		cnt += x;
		a[s] -= x * n;
		for (int i = 0; i < n; i++) {
			if (i != s)a[i] += x;
		}
	}
	cout << cnt << endl;
}

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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 1e5 + 21, inf = 1e18 + 21, LG = 20;

int n, m;
int a[MAXN];
map <int, bool> mp;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    mp[1] = true;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        a[i] = 1;

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        if (mp[x] == true) {
            if (a[x] == 1) {
                mp[x] = false;
                mp[y] = true;
            }
            else if (a[x] > 1) 
                mp[y] = true;
        }
        a[x]--;
        a[y]++;
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++)
        if (mp[i])
            ans++;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   while (true) {
      int n;
      cin >> n;
      if (n == 0) return 0;
      vector<P> vec;
      rep(i, 0, n) {
         int x, y;
         cin >> x >> y;
         vec.emplace_back(x, y);
      }
      sort(vec.begin(), vec.end());

      int ans = 0;
      rep(i, 0, n) rep(j, i + 1, n) {
         int x_i = vec[i].first, y_i = vec[i].second;
         int x_j = vec[j].first, y_j = vec[j].second;
         P Q(x_j - y_j + y_i, y_j + x_j - x_i),
             R(x_i - y_j + y_i, y_i + x_j - x_i);
         auto itq = lower_bound(vec.begin(), vec.end(), Q);
         auto itr = lower_bound(vec.begin(), vec.end(), R);

         if (itq == vec.end() || itr == vec.end()) continue;
         if (itq->first == Q.first && itq->second == Q.second &&
             itr->first == R.first && itr->second == R.second) {
            chmax(ans, (x_i - x_j) * (x_i - x_j) + (y_i - y_j) * (y_i - y_j));
         }
      }
      cout << ans << endl;
   }

   return 0;
}


Measured memory_bytes: 3276
import numpy as np

n,m,x = map(int, input().split())
mat = []
for _ in range(n):
    mat.append(list(map(int,input().split())))
mat = np.array(mat)
min_cost = 10**5 *12+1
x_m = np.array([x]*m)
for i in range(2**n):
    sum_a = np.zeros((1,m), int)
    sum_c = 0
    for j in range(n):
        if ((i>>j)&1):
            sum_a += mat[j,1:]
            sum_c += mat[j,0]

    if np.sum(sum_a>=x_m)==m:
        if sum_c < min_cost:
            min_cost = sum_c

if min_cost > 10**5*12:
    print(-1)
else:
    print(min_cost)


Measured memory_bytes: 27300
#include<stdio.h>
    int main()
    {
        int a[]={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
};
        int b;
        
        scanf("%d", &b);
        
        
        printf("%d ",a[b-1]);
        return 0;
    }

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    deque<int> d;
    rep(i, n){
        int p = lower_bound(all(d), a[i]) - d.begin();
        if(p == 0){
            d.push_front(a[i]);
        }else d[p-1] = a[i];
    }
    cout << d.size() << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int i,j,h,w;
    
    while(1) {
        
        scanf("%d %d",&h,&w);
        
        if (h == 0 && w == 0) {
            break;
        }
        
        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                
                if (i == 0 || i == h-1 || j == 0 || j == w-1) {
                    printf("#");
                } else {
                    printf(".");
                }
                
            }
            printf("\n");
        }
        
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    int k = 1;
    for(k = 1;  k*(k-1)<=2*n; k++){
        if(k*(k-1)/2 == n)break;
    }
    if(k*(k-1)/2!=n){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << k << endl;
    vector<int>s[1000];
    int cnt = 1;
    rep(i,k){
        for(int j = i+1 ; j < k; j++){
            s[i].push_back(cnt);
            s[j].push_back(cnt++);
        }
    }
    rep(i,k){
        cout << k-1 << " ";
        rep(j,k-2){
            cout << s[i][j] << " ";
        }
        cout << s[i][k-2] << endl;
    }
}

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

using namespace std;

typedef long long ll;

// #define DBG

#ifdef DBG
#define dout if(true) cout 
#define dfor if(true) for
#else
#define dout if(false) cout
#define dfor if(false) for
#endif


int main() {
	string s,t;
	int c = 0;
	cin >> s >> t;
	for(int i=0 ; i < 3; i++){
		if(s[i] == t[i])c++;
	}
	cout << c;
	return 0;
}

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

#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
#define pii pair<ll int, ll int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define repi(i, n) for(ll i=0; i<n; i++)
#define rep(i, a, b) for(ll i=a; i<=b; i++)
#define M 1000000007

using namespace std;

int main() {
    ios
    ll n; cin>>n;
	ll a[n], b[n-1];
	repi(i,n-1) cin>>b[i];
	a[0] = b[0];
	rep(i,1,n-1) a[i] = b[i-1];
	for(ll i=n-1; i>0; i--){
		if(a[i]>b[i-1]) a[i]=b[i-1];
		if(a[i-1]>b[i-1]) a[i-1]=b[i-1];
	}
	ll ans=0;
	repi(i,n) ans += a[i];
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;
		
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}

ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
vector<ll> factorial;
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%mod;
        a = a * a%mod;
        b >>= 1;
    }
    return res;
}

ll CC(ll n, ll k) {
    return factorial[n] * inv(factorial[k]) % mod * inv(factorial[n - k]) % mod;
}


void fill_factorial(ll n) {
    factorial.resize(n+1);
    factorial[0] = 1;
    for(ll i=1; i<=n; i++) factorial[i] = (factorial[i-1]*i)%mod;
}

int main() {
	ll tttt; 
	//cin>>tttt;
	tttt = 1;
    while(tttt--) { 	
		ll n; cin>>n;
		vector<pair<ll,ll>> v;
		ll a[n],b[n],c[n],d[n];
		for(int i=0; i<n; i++) { ll x,y; cin>>x>>y; v.pb(mp(x,y)); }
		for(int i=0; i<n; i++) {
			a[i] = v[i].fi + v[i].se;
			b[i] = v[i].fi - v[i].se;
			c[i] = -v[i].fi + v[i].se;
			d[i] = -v[i].fi - v[i].se;
		}
		sort(a,a+n); sort(b,b+n); sort(c,c+n); sort(d,d+n);
		ll ans = a[n-1] - a[0];
		ans = max(ans,c[n-1]+b[n-1]);
		cout<<ans;
    } 
    return 0; 
}

Measured memory_bytes: 12640
#include <iostream>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;

int main()
{
  int sx, tx, sy, ty;
  cin >> sx >> sy >> tx >> ty;
  int X = tx - sx, Y = ty - sy;
  REP(i, X) cout << 'R';
  REP(i, Y) cout << 'U';
  REP(i, X) cout << 'L';
  REP(i, Y) cout << 'D';
  cout << 'D';
  REP(i, X + 1) cout << 'R';
  REP(i, Y + 1) cout << 'U';
  cout << 'L';
  cout << 'U';
  REP(i, X + 1) cout << 'L';
  REP(i, Y + 1) cout << 'D';
  cout << 'R';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, M;
    long K;
    cin >> N >> M >> K;
    int A[N + 10], B[M + 10];
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
    }
    for (int i = 1; i <= M; i++)
    {
        cin >> B[i];
    }
    int count_A = 0;
    long total_time = 0;
    for (int i = 1; i <= N; i++)
    {
        if (total_time + A[i] > K)
            break;
        total_time += A[i];
        count_A++;
    }
    int max = count_A;
    int count = count_A;
    int n = 1;
    for (int i = count_A; i >= 0; i--)
    {
        while (total_time + B[n] <= K)
        {
            total_time += B[n];
            count++;
            n++;
            if (n > M)
            {
                max = (max > count) ? max : count;
                cout << max;
                return 0;
            }
        }
        max = (max > count) ? max : count;
        total_time -= A[i];
        count--;
    }
    cout << max;
    return 0;
}

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

using pii = pair<int, int>;

int main() {
    int p, r, t;
    cin >> p >> r >> t;
    vector<int> l(r);
    vector<vector<int>> n(p, vector<int>(r));
    vector<int> P(t), R(t);
    for(int i = 0; i < r; ++i) {
        cin >> l[i];
    }
    for(int i = 0; i < p; ++i) {
        for(int j = 0; j < r; ++j) {
            cin >> n[i][j];
        }
    }
    for(int i = 0; i < t; ++i) {
        cin >> P[i] >> R[i];
        P[i]--; R[i]--;
    }

    int lb = 0, ub = t + 1;
    while(ub - lb > 1) {
        int m = (lb + ub) / 2;
        vector<int> available = l;
        vector<vector<pii>> need_r(r, vector<pii>(p));
        vector<vector<int>> used_r(p, vector<int>(r));
        vector<int> pos(r), cnt(p);
        queue<int> term_process;
        for(int i = 0; i < r; ++i) {
            for(int j = 0; j < p; ++j) {
                need_r[i][j] = make_pair(n[j][i], j);
            }
        }
        for(int i = 0; i < m; ++i) {
            available[R[i]]--;
            need_r[R[i]][P[i]].first--;
            used_r[P[i]][R[i]]++;
        }
        for(int i = 0; i < r; ++i) {
            sort(begin(need_r[i]), end(need_r[i]));
        }
        for(int i = 0; i < r; ++i) {
            while(pos[i] < p && (need_r[i][pos[i]].first == 0 || available[i] >= need_r[i][pos[i]].first)) {
                int process_id = need_r[i][pos[i]].second;
                if(++cnt[process_id] == r) {
                    term_process.push(process_id);
                }
                pos[i]++;
            }
        }
        while(!term_process.empty()) {
            int idx = term_process.front();
            term_process.pop();
            for(int i = 0; i < r; ++i) {
                available[i] += used_r[idx][i];
                while(pos[i] < p && available[i] >= need_r[i][pos[i]].first) {
                    int process_id = need_r[i][pos[i]].second;
                    if(++cnt[process_id] == r) {
                        term_process.push(process_id);
                    }
                    pos[i]++;
                }
            }
        }
        if(count(begin(cnt), end(cnt), r) == p) {
            lb = m;
        } else {
            ub = m;
        }
    }
    if(ub == t + 1) {
        cout << -1 << endl;
    } else {
        cout << ub << endl;
    }
}


Measured memory_bytes: 5776
import heapq as hq

Q = int(input())



low = []
high = []

_,mid,val = map(int,input().split())

for _ in range(Q-1):
    s = input()
    if s[0] == '1':
        _,a,b = map(int,s.split())
        if mid is None:
            if a < -low[0]:
                mid = -hq.heapreplace(low, -a)
            elif a > high[0]:
                mid = hq.heapreplace(high, a)
            else:
                mid = a
            val += abs(mid-a)+b
        else:
            val += abs(mid-a)+b
            x,y = sorted((a,mid))
            hq.heappush(high, y)
            hq.heappush(low, -x)
            mid = None

    else:
        print(-low[0] if mid is None else mid, val)

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

using namespace std;


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

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

    string u;
    cin >> u;

    if (s == u) {
        a--;
    } else if (t == u) {
        b--;
    }

    cout << a << " " << b << endl;
}


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

typedef long long int ll;

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

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
while (True):
    n=int(input())
    if n==0:
        break
    D=[]
    for k in range(1,int(n)+1):
       a=input()
       D.append(a)
    for i in D:
        
        A=i.replace('Hoshino','Hoshina')
        print (A)
    else:
        break



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

long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }

    return gcd(y, x%y);
}

long long lcm(long long x, long long y){
    return x/gcd(x,y)*y;
}

int main(){
    long long n;
    cin >> n;

    long long T[n];

    for(long long i = 0; i < n; i++){
        cin >> T[i];
    }

    long long ans = T[0];
    for(long long i = 1; i < n; i++){
        ans = lcm(ans, T[i]);
    }

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
    
    
int main(){
     
    int K;
    int n[32]={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};

    cin>>K;
    cout<<n[K-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
	int l = Integer.parseInt(sc.next());
    
	int x[] = new int[n];
    int y[] = new int[n];
    
    for(int i=0; i<n; i++){
      x[i] = Math.abs(l + i);
      y[i] = l + i;
    }
    
    Arrays.sort(x);
    
	int ans = 0;
	
    for(int i=0; i<n; i++){
      ans += y[i];
    } 

    int sub = 0;
    for(int i=0; i<n; i++){
      if(x[0] == Math.abs(y[i])){
        sub = y[i];
        break;
      }
    }
    
    System.out.println(ans - sub);
    
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s1, s2;
  cin >> s1;
  cin >> s2;
  bool ok = true;
  REP(i,3){
      if(s1[i]!=s2[2-i])ok = false;
  }
  if (ok)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
using System;

public class Program
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var nums = Console.ReadLine().Split(' ');
        var numsInt = new int[nums.Length];
        for (int i = 0; i < numsInt.Length; i++)
        {
            numsInt[i] = int.Parse(nums[i]);
        }
        var sortedArray = new int[numsInt.Length];
        Array.Copy(numsInt,sortedArray, numsInt.Length);
        Array.Sort(sortedArray);

        int diff = 0;
        for (int i = 0; i < numsInt.Length; i++)
        {
            if (numsInt[i] != sortedArray[i])
            {
                diff++;
            }
        }

        if (diff <= 2)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		double ans = 0;
		for (int i = 0; i < a.length; i++) {
			ans += 1.0 / a[i];
		}
		System.out.println(1 / ans);
	}
}


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

int main(){
  char s[114514];
  cin >> s;
  char copy[114514];
  int c = 0;
  for(int i = 0; i < 114514; i += 2){
    copy[c] = s[i];
    c++;
  }
  cout << copy << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)return 0;
		int sum = 0;
		for (int i = 0; i < n; i++){
			int a, b, c, d; cin >> a >> b >> c >> d;
			a += b + c;
			if		(a <= 60 && d <= 2)sum += 600;
			else if (a <= 80 && d <= 5)sum += 800;
			else if (a <= 100 && d <= 10)sum += 1000;
			else if (a <= 120 && d <= 15)sum += 1200;
			else if (a <= 140 && d <= 20)sum += 1400;
			else if (a <= 160 && d <= 25)sum += 1600;
			else {}
		}
		cout << sum << endl;
	}
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n";

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;



int main(){
    

    ll a,b; cin>>a>>b;
  	if(a==1 || b==1) {cout<<1; return 0;}
    cout<< (a*b+1)/2 <<"\n";
    
}


/*

// 

*/


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

long long N, M;
bool visit[200005];
vector<long long> route[200005];


bool reach(long long cur, long long depth){
	if(cur == N - 1){
		return true;
	}
	if(depth == 2){
		return false;
	}
	if(visit[cur]){
		return false;
	}
	visit[cur] = true;

	for(long long i = 0; i < route[cur].size(); i++){
		if( reach(route[cur][i], depth + 1)){
			return true;
		}
	}
	return false;
}


int main(){
	cin >> N >> M;
	for(long long i = 0; i < M; i++){
		long long a,b ;
		cin >> a >> b;
		a--;b--;
		route[a].push_back(b);
		route[b].push_back(a);
	}

	if(reach(0, 0)){
		cout << "POSSIBLE" << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}




}



Measured memory_bytes: 12904
(let* ((n (read))
       (as (make-array n :element-type 'fixnum)))
  (loop for i from 0 below n
        do (setf (aref as i) (read)))
  (setf as (sort as #'>))
  (princ (loop for i from 1 below n
               do (when (= (aref as i) (aref as (- i 1)))
                    (return "NO"))
               finally (return "YES")))
  (terpri))

Measured memory_bytes: 59752
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    ll s=1;
    for(int i=1;i<=n;i++)
    {
        s=(s*i)%mod;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
using namespace std;
const int num = 10000, num1 = 1000;
const int INF = 2000000000;
inline int bezout(int a, int b, int &x, int &y) {
	int d;
	if (b == 0) {
		x = 1; y = 0; return d = a;
	}
	else {
		d = bezout(b, a % b, y, x);
		y -= a / b * x;
		return d;
	}
}
int main() {
	int a, b, x, y;
	cin >> a >> b;
	bezout(a, b, x, y);
	cout << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(all(a));
    reverse(all(a));

    int center = a[0] / 2;
    int index = 1e9;
    int ans;
    repd(i, 1, n) {
        if (abs(a[i] - center) <= index) {
            index = abs(a[i] - center);
            ans = a[i];
        }
        if (abs(a[i] - (a[0] - center)) <= index) {
            index = abs(a[i] - (a[0] - center));
            ans = a[i];
        }
    }

    cout << a[0] << " " << ans << endl;
    return 0;
}

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

const int N = (int)1e5;

int microwave[N + 5];
int refrigerator[N + 5];

int main() {
    int a,b,m; scanf("%d %d %d", &a, &b, &m);

    int min_microwave = (int)1e6;
    for (int i=1; i<=a; i++) {
        scanf("%d", microwave+i);
        min_microwave = min(min_microwave, microwave[i]);
    }

    int min_refrigerator = (int)1e6;
    for (int i=1; i<=b; i++) {
        scanf("%d", refrigerator+i);
        min_refrigerator = min(min_refrigerator, refrigerator[i]);
    }

    int res = min_microwave + min_refrigerator;
    for (int i=1; i<=m; i++) {
        int x,y,c; scanf("%d %d %d", &x, &y, &c);
        res = min(res, microwave[x] + refrigerator[y] - c);
    }

    printf("%d\n", res);
    return 0;
}


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

using namespace std;

const int N = 777;
const int M = 1234567;

int a[N];
bool ok[N];
int q[N];
int d[N][N];
int x[M], y[M];
vector <int> g[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", x + i, y + i);
    x[i]--; y[i]--;
    g[x[i]].push_back(i);
    g[y[i]].push_back(i);
  }
  for (int st = 0; st < n; st++) {
    for (int i = 0; i < n; i++) {
      a[i] = -1;
    }
    int b = 0, e = 1;
    q[0] = st;
    a[st] = m;
    ok[st] = true;
    while (b < e) {
      for (int j : g[q[b]]) {
        if (j >= a[q[b]]) {
          break;
        }
        int to = x[j] + y[j] - q[b];
        if (a[to] != -1) {
          ok[st] = false;
          break;
        }
        q[e] = to;
        a[to] = j;
        e++;
      }
      if (!ok[st]) {
        break;
      }
      b++;
    }
    for (int i = 0; i < n; i++) {
      d[st][i] = a[i];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (ok[i] && ok[j]) {
        bool err = false;
        for (int k = 0; k < n; k++) {
          if (d[i][k] != -1 && d[j][k] != -1 && d[i][k] != d[j][k]) {
            err = true;
            break;
          }
        }
        if (!err) {
          ans++;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 6656