akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int a, b;
	cin >> a >> b;
	if (b >= a) cout << "unsafe";
	else cout << "safe";
	return 0;
}



Measured memory_bytes: 3608
s = input()
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print("Yes")
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print("Yes")
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9128
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=int(1e5+5);
typedef long long LL;
#define INF LL(1e15)
LL s1,s2,as,n;
LL sz[MAXN],fh[MAXN];
char c[5];
int main()
{
	scanf("%lld",&n);
	scanf("%lld",&as);
	getchar();
	for(LL i=1;i<=n-1;i++) {
		scanf("%s",c);
		scanf("%d",&sz[i]);
		fh[i]=c[0];
	}
	s1=s2=-INF;
	for(LL i=1;i<=n-1;i++) {
		if(fh[i]=='-') {
			as-=sz[i];
			s2-=sz[i];
			s1+=sz[i];
			s2=max(s1,s2);
			s1=max(as,s1);
			as=max(s1,s2);
		}
		else {
			as+=sz[i];
			s2+=sz[i];
			s1-=sz[i];
			s1=max(s1,s2);
			as=max(s1,as);
		}
	}
	printf("%lld",as); 
}
/*
5
7 - 8 + 9 - 10 - 2*/

Measured memory_bytes: 1664
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) throws Exception {
        String s = sc.next();
        int k = sc.nextInt();
        Set<String> subs = new HashSet<>();
        
        for(int i = 1; i <= k; ++i) {
            for(int tail = i; tail <= s.length(); ++tail) {
                int head = tail - i;
                subs.add(s.substring(head, tail));
            }
        }
        
        String[] subStringArray = subs.toArray(new String[0]);
        Arrays.sort(subStringArray);
        System.out.println(subStringArray[k - 1]);
    }
}


Measured memory_bytes: 24472
/* 
 * File:   main.c
 * Author: s1252005
 *
 * Created on July 30, 2018, 8:00 PM
 */

#include <stdio.h>
#define INF (1<<28);//flag

int main() {
  int M[101][101];
  int size;
  int id, next, pathweight, k;
  
  for(int i = 0; i < 101; ++i)
  {
    for(int j = 0; j < 101; ++j)
    {
        if( i== j )
           M[i][j] = 0;
        else
           M[i][j] = INF;
    }
  }
  scanf("%d", &size);
  for(int i = 0; i < size; ++i)
  {
    scanf("%d %d", &id, &k);
    
    while( k--) 
    {
      scanf("%d %d", &next, &pathweight);
      M[id][next] = pathweight;
    }
  }
  
  int temp;
  for(k = 0; k < size; ++k)
  {
    for(int i = 0; i < size; ++i) 
    {
      for(int j = 0; j < size; ++j) 
      {
        temp = M[i][k] + M[k][j];
        if(temp < M[i][j]) 
            M[i][j] = temp;
      }
    }
  }

  for(int i = 0; i < size; ++i) {
    printf("%d %d\n", i, M[0][i]);
  }

  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
    unordered_set<int> s;
    for (int i = 0; i < 9; ++i) {
        for (int j = 0; j < 9; ++j) {
            s.insert((i + 1) * (j + 1));
        }
    }
    int n;
    cin >> n;
    cout << (s.find(n) != s.end() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<int> pt(3);
	int n;
	cin >> n >> pt[0] >> pt[1] >> pt[2];
	vector<pair<int,int>> q;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if(s == "AB") q.push_back(make_pair(0, 1));
		if(s == "AC") q.push_back(make_pair(0, 2));
		if(s == "BC") q.push_back(make_pair(1, 2));
	}
	vector<int> ans;
	for(int i = 0; i < n; i++) {
		int p1 = q[i].first, p2 = q[i].second;
		if(pt[p1] == 0 && pt[p2] == 0) {
			cout << "No";
			exit(0);
		}
		if(pt[p1] == pt[p2]) {
			if(i != n-1 && (p1 == q[i+1].first || p1 == q[i+1].second)) {
				pt[p1]++;
				pt[p2]--;
				ans.push_back(p1);
			}
			else {
				pt[p2]++;
				pt[p1]--;
				ans.push_back(p2);
			}
		}
		else {
			if(pt[p1] > pt[p2]) {
				pt[p2]++;
				pt[p1]--;
				ans.push_back(p2);
			}
			else {
				pt[p1]++;
				pt[p2]--;
				ans.push_back(p1);
			}
		}
	}
	cout << "Yes\n";
	for(int x : ans) {
		if(x == 0) cout << "A\n";
		if(x == 1) cout << "B\n";
		if(x == 2) cout << "C\n";
	}
	return 0;
}


