akhauriyash/Code-Regression huggingface dataset:
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')

INF = 10**12
d = lambda a, b: abs(a - b)


def main():

    A, B, Q = in_nn()
    tmp = list(map(int, read().split()))
    s = tmp[:A]
    t = tmp[A:A + B]
    x = tmp[A + B:]

    a = [0] * Q

    for i in range(Q):

        n = x[i]

        if n <= s[0]:
            a1 = -INF
            a2 = s[0]
        elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
        else:
            si = bisect.bisect_right(s, n)
            a1 = s[si - 1]
            a2 = s[si]

        if n <= t[0]:
            b1 = -INF
            b2 = t[0]
        elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
        else:
            ti = bisect.bisect_right(t, n)
            b1 = t[ti - 1]
            b2 = t[ti]

        # print(a1, a2, b1, b2)
        ans = d(n, a1) + min(d(a1, b1), d(a1, b2))
        ans = min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2)))
        ans = min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2)))
        ans = min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2)))
        a[i] = ans

    print('\n'.join(map(str, a)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 37300
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

ll power(ll x, ll y) {
	if (y==0) return 1;
	else if (y==1) return x%MOD;
	else if (y%2==0) { ll pow=power(x,y/2); return (pow*pow)%MOD; } 
	else { ll pow=power(x,y/2); return ((pow*pow)%MOD)*x%MOD; }
}

int main(){
	int n; cin >> n;
	VI a(n), b(n);
	REP(i,n) cin >> a[i] >> b[i];
	int z=0;
	map<P,P> mp;
	REP(i,n){
		if(a[i]==0||b[i]==0){
			if(a[i]==0){
				if(b[i]==0)
					z++;
				else
					mp[{0,1}].first++;
			}
			else
				mp[{0,1}].second++;
		}
		else{
			ll g=gcd(abs(a[i]),abs(b[i]));
			if((a[i]>0&&b[i]>0)||(a[i]<0&&b[i]<0))
				mp[{abs(a[i]/g),abs(b[i]/g)}].first++;
			else
				mp[{abs(b[i]/g),abs(a[i]/g)}].second++;
		}
	}
	ll ans=1;
	for(auto p:mp){
		ans*=power(2,p.second.first)+power(2,p.second.second)+MOD-1;
		ans%=MOD;
	}
	ans+=z; ans+=MOD-1;
	ans%=MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 21980
# 長さnの文字列Sについて，各iに対しSとS[i:-1]の最長共通接頭辞(LCP)の長さを求める
def Z_algorithm(S): # O(n)
    n = len(S)
    LCP = [0]*n
    i = 1
    j = 0
    LCP[0] = l = n
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        LCP[i] = j
        k = 1
        while l-i > k < j - LCP[k]:
            LCP[i+k] = LCP[k]
            k += 1
        i += k
        j -= k
    return LCP # LCP:list[int,...] (LCP[i]はSとS[i:-1]の最長共通接頭辞の長さ)



N = int(input())
S = input()
ans = 0
for i in range(N):
    lcp = Z_algorithm(S[i:])
    for j in range(len(lcp)):
        if lcp[j]<=j:
            ans = max(ans,lcp[j])
print(ans)


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vi b(m);
    rep(i, m) cin >> b[i];
    vector<vi> a(n, vi(m));
    rep(i, n) rep(j, m) cin >> a[i][j];
    int ans = 0;
    rep(i, n) {
        int sum = 0;
        rep(j, m) sum += a[i][j] * b[j];
        sum += c;
        if (sum > 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    for(int i = 1; i <= 1000; i++) {
        if(i * 8/100 == a && i * 10/100 == b) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	int a,b;
	cin >> a >> b;
	if (a > b) {
		cout << ((gcd(a,b) == b)? a+b : b-a) << endl;
	} else {
		cout << ((gcd(a,b) == a)? a+b : b-a) << endl;
	}

}



Measured memory_bytes: 256
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x < a :
  distance_xa = a - x
else :
  distance_xa = x - a
 
if x < b:
  distance_xb = b - x
else:
  distance_xb = x - b
  
if distance_xa < distance_xb :
  print("A")
else :
  print("B")

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N;
    cin >> N;
    vector<int> P(N, 0);
    REP(i, N) { cin >> P[i]; }
    int ans = 0;
    for(int i = 1; i < N - 1; ++i) {
        vector<int> check;
        check.push_back(P[i-1]);
        check.push_back(P[i]);
        check.push_back(P[i+1]);
        SORT(check);
        if(check[1] == P[i]) { ans++; }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#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 pii pair < int , int >
#define X first
#define Y second
#define rint read<int>
#define int long long

using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;

template < class T >
    inline T read () {
        T x = 0 , f = 1 ; char ch = getchar () ;
        while ( ch < '0' || ch > '9' ) {
            if ( ch == '-' ) f = - 1 ;
            ch = getchar () ;
        }
        while ( ch >= '0' && ch <= '9' ) {
            x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
            ch = getchar () ;
       }
   return f * x ;
}

const int N = 4e3 + 100 ;
const int mod = 1e9 + 7 ;

int n , k , v[N] , ans ;

inline int quick (int a , int p) {
    int res = 1 ;
    while ( p ) {
        if ( p & 1 ) res = ( res * a ) % mod ;
        a = ( a * a ) % mod ; p >>= 1 ;
    }
    return res ;
}

const int inv = quick ( 2ll , mod - 2 ) ;

signed main() {
    n = rint () ; k = rint () ; rep ( i , 1 , n ) v[i] = rint () ;
    rep ( i , 1 , n ) rep ( j , i + 1 , n ) if ( v[i] > v[j] ) ++ ans ;
    ans = ( ans * k ) % mod ; rep ( i , 1 , n ) v[i+n] = v[i] ;
    rep ( i , 1 , n )
        rep ( j , n + 1 , ( n << 1 ) )
            if ( v[i] > v[j] ) ans = ( ans + k * ( k - 1 ) % mod * inv % mod ) % mod ;
    printf ("%lld\n" , ans % mod ) ;
    return 0 ;
}

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

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;




int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]==','){cout<<" ";}
        else{cout<<s[i];}
    }
    cout<<endl;
    
    
    
    return 0;
}


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

int main() {
  ll n,count=0,res=0;
  cin>>n;
  vector<ll> h;
  for(ll i=0; i<n; i++){
    ll x;
    cin>>x;
    h.push_back(x);
  }
  for(ll i=0; i<n-1; i++){
    if(h[i]>=h[i+1]) {
      count++;
    }
    else{
        res=max(res,count);
        count=0;
    }
  }
  cout<<max(res,count);
}

Measured memory_bytes: 1400
package main

import (
    "fmt"
)

func main() {
    var n, max, cnt int 
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        var h int 
        fmt.Scan(&h)
        if h >= max {
            cnt++
            max = h 
        }   
    }   
    fmt.Println(cnt)
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	long long m;
	cin >> n >> m;
	vector<long long> a(n+1, 0);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] += a[i-1];
	}
	map<long long, long long> memo;
	for(long long x : a){
		memo[x%m]++;
	}
	long long ans = 0;
	for(auto& p : memo){
		ans += p.second * (p.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

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

void draw(int n){
  int m[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
  int t=0, muki=0, x=n+1, y=2;
  int cn[n+4][n+4];
  for(int i=1; i<n+3; i++)
    for(int j=1; j<n+3; j++)
      cn[i][j]=0;
  for(int i=0; i<n+4; i++){
    cn[i][0]=1;
    cn[i][n+3]=1;
    cn[0][i]=1;
    cn[n+3][i]=1;
  }

  while(t<2){
    if(t==1){
      if(cn[x+m[muki%4][0]+m[(muki+1)%4][0]][y+m[muki%4][1]+m[(muki+1)%4][1]]==1)
	break;
    }
    if(cn[x+2*m[muki%4][0]][y+2*m[muki%4][1]]==1)
      {t++; muki++; cn[x][y]=1;}
    else{
      t = 0;
      cn[x][y]=1;
      x+=m[muki%4][0];
      y+=m[muki%4][1];
    }
  }
  
  for(int i=2; i<n+2; i++){
    for(int j=2; j<n+2; j++){
      if(cn[i][j]==1)
	cout << "#";
      else
	cout << " ";
    }
    cout << endl;
  }
}

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

  for(int i=0; i<d-1; i++){
    cin >> n;
    draw(n);
    cout << endl;
  }
  cin >> n;
  draw(n);
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,n,a) for(int i=n;i>=a;i++)
#define ll long long int
#define p(a,b) pair<a,b>
#define mp(a,b) make_pair(a,b)
#define hpq(a) priority_queue<a>
#define lpq(a) priority_queue<a, vector<a>, greater<a>>
#define nl endl
#define pb(x) push_back(x);
#define ft(x,a) for(auto &it : a)
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
/*

   *                          (                            (
 (  `          )   )          )\ )            )            )\ )        (      )    *   )              )                                                  (
 )\))(      ( /(( /(   (  (  (()/(  (      ( /(   (  (    (()/(        )\  ( /(  ` )  /((   (      ( /(                   (         )    (               )\ )  (
((_)()\  (  )\())\()) ))\ )(  /(_))))\  (  )\()) ))\ )(    /(_))  (   ((_) )\())  ( )(_))(  )\ )   )\())(     (  (  `  )  )\ )     (     )\ )    (  (   (()/( ))\
(_()((_) )\(_))((_)\ /((_|()\(_))_/((_) )\((_)\ /((_|()\  (_))_   )\  )\ )(_))/  (_(_()|()\(()/(  (_))/ )\    )\ )\ /(/( (()/(     )\  '(()/(    )\ )\   ((_))((_)
|  \/  |((_) |_| |(_|_))  ((_) |_(_))( ((_) |(_|_))  ((_)  |   \ ((_)_(_/(| |_   |_   _|((_))(_)) | |_ ((_)  ((_|(_|(_)_\ )(_))  _((_))  )(_))  ((_|(_)  _| (_))
| |\/| / _ \  _| ' \/ -_)| '_| __| || / _|| / // -_)| '_|  | |) / _ \ ' \))  _|    | | | '_| || | |  _/ _ \ / _/ _ \ '_ \) || | | '  \()| || | / _/ _ \/ _` / -_)
|_|  |_\___/\__|_||_\___||_| |_|  \_,_\__||_\_\\___||_|    |___/\___/_||_| \__|    |_| |_|  \_, |  \__\___/ \__\___/ .__/ \_, | |_|_|_|  \_, | \__\___/\__,_\___|
                                                                                            |__/                   |_|    |__/           |__/

*/
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b)
    {
        while(b--)
            cout<<a;
    }
    else
        while(a--)
            cout<<b;
}


Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int h, w;

            while (true)
            {
                string[] num = Console.ReadLine().Split(' ');
                h = int.Parse(num[0]);
                w = int.Parse(num[1]);

                if (h == 0 && w == 0)
                {
                    break;
                }

                for (int i = 1; i <= h; i++)
                {
                    for (int j = 1; j <= w; j++)
                    {
                        if (j % 2 == 1 && i % 2 == 1)
                        {
                            Console.Write("#");
                        }
                        else if (j % 2 == 0 && i % 2 == 0)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
        }
    }



Measured memory_bytes: 8840
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <math.h> 

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (i = 0; i < n; i++)
#define FOR(i, a, b) for (i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

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

int main()
{

    std::cin.tie(0);

    string T;
    cin >> T;

    int size = T.size();
    string tmp,res;

    for (int i = 0; i < size; i++){
        //  if(T[0] == '?'){
        //     T[0] = 'D';
        //     continue;
        // } 
         if(T[i] == '?'){
            //T[i+1] == 'P';
            T[i] = 'D';
            continue;
        } 

        if(i == size-1 && T[0] == '?'){
            T[i] = 'D';
            break;
        } 

    }

    cout << T << endl;

    return 0;

}



Measured memory_bytes: 3752
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{ 
    int n,x,sum=0,sum2=0;
    cin>>n>>x;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        sum+=a;
        if(sum<=x)
         sum2++;
    }
    cout<<sum2+1;
    
    
    
    
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define zero return 0;
int a,b,c,d,bj1,bj2,bj3;
char ch;
inline void dfs(int x,int y ,int z){
	if(x>2||y>2||z>2){
		return ;
	}
	int ans=a;
	if(x==1) {
	ans+=b;
}
	else {
	ans-=b;
}
	if(y==1)
	{
	ans+=c;
}
	else 
	{
	ans-=c;
}
	if(z==1) {
	ans+=d;
}
	else {
	ans-=d;
}
	if(ans==7) 
	{
	bj1=x,bj2=y,bj3=z;
	return ;
}
	dfs(x,y,z+1);
	dfs(x,y+1,z);
	dfs(x+1,y,z);
	return ;
}
int main(){
	ch=getchar();
	a=ch-'0';
	ch=getchar();
	b=ch-'0';
	ch=getchar();
    c=ch-'0';
	ch=getchar();
	d=ch-'0';
	dfs(1,1,1);
	printf("%d",a);
	if(bj1==1){
		printf("+");
	}
	else{
		printf("-");
	}
		printf("%d",b);
	if(bj2==1){
		printf("+");
	}
	else{
		printf("-");
	}
		printf("%d",c);
	if(bj3==1){
		printf("+");
	}
	else{
		printf("-");
	}
	printf("%d=7\n",d);
	zero
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
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);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    string s;
    cin >> s;
    int mi = pow(10,6);
    for(int i = 0; i< s.size()-2; i++) {
        mi = min(mi,abs(753-stoi(s.substr(i,3))));
    }
    cout << mi << endl;
    
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int low[100005];
int cnt,dep[100005],pos[100005];
vector<int> g[100005];
int n,m;
void dfs(int ind,int lst){
    dep[ind]=dep[lst]+1;
    low[ind]=dep[ind];
    //low[ind]=pos[ind]=++cnt;
    for(int i=0;i<g[ind].size();i++){
        int now=g[ind][i];
        if(now==lst) continue;
        if(dep[now]){
            low[ind]=min(low[ind],dep[now]);
            continue;
        }
        dfs(now,ind);
        low[ind]=min(low[ind],low[now]);
    }
}
int main(){
    scanf("%d %d",&n,&m);
    for(int i=1;i<=m;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(1,0);
    cnt=0;
    for(int i=1;i<=n;i++)
        if(dep[i]==low[i] && i!=1)
            cnt++;
    printf("%d\n",cnt);
    return 0;
}
/*
7 7
1 3
3 4
4 5
4 6
5 6
6 7
7 2
*/

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

  

int main() {
    ll A,B,K;
    cin >> A >> B >>K;
    ll num =0;
    for(int i=100;i>=0;--i){
        if(A%i ==0 && B%i==0){
            num++;
        }
        if(num == K){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ans = b;
    if (a < 13){
        ans /= 2;
    } 
    if (a < 6){
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
H,W,K,*L = open(0).read().split()
H,W,K = map(int, (H,W,K))
sheet = [[0]*W for i in range(H)]
cnt = 1
sep = [0]
n = 1
for i in range(H):
  for j in range(W):
    if L[i][j]=='#':
      sheet[i][j] = n
      n += 1      
for i in range(H):
  p = 0
  for j in range(W):
    if sheet[i][j]!=0:
      p = sheet[i][j]
    sheet[i][j] = p
for i in range(H):
  p = 0
  for j in range(W-1,-1,-1):
    if sheet[i][j]!=0:
      p = sheet[i][j]
    sheet[i][j] = p
for j in range(W):
  p = 0
  for i in range(H):
    if sheet[i][j]!=0:
      p = sheet[i][j]
    sheet[i][j] = p

for j in range(W):
  p = 0
  for i in range(H-1,-1,-1):
    if sheet[i][j]!=0:
      p = sheet[i][j]
    sheet[i][j] = p
for ans in sheet:
  print(' '.join(map(str,ans)))

Measured memory_bytes: 45676
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int h[20];
int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> h[i];
    int ans = 0;
    int mx = 0;
    rep(i, n){
        if(mx <= h[i]){
            ans++;
            mx = h[i];
        }
    }
    cout << ans <<endl;
}



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

void Sort( int* a )
{
    for( int i = 0; i < 4; i++ )
    {
        for( int j = i + 1; j < 5; j++ )
        {
            if( a[i] > a[j] )
            {
                int temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }
}

bool fourCard( int* a )
{
    if( a[0] == a[1] && a[2] == a[3] && a[1] == a[2] || a[1] == a[2] && a[3] == a[4] && a[2] == a[3] )
        return true;
    else
        return false;
}

bool fullHouse( int* a )
{
    if( a[0] == a[1] && a[2] == a[3] && a[3] == a[4] || a[0] == a[1] && a[0] == a[2] && a[3] == a[4] )
        return true;
    else
        return false;
}

bool threeCard( int* a )
{
    if( a[0] != a[1] && a[2] == a[3] && a[3] == a[4] || a[3] != a[4] && a[0] == a[1] && a[0] == a[2] || a[0] != a[4] && a[1] == a[2] && a[2] == a[3] )
        return true;
    else
        return false;
}

bool straight( int* a )
{
    if( a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13 )
        return true;
    for( int i = 0; i < 4; i++ )
        if( a[i+1] - a[i] != 1 )
            return false;
    return true;
}

bool twoPair( int* a )
{
    if( fourCard(a) == false && ( a[0] == a[1] && a[2] == a[3] || a[0] == a[1] && a[3] == a[4] || a[1] == a[2] && a[3] == a[4] ) )
        return true;
    else
        return false;;
}

bool onePair( int * a )
{
    if( twoPair(a) == false && threeCard(a) == false && ( a[0] == a[1] || a[1] == a[2] || a[2] == a[3] || a[3] == a[4] ) )
        return true;
    else
        return false;
}

int main()
{
    int card[5];
    char p;

    while( cin >> card[0] >> p >> card[1] >> p >> card[2] >> p >> card[3] >> p >> card[4] )
    {
        Sort(card);
        if( fullHouse(card) == true )
            cout << "full house" << endl;
        else if( fourCard(card) == true )
            cout << "four card" << endl;
        else if( threeCard(card) == true )
            cout << "three card" << endl;
        else if( twoPair(card) == true )
            cout << "two pair" << endl;
        else if( onePair(card) == true )
            cout << "one pair" << endl;
        else if( straight(card) == true )
            cout << "straight" << endl;
        else
            cout << "null" << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;




int main()
{
    
    string S;
    cin >> S;
    
    string T = "";
    vector<string> ss = {"dream","dreamer","eraser","erase"};
    
    while (T == S || T.length() < S.length()) {
        //cout << T << endl;
        if(T+"dream" == S.substr(0,T.length()+5)){
            T+="dream";
            if(T+"eraser" == S.substr(0,T.length()+6)){
                T+="eraser";
            }else if(T+"erase" == S.substr(0,T.length()+5)){
                T+="erase";
            }else if(T+"er" == S.substr(0,T.length()+2)){
                T+="er";
            }
        }else{
            if(T+"eraser" == S.substr(0,T.length()+6)){
                T+="eraser";
            }else if(T+"erase" == S.substr(0,T.length()+5)){
                T+="erase";
            }else{
                break;
            }
        }
    }
    
    if(S == T) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}



Measured memory_bytes: 768
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod7=1e9+7;
const int mod=998244353;
const double pi=3.14;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0') if(ch=='-') d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9') a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0') if(ch=='-') d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9') a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    int a[6];
    for(re int i=1;i<=5;i++) read(a[i]);
    for(re int i=1;i<=5;i++) if(a[i]==0) return printf("%d\n",i),0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);

  int N;
  while (cin >> N  && N){
    vector<int> A(N);
    vector<int> B(N);

    REP(i, N){
      string str;
      cin >> str;
      B[i] = ! (str == "x");
      
      if (str != "x"){
        A[i] = atoi(str.c_str());
      }
    }

    vector<int> candidate;
    REP (i, N) if (B[i]){
      candidate.push_back(A[i] - 2);
      candidate.push_back(A[i] - 1);
      candidate.push_back(A[i]);
      candidate.push_back(A[i] + 1);
      candidate.push_back(A[i] + 2);
    }

    sort(ALL(candidate));
    candidate.erase(unique(ALL(candidate)), candidate.end());

    vector<int> ans;

    for (auto v : candidate){
      REP(i, N) if (B[i] == 0){
        A[i] = v;
      }

      bool ok = true;

      REP(i, N){
        if (i % 2 == 0){
          ok = ok && (i == 0 || A[i - 1] > A[i]);
          ok = ok && (i == N - 1 || A[i + 1] > A[i]);
        } else {
          ok = ok && (i == 0 || A[i - 1] < A[i]);
          ok = ok && (i == N - 1 || A[i + 1] < A[i]);
        }
      }
      if (ok){
        ans.push_back(v);
      }
    }
      
    if (ans.empty()){
      cout << "none" << endl;
    } else if (ans.size() > 1){
      cout << "ambiguous" << endl;
    } else  {
      cout << ans[0] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

bool solve(){
    int n;
    cin >> n;
    vector<P> p(n);
    REP(i,n) p[i].second = in();
    REP(i,n) p[i].first = in();
    sort(ALL(p));
    VI a(n), b(n);
    REP(i,n){
        a[i] = p[i].second;
        b[i] = p[i].first;
    }
    // REP(i,n) cout << a[i] << " " << b[i] << endl;
    VI c(n);
    REP(i,n){
        if (a[i] > b[n - 1]){
            return false;
        }
        int x = lower_bound(ALL(b), a[i]) - b.begin();
        c[i] = n - 1 - x;
    }
    VI d(c);
    sort(ALL(d));
    // REP(i,n){
    //     cout << a[i] << " " << b[i] << " " << c[i] << endl;
    // }
    REP(i,n){
        if (d[i] < i) return false;
    }
    REP(i,n){
        if (d[i] > i) return true;
    }
    REP(i,n) c[i] = n - 1 - c[i];
    VI visit(n);
    int x = 0;
    while (!visit[x]){
        visit[x] = 1;
        x = c[x];
    }
    REP(i,n) if (!visit[i]) return true;
    return false;
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


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

int main() 
{
    vector<ll> v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(v.begin(),v.end());
    //for(ll i=0;i<3;i++){cout<<v[i];}
    //cout<<k<<endl;
    //cout<<v[3]<<" "<<v[2];
    ll k=v[2]-v[1];
    v[0]+=k;
    v[1]+=k;
    ll op=k;
    //cout<<op;
    ll k2=v[2]-v[0];
    if(k2%2==0)
    {
        op+=(k2/2);
        //cout<<op<<endl;
    }
    else
    {
        op++;
        op+=(k2/2)+1;
        //cout<<op<<endl;
    }
    v[0]-=k;
    v[1]-=k;
    ll op2=0;
    k=v[1]-v[0];
    v[0]+=k;
    v[2]+=k;
    op2+=k;
    k2=v[2]-v[1];
    if(k2%2==0)
    {
        op2+=k2;
    }
    else
    {
        op2=INT_MAX;
    }
    cout<<min(op,op2);
    //if(v[2]-v[1])
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define vint vector<int> 
#define vbool vector<bool>
#define vvint vector<vector<int>>
 
#define rep(a, b, c) for(int (a)=(b); (a)<(c); (a)++)
#define all(a) (a).begin(), (a).end()
 
int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
 
    double r;
    cin >>r;
    cout << 2*r*3.1415;
 
 
}

Measured memory_bytes: 3780
import math
N,M=map(int,input().split())
A=[0]*N
B=[0]*M
for i in range(N):
  A[i]=str(input())
for i in range(M):
  B[i]=str(input())
k=math.ceil(N/M)

def macthing(y,x):
  flag=0
  for p in range(M):
    if A[y+p][x:x+M]!=B[p]:
      flag=1
      break
  if flag==0:
    return True
  else:
    return False

for i in range(k):
  for j in range(k):
    if macthing(i,j):
      print('Yes')
      exit()
print('No')


Measured memory_bytes: 9040
using System;

namespace _0510
{
	class Test
	{
		static void Main(string[] args)
		{
			int[] i, j;
			i = j = new int[4];
			string p, q;
			p = Console.ReadLine();
			q = Console.ReadLine();
			string[] a, b;
			a = p.Split(' ');
			b = q.Split(' ');
			for (int x = 0; x < 4;x++)
			{
				i[x] = Convert.ToInt32(a[x]);
				j[x] = Convert.ToInt32(b[x]);
			}

			int asum = 0;
			int bsum = 0;
			for (int y = 0; y < 4; y++)
			{
				asum += i[y];
				bsum += j[y];
			}

			if (asum <= bsum)
				Console.WriteLine(bsum);
			else Console.WriteLine(asum);
		}
	}
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int N; cin >> N;
    VI b(N); REP(i,N) cin >> b[i];
    VI ans;
    REP(j,N){
        int ptr = -1;
        REP(i,N-j) if(b[i] == i+1) ptr = i;
        if(ptr == -1) break;
        b.erase(b.begin()+ptr);
        ans.push_back(ptr+1);
    }
    REVERSE(ans);
    if(!b.empty()) cout << -1 << en;
    else{
        REP(i,N) cout << ans[i] << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  
  cin >> N;
 
  int l, r;
  int sum = 0;
  rep (i, N) {
      cin >> l >> r;
      
      sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
map<tuple<vector<vector<int>>, vector<pair<int, int>>, int, int>, int> mp;
int dfs(vector<vector<int>> d, vector<pair<int, int>> c, int turn, int pass){
  tuple<vector<vector<int>>, vector<pair<int, int>>, int, int> T = make_tuple(d, c, turn, pass);
  if (mp.count(T)){
    return mp[T];
  }
  set<int> next;
  if (!d[turn].empty()){
    vector<pair<int, int>> c2 = c;
    c2.push_back(make_pair(d[turn][0], turn));
    vector<vector<int>> d2 = d;
    d2[turn].erase(d2[turn].begin());
    next.insert(dfs(d2, c2, 1 - turn, 0));
  }
  if (pass == 1){
    next.insert(0);
  }
  if (c.empty() && pass == 0){
    next.insert(dfs(d, c, 1 - turn, 1));
  }
  if (!c.empty()){
    vector<int> score(2, 0);
    vector<bool> ok(2, true);
    int sz = c.size();
    for (int i = sz - 1; i >= 0; i--){
      if (c[i].first == -1){
        ok[1 - c[i].second] = false;
      } else if (ok[c[i].second]){
        score[c[i].second] += c[i].first;
      }
    }
    vector<pair<int, int>> c2(0);
    next.insert(score[0] - score[1] + dfs(d, c2, 1 - turn, 0));
  }
  int ans;
  if (turn == 0){
    ans = *next.rbegin();
  } else {
    ans = *next.begin();
  }
  mp[T] = ans;
  return ans;
}
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> d(2);
  d[0] = vector<int>(n);
  for (int i = 0; i < n; i++){
    cin >> d[0][i];
  }
  d[1] = vector<int>(m);
  for (int i = 0; i < m; i++){
    cin >> d[1][i];
  }
  vector<pair<int, int>> c;
  cout << dfs(d, c, 0, 0) << endl;
}


Measured memory_bytes: 105136
#include <bits/stdc++.h>
using namespace std;
int dp[10][100005];
int main()
{
  int n;
  int hap[10][100005];
  
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=3;j++){
      cin>>hap[j][i];
    }
  }
     
  dp[1][1]=hap[1][1];
  dp[2][1]=hap[2][1];
  dp[3][1]=hap[3][1];
     
  for(int i=2;i<=n;i++){
    dp[1][i]=max(dp[2][i-1],dp[3][i-1])+hap[1][i];
    dp[2][i]=max(dp[1][i-1],dp[3][i-1])+hap[2][i];
    dp[3][i]=max(dp[2][i-1],dp[1][i-1])+hap[3][i];
  }
     
  cout<< max(dp[1][n],max(dp[2][n],dp[3][n]))<<endl;
  return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n, k;
  cin >> n >> k;
  vector<bool> snuke(n);
  rep(ik,k) {
    int d = in();
    rep(i,d) {
      int a = in();
      snuke[a-1] = true;
    }
  }

  int cnt = 0;
  rep(i,n) {
    if (snuke[i]) cnt++;
  }
  cout << n-cnt << endl;
  return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<unordered_map>
using namespace std;

int main()
{
	int n,m,count=0,sum=0;cin>>n>>m;
	double v;
	v=1.0/(4*m);
	int a[n],i;for(i=0;i<n;i=i+1){cin>>a[i];sum=sum+a[i];}
	v=sum*v;
	
	for(i=0;i<n;i=i+1)
	{
	    if(a[i]>=v){count=count+1;}
	}
	if(count>=m){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
}

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 1e18;
    for (int C = 0; C <= max(2*x,2*y); C++) {
        int A = max(x-C/2,0);
        int B = max(y-C/2,0);
        ll cost = a*A + b*B + c*C;
        ans = min(ans,cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  s[5] = s[13] = ' ';
  cout << s << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
  int c[4] = {};
  for (int i = 0; i < 3; ++i)
  {
    int a, b;
    cin >> a >> b;
    c[a - 1]++;
    c[b - 1]++;
  }
  for (int i = 0; i < 4; ++i)
  {
    if (c[i] == 3)
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj0037/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/xxxyyyy/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		char[][] table = new char[9][9];
		for (int i = 0; i < 9; i++) {
			char[] str = sc.next().toCharArray();
			if (i % 2 == 0) {
				for (int col = 1; col < 9; col += 2)
					table[i][col] = str[col / 2];
			} else {
				for (int col = 0; col < 9; col += 2)
					table[i][col] = str[col / 2];
			}
		}
		System.out.println(solve(table));

	}

	String solve(char[][] table) {
		int row = 0, col = 0, dir = 0;
		char[] dirs = "RDLU".toCharArray();
		int[] dr = { 0, 1, 0, -1 };
		int[] dc = { 1, 0, -1, 0 };
		StringBuilder sb = new StringBuilder();
		do {
			for(int i = 0; i < 4; i++) {
				int next_dir = (dir + i + 3) % 4;
				int nr = row + dr[next_dir];
				int nc = col + dc[next_dir];
				if( !(0 <= nr && nr < 9 && 0 <= nc && nc < 9) ) continue;
				if( table[nr][nc] != '1' ) continue;
				row = nr + dr[next_dir];
				col = nc + dc[next_dir];
				dir = next_dir;
				sb.append(dirs[dir]);
				break;
			}
		} while( (row | col) != 0);
		return sb.toString();
	}
	

	void debug(Object... os) {
		System.err.println(deepToString(os));
	}
}

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

int main(){
  int n,i,a=100000;

  cin>> n;
  for(i=0;i<n;i++){
    a=a+(a*0.05);
    if(a%1000 != 0){
      a=a-(a%1000)+1000;
    }
  }
  cout << a << endl;



}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }



int main(){
  int a,b;
  cin >> a >> b;
  cout << (a + b)% 24 << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

int main(){
	LL n;cin>>n;
	cout<<n*(n-1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h=0,n;
    cin>>n;
    while(n>=500)
    {
        h+=1000;
        n-=500;
    }
    while(n-5>0)
    {
        h+=5;
        n-=5;
    }
    cout<<h;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    rep(i, 3) if (S[i] == '7') {cout << "Yes" << endl; return 0;}
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = 1050000000;
constexpr auto MOD = 1000000007;


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

	bool can = false;

	rep(i, 1 << 4) {
		string t = "";
		if (i % 2)t += "A";
		t += "KIH";
		if ((i / 2) % 2)t += "A";
		t += "B";
		if ((i / 4) % 2)t += "A";
		t += "R";
		if ((i / 8) % 2)t += "A";

		if (s == t)can = true;
	}
	
	cout << (can? "YES":"NO") << endl;
}

Measured memory_bytes: 256