akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		if(n==m)
			System.out.print("Yes");
		else
			System.out.print("No");
	}
} 

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
string s,t;
int ans=INT_MAX;
int main(){
	cin>>s>>t;
	for(int i=0;i<s.size();++i)
	{
		int sum=0;
		if(i+t.size()>s.size())continue;
		for(int j=i;j<i+t.size();++j)
		{
			if(s[j]!=t[j-i])sum++;
			if(sum>=ans)break;
		}
		ans=min(ans,sum);
	}cout<<ans;
	return 0;
}


Measured memory_bytes: 3612
<?php
$numbers = fgets(STDIN);
$n = intval($numbers);
// print $n;
$array = [];
for($i = 0; $i < $n; $i++){
    $numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
    $array[] = array('one' => $numbers[0], 'two'=>$numbers[1]);
}
foreach( $array as $value) {
    $one_array[] = $value['one'];
    $two_array[] = $value['two'];
}

array_multisort( $one_array, SORT_ASC, SORT_NUMERIC, $two_array, SORT_ASC, SORT_NUMERIC, $array);
foreach( $array as $v) {
    echo $v['one'] . " ". $v['two'];
    echo PHP_EOL;
}


Measured memory_bytes: 99076
N = int(input())
S = [input() for i in range(N)]
S.sort()
maxi = 0
tmp = 1
ans = []
for i in range(N-1):
  if S[i] == S[i+1]:
    tmp += 1
  else:
    if tmp > maxi:
      maxi = tmp
      ans.clear()
      ans.append(S[i])
    elif tmp == maxi:
      ans.append(S[i])
    tmp = 1
  if i == N-2:
      if S[i] == S[i+1]:
        if tmp > maxi:
          maxi = tmp
          ans.clear()
          ans.append(S[i])
        elif tmp == maxi:
          ans.append(S[i])
      else:
        if maxi == 1:
          ans.append(S[N-1])
for i in range(len(ans)):
  print(ans[i])