Measured memory_bytes: 4812
#include <iostream>
#include <cstdio>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;

int dp[1024];

int s[512], l[512], p[512];
int w[512];
int ans[512];

int main(){
    int n,m;
    cin >> n;
    rep(i,n) cin >> s[i] >> l[i] >> p[i];
    rep(i,394) rep(j,n) loop(len,s[j],l[j]+1) dp[i+len] = max(dp[i] + p[j], dp[i+len]);
    cin >> m;
    rep(i,m){
        int t;
        cin >> t;
        if(dp[t]==0){
            cout << -1 << endl;
            exit(0);
        } else {
            ans[i] = dp[t];
        }
    }
    rep(i,m) cout << ans[i] << endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp  make_pair
#define pb  push_back
#define  sz(x)   (int)x.size()
#define  all(x)  x.begin(), x.end()
#define	 allr(x)  x.rbegin(), x.rend()
#define  bit(x)  __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
int mul (int x, int y) { return ((ll)x * y) % mod; } 
int sub (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int) 3e5;
 
int a[maxn];

void solve () {
	int n, m;
	cin >> n >> m;
	multiset <int> s;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		s.insert (a[i]);
	}	

	for (int i = 1; i <= m; i ++) {
		int x = *--s.end ();
		s.erase (--s.end ());
		s.insert (x / 2);
	}

	ll res = 0;
	for (auto to: s)
		res += to;

	cout << res;
}

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

Measured memory_bytes: 8740
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{
	auto line = readln().split(); 
	if (line.length < args.length) return;
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
};
void read(T...)  (auto ref T args){ mixin(readMixin);}
void readArray(T)(auto ref T args){ mixin(readMixin);}
//------------------------------
const coin = [10,50,100,500];
void main(){	
	int total;
	read(total);
	while(total){
		auto have = new int[4];
		readArray(have);
		int howMany = int.max; 
		auto uses = new int[4];
		//(0,0,0,0) ~ (n0,n1,n2,n3) ?????§??? n0 * n1 * n2 * n3 ?????¶???????????£?????¨??¢?´¢
		foreach(i0;iota(have[0]+1)){
			foreach(i1;iota(have[1]+1)){
				foreach(i2;iota(have[2]+1)){
					foreach(i3;iota(have[3]+1)){
						auto tmpuses = [i0,i1,i2,i3];
						auto pay = i0 * coin[0] + i1 * coin[1] + i2 * coin[2] + i3 * coin[3];	
						if (pay < total) continue;
						int tmpHowMany = have.sum + howManyCoins(pay - total) - tmpuses.sum;
						if (tmpHowMany < howMany ){
							howMany = tmpHowMany;
							uses = tmpuses;
						}
					}
				}
			}
		}
		foreach(i,u;uses){if(u >0)writeln(coin[i]," ",u);}
		read(total);
		if (total) writeln();
	}
}
int howManyCoins(int pay){
	int res;
	foreach_reverse(i,c;coin){
		while(pay >= c){ pay -= c;res ++;}
	} 
	return res;
}

Measured memory_bytes: 3176
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] t = new int[n+1];
      	t[0] = 0;
		for(int i=1; i<n+1; i++){
			t[i] = scn.nextInt();
		}
      	int sum = 0;
      	for(int i=0; i<n+1; i++){
          sum += t[i];
        }
      	int m = scn.nextInt();
		int[] p = new int[m+1];
      	p[0] = 0;
      	int[] x = new int[m+1];
      	x[0] = 0;
		for(int i=1; i<m+1; i++){
			p[i] = scn.nextInt();
          	x[i] = scn.nextInt();
		}
      	int dif = 0;
      	for(int i=1; i<m+1; i++){
          dif = t[p[i]]-x[i];
          System.out.println(sum-dif);
        }
	}
}


Measured memory_bytes: 36252
import heapq
from collections import defaultdict

N, M = map(int, input().split())

As = map(int, input().split())
counts = defaultdict(int)
for A in As:
    counts[A] += 1
h = sorted(counts.keys())

for i in range(M):
    B, C = map(int, input().split())

    if C not in counts:
        heapq.heappush(h, C)
    counts[C] += B
    if len(h) > N:
        v = heapq.heappop(h)
        del counts[v]

