akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  int x[m];
  rep(i,0,m) cin>>x[i];
  sort(x,x+m);
  int y[m-1];
  rep(i,0,m-1) y[i]=x[i+1]-x[i];
  sort(y,y+(m-1));
  int ans=0;
  rep(i,0,m-n) ans+=y[i];
  cout<<ans<<endl;
}

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

using namespace std;

int n, k;
int a[110];
bool f[100010];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	for (int i = 1; i <= k; ++ i)
		for (int j = 1; j <= n && a[j] <= i; ++ j)
			if (! f[i - a[j]])
			{
				f[i] = 1;
				break;
			}
	printf(f[k] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
char map[12][13];
int d[4] = { 0,-1,0,1 };
int ans;
void f(int, int);
int main() {
	int i, j;
	for (; ~fscanf(stdin, "%s", map[0]) != NULL; P(d, ans)) {
		getchar();
		ans = 0;
		for (i = 1; i < 12; i++) fscanf(stdin, "%s", map[i]);
		for (i = 0; i < 12; i++)
			for (j = 0; j < 12; j++)
				if (map[i][j] == '1') {
					ans++;
					f(i, j);
				}
	}
	return 0;
}

void f(int y, int x) {
	int i;
	map[y][x] = '0';
	for (i = 0; i < 4; i++) {
		if (0 <= x + d[i] && x + d[i] < 12 && map[y][x + d[i]] == '1') f(y, x + d[i]);
		if (0 <= y + d[i] && y + d[i] < 12 && map[y+d[i]][x] == '1') f(y+d[i], x);
	}
	return;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    string s;
    cin >> n >> k >> s;
    string ns = 'R' + s + 'L';
    ll diff = 0;
    rep(i, n) {
        ll dir = (ns[i + 1] == 'L') ? -1 : 1;
        if (ns[i + 1] != ns[i + 1 + dir]) diff++;
    }
    ll ans = n - max(1LL, diff - 2 * k);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#define int long long 

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, v;
    cin >> a >> v;
    int b, w;
    cin >> b >> w;
    int t;
    cin >> t;
    if (w > v) {
        cout << "NO\n";
        return 0;
    }
    if (abs(a - b) > abs(w - v) * t) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, m;
    cin >> n;
    vector <long long> a(n);
    vector <long long> b;
    vector <long long> c, d, e;
    long long ans, ans1, ans2, ans3, ans4;
    ans = 0;
    ans1 = 0;
    ans2 = 0;
    ans3 = 0;
    ans4 = 0;
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if(n == 3){
        b.push_back(a[1]);
        b.push_back(a[0]);
        b.push_back(a[2]);
        c.push_back(a[0]);
        c.push_back(a[2]);
        c.push_back(a[1]);
        for (int i=0; i<n-1; ++i){
            ans1 += llabs(b[i+1]-b[i]);
            ans2 += llabs(c[i+1]-c[i]);
        }
        ans = max(ans1, ans2);
    }
    else if(n % 2 == 1){
        m = n / 2;
        b.push_back(a[m]);
        c.push_back(a[m]);
        for(int i=0; i<m; ++i){
            b.push_back(a[n-1-i]);
            b.push_back(a[i]);
            c.push_back(a[i]);
            c.push_back(a[n-1-i]);
        }
        //for(int i=0; i<n; ++i){
        //    cout << c[i] << endl;
        //}
        for (int i=0; i<n-1; ++i){
            ans1 += llabs(b[i+1]-b[i]);
            ans2 += llabs(c[i+1]-c[i]);
        }
        if(ans1 >= ans2){
            ans = ans1;
        }
        else {
            ans = ans2;
        }
    }
    else {
        m = n / 2 - 1;
        b.push_back(a[m]);
        c.push_back(a[m+1]);
        d.push_back(a[m+1]);
        e.push_back(a[m]);
        for(int i=0; i<m; ++i){
            b.push_back(a[n-1-i]);
            b.push_back(a[i]);
            c.push_back(a[i]);
            c.push_back(a[n-1-i]);
            d.push_back(a[n-1-i]);
            d.push_back(a[i]);
            e.push_back(a[i]);
            e.push_back(a[n-1-i]);
        }
        b.push_back(a[m+1]);
        c.push_back(a[m]);
        d.push_back(a[m]);
        e.push_back(a[m+1]);
        for (int i=0; i<n-1; ++i){
            ans1 += llabs(b[i+1]-b[i]);
            ans2 += llabs(c[i+1]-c[i]);
            ans3 += llabs(d[i+1]-d[i]);
            ans4 += llabs(e[i+1]-e[i]);
        }
        ans = max(ans1, ans2);
        ans = max(ans, ans3);
        ans = max(ans, ans4);
        ans = max(ans, ans1);
    }
    cout << ans << endl;
}



Measured memory_bytes: 4312
/*author:anshumanc007
created on:12/05/2019*/

//            :(



#include <bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;
typedef pair<long long int,long long int>pa;
#define pb push_back
#define MAX 1000005
long long int MOD=1e9+7;
long long int INF=1e18;


int main()
{
       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
       cout.tie(NULL);
long long int i,j,k=0,l=0,r=0,m=0,n,a,b,c,p=0,cnt=0,cnt1=0,low,mid,high,ans=0,maxi=0,mini=INF,t;
cin>>n;
long long int A[n];
vector<long long int>V;
for(i=0;i<n;i++)
{
    cin>>A[i];
}
for(i=1;i<n;i++)
{
    l=__gcd(l,A[i]);
}
k=A[0];
for(i=1;i<=sqrt(k);i++)
{
    if(k%i==0)
    {
        V.pb(i);
        if(k!=i*i)
        {
         V.pb(k/i);
        }
    }
}
for(i=0;i<V.size();i++)
{ p=0;
    for(j=0;j<n;j++)
{
    if(A[j]%V[i]==0)
    {

    }
    else
    p++;
}
if(p<=1)
{
    l=max(l,V[i]);
}
}
cout<<l<<endl;


}



Measured memory_bytes: 1024
#include <cstdio>
using namespace std;
const int N=605;
int n,d1,d2,c,a[N][N];
void color(int d){
  int w=0;
  while (d%4==0) d/=4,w++;
  if (d%4==1){
  	for (int i=0;i<2*n;i++)
  	  for (int j=0;j<2*n;j++)
  	    if (((i>>w)&1)^((j>>w)&1))
  	      a[i][j]=1;
  }
  else
    {
     for (int i=0;i<2*n;i++)
       for (int j=0;j<2*n;j++)
         if ((j>>w)&1)
           a[i][j]=1;
	}
}
int main(){
  scanf("%d%d%d",&n,&d1,&d2);
  color(d1);color(d2);
  for (int i=0;i<2*n;i++)
    for (int j=0;j<2*n;j++)
      if (c<n*n&&!a[i][j])
        printf("%d %d\n",i,j),c++;
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << (!(!(n % m))) << endl;
    return 0;
}

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define print(n) cout << n << endl

ll modpow(ll m, ll n, ll mod){
    ll ans = 1;
    while(n){
        if(n & 1) ans = ans * m % mod;
        m = m * m % mod;
        n >>= 1;
    }
    return ans;
}

int main(){
    ll n;
    ll k;
    ll ans=0;
    const int mod = 1000000007;

    cin >> n >> k;
    int m;
    vector<ll> vec(k+1);
    rrep(i,k){
        m = k/i;
        vec.at(i) = modpow(m,n,mod);
        if(m>=2) for(int j=2;j<m+1;j++) vec.at(i) = (vec.at(i) - vec.at(i*j) + mod) % mod;
        ans = (ans + vec.at(i) * i) % mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    ll ans = 1;

    rep(i,N){
        ll t;
        cin >> t;

        ans = ans / gcd(ans,t) * t;

    }

    cout << ans << endl;


}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  long long div = n / k;
  n -= (div * k);
  while (abs(n - k) < n) n = abs(n - k);
  cout << n << '\n';
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    //sort(l.begin(), l.end());
    //l.erase(unique(l.begin(), l.end()), l.end());
    int m = l.size();
    int cnt = 0;
    rep(i, m) {
        rep(j, m) {
            rep(k, m) {
                if (i == j || j == k || k == i) continue;
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if (l[i] + l[j] <= l[k] || l[j] + l[k] <= l[i] || l[k] + l[i] <= l[j]) continue;
                //cout << i<<" " << j<<" " << k << endl;
                cnt++;
            }
        }
    }
    cout << cnt/6 << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int L,R;
  L=A+B;
  R=C+D;
  if(L>R)
  {
    cout<<"Left"<<endl;
  }
  else if(L==R)
  {
    cout<<"Balanced"<<endl;
  }
  else
  {
    cout<<"Right"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int n = S.length();
        
        List<Character>list = new ArrayList<>();
        list.add(S.charAt(0));
        
        for(int i = 0; i < n - 1; i++){
            if(S.charAt(i) != S.charAt(i + 1)){
                list.add(S.charAt(i + 1));
            }
        }

        int ans = list.size() - 1;
        System.out.println(ans);
    }
}


Measured memory_bytes: 28580
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int[] prime;
	static int[] Prime(int[] prime) {
		int k = 0;
		for(int i=2;i<150000;i++) {
			boolean is = true;
			for(int j=2;j*j<=i;j++) {
				if(i%j==0)is = false;
			}
			if(is) {
				prime[k]=i;
				k++;
			}
		}
		return prime;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		prime =  new int[1000001];
		prime = Prime(prime);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			int p = sc.nextInt();
			if(n+p==-2)break;
			
			List<Integer> res = new ArrayList<Integer>();
            int f=0;
            while(prime[f]<=n)f++;
            for(int i=f;i<f+p;i++)for(int j=i;j<f+p;j++)res.add(prime[i]+prime[j]);
            Collections.sort(res);
            System.out.println(res.get(p-1));
		}
	}
}