Measured memory_bytes: 20680
/***************************************************************
	File name: D.cpp
	Author: ljfcnyali
	Create time: 2019年07月20日 星期六 20时13分42秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i ) 
#define mem(a) memset ( (a), 0, sizeof ( a ) ) 
#define str(a) strlen ( a ) 

const int maxn = 200010;

int n, a[maxn], sum;
bool vis[maxn];

int main()
{
    scanf("%d", &n); REP(i, 1, n) scanf("%d", &a[i]);
    for ( int i = n; i >= 1; -- i )
    {
        int s = 0;
        for ( int j = i + i; j <= n; j += i ) s += vis[j];
        if ( s % 2 != a[i] ) { vis[i] = true; ++ sum; }
    }
    printf("%d\n", sum); REP(i, 1, n) if ( vis[i] ) printf("%d ", i); puts("");
    return 0;
}

Measured memory_bytes: 1920
#!/usr/bin/perl

use strict;
use warnings;
use 5.010;

use Data::Dumper;

my @INPUT;
while (<>) {
    chomp;
    push @INPUT, $_;
}

my $D = $INPUT[0];

if ($D == 22) {
    say "Christmas Eve Eve Eve";
} elsif ($D == 23) {
    say "Christmas Eve Eve";
} elsif ($D == 24) {
    say "Christmas Eve";
} elsif ($D == 25) {
    say "Christmas";
}


Measured memory_bytes: 1920
import java.util.Scanner;
class Main{
  static int N;
  static int K;
  static int[] h;
  static int[] memo;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    K = sc.nextInt();
    h = new int[N];
    memo = new int[N];

    for(int i = 0; i < N; i++){
      h[i] = sc.nextInt();
      memo[i] = -1;
    }
    memo[0] = 0;
    System.out.println(dp(N - 1));
  }

  static int dp(int i){
    if(memo[i] == -1){
      int min = (int)1e9;
      for(int n = 1; n <= K && n <= i; n++){
        int tmp = dp(i - n) + Math.abs(h[i] - h[i - n]);
        if(tmp < min)
          min = tmp;
      }
      memo[i] = min;
    }
    return memo[i];
  }
}

Measured memory_bytes: 70600
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll n, k; cin >> n >> k;
	vector<ll> m, p, z;
	rep(i, n)
	{
		ll a; cin >> a;
		if (a < 0)m.push_back(a);
		else if (a > 0)p.push_back(a);
		else z.push_back(a);
	}
	ll mNum = m.size();
	ll pNum = p.size();
	ll zNum = z.size();
	ll mCnt = mNum * pNum;
	ll pCnt = (mNum * (mNum - 1) / 2) + (pNum*(pNum - 1) / 2);
	ll zCnt = zNum * (mNum + pNum) + (zNum*(zNum - 1) / 2);
	if (k <= mCnt)
	{
		sort(all(m));
		ll ng = -1e18-1, ok = -1;
		while (abs(ok - ng) > 1)
		{
			ll mid = (ok + ng) / 2;
			ll cnt = 0;
			rep(i, pNum)cnt += upper_bound(all(m), (mid - p[i] + 1) / p[i]) - m.begin();
			if (k <= cnt)ok = mid;
			else ng = mid;
		}
		cout << ok << endl;
	}
	else if (k <= mCnt + zCnt)cout << 0 << endl;
	else
	{
		k -= mCnt + zCnt;
		sort(all(p));
		rep(i, mNum)m[i] *= -1;
		sort(all(m));
		ll ng = 0, ok = 1e18;
		while (abs(ok - ng) > 1)
		{
			ll mid = (ok + ng) / 2;
			ll cnt = 0;
			rep(i, pNum)
			{
				ll it = upper_bound(all(p), mid / p[i]) - p.begin() - i - 1;
				cnt += max(0LL, it);
			}
			rep(i, mNum)
			{
				ll it = upper_bound(all(m), mid / m[i]) - m.begin() - i - 1;
				cnt += max(0LL, it);
			}
			if (k <= cnt)ok = mid;
			else ng = mid;
		}
		cout << ok << endl;
	}
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb  push_back
int32_t main()
{
    string  X;
    cin>>X;
    if((X=="AAA") || (X=="BBB"))
    cout<<"No";
    else
    cout<<"Yes";
    return 0;
}




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

// why am I so weak

int n, m;
int a[355][355];
int cnt[355];

bool used[355];

void rebuild() {
	memset(cnt, 0, sizeof(cnt));

	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (!used[a[i][j]]) {
		cnt[a[i][j]]++;
		break;
	}
}
int main() {
	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
		scanf("%d", &a[i][j]);
		a[i][j]--;
	}

	for (int i = 0; i < n; i++) cnt[a[i][0]]++;

	int res = *max_element(cnt, cnt + m);

	for (int _ = 0; _ + 1 < m; _++) {
		int id = -1;

		for (int i = 0; i < m; i++) if (!used[i]) {
			if (id < 0 || cnt[id] < cnt[i]) {
				id = i;
			}
		}

		used[id] = true;
		rebuild();

		res = min(res, *max_element(cnt, cnt + m));
	}

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

	return 0;
}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;

/////////////////////////////////

int const MAX = 2e5 + 41;
int const MOD = 998244353;

string s;
int n;
int ans;
int d[MAX][4][3][2];
int addone;

int add(int a, int b) {
	return (a + b) % MOD;	
}

int mult(int a, int b) {
	return (ll) a * b % MOD;
}

void init() {
	set<int> t;
	addone = true;
	fi(0, sz(s) - 1) {
		t.insert(s[i]);
		if (i + 1 < sz(s)) {
			if (s[i] == s[i + 1]) addone = 0;
		}
	}
	if (sz(t) == 1) {
		printf("1\n");
		exit(0);
	}
}

set<string> t;

char getnxt(char a, char b) {
	if (a > b) swap(a, b);
	if (a == 'a' && b == 'b') return 'c';
	if (a == 'a' && b == 'c') return 'b';
	return 'a';
}

void dfs(string s) {
	t.insert(s);
	fi(0, sz(s) - 2) {
		if (s[i] == s[i + 1]) continue;
		string s1 = s;
		s1[i] = s1[i + 1] = getnxt(s[i], s[i + 1]);
		if (t.find(s1) != t.end()) continue;
		dfs(s1);
	}
}

void solve() {
	if (sz(s) < 7) {
		dfs(s);
		printf("%d\n", sz(t));
		return;
	}
	init();	
	int sum = 0;
	vi v;
	fi(0, sz(s) - 1) {
		v.pb(s[i] - 'a');
	}
	fi(0, sz(v) - 1) {
		sum += v[i];
	}
	sum %= 3;
	d[0][3][0][0] = 1;
	fi(0, sz(v) - 1) {
		for (int c1 = 0; c1 <= 3; c1++) {
			for (int s = 0; s < 3; s++) {
				for (int f = 0; f < 2; f++) {
					for (int c2 = 0; c2 <= 2; c2++) {
						int nc = c2;
						int ns = (s + c2) % 3;
						int nf = f;
						if (c1 == c2) nf = 1;
						d[i + 1][nc][ns][nf] = add(d[i + 1][nc][ns][nf], d[i][c1][s][f]);
					}
				}
			}
		}
	}
	ans = add(ans, addone);
	fi(0, 2) {
		ans = add(ans, d[sz(s)][i][sum][1]);
	}
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  cin >> s;
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

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

int main() {
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	if((A+B)>(C+D)){
		cout<<"Left"<<endl;
	}
	else if((A+B)<(C+D)){
		cout<<"Right"<<endl;
	}
	else{
		cout<<"Balanced"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
	ll n,k; cin>>n>>k;
	ll r,S,p; cin>>r>>S>>p;
	string s; cin>>s;
	vector<char> c(n);
	int ans=0;
	for(int i=0;i<n;i++){
		if(i<k){
			if(s[i]=='r') c[i]='p',ans+=p;
			else if(s[i]=='p') c[i]='s',ans+=S;
			else if(s[i]=='s') c[i]='r',ans+=r;
		}else{
			if(s[i]=='r'){
				if(c[i-k]!='p'){
					c[i]='p';
					ans+=p;
				}else{
					if(i+k>=n) c[i]='r';
					else {
						c[i]=s[i+k];
					}
				}
			}
			if(s[i]=='p'){
				if(c[i-k]!='s'){
					c[i]='s';
					ans+=S;
				}else{
					if(i+k>=n) c[i]='p';
					else {
						c[i]=s[i+k];
					}
				}
			}
			if(s[i]=='s'){
				if(c[i-k]!='r'){
					c[i]='r';
					ans+=r;
				}else{
					if(i+k>=n) c[i]='s';
					else {
						c[i]=s[i+k];
					}
				}
			}
		}
	}
//	for(char x:c) cout<<x; cout<<endl;
	cout<<ans;
}


Measured memory_bytes: 3832
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n, m = 0;
  set<int> a;

  cin >> n;
  REP(i, n)
  {
    int ai;
    cin >> ai;
    for (auto &aa : a)
    {
      m = max(m, abs(aa - ai));
    }
    a.insert(ai);
  }

  cout << m << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[114][114];
int main(){
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>a[i];
	for(int i=0;i<h+2;i++){
		for(int j=0;j<w+2;j++){
			if(i==0||j==0||i==h+1||j==w+1)cout<<'#';
			else cout<<a[i-1][j-1];
			}
			cout<<endl;
		}
	}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
using namespace std;

int a[13];
bool m[13][13];
int pr[] = {1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5};
int pc[] = {3, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 3};
long long int g;

typedef pair<int, long long int> P;

long long int encode(int *x) {
  long long int t = 0;
  for (int i=0; i<13; ++i) {
    t <<= 4;
    t |= x[i];
  }
  return t;
}

void decode(long long int s, int *x) {
  for (int i=12; i>=0; --i) {
    x[i] = (int)(s & 0xf);
    s >>= 4;
  }
}

int manhattan(int *x) {
  int y = 0;
  for (int i=0; i<13; ++i) {
    if (!x[i]) {
      continue;
    }
    y += abs(pr[x[i]] - pr[i]);
    y += abs(pc[x[i]] - pc[i]);
  }
  return y;
}

void init() {
  a[0] = a[12] = 0;
  for (int i=1; i<12; ++i) {
    a[i] = i;
  }
  g = encode(a);

  for (int i=0; i<13; ++i) {
    int r1 = pr[i];
    int c1 = pc[i];
    m[i][i] = false;
    for (int j=i+1; j<13; ++j) {
      int r2 = pr[j];
      int c2 = pc[j];
      if (((r1 == r2) && (c1 == c2 + 1 || c1 == c2 - 1))
          || ((c1 == c2) && (r1 == r2 + 1 || r1 == r2 - 1))) {
        m[i][j] = m[j][i] = true;
      } else {
        m[i][j] = m[j][i] = false;
      }
    }
  }
}

bool input() {
  int t;
  for (int i=0; i<13; ++i) {
    cin >> t;
    if (!i && t == -1) {
      return false;
    }
    a[i] = t;
  }
  return true;
}

struct Comparator {
  bool operator()(const P l, const P r) const {
    return l > r;
  }
};

int solve() {
  priority_queue<P, vector<P>, Comparator> q;
  set<long long int> u;

  long long int t;
  t = encode(a);
  q.push(make_pair(manhattan(a), t));

  while (!q.empty()) {
    P p = q.top();
    q.pop();

    if (u.find(p.second) != u.end()) {
      continue;
    }
    u.insert(p.second);

    if (p.second == g) {
      return p.first;
    }

    decode(p.second, a);
    int x = manhattan(a);
    int y = p.first - x;
    if (y >= 20) {
      break;
    }
    for (int i=0; i<13; ++i) {
      if (a[i]) {
        continue;
      }
      for (int j=0; j<13; ++j) {
        if (!m[i][j]) {
          continue;
        }
        a[i] = a[j];
        a[j] = 0;
        int z = manhattan(a);
        q.push(make_pair(y + 1 + z, encode(a)));
        a[j] = a[i];
        a[i] = 0;
      }
    }
  }
  return -1;
}

int main() {
  int ans;
  init();
  while (1) {
    if (!input()) {
      break;
    }
    ans = solve();
    if (ans >= 0) {
      cout << ans << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1328
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    int i,j,l,c=0,z=0,g=0,d=0,f;
    char s[205], k[205];
    cin>>s;
    cin>>k;
    l = strlen(s);
    char mim[l];
    for(i=0; i<l; i++){
        for(j=i; j<l-1; j++){
            if(k[g]==s[j+1])d++;
            g++;
        }
        for(f=0; f<i; f++){
            if(k[g]==s[f])d++;
            g++;
        }
        g=0;
        if(d==l-1)z++;
        d=0;

    }
    if(z>0)cout<<"Yes";
    else cout<<"No";

    return 0;

}


Measured memory_bytes: 256
N = int(input())
for h in range(N//4 + 1, 3501):
    for n in (N * h // (4 * h - N) + 1, 3501):
        w = N * h * n // (4 * h * n - N * h - N * n)
        if w * (4 * h * n - N * h - N * n) == N * h * n:
            print(h, n, w)
            exit()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1e9

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

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

    ll N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;

    if(S[0] != T[0]) {
        cout << -1 << endl;
        exit(0);
    }

    ll x = lcm(N, M);


    if (lcm(x/N, x/M) < x) {
        /*
        string large;
        string small;
        ll lsize;
        ll ssize;
        if(N<=M) {
            large = T;
            small = S;
            lsize = M;
            ssize = N;
        }else {
            large = S;
            small = T;
            lsize = N;
            ssize = M;
        }
        ll index = lsize/ssize;
        ll z = 1;
        while (index < lsize) {
            //cout << index << endl;
            //cout << large[index] << " " << small[z] << endl;
            if (large[index] != small[z]) {
                cout << -1 << endl;
                exit(0);
            }
            z++;
            index *= z;
        }
        */
        ll i = x/N;
        ll j = x/M;
        ll x2 = lcm(i, j);
        //cout << i << j << endl;
        for (ll k = 1; k*x2 < x; k++) {
            if (S[k*x2/i] != T[k*x2/j]) {
                cout << -1 << endl;
                exit(0);
            }
        }
    }

    cout << x << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

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

	}
	return 0;
}

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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n - 1; ++i)
    {
        int u;
        cin >> u;
        --u;
        ++a[u];
    }
    for (int i = 0; i < n; ++i)
    {
        cout << a[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3932
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
map<long long,long long> mp;
int main(){
	long long n,p;
	cin>>n>>p;
	set<long long> s;
	long long P=p;
	vector<long long> v;
	for(long long i=2;i*i<=P;i++){
		if(P%i==0){
			while(p&&p%i==0){
				p/=i;
				s.insert(i);
				mp[i]++;
			}
			v.push_back(P/i);
		}
	}
	for(int i=0;i<v.size();i++){
		while(p&&p%v[i]==0){
			p/=v[i];
			s.insert(v[i]);
			mp[v[i]]++;
		}
	}
	if(s.size()==0){
		s.insert(P);
		mp[P]++;
	}
	long long cnt=1;
	for(set<long long> ::iterator it=s.begin();it!=s.end();it++){
		if(mp[*it]>=n){
			for(int j=0;j<mp[*it]/n;j++)cnt*=*it;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int x,y,w,h,r;
    cin>>w>>h>>x>>y>>r;
if((x-r)<0||(x+r)>w||(y-r)<0||(y+r)>h)
        cout<<"No\n";
    else
        cout<<"Yes\n";
}



Measured memory_bytes: 3084
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
list<LL>li[20000];
vector<LL>v;
map<string, vector<LL>>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	rep(i, m) {
		LL x, y,z;
		cin >> x;
		if (x == 0) {
			cin >> y >> z;
			li[y].push_back(z);
		}
		if (x == 1) {
			cin >> y;
			for (auto itr = li[y].begin(); itr != li[y].end();itr++) {
				if (itr != li[y].begin())cout << " ";
				cout << *itr;
			}
			cout << endl;
		}
		if (x == 2) {
			cin >> z >> y;
			li[y].splice(li[y].end(), move(li[z]));
		}
	}
	return 0;
}


Measured memory_bytes: 23720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b==0) return a;
    else{
    	return gcd(b,a%b);
    }
}
 
int main() {
	ll a,b,c;
  	cin >> a >> b >> c;
  	if((a*100+b*10+c)%4==0){
      cout << "YES" << endl;
    }
  	else{
      cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 1e5 + 500;

int dp[N], n, m, vel[N];

int main(){
	scanf("%d%d", &n, &m);
	dp[1] = 1;
	for(int i = 1;i <= n;i++)
		vel[i] = 1;
	for(int i = 0;i < m;i++){
		int x, y; scanf("%d%d", &x, &y);
		if(dp[x]){
			dp[y] = 1;
		}
		vel[y]++; vel[x]--;
		if(!vel[x])
			dp[x] = 0;
	}
	int sol = 0;
	for(int i = 1;i <= n;i++)
		sol += dp[i];
	printf("%d\n", sol);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)       sort((a).begin(), a.end()), (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;

LL gcd(LL a, LL b)
{
	if (!a)return b; return gcd(b%a, a);
}
double intlog(double base, double x) {
	return (double)((double)log(x) / (double)log(base));
}

int main()
{
	int n;
	cin >> n;
	VI v(n);
	rep(i, n)cin >> v[i];

	v[0]--;
	for (int i = 1; i < n; i++)
	{
		if (v[i] > v[i - 1])
		{
			v[i]--;
		}
		else if(v[i]<v[i-1])
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}













Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;

int main()
{
	vector<int> a,b,c;
  	int i, nsat;
	int n;
	cin >> n;
	for (i = 0; i < n; i++)
  	{
		int x;
		cin >> x;
		a.push_back(x);
	}
	for (i = 0; i < n; i++)
  	{
		int x;
		cin >> x;
		b.push_back(x);
	}	for (i = 0; i < n - 1; i++)
  	{
		int x;
		cin >> x;
		c.push_back(x);
	}
  i = 0;
  while (i < a.size())
    {
      int index = a[i] - 1;
      nsat += b[index];
      if (index > 0 && a[i] - a[i - 1] == 1)
      {
        nsat += c[index - 1];
      }
    i++;
    }
  	cout << nsat;
 	 return 0;
}

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

using namespace std;

const int N = 110;
int n;
long long d[N][N];

void floyd() {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (d[i][k] == INT_MAX || d[k][j] == INT_MAX) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int e, u, v, c;
    cin >> n >> e;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            d[i][j] = i == j ? 0 : INT_MAX;
        }
    }

    for (int i = 0; i < e; i++) {
        cin >> u >> v >> c;
        d[u][v] = c;
    }

    floyd();

    bool negative = false;
    for (int i = 0; i < n; i++) {
        if (d[i][i] < 0) {
            negative = true;
            break;
        }
    }

    if (negative) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j) cout << " ";
                if (d[i][j] == INT_MAX) cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    long long ans = 0;
    long long tol = a[0];
    for(int i=0; i<n; i++){
        if(a[i] > tol) tol = a[i];
        else ans += tol - a[i];
    }
    cout << ans << endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) (int)(a).size()
#define mins(a,...) a = min({a, ## __VA_ARGS__})
#define maxs(a,...) a = max({a, ## __VA_ARGS__})
#define plusMod(a,b) a = (a % mod + b % mod) % mod
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) {
    return os.put(os.widen('\n'));
}
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}