total_count = 0
total = 0
for k in sorted(h, reverse=True):
    c = counts[k]
    c = min(c, N - total_count)
    total += k * c
    total_count += c
    if total_count > N:
        break
print(total)

Measured memory_bytes: 24224
#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 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

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int mem[100005];
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}



int main(){
	cmbset(SIZE_mod-1);
	int n,x;
	cin>>n>>x;
  vector<LL> s;
  FOR(i,0,n){
    LL a;
    cin>>a;
    s.PB(a);
  }
  sort(s.rbegin(),s.rend());
  vector<vector<LL>> dp(n+1,vector<LL>(x+1,0));
  dp[0][x]=1;
	FOR(i,0,n){
    FORQ(j,0,x){
      dp[i+1][j]=add(dp[i+1][j],(n-i-1)*dp[i][j]);
      dp[i+1][j%s[i]]=add(dp[i+1][j%s[i]],dp[i][j]);
    }
  }
  LL ans=0;
  FORQ(i,1,x){
    ans=add(ans,dp[n][i]*i);
    //cerr<<dp[n][i]<<endl;
  }
  cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 160128
import java.util.Scanner;

public class Main {


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

        System.out.println(solve(N));
    }

    static String solve(int N) {
        for (int i = 0; i < 13; i++) {
            for (int j = 0; j < 25; j++) {
                if( i * 7 + j * 4 == N ) {
                    return "Yes";
                }
            }
        }
        return "No";
    }
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
// typedef vector vec;

ll mod = 1e9 + 7;

#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
// cout<<endl;


int main()
{
	fastio();
	int n, m;
	cin>>n>>m;
	if(n > m) cout<<"No\n";
	else cout<<"Yes\n";
}


Measured memory_bytes: 256
void main(){
  import std.stdio, std.conv, std.string, std.algorithm;

  long n, a, b, k; rd(n, a, b, k);

  const long mod=998244353;
  const int M=1_000_00*4;
  static fact=new long[](M);
  static inv_fact=new long[](M);
  { // init
    fact[0]=fact[1]=1;
    foreach(i; 2..M) fact[i]=i*fact[i-1]%mod;
    long powmod(long a, long x){
      if(x==0) return 1;
      else if(x==1) return a;
      else if(x&1) return a*powmod(a, x-1)%mod;
      else return powmod(a*a%mod, x/2);
    }
    foreach(i; 0..M) inv_fact[i]=powmod(fact[i], mod-2);
  }
  long comb(long nn, long rr){
    if(nn<rr) return 0;
    long ret=fact[nn]%mod;
    (ret*=inv_fact[rr])%=mod;
    (ret*=inv_fact[nn-rr])%=mod;
    return ret;
  }
  
  long tot=0;
  for(long x=0; x<=n; x++)if(k-a*x>=0){
    if((k-a*x)%b==0){
      long y=(k-a*x)/b;
      if(y>n) continue;
      (tot+=comb(n, x)*comb(n, y)%mod)%=mod;
    }
  }
  writeln(tot);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 6524
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 210
using namespace std;
int n,a[szxb];
inline int so(int x)
{
	int tot(0);
	while(!(x&1)){tot++,x>>=1;}
	return tot;
}
signed main()
{
	scanf("%d",&n);int t;
	for(register int i(1);i<=n;i++){scanf("%d",&t),a[i]=(so(t));}
	printf("%d",(*min_element(a+1,a+n+1)));
	return putchar(10),0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    long long n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];
    vector<int> s;
    vector<int> ord(n+1,-1);
    int v = 1,d=1,e=0;//d周期、e残り
    while(ord[v]==-1){
        s.push_back(v);
        ord[v] = s.size();
        v = a[v-1];
    }
    e = ord[v]-1;
    d = s.size()-e;
    if(k<e) cout << s[k] << endl;
    else cout << s[(k-e)%d+e] << endl;
}

Measured memory_bytes: 5792
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

const int MAX_N = 110;
const int MAX_V = 100010;

int N;
ll W;
ll w[MAX_N], v[MAX_V];
ll dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];

    // DP init
    rep(i, MAX_N) { rep(j, MAX_V) dp[i][j] = INF;}
    dp[0][0] = 0;

    for (int i = 0; i < N; i++) {
        for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
            // i番目の品物を選ぶとき
            if (sum_v - v[i] >= 0) {
                chmin(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i]);
            }

            // 選ばないとき
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    ll ans = 0;
    for (int sum_v = 0; sum_v <= MAX_V; sum_v++) {
        if (dp[N][sum_v] <= W) ans = sum_v;
    }
    cout << ans << endl;
}