Measured memory_bytes: 73764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int target = 100*r + 10*g + b;
    if(target % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,c,d=map(int,input().split())
    x=-(-c//b)
    y=-(-a//d)
    if x<=y:
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    main()

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
#include <map>
using namespace std;

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

typedef long long ll;



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

    int ans = 0;
    int i = 0;
    int j = s.size() - 1;
    

    while(i < j)
    {
        if(s.at(i) != s.at(j)) ans++;
        i++;
        j--;
    }

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
import sys

x = int(input())

a = 0
a_list = []
b = 0
b_list = []
c = 0
c_list = []

while a ** 5 < 10 ** 18:
  a_list.append(a)
  a += 1
  b_list.append(b)
  b -= 1
  c_list.append(c)
  c += 1


for i in a_list:
  for j, k in zip(b_list, c_list):
    if(i ** 5 - j ** 5 == x):
      print(i, j)
      sys.exit()
    elif(i ** 5 - k ** 5 == x):
      print(i, k)
      sys.exit()


Measured memory_bytes: 68192
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
struct node
{
    string s;
    int x,num;
}a[100000];
int cmp1(node a,node b)
{
    if(a.s==b.s)
    {
        return a.x>b.x;
    }
    else
    {
        return a.s<b.s;
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        a[i].num=i;
        cin>>a[i].s;
        scanf("%d",&a[i].x);
    }
    sort(a+1,a+n+1,cmp1);
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",a[i].num);
    }

    return 0;
}


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

int main() {
    long A, B, C, K;
    cin >> A >> B >> C >> K;
    if (abs(A - B) > 1e18) return cout << "Unfair" << endl, 0;
    cout << ((K % 2) ? -(A - B) : A - B) << endl;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int a[maxn];
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  return 1;
}

void solve() {
  int res = 1;

  int k = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] < 2 * k + 1) {
      res = mult(res, k + 1);
      continue;
    }
    ++k;
  }

  for (int i = 1; i <= k; ++i) {
    res = mult(res, i);
  }

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

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 640
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_A
# やるだけ # 本では番兵を用いた実装だと定数倍早いとあるが、pythonではwhileが遅いのでおとなしくfor文を書く