string s;
void solve() {
    cin >> s;

    auto n = sz(s);
    int l = 0, r = n - 1;
    int ans = 0;
    bool ok = true;
    while (l < r) {
        if (s[l] == s[r]) {
            ++l, --r;
        }
        else {
            if (s[l] == 'x') {
                ++ans;
                ++l;
            }
            else if (s[r] == 'x') {
                ++ans;
                --r;
            }
            else {
                ok = false;
                break;
            }
        }
    }

    if (ok)
        cout << ans << endn;
    else
        cout << -1 << endn;

}


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

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 512
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B = lr()
for x in range(1, 10001):
    if x * 8 // 100 == A and x * 10 // 100 == B:
        print(x); exit()

print(-1)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
vector<Int> edge[108000];

Int cond[108000];
bool done[108000];
Int u[108000];
Int cnt[108000];

Int r(Int x){
  if(u[x] == x)return x;
  return u[x] = r(u[x]);
}

void unite(Int a, Int b){
  a = r(a);
  b = r(b);
  if(a == b)return;
  u[a] = b;
}

bool dfs(Int x, Int parity = 1){
  if(cond[x] != -1){
    return cond[x] == parity;
  }
  cond[x] = parity;
  for(Int i = 0;i < edge[x].size();i++){
    Int to = edge[x][i];
    if(!dfs(to, !parity))return false;
  }
  return true;
}


  Int a, b, c, n, m;