Measured memory_bytes: 86272
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <map>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;
typedef long long ll;

int N;
int x[10], y[10];

double dist(int i, int j){
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    return pow(dx*dx+dy*dy, 0.5);
}

int main(){
    cin >> N;
    for(int i=0; i < N; i++){
        cin >> x[i] >> y[i];
    }
    double sum = 0.0;
    vector<int> v(N);
    for(int i=0; i<N; i++){
        v[i] = i;
    }
    do {
        for(int i=0; i<N-1; i++){
            sum += dist(v[i], v[i+1]);
        }
    }while(next_permutation(v.begin(), v.end()));

    int Factorial = 1;
    for(int i=1; i<N+1; i++){
        Factorial *= i;
    }
    printf("%.12f\n", sum/Factorial);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        if (e-a > k) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }

}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int a[25];
	int ans=0;
	cin>>n;
	for(int i=0; i<n; i++)
		cin>>a[i];
	for(int i=1; i<n-1; i++)
	{
		if(a[i]>a[i-1] && a[i]<a[i+1])
			ans++;
		if(a[i]<a[i-1] && a[i]>a[i+1])
			ans++;

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

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

a = list(map(int, input().split()))

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  else:
    c[8] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = sum(c)
print(cmin, cmax)

Measured memory_bytes: 9200
#include <iostream>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int houses[K];
	for (int i = 0; i < K; i++) {
		cin >> houses[i];
	}
	
	int maxDist = 0, totalDist = 0;
	for (int h = 0; h < K; h++) {
		int dist;
		if (h == K - 1) {
			dist = N - houses[h] + houses[0];
		}
		else {
			dist = houses[h + 1] - houses[h];
		}
		totalDist += dist;
		maxDist = max(maxDist, dist);
	}
	cout << totalDist - maxDist << endl;
	return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize("trapv")
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cassert>
#include <iomanip>
#include <algorithm>
#include <unordered_set>
#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 2e9;

void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

signed main()
{
	fast();
	int n, x, t;
	cin >> n >> x >> t;

	cout << ((n - 1) / x + 1) * t;
	return 0;
}


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

int H, W, N, R, C;
char T[202020], S[202020];

int main(){
    scanf("%d %d %d", &H, &W, &N);
    scanf("%d %d", &R, &C);
    scanf("%s", T+1);
    scanf("%s", S+1);
    int top=1, bot=H;
    for(int i=N; i>=1; i--){
        if (S[i] == 'U') bot = min(H, bot+1);
        if (S[i] == 'D') top = max(1, top-1);
        if (T[i] == 'U') top++;
        if (T[i] == 'D') bot--;
        if (top > bot) break;
    }
    if (R < top || R > bot){
        puts("NO");
        return 0;
    }
    top=1, bot=W;
    for(int i=N; i>=1; i--){
        if (S[i] == 'L') bot = min(W, bot+1);
        if (S[i] == 'R') top = max(1, top-1);
        if (T[i] == 'L') top++;
        if (T[i] == 'R') bot--;
        if (top > bot) break;
    }
    if (C < top || C > bot){
        puts("NO");
        return 0;
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 640
N=int(input())
A=list(map(int,input().split()))
b=(N//2)+1

ans=[]
for _ in range(N):
    ans.append(0)
for i in range(b-1,N):
    ans[i]=A[i]


for j in range(0,b-1)[::-1]:
    n=2
    sum=0
    while True:
        if n*(j+1)-1<=N-1:
            sum+=ans[n*(j+1)-1]
            n+=1
        else:
            break
    if sum%2!=A[j]:
        ans[j]=1

M=0
Ans=[]
for k in range(N):
    if ans[k]==1:
        M+=1
        Ans.append(k+1)
print(M)
if len(Ans)>0:
    print(*Ans)


        



Measured memory_bytes: 14136
// Comparison
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()){
        cout<<"GREATER";
        return 0;
    }if(a.size()<b.size()){
        cout<<"LESS";
        return 0;
    }
    for(int i=0;i<a.size();i++){
        if(a[i]>b[i]){
        cout<<"GREATER";
            return 0;
        }if(a[i]<b[i]){
            cout<<"LESS";
            return 0;
        }
    }
    cout<<"EQUAL";
}

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

#define ll long long
#define pb push_back
#define MP make_pair
#define PLL pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()
{
  ll t;
  t=1;
  while(t--)
  {
    string s;
    cin >> s;

    ll i,n=s.length(),ans=0;

    while(i<n)
    {
      if(s[i]=='R')
      {
        ll count=0;
        while(i<n && s[i]=='R')
        count++,i++;
        ans=max(count,ans);
      }
      i++;
    }

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


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    int ans=1;
    ll sum=0;
    REP(i,n-1){
        sum+=a[i];
        if(sum*2>=a[i+1]){
            ans++;
        }
        else{
            ans=1;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void){

   int x;
   cin >> x;

   if(x <100){
      cout << 0 << endl;
      return 0;
   }

   if(x %100 == 0){
      cout << 1 << endl;
      return 0;
   }
   int xx = x / 100;
   int mod = x % 100;

   puts(5*xx >= mod ? "1" : "0");
   return 0;
}

Measured memory_bytes: 256
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int n;
    cin >> n;
    int k;
    cin >> k;
    long long sol = 0ll;
    long long prefix[n + 2];
    prefix[0] = 0;
    for(int i = 1;i <= n + 1;i++)
    {
        prefix[i] = i - 1;
        prefix[i] += prefix[i - 1];
    }
    for(int i = k;i <= n + 1;i++)
    {
        long long diff = prefix[n + 1] - prefix[n + 1 - i];
        diff -= prefix[i];
        // cout  << diff << " " << i << endl;
        sol += diff + 1;
        sol %= MOD;
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 5160
#include<iostream>
#include<cmath>
#include<sstream>

using namespace std;


unsigned int A;
unsigned int ah;
unsigned int B;
unsigned int bh;
long int x;
unsigned int i;


int main() {

	cin >> A >> B;

	while (1) {
		i++;
		ah = i * 0.08;
		bh = i * 0.10;

		if (ah == A) {

			if (bh == B) {

				x = i;

				break;
			}

		}

		if (i > 1000000000) {
			x = -1;
			break;
		}

	}

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R,C;
    while(cin >> R >> C,R){
        vector<vector<int>> state(R,vector<int>(C));
        rep(i,R) rep(j,C) cin >> state[i][j];
        int ans=0;
        rep(bit,1<<R){
            vector<vector<int>> save=state;
            rep(i,R) if (bit&1<<i) rep(j,C) save[i][j]^=1;
            int cnt=0;
            rep(j,C){
                int cntrow=0;
                rep(i,R) cntrow+=save[i][j];
                cnt+=max(R-cntrow,cntrow);
            }
            chmax(ans,cnt);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3836
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');
    var A = parseInt(lines[0],10);
    var B = parseInt(lines[1],10);
    
    var A_amari = A % 3;
    var B_amari = B % 3;
    var AB_amari = (A + B) % 3;
    
    if(A_amari !== 0 && B_amari !== 0 && AB_amari !== 0){
        console.log("Impossible");
    }else{
        console.log("Possible");
    }
    
});


Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int a[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};
    int k;
    cin>>k;
    rep(i,32){
        if(k-1==i)cout<<a[i]<<endl;
    }
}


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

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;
    vector<vector<int>> sum(M, vector<int>(N + 1));
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        sum[--x][i + 1] = 1;
    }

    for (int i = 0; i < M; i++) {
        for (int j = 1; j <= N; j++) {
            sum[i][j] += sum[i][j - 1];
        }
    }
    
    constexpr int INF = 114514;
    vector<int> dp(1 << M, INF);    
    dp[0] = 0;
    
    for (int i = 0; i < (1 << M); i++) {
        int s = 0;
        for (int j = 0; j < M; j++) {
            if (i >> j & 1) {
                s += sum[j][N];
            }
        }
        for (int j = 0; j < M; j++) {
            if (i >> j & 1) continue;
            int ni = i | (1 << j);
            int cost = sum[j][N] - sum[j][s + sum[j][N]] + sum[j][s];
            dp[ni] = min(dp[ni], dp[i] + cost);
        }
    }    
    cout << dp[(1 << M) - 1] << endl;    
    return 0;
}

Measured memory_bytes: 14584
n,m,k=map(int,input().split())
mod=998244353
res=0
pat=1
for i in range(0,k+1):
  res+=pat*pow(m-1,n-1-i,mod)
  pat*=(n-1-i)*pow(i+1,mod-2,mod)
  pat%=mod
  
print((m*res)%mod)

Measured memory_bytes: 9224
from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

d = [0 for i in range(2019)]
d[0] = 1
tmp = 0
_10 = 1
# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    # print(int(s[i]), _10)
    tmp += (int(s[i]) * _10) % 2019
    _10 *= 10
    _10 %= 2019
    # print(tmp, tmp % 2019)
    d[tmp % 2019] += 1

# for i in reversed(range(0, n)):
#     print((b[n-i-1]), int(s[i]))
#     tmp += _10 * int(s[i]) % 2019
#     _10 *= 10 % 2019
#     print(tmp, tmp % 2019)
#     a[tmp % 2019] += 1


# count = 0
# for i in range(len(d)):
#     if d[i] >= 2:
#         count += (d[i])*(d[i]-1)//2
# print(count)

# # print(dd)
print(sum(v*(v-1)//2 for v in d))


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

#define int long long

main()
{
    int N;
    int A[100005];
    int ans = 0;

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    A[N] = 0;
    for(int i = 0; i < N; i++) {
        ans += A[i] / 2;
        A[i] -= A[i] / 2 * 2;
        if(A[i] == 1 && A[i + 1] > 0) A[i + 1]--, ans++;
    }
    cout << ans << endl;

    return (0);
}

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

int cost[100][100];
int main() {
	int v, e; scanf("%d%d", &v, &e);
	memset(cost, 0x7f, sizeof(cost));
	rep(i, v)cost[i][i] = 0;
	rep(i, e) {
		int s, t, d; scanf("%d%d%d", &s, &t, &d);
		cost[s][t] = d;
	}
	rep(k, v)rep(i, v)rep(j, v) {
		if (cost[i][k] != INF&&cost[k][j] != INF)
			cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
	}
	rep(i, v) {
		if (cost[i][i] < 0) {
			puts("NEGATIVE CYCLE");
			return 0;
		}
	}
	rep(i, v)rep(j, v) {
		if (cost[i][j] == INF)printf("INF");
		else printf("%d", cost[i][j]);
		if (j == v - 1)printf("\n");
		else printf(" ");
	}
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,x,y,c,m;cin>>a>>b>>m;
  lvector A(a,0),B(b,0);
  rep(i,a) cin>>A[i];rep(i,b) cin>>B[i];
  ll ans=*min_element(A.begin(),A.end())+*min_element(B.begin(),B.end());
  rep(i,m) {
    cin>>x>>y>>c;
    ll ans_=A[x-1]+B[y-1]-c;
    ans=min(ans,ans_);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1792
function Main(input) {
    input = input.split(" ").map(Number);
  	var M=input[0], 
        D=input[1],
        n=0;
  
  	for(var i=1;i<=M;i++){
      for(var j=1;j<=D;j++){
        var a=Math.floor((j/10)),
            b=j%10;
        if(a>=2 && b>=2 && i === a*b){
        	n++;
        }
      }
    }
  console.log(n);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  return i;
}


void solve(){
  int a;
  cin >> a;
  int d=a%10;
  if(d ==3)cout << "bon" << endl;
  else if(d==0||d==1||d==6||d==8)cout<<"pon" <<endl;
  else cout <<"hon"<< endl;

}

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


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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

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

    int a, v, b, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    int dist = abs (a - b);
    int speed = v - w;
    if (speed <= 0) {
        cout << "NO\n";
        return 0;
    }
    if (1ll * t * speed >= dist)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>

int length(char s[]) {
	int x;
	x = strlen(s);
	return x;
}

int main() {
	char s[100];
	int i, j;
	scanf("%s", &s);
	i = length(s);
	for (j = 1; j <= i; j++) {
		printf("x");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    vecl A(N);
    REP(i,N) {
        ll a; cin >> a;
        A[i] = a - (i+1);
    }
    sort(A.begin(),A.end());
    ll b;
    if(N%2 != 0) b = A[N/2];
    else b = (A[N/2-1]+A[N/2])/2;
    ll ans = 0;
    REP(i,N) ans += abs(A[i]-b);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  string s;
  cin >> s;
  int n;
  n = s.size();
  int count_0 = 0;
  int count_1 = 0;
  for(int i=0; i<n; i++){
    int b = i % 2;
    if(b == 0){
      if(s[i] == '0') count_1++;
      else count_0++;
    }
    else{
      if(s[i] == '0') count_0++;
      else count_1++;
    }

  }
  cout << min(count_0, count_1) << endl;
}



Measured memory_bytes: 512
N = gets.to_i
X = Array.new N 
Y = Array.new N
dmax = 0
dmin = (10**9) * 2
N.times do |i|
    X[i], Y[i] = gets.split.map(&:to_i)
    d = X[i] + Y[i]
    if d > dmax
        dmax = d
    end
    if d < dmin 
        dmin = d
    end
end

res = dmax - dmin

dmax = -(10**9) * 2
dmin = (10**9) * 2
N.times do |i|
    d = X[i] - Y[i]
    if d > dmax
        dmax = d
    end
    if d < dmin 
        dmin = d
    end
end
res2 = dmax - dmin

puts [res, res2].max

Measured memory_bytes: 17504
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int n;
struct students{int a,c;};
students s[N];
bool cmp(const students &x,const students &y){return x.a<y.a;}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i].a;
		s[i].c=i;
	}
	sort(s+1,s+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(i<n)cout<<s[i].c<<" ";
		else cout<<s[i].c<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <set>
using namespace std;

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


    if( s == t ){
        cout << "No" << endl;
    } else {
        int slen = s.length(), tlen = t.length();
        multiset<char> ss, tt;
        for( int i = 0; i < slen; ++i )
            ss.insert(s[i]);
        for( int i = 0; i < tlen; ++i )
            tt.insert(t[i]);
        
        int ans = -1;
        auto sitr = ss.begin();
        auto titr = tt.rbegin();
        int len = slen < tlen ? slen : tlen;
        for( int i = 0; i < len; ++i, ++sitr, ++titr ){
            //cout << *sitr << " " << *titr << endl;
            if( *sitr < *titr ){
                ans = 1;
                break;
            }
            if( *titr < *sitr ){
                ans = 0;
                break;
            }
        }
        
        if( ans == -1 ) ans = len == slen ? 1 : 0;

        if( ans ) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N, K;
vector<Int> H;

_int used[310][310][310];
Int mem[310][310][310];

Int dfs(Int i, Int k, Int last){
  if(i == N) return 0;
  if(used[i][k][last]++) return mem[i][k][last];

  Int a = INF, b = INF;
  a = dfs(i+1, k, i) + max(0LL, H[i] - H[last]);
  if(k < K) b = dfs(i + 1, k + 1, last);
  Int res = min(a, b);
  return mem[i][k][last] = res;
}
signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);


  cin>>N>>K;
  H.resize(N);
  cin>>H;
  N++;
  H.insert(H.begin(), 0);

  Int ans = dfs(1, 0, 0);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 340352
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

class UnionFind:
    def __init__(self, N):
        self.rank = [0] * N
        self.parent = [i for i in range(N)]
        self.n = N

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

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

        if (self.rank[x] < self.rank[y]):
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

    def get_parents(self):
        count = 0
        for i in range(self.n):
            if self.find(i) == i:
                count += 1

        return count


# その辺を抜いてUnionFindして親の数が2個以上なら count すればいい？

N, M = map(int, input().split())

A = [0] * M
B = [0] * M

for i in range(M):
  a, b = map(int, input().split())
  A[i] = a-1
  B[i] = b-1

count = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i == j:
            continue
        uf.unite(A[j], B[j])

    # 親の繋ぎ変え
    for i in range(N):
        uf.find(i)

#    print(uf.parent)

    if uf.get_parents() > 1:
        count += 1

print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
//
//int main() {
//	double A, B;
//	cin >> A >> B;
//	double tmp;
//	tmp = A * B;
//	cout << (ll)tmp;
//}

int main() {
	ll N;
	cin >> N;
	map<ll, ll>m;
	vector<ll>A(N);
	rep(i, N) {
		cin >> A[i];
		m[A[i]]++;
	}
	if (m[0] != 0) {
		cout << 0;
		return 0;
	}
	ll ans=1;
	ll tmp = pow(10, 18)-1;
	rep(i, N) {
		if (tmp /ans < A[i]) {
			cout << -1;
			return 0;
		}
		ans *= A[i];
	}
	

	cout << ans;
}



Measured memory_bytes: 10304
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>

//const int64_t cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.second > another.second;
}


int main()
{
   int64_t a,b,c,d;
   std::cin>> a;
   std::cin>> b;
   std::cin>> c;
   std::cin>> d;

   std::vector< int64_t > first( a );
   std::vector< int64_t > second( b );
   std::vector< int64_t > third( c );

   for( int64_t i = 0; i < first.size(); i++ )
   {
       std::cin>> first[i];
   }

   for( int64_t i = 0; i < second.size(); i++ )
   {
       std::cin>> second[i];
   }

   for( int64_t i = 0; i < third.size(); i++ )
   {
       std::cin>> third[i];
   }

   std::priority_queue< int64_t > check;

   for( int64_t i = 0; i < first.size(); i++ )
   {
       for( int64_t r = 0; r < second.size(); r++ )
       {
           check.push( first[i] + second[r] );
       }
   }

   std::priority_queue< int64_t > check_list;

   for( int64_t i = 0; i < d; i++ )
   {
       if( check.empty() )
       {
           break;
       }
       
       check_list.push( check.top() );
       check.pop();
   }

   std::priority_queue< int64_t > result;
   //std::cout<< check_list.size() <<"\n";
   
   while( !check_list.empty() )
   {
       for( int64_t r = 0; r < third.size(); r++ )
       {
           result.push( check_list.top() + third[r] );
       }

       check_list.pop();
   }

   for( int64_t i = 0; i < d; i++ )
   {
       std::cout<< result.top() <<"\n";
       result.pop();
   }
}


Measured memory_bytes: 43400
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main(){
	char str[1001];

	fgets(str,sizeof(str),stdin);

	for(int i = 0; i < 1000; i++){
		if(str[i] == 'p' && str[i+1] == 'e' && str[i+2] == 'a'
			&& str[i+3] == 'c' && str[i+4] == 'h'){

			str[i] = 'a';
			str[i+1] = 'p';
			str[i+2] = 'p';
			str[i+3] = 'l';
			str[i+4] = 'e';
		}
		else if(str[i] == 'a' && str[i+1] == 'p' && str[i+2] == 'p'
			&& str[i+3] == 'l' && str[i+4] == 'e'){

			str[i] = 'p';
			str[i+1] = 'e';
			str[i+2] = 'a';
			str[i+3] = 'c';
			str[i+4] = 'h';
		}
	}

	cout << str;

	return 0;
}

Measured memory_bytes: 1088
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;
    std::cin >> N;

    std::map<std::string, int64_t> ans;
    for (int64_t i = 0; i < N; ++i) {
        std::string str;
        std::cin >> str;
        ans[str]++;
    }

    int64_t count = 0;

    auto it = ans.find("AC");
    count = it == ans.end() ? 0 : it->second;
    std::cout << "AC x " << count << std::endl;

    it = ans.find("WA");
    count = it == ans.end() ? 0 : it->second;
    std::cout << "WA x " << count << std::endl;

    it = ans.find("TLE");
    count = it == ans.end() ? 0 : it->second;
    std::cout << "TLE x " << count << std::endl;

    it = ans.find("RE");
    count = it == ans.end() ? 0 : it->second;
    std::cout << "RE x " << count << std::endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  bool ans = false;
  ll i = 0;
  while(7*i<=n){
    ll x = n;
    x -= 7 * i;
    if(x%4==0){
      ans = true;
      break;
    }
    i++;
  }
  if(ans){
    print("Yes");
  }
  else{
    print("No");
  }
}


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

int main(){
	int N;
	cin >> N;
	int L[N];
	vector<int> a(2005);
	rep(i,N) {
		cin >> L[i];
		a[L[i]]++;
	}
	sort(L,L+N);
	rep(i,2005) a[i+1] += a[i];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			ans += a[L[i]+L[j]-1] - (j+1);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  for (int i = 0; i < A; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> b[i];
  }

  vector<int> x(M), y(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> x[i] >> y[i] >> c[i];
    x[i]--;
    y[i]--;
  }

  ll ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());

  for (int i = 0; i < M; i++) {
    ll tmp = a[x[i]] + b[y[i]] - c[i];
    if (ans > tmp) {
      ans = tmp;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	int N;
  	cin>>N;
  
  	ll a[N];
  	rep(i,N) cin>>a[i];
  	bool upflag=false;
  	bool downflag=true;
  	ll money=1000;
  	ll stock=0;
  	
  	rep(i,N-1){
     	if(a[i+1]-a[i]>0){
          	if(downflag){
             	stock+=money/a[i];
              	money-=stock*a[i];
            }
         	upflag=true;
          	downflag=false;
        }
      	if(a[i+1]-a[i]<0){
          	if(upflag){
             	money+=stock*a[i];
              	stock=0;
            }
         	upflag=false;
          	downflag=true;
        }
    }
  
    money+=stock*a[N-1];
    stock=0;
  	
    cout<<money<<endl;
  	
  
  	
}

Measured memory_bytes: 3604