n = input()
S = list(map(int, input().split()))
q = input()
T = list(map(int, input().split()))

cnt = 0
# for t in T:
#     for s in S:
#         if t == s:
#             cnt += 1
#             break

for t in T:
    if t in S:
        cnt += 1

print(cnt)

# list.index(hoge)とかlist.count(hoge)とかもよく使う。



Measured memory_bytes: 6288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n;
  cin >> n;
  
  vector<int> pn(n);
  rep(i,n)  cin >> pn[i];
 
  int cnt = 1;
  int pi = 0;
  int pj = 0;
  rep(i,n){  
    pi = pn[i];
    if(pj > pi){
      cnt = cnt + 1;
      pj = pi;
    }
    if(i == 0){
      pj = pi;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
N=int(input())
P=[None]*(N+1)
for i in range(1,N+1):
    P[i]=int(input())

#最大長の「一つずつ増加する部分列」を求めればよい

Q=[0]*(N+2)

for i in range(1,N+1):
    Q[P[i]]=i

count=0
Ans=0
for i in range(1,N+2):
    if Q[i]>Q[i-1]:
        count+=1
    else:
        Ans=max(count,Ans)
        count=1

print(N-Ans)


Measured memory_bytes: 18804
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <cstdio>
#include <cstdint>
#include <unistd.h>

using i64 = std::uint_fast32_t;

struct fio {
private:
  constexpr static int is = 1 << 17;
  char ib[is], *ip = ib + is;
public:
  inline fio& operator>>(char& c) {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    c = *ip++;
    return *this;
  }
  inline fio& operator>>(i64& r) {
    char it;
    r = 0;
    while ((*this >> it, it & 16)) r = r * 10 + it - '0';
    return *this;
  }
};

fio fio;

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(i64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  i64 h, n;
  fio >> h >> n;
  i64 s = 0;
  for (int i = 0; i < n; i++) {
    i64 a;
    fio >> a;
    s += a;
  }
  if (s >= h) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
let () =
  let group = [|0; 1; 3; 1; 2; 1; 2; 1; 1; 2; 1; 2; 1|] in
  Scanf.scanf "%d %d" @@ fun x y ->
    print_endline @@
      if group.(x) = group.(y) then "Yes" else "No"

Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007
 
int main()
{
    boost
    int n, m;
    cin >> n >> m;

    vector<vi> G(n + 1);
    vii edge(m);
    for(int i = 0; i < m; i++)
    {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }

    float min_ = 1e9;
    vector<float> DP(n + 1, 0);
    vi max_child(n + 1, -1);
    for(int i = n - 1; i > 0; i--)
    {
        int size = 0;
        int  idx = -1;
        double max = 0;
        loop(q, G[i])
        {
            DP[i] += DP[q];
            if(max < DP[q]) max = DP[q], idx = q;
            size++;
        }
        max_child[i] = idx;
        if(size) DP[i] /= size;
        DP[i]++;
    }
    min_ = DP[1];

    for(int j = 1; j <= n; j++)
    {
        pii z = {j, max_child[j]};
        fill(DP.B, DP.E, 0.0);
        for(int i = n - 1; i > 0; i--)
        {
            int size = 0;
            loop(q, G[i])
            {
                if(i == z.F && q == z.S) continue;
                DP[i] += DP[q];
                size++;
            }
            if(size)
            {
                DP[i] /= size;
                DP[i]++;
            }
            else DP[i] = 1e9;
        }
        min_ = min(min_, DP[1]);
    }

    cout << fixed << setprecision(9) << min_ << nl;
    return 0;
}


Measured memory_bytes: 2816
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
 
int n, x ;
 
signed main(){
	scanf("%d", &n) ;
	rep(i, 1, n) {
		scanf("%d", &x) ;
		if (x % 2) PRINT("first") ;
	}
	PRINT("second") ;
	return 0 ;
}
 
/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, T[100010], M, P, X;

    cin >> N;

    long long int S = 0;

    for (int i = 1; i <= N; i++)
    {
        cin >> T[i];
        S += T[i];
    }

    cin >> M;

    for (int i = 1; i <= M; i++)
    {
        cin >> P >> X;

        cout << S - T[P] + X << endl;
    }
}

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

int main() {
    int s;
    cin >> s;
    int upp = s / 100;
    int lwr = s % 100;
    if(upp >= 1 && upp <= 12) {
        if(lwr >= 1 && lwr <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if(lwr >= 1 && lwr <= 12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b, c, x, y, price_min, price_ab, price_c_max, price_ab_c;

	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
	price_ab = a*x + b*y;
	if(x > y){
		price_c_max = x*2*c;
		price_ab_c  = y*2*c + (x-y)*a;
	}else{
		price_c_max = y*2*c;
		price_ab_c  = x*2*c + (y-x)*b;
	}
	if(price_ab > price_c_max){
		price_min = price_c_max;
		if(price_min > price_ab_c){
			price_min = price_ab_c;
		}		
	}else if(price_ab > price_ab_c){
		price_min = price_ab_c;
	}else{
		price_min = price_ab;
	}
	printf("%d\n", price_min);
	return 0;
}


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

#define MOD (10007)

int main(void)
{
    int N;
    char in[1001];
    int key, key_prev, key_prev_prev;
    int schedule[8], schedule_next[8];
    int conv;
    int i, j, k;
    
    
    scanf("%d", &N);
    scanf("%s", in);

    key_prev = 1;   // 最初に鍵を持っているのはJ
    key_prev_prev = 0;
 
 
    memset(schedule, 0, sizeof(schedule));
    schedule[1] = 1;
    
    for (i = 0; i < N; i++){
        switch (in[i]){
          case 'J':
            key = 1;
            break;
          
          case 'O':
            key = 2;
            break;
            
          case 'I':
            key = 4;
            break;
        }
        memset(schedule_next, 0, sizeof(schedule_next));
 
        if (i == 0){
            for (j = 0; j <= 7; j++){
                if ((j & (key | key_prev)) == (key | key_prev)){
                    schedule_next[j] = 1;
                }
            }
            key_prev_prev = key_prev;
            key_prev = key;
            memcpy(schedule, schedule_next, sizeof(schedule));

//for (j = 0; j <= 7; j++){
//    printf("(%d:%d)", j, schedule[j]);
//}
//printf("\n");
            continue;
        }
        for (j = 0; j <= 7; j++){
//            if ((j & (key | key_prev)) == (key | key_prev)){
            if ((j & (key | key_prev)) != 0){
                for (k = 0; k <= 7; k++){

                    if (((k & j) != 0) && ((k & key) != 0)){
//printf("(%d,%d,%d)", k, j, key);
                        schedule_next[k] += schedule[j];
						schedule_next[k] %= MOD;
                    }
                }
            }
        }
        
        key_prev_prev = key_prev;
        key_prev = key;
        memcpy(schedule, schedule_next, sizeof(schedule));
        
//for (j = 0; j <= 7; j++){
//    printf("[%d:%d]", j, schedule[j]);
//}
//printf("\n");

    }
    conv = 0;
    for (i = 0; i <= 7; i++){
        conv += schedule[i];
		conv %= MOD;
    }
    
    printf("%d\n", conv);
    
    return (0);
}

Measured memory_bytes: 596
//鏡餅
#include <iostream>
#include <vector>
#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];
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());

    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

unordered_map<int, int> get_primes(ll n) {
    unordered_map<int, int> facs;
    ll n2 = n;
    for(ll i = 2; i*i <= n; i++) {
        while (n2 % i == 0) {
            facs[i] += 1;
            n2 /= i;
        }
    }
    if (n2 > 1)
        facs[n2] += 1;
    return facs;
}

vector<int> get_facs(unordered_map<int, int>& primes) {
    vector<int> nums, cnt;
    for(auto p: primes) {
        nums.push_back(p.first);
        cnt.push_back(p.second);
    }
    vector<int> ans;
    auto dfs = [&] (auto self, int d, int cur) -> void {
        if (d == nums.size()) {
            ans.push_back(cur);
            return;
        }
        int pre_mul = 1;
        for(int i = 0; i <= cnt[d]; i++) {
            self(self, d+1, cur*pre_mul);
            pre_mul *= nums[d];
        }
    };
    dfs(dfs, 0, 1);
    return ans;
}

int main() {
    ll x;
    cin >> x;

    // a^n - b*n = X
    // if n == 5 (odd), a^n - b^n = (a-b) * (a^4 + a^3*b + a^2*b*2 + a*b*3 + b*4);
    // if fac == (a-b), a = b + fac
    // => (b+fac)^5 - b^5 = X
    // binary search
    ll diff = 4;
    for(int i = -diff; i <= 100; i++) {
        // cout << i << " " << ll(pow(i+diff, 5) - pow(i, 5)) << endl;
    }
    auto primes = get_primes(x);
    for(ll fac: get_facs(primes)) {
        // cout << fac << " " << endl;
        ll l = -(fac/2), r = 1e5;
        while(l <= r) {
            ll mid = l+(r-l)/2;
            double m = mid;
            double res = pow(m+fac, 5) - pow(m, 5);
            // cout << "mid " << mid << ", res = " << res << endl;
            if (res >= 1e9 || ll(res) > x) {
                r = mid-1;
            } else if (ll(res) < x) {
                l = mid+1;
            } else {
                cout << ll(mid+fac) << " " << ll(mid) << endl;
                return 0;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 4148
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

// n の約数を返す
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1LL; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  vector<ll> div1 = divisor(n);
  vector<ll> div2 = divisor(n-1);
  int ans = div2.size() - 1;
  for(auto d: div1){
    if(d==1) continue;
    ll nn = n;
    while(nn%d==0) nn /= d;
    if((nn-1)%d==0) ans++;
  }
  cout << ans << '\n';
	return 0;
}



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

int main(){
    string s;
    cin >> s;
    int size = s.size();
    string black, white;
    rep(i, 1, size+1){
        if (i%2 == 0){
            white += '1';
            black += '0';
        }
        else{
            white += '0';
            black += '1';
        }
    }
    int toBlack = 0;
    int toWhite = 0;
    rep(i, 0, size){
        if (s[i] != black[i]) toBlack ++;
        if (s[i] != white[i]) toWhite ++;
    }
    cout << min(toBlack, toWhite) << endl;
   return 0;
}

Measured memory_bytes: 768
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for _ in range(n)]

if n == 1:
    print(ka[0][0])
    exit()

counter = [0] * m
for x in ka:
    for a in x[1:]:
        counter[a - 1] += 1
ans = 0
for i in range(m):
    if counter[i] == n:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e3, inf = 1e9; int n, m;
struct Pos
{
  int i, j;
  void read() { scanf("%d %d", &i, &j); i--, j--; }
  bool operator==(const Pos &other) const { return i == other.i && j == other.j; }
};
int di[4] = {0, 0, 1, -1}, dj[4] = {1, -1, 0, 0};
Pos origin, destination;
char maze[maxN][maxN + 1];

struct Node
{
  Pos position; int portal;
  bool operator<(const Node &other) const { return portal > other.portal; }
};
int dist[maxN][maxN];
int dijkstra()
{
  for (int i = 0; i < n; i++)
    fill(dist[i], dist[i]+m, inf);
  priority_queue<Node> pq; pq.push(Node{origin, 0});
  while (!pq.empty())
  {
    Node u = pq.top(); pq.pop();
    if (u.position == destination)
      return u.portal;
    if (dist[u.position.i][u.position.j] < u.portal)
      continue;

    for (int k = 0; k < 4; k++)
    {
      int ni = u.position.i + di[k], nj = u.position.j + dj[k];
      if (ni < 0 || nj < 0 || ni >= n || nj >= m || maze[ni][nj] == '#') continue;
      if (u.portal < dist[ni][nj])
        pq.push(Node{Pos{ni, nj}, dist[ni][nj] = u.portal});
    }
    for (int i = -2; i <= 2; i++)
      for (int j = -2; j <= 2; j++)
      {
        int ni = u.position.i + i, nj = u.position.j + j;
        if (ni < 0 || nj < 0 || ni >= n || nj >= m || maze[ni][nj] == '#') continue;
        if (u.portal + 1 < dist[ni][nj])
          pq.push(Node{Pos{ni, nj}, dist[ni][nj] = u.portal + 1});
      }
  }
  return -1;
}

int main()
{
  while (scanf("%d %d", &n, &m) != EOF)
  {
    origin.read();
    destination.read();
    for (int i = 0; i < n; i++) scanf(" %s", maze[i]);

    int ans = dijkstra();
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 8756
#include<bits/stdc++.h>
#include <unordered_map>
#include <vector>


using namespace std;

int main(){
  int N;
  cin>>N;
  vector<string>s(N);
  long count=0;
  unordered_map <string,int>num;
  for(int i=0; i<N; i++){
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
    if(num[s[i]]){
      num[s[i]]++;
      count+=(num[s[i]]-1);
    }else{
      num[s[i]]=1;
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 17700
#include <bits/stdc++.h>
#define DIM 407
#define INF 1000000000000000007LL
using namespace std;

long long n,a[DIM],p[DIM],d[DIM][DIM];

long long F(int l, int r)
{
    if(d[l][r]!=-1) return d[l][r];
    if(l==r) return d[l][r] = 0,0;
    d[l][r] = INF;
    for(int i = l; i < r; ++i)
        d[l][r] = min(d[l][r],F(l,i)+F(i+1,r)+p[r]-p[l-1]);
    return d[l][r];
}

int main()
{
    cin>>n;
    for(int i = 1; i <= n; ++i)
        cin>>a[i],p[i]=p[i-1]+a[i];

    memset(d,-1,sizeof(d));
    cout<<F(1,n);
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

void dfs(std::vector<size_t>& v, size_t n, size_t max){
    if(n > max) return;

    auto s = std::to_string(n);
    std::ptrdiff_t cnt[3] = {std::count(s.begin(), s.end(), '3'), std::count(s.begin(), s.end(), '5'), std::count(s.begin(), s.end(), '7')};

    if(std::all_of(std::begin(cnt), std::end(cnt), [](size_t x){ return x > 0; })){
        v.emplace_back(n);
    }

    dfs(v, n * 10 + 3, max);
    dfs(v, n * 10 + 5, max);
    dfs(v, n * 10 + 7, max);
}

int main(){

    size_t n;
    std::cin >> n;

    std::vector<size_t> v;

    dfs(v, 0, n);

    std::cout << v.size() << std::endl;

    return 0;
}


Measured memory_bytes: 640
n=int(input())
A=list(map(int,input().split( )))
B=list(map(int,input().split( )))
count=0
flag=True
while flag:
    flag=False
    for i in range(-1,n-1):
        tonari=B[i-1]+B[i+1]
        tmp=(B[i]-A[i])//tonari
        if tmp>0:
            B[i]-=tonari*tmp
            count+=tmp
            flag=True
if A==B:
    print(count)
else:
    print(-1)


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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()
{
    cout << fixed << setprecision(15);
    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = 0;
    for(ll i= 1; i<=N; i++){
        ll temp = 0;
        ll k = i;
        while(k>0){
            temp += k%10;
            k = k/10;
        }
        if(temp>=A && temp<=B){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<int MOD> struct modnum {
    int v;
    modnum() : v(0) {}
    modnum(ll _v) : v(_v % MOD) { if (v < 0) v += MOD; }
    explicit operator int() const { return v; }
    friend ostream& operator << (ostream& o, const modnum& n) { return o << n.v; }
    friend istream& operator << (istream& i, modnum& n) { ll v; i >> v; n = modnum(v); return i; }

    friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
    friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

    modnum& operator += (const modnum& o) { v += o.v; if (v >= MOD) v -= MOD; return *this; }
    modnum& operator -= (const modnum& o) { v -= o.v; if (v < 0) v += MOD; return *this; }
    modnum& operator *= (const modnum& o) { v = int(ll(v) * ll(o.v) % MOD); return *this; }
    modnum operator - () { modnum res; if (v) res.v = MOD - v; return res; }
    friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
    friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
    friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }

    modnum pow(int e) const {
        if (e == 0) return 1;
        if (e & 1) return *this * this->pow(e-1);
        return (*this * *this).pow(e/2);
    }

    modnum inv() const {
        int g = MOD, x = 0, y = 1;
        for (int r = v; r != 0; ) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }

        assert(g == 1);
        assert(y == MOD || y == -MOD);
        return x < 0 ? x + MOD : x;
    }
    modnum& operator /= (const modnum& o) { return (*this) *= o.inv(); }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= modnum(b); }
};
using mn = modnum<1'000'000'007>;
using vmn = vector<mn>;

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

    int N;
    cin >> N;

    vmn fact(N + 1);
    fact[0] = 1;
    for (int i = 1; i <= N; i++)
        fact[i] = i * fact[i - 1];

    auto ncr = [&fact](int n, int r) {
        if (r < 0 || n < r) return mn(0);
        return fact[n] / (fact[r] * fact[n-r]);
    };

    vmn matl(N);
    for (int miss = 0; miss <= N - 2; miss++) {
        mn pick = ncr(N - 2 - miss, miss);
        matl[miss] = pick * fact[N - 1 - miss] * fact[miss];
    }

    mn ans = 0;
    for (int miss = 0; miss <= N - 2; miss++) {
        ans += (matl[miss] - matl[miss + 1]) * mn(N - 1 - miss);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 8064
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

void Main() {
  ll n; cin >> n;
  ll ans = n / 500 * 1000;
  n %= 500;
  cout << ans + n / 5 * 5 << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

vector < vector < bool >> g;
vector<bool> vis;
vi a, b;

void dfs(int node) {
	vis[node] = true;
	rep(i, vis.size()) {
		if (g[node][i] && !vis[i]) {
			dfs(i);
		}
	}
}

int main() {
	int n, m, in, inn, ans = 0;
	cin >> n >> m;
	rep(i, n) {
		vector < bool > tmp;
		rep(j, n) {
			tmp.push_back(false);
		}
		g.push_back(tmp);
	}
	vis.resize(n);

	rep(i, m) {
		cin >> in >> inn;
		a.push_back(in - 1);
		b.push_back(inn - 1);
		g[a[i]][b[i]] = true;
		g[b[i]][a[i]] = true;
	}
	rep(i, m) {
		g[a[i]][b[i]] = false;
		g[b[i]][a[i]] = false;
		rep(i, n) {
			vis[i] = false;
		}

		dfs(0);

		rep(j, n) {
			if (!vis[j])break;
			if (j == n - 1)ans++;
		}

		g[a[i]][b[i]] = true;
		g[b[i]][a[i]] = true;
	}
	cout << m-ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数の入力
            var test = Console.ReadLine();
            long n = long.Parse(test);


            string result = "Yes";

            List<string> list = new List<string>();
            for (int i = 0; i < n; ++i) {
                // 文字列の入力
                list.Add(Console.ReadLine());
            }

            string str = list[0];

            List<string> checkList = new List<string>();
            checkList.Add(str);

            for (int i = 1; i < n; ++i) {

                var end = str.Substring(str.Length - 1, 1);
                string next = list[i];

                if (checkList.Contains(next)) {
                    result = "No";
                    break;
                }

                checkList.Add(next);

                var first = next.Substring(0, 1);
                if(end != first) {
                    result = "No";
                    break;
                }

                str = next;
            }
            
            Console.WriteLine(result);

        }
    }
}

Measured memory_bytes: 13148
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>
#include<map>
#include<bitset>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

void solve() {
	string S,T;
	int A, B;
	string U;
	cin >> S >> T >> A >> B >> U;
	if (S == U)A--;
	if (T == U)B--;
	cout << A << " " << B << endl;
}

int main()
{
	solve();
	return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;
    cin>> s;


    int mn= 1000;

    for(int i=0; i<s.size()-2; i++)
       mn= min (mn, abs(753-(  ((s[i]- '0') *100 )+((s[i+1]- '0')* 10 )+ ((s[i+2]- '0')) ) ) );


    cout << mn;
    nl;


    return 0;
}




Measured memory_bytes: 3620
#include <iostream>

using namespace std;

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

    if ((n[0] == n[1] && n[1] == n[2]) ||
        (n[1] == n[2] && n[2] == n[3])) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}



Measured memory_bytes: 256
#include<stdio.h>

int main() {
   int N;

   scanf("%d", &N);

   if(N % 10 == 3) {
      printf("bon");
   }else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
      printf("pon");
   }else {
      printf("hon");
   }
   return 0;
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int N, T, A;
    cin >> N >> T >> A;
    T *= 1000, A *= 1000;
    int ans = -1, t = 1e9;
    for(int i = 0; i < N; i++) {
        int h;
        cin >> h;
        int t_ = abs(T - 6 * h - A);
        if(t > t_) {
            t = t_;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

Q = int(input())
sosu = [2]

for L in range(3, 10**5, 2): # 2 以外の素数は奇数なので
    for L2 in sosu:
        if L % L2 == 0:
            break # 素数でないことがわかったらそれ以上ループする必要はない
    else: # break で抜けることがなかったら L は素数（Python 特有の制御構文）
        sosu.append(L)

sosu = set(sosu)

d = {0:0}
now = 0
for x in range(1, 10**5+1):
    if x % 2 == 1:
        if x in sosu and (x+1)/2 in sosu:
            now += 1
    d[x] = now

li = []
for i in range(Q):
    l, r = map(int, input().split())
    li.append((l, r))

for l,r in li:
    ans = 0
    print(d[r]-d[l-1])

Measured memory_bytes: 70236
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n, m;
	cin >> n >> m;
	vector<vector<int>> G(n, vector<int>());
	vector<int> h(n, 0); // 入次数

	rep(i, m) {
		int x, y;
		cin >> x >> y;
		G[x - 1].push_back(y - 1);
		h[y - 1]++;
	}

	// ここからトポロジカルソート
	// 移動先がない点を保存する
	stack<int> st;
	rep(i, n) if (h[i] == 0) st.push(i);
	// ソート後のグラフ
	vector<int> sortG;

	while (!st.empty()) {
		int i = st.top(); st.pop();
		sortG.push_back(i);
		for (auto& j : G[i]) {
			// 隣接する頂点の入次数を-1
			h[j]--;
			if (h[j] == 0) st.push(j);
		}
	}

	// ここからDP
	vector<int> dp(n + 1, 0);
	rep(i, n) {
		int from = sortG[i];
		rep(j, (int)G[from].size()) {
			int to = G[from][j];
			dp[to] = max(dp[to], dp[from] + 1);
		}
	}

	cout << *max_element(allof(dp)) << endl;

	return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

bool is_harshad(int x){
	int X = x;

	int f = 0;
	while(x > 0){
		f += (x % 10);
		x /= 10;
	} // end while

	return (X % f == 0);
}

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

	int N; cin >> N;
	
	bool res = is_harshad(N);

	cout << (res ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256