int main(){
  cin >> n >> m;
  for(int i = 0;i < 108000;i++)u[i] = i;
  for(Int i = 0;i < m;i++){
    int u, v;
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
    unite(u, v);
  }
  for(Int i = 1;i <= n;i++){
    cond[i] = -1;
    cnt[r(i)]++;
  }
  for(Int i = 1;i <= n;i++){
    if(cnt[r(i)] == 1){
      c++;
      continue;
    }
    
    if(done[r(i)])continue;
    done[r(i)] = true;

    if(dfs(i))a++;
    else b++;
  }
  cout << a*a + (a+b)*(a+b) + 2*n*c - c*c << endl;
  return 0;
}

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

using namespace std;
int main(){
  long n,m;
  cin >> n >> m;
  
  pair<long,long> p[n+m];
  
  for(int i=0;i<n;i++){
   long a;
    cin >> a;
    p[i]=make_pair(a,long(1));
  }
  for(int i=n;i<n+m;i++){
   long b,c;
    cin >> b >> c;
    p[i]=make_pair(c,b);
  }
  
  sort(p,p+n+m);
  
  long res=0;
  long num=0;
  long ptr=n+m-1;
  while(num<n){
   if(num+p[ptr].second<=n) {
     res+=(p[ptr].first)*(p[ptr].second);
    num+=p[ptr].second;
   }
   else {
     res+=(p[ptr].first)*(n-num);
    num=n;
   }
    ptr--;
  }
  
 cout << res << endl;
  
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[][] c = new int[3][];
        for (int i = 0; i < 3; i++)
        {
          int[] row = Console.ReadLine().Split().Select(int.Parse).ToArray();
            c[i] = row;
        }

        int[] a = new int[3];
        int[] b = new int[3];

        a[0] = 0;
        b[0] = c[0][0];
        b[1] = c[0][1];
        b[2] = c[0][2];
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];

        for (int i = 1; i < 3; i++)
        {
            for (int j = 1; j < 3; j++)
            {
                if (c[i][j] != a[i] + b[j])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }

        Console.WriteLine("Yes");
    }

}


Measured memory_bytes: 13396
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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

typedef pair <ll,ll> P;

bool pairCompareF(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}

bool pairCompareS(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main()
{
    string s;
    cin >> s;
    vector<char> ss;
    rep(i, s.length())
    {
        if (s[i] == 'B') {
            if (ss.size() != 0) ss.pop_back();
        } else {
            ss.push_back(s[i]);
        }
    }
    rep(i, ss.size()) {
        cout << ss[i];
    }
    cout << endl;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b, c;

int main(void) {
  // Here your code !
  scanf("%d %d %d", &a, &b, &c);

  printf("%d\n", min(b / a, c));

  return 0;
}


Measured memory_bytes: 256
a = raw_input()

t = ['dream', 'dreamer', 'erase', 'eraser']

while len(a) > 0:
	if a[:7] == 'dreamer' and a[:8][-1] != 'a':
		a = a[7:]
	elif a[:6] == 'eraser':
		a = a[6:]
	elif a[:5] in ['dream', 'erase']:
		a = a[5:]
	else:
		print "NO"
		break

if len(a) == 0:
	print "YES"


Measured memory_bytes: 2820
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    string s;
    cin >> s;
    reverse(all(s));
    while(!s.empty()) {
        if(s.size() < 3) break;
        if(s.substr(0, 3) == "mae" and s.size() >= 5 and s.substr(0, 5) == "maerd") {
            s = s.substr(5);
        } else if(s.substr(0, 3) == "rem" and s.size() >= 7 and s.substr(0, 7) == "remaerd") {
            s = s.substr(7);
        } else if(s.substr(0, 3) == "esa" and s.size() >= 5 and s.substr(0, 5) == "esare") {
            s = s.substr(5);
        } else if(s.size() >= 6 and s.substr(0, 6) == "resare") {
            s = s.substr(6);
        } else {
            break;
        }
    }

    cout << (s.empty() ? "YES":"NO") << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main() {
    int n;
    char s;
    
    bool y = false;
    
    cin >> n;
    REP(i, n){
        cin >> s;
        if(s == 'Y'){
            y = true;
        }
    }
    
    if(y){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if (S.length() == 2)
			System.out.println(S);
		else
			System.out.println(S.charAt(2) +"" +S.charAt(1)+"" +S.charAt(0));
	}
}	


Measured memory_bytes: 23380
N, Y=list(map(int, input().split()))

x, y, z = -1, -1 ,-1
for i in range(0, N+1):
    for j in range(0, N-i+1):
        if 10000*i+5000*j+1000*(N-i-j)==Y:
            x, y, z = i, j, N-i-j
            break
print(x, y, z)


Measured memory_bytes: 3060
s = input()
n = len(s)

make = [[0 for i in range(4)] for j in range(n + 1)]

make[n][3] = 1

mod = 10**9 + 7

for i in range(n - 1, -1, -1):
	if s[i] == '?':
		make[i][0] += make[i + 1][0] * 3 + make[i + 1][1]
		make[i][1] += make[i + 1][1] * 3 + make[i + 1][2]
		make[i][2] += make[i + 1][2] * 3 + make[i + 1][3]
		make[i][3] += make[i + 1][3] * 3
	elif s[i] == 'A':
		make[i][0] += make[i + 1][0] + make[i + 1][1]
		make[i][1] += make[i + 1][1]
		make[i][2] += make[i + 1][2]
		make[i][3] += make[i + 1][3]
	elif s[i] == 'B':
		make[i][0] += make[i + 1][0]
		make[i][1] += make[i + 1][1] + make[i + 1][2]
		make[i][2] += make[i + 1][2]
		make[i][3] += make[i + 1][3]
	elif s[i] == 'C':
		make[i][0] += make[i + 1][0]
		make[i][1] += make[i + 1][1]
		make[i][2] += make[i + 1][2] + make[i + 1][3]
		make[i][3] += make[i + 1][3]

	make[i][0] %= mod
	make[i][1] %= mod
	make[i][2] %= mod
	make[i][3] %= mod

print(make[0][0])

Measured memory_bytes: 27588
import bisect

N = int(input(), 10)

heads = list(sorted(map(int,input().split())))
bodies = list(map(int,input().split()))
legs = list(sorted(map(int,input().split())))


cnt = 0
for body in bodies:
    #  頭は、体より小さくなければならない
    head_cnt = bisect.bisect_left(heads, body)
    #  足は、体より大きくなければならない
    leg_cnt = N - bisect.bisect_right(legs, body)

    cnt += head_cnt * leg_cnt # 組み合わせの掛け算

print(cnt)


Measured memory_bytes: 23872
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	prefixSum := make([]int, n)
	var sum int
	for i := 0; i < n; i++ {
		scanner.Scan()
		w, _ := strconv.Atoi(scanner.Text())
		sum += w
		prefixSum[i] = sum
	}

	smallest := math.MaxInt32
	for i := 0; i < n-1; i++ {
		s1 := prefixSum[i]
		s2 := prefixSum[n-1] - prefixSum[i]
		abs := s2 - s1
		if abs < 0 {
			abs = -abs
		}
		if abs < smallest {
			smallest = abs
		}
	}

	fmt.Println(smallest)
}


Measured memory_bytes: 640
'use strict'

function main(input) {
  input = input
    .trim()
    .split(' ')
    .map(v => ~~v)
  const k = input[0]
  const x = input[1]

  if (k === 1) {
    console.log(x + '')
    return
  }

  let ans = []
  for (let i = x - (k - 1); i < x + k; i++) {
    ans.push(i)
  }
  console.log(ans.join(' '))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int a, b, x;

int main(void) {

	cin >> a >> b >> x;

	int V = a*a*b;

	long  double y, z;

	long double ans;

	if (2 * x >= V) { y = 2.0L*(V - x) / a/a; 
	
	ans = atan(y / a)*180.0 / 3.14159265358979;;
	}
	else { z = 2.0L*x / a / b;

	ans = atan(b/z)*180.0/3.14159265358979;

	}

	//cout << z << endl;

	cout << setprecision(12)<<fixed<<ans << endl;
	return 0;
}

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

typedef long long ll;

const int INF = 100000000;

int main() {
    string S;
    cin >> S;
    int ans = 0;

    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<cstdlib>
#define INF 1001001001001001001
#define MAX 2001001

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long>a(n);
	rep(i, 0, n)cin >> a[i];

	long long int ans = 0, m = 0;
	rep(i, 0, n) {
		if (a[i] >= m) {
			m = max(m, a[i]);
			continue;
		}
		ans += m - a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4776
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60

def prime_factorize(n):
    a = defaultdict(int)
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

def main():
    N = int(readline())
    a = prime_factorize(N)
    
    ans = 0
    for power in a.values():
        ans += int(((1 + 8 * power) ** 0.5 - 1 ) / 2)
        
    print(ans)
    return


if __name__ == '__main__':
    main()


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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    Int res = 0;
    for (Int i = 1; i <= (Int)n; i++) {
        if (i % 3 != 0 and i % 5 != 0) {
            res += i;
        }
    }
    print(res);
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
typedef pair<ll, ll> P;
const int limit = 50;
int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v)
{
    // vを起点とする
    // vを到達済みとする
    visited[v] = true;
    // vから伸びる辺を通って行ける点でDFSをする
    for (int v2 = 0; v2 < n; v2++) {
        if (graph[v][v2] && !visited[v2]) {
            dfs(v2);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        // a，b間での辺があるとする
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < m; i++) {
        // ある辺がなくなったとする
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        // すべての点に行けないとする
        for (int j = 0; j < n; j++) {
            visited[j] = false;
        }

        // 0からdfsをする
        dfs(0);

        // もし行けない点が存在したらans++
        bool bridge = false;
        for (int j = 0; j < n; j++) {
            if (!visited[j]) {
                bridge = true;
                break;
            }
        }
        if (bridge) {
            ans++;
        }
        // 再びgraphを初期化する
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define INF 99999999
using namespace std;

int main() {
    int n, a1, b1, amax = 0;
    long long h, ans = 0, cnt = 0;
    cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a1 >> b1;
        b[i] = b1;
        amax = max(amax, a1);
    }
    sort(b.begin(), b.end(), greater<>());
    int i = 0;
    while(b[i] > amax and h > 0 and i < n) {
        h -= b[i];
        ++i;
        ++ans;
        cnt++;
    }
    if(h > 0) ans += ceil(h*1.0/amax);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << 
 << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int n;
    cin >> n;
    VVI a(n, VI(26));
    string s;
    REP(i,0,n) {
        cin >> s;
        REP(j,0,s.size()) {
            a[i][s[j]-'a']++;
        }
    } 
    REP(i,0,26) {
        int mv = 999;
        REP(j,0,n) mv = min(mv, a[j][i]);
        REP(j,0,mv) cout << (char)(i + 'a');
    }
    cout << endl;
    
    return 0;
}

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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int cnt = 0;
    vector<int> ans;
    vector<int> :: iterator it;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if(a == b){
            cnt++;
            ans.push_back(cnt);
            //cout << cnt << endl;
        }
        else{
            //cout <<  cnt << endl;
            cnt = 0;
        }
    }
    int fi = 0;
    //it = find(ans.begin(), ans.end())
    /*
    for(auto i: ans){
        cout << i << " ";
    }
    cout << endl;
    */
    for(int i = 0; i < ans.size(); i++){
        if(ans[i] >= 3 && ans[i] % 3 == 0){
            fi++;
        }
    }
    //cout << fi << endl;
    if(fi >= 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    string S;

    cin >> N;
    cin >> S;
    deque<char> ans(N);
    int m = 0; // ')' の数-'('の数
    int b = 0;
    for (size_t i = 0; i < N; i++)
    {
        ans[i] = S[i];
    }

    for (int i = 0; i < N; ++i)
    {
        if (S[i] == ')')
            m++;
        else
            m--;

        if (m > 0)
        {
            ans.push_front('(');
            m--;
        }
    }
    m = 0;
    for (int i = N - 1; i >= 0; --i)
    {
        if (S[i] == '(')
            m++;
        else
            m--;

        if (m > 0)
        {
            ans.push_back(')');
            m--;
        }
    }
    for (auto &&i : ans)
    {
        cout << i;
    }

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    map<string, int> S{};
    for (int i = 0; i < N; i++) {
        string si;
        cin >> si;
        S[si] = 1;
    }
    cout << S.size() << endl;
    
        
}

Measured memory_bytes: 19172
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int H,A;
    cin>>H>>A;
    if(H%A==0){
        cout<<H/A<<endl;
    }else{
        cout<<H/A+1<<endl;
    }
}

Measured memory_bytes: 256
import itertools

n = int(input())
a = [0] * 5
ans = 0
for i in range(n):
    s = input()
    if s[0] == "M":
        a[0] += 1
    if s[0] == "A":
        a[1] += 1
    if s[0] == "R":
        a[2] += 1
    if s[0] == "C":
        a[3] += 1
    if s[0] == "H":
        a[4] += 1

a_c = list(itertools.combinations([0,1,2,3,4], 3))
for i in range(len(a_c)):
    ans += a[a_c[i][0]]*a[a_c[i][1]]*a[a_c[i][2]]
print(ans)



Measured memory_bytes: 3188
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    b = 0
    dp = [True] * (a[-1] + 1)
    for ai in a:
        if not dp[ai]:
            continue
        for j in range(ai * 2, a[-1] + 1, ai):
            dp[j] = False
        if ai == b:
            dp[ai] = False
        b = ai
    print(sum(dp[ai] for ai in a))


if __name__ == '__main__':
    main()

Measured memory_bytes: 32192