akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int sumW[n + 1] = {}, sumR[n + 1] = {};
    rep(i, n) {
        sumW[i + 1] = sumW[i] + (s[i] == 'W');
    }
    reverse(ALL(s));
    rep(i, n) {
        sumR[i + 1] = sumR[i] + (s[i] == 'R');
    }
    int ans = INF;
    for (int i = 0; i <= n; i++) {
        ans = min(ans, max(sumW[i], sumR[n - i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5272
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int sam = sc.nextInt();
        int total;int count = 0;
      
      for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
          for(int k=0;k<=c;k++){
            total = i*500+j*100+k*50;
            if(total==sam){count++;}
          }
        }
      }

      System.out.print(count);
    }
}

Measured memory_bytes: 21972
/// 5:22 PM 10/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>

using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define VARIABLE_ERROR(x) cout << #x << " = " << x << endl;
#define CONTAINER_ERROR(v) cout << "{";for (auto &x:v) { cout << x << ','; }cout << "}" << endl;
#define PI 3.14159265358979323846
#define M 1000000007
#define INF 1e15
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    ll k;
    cin >> k;
    vector<ll> v(n);
    for(auto &x:v) {
        cin >> x;
        x--;
    }
    vector<ll> dist(n,INF);
    ll slow = v[0];
    ll fast = v[v[0]];
    ll len = 1;
    dist[slow] = 1;
    while(slow != fast) {
        slow = v[slow];
        len++;
        dist[slow] = min(dist[slow], len);
        fast = v[v[fast]];
    }
    ll ns = 0;
    ll nf = fast;
    while(ns != nf) {
        ns = v[ns];
        nf = v[nf];
    }
    ll loop_len = 0;
    ll nss = v[ns];
    loop_len ++;
    while(nss != ns) {
        nss = v[nss];
        loop_len++;
    }
    if(k <= dist[ns]) {
        ll ans = 0;
        for(ll i=0;i<k;i++) {
            ans = v[ans];
        }
        cout << ans + 1;
        return 0;
    }
    ll nd = k - dist[ns];
    ll travel = nd % loop_len;
    ll ans = ns;
    for(ll i=0;i<travel;i++) {
        ans = v[ans];
    }
    cout << ans + 1;
    return 0;
}

Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define line cout<<"\n"
#define ci std ::cin
#define co std ::cout
#define sf scanf
#define sff(n,m) scanf("%d%d",&n,&m)
#define pf printf
#define p_line printf("\n")
#define cas(n) printf("Case %d: ",n++)
#define task return
#define loop(x,n)  for(int x = 0 ; x < n ; x++)
#define constloop(x,a,n) for(int x = a ; x < n ; x++)
#define revloop(x,a,n)  for(int x = a ; x >= n ; x--)
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
#define mx 10000000
/*ll P[mx+5],cnt=1;
bool nP[mx+5];
void sieve(void)
{
    P[0]=2;
    nP[0]=true;
    nP[1]=true;
    for(ll i=3 ; i<=mx ; i+=2)
    {
        if(nP[i]==true)
            continue;
        for(ll j=i+i ; j<=mx ; j+=i)
            nP[j]=true;
        P[cnt++]=i;
    }
}*/
ll modd=1e9+7;
ll bigmod(ll base,ll pow)
{
	if(pow==0)
		return 1;
	if(pow==1)
		return base%modd;
	ll ans=bigmod(base,pow/2);
	ans=(ans*ans)%modd;
	if(pow%2==1)
		ans=(ans*base)%modd;
	return ans;
}
void solve()
{
    //Code here
 	ll n;
 	ci>>n;
 	ll ans1=1,ans2=1,ans3=1;
 	ll a=10,b=9,c=8;
 	ans1=bigmod(a,n);
 	ans2=bigmod(b,n);
 	ans3=bigmod(c,n);
 	ll ans=((((ans1-ans2+modd)%modd-ans2+modd)%modd)+ans3)%modd;
 	co<<ans;
 	line;
}
int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	/*ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);*/
	solve();
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,z,w; cin>>n>>z>>w;
	VI a(n); rep(i,n) cin>>a[i];
	int ans;
	if(n==1) ans=abs(a[0]-w);
	else ans=max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w));
	// if(a[n-2]>a[n-1]) ans=a[n-2]-a[n-1];
	// else ans=abs(a[n-1]-w);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import fnmatch
S=[]
S.append(input())
if S == fnmatch.filter(S, "*keyence") or S == fnmatch.filter(S, "k*eyence") or S == fnmatch.filter(S, "ke*yence") or S == fnmatch.filter(S, "key*ence") or S == fnmatch.filter(S, "keye*nce") or S == fnmatch.filter(S, "keyen*ce") or S == fnmatch.filter(S, "keyenc*e") or S == fnmatch.filter(S, "keyence*"):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 4212
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
typedef vector<int> VI;
typedef vector<pr> VP;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
const int inf = 1e17;
const int MAXN = 200001;
int fast_pow(int x, int y, int p);




void solve() {
	double a,v;cin>>a>>v;
	double b,w;cin>>b>>w;
	double t;cin>>t;

	if(v<=w){
		cout<<"NO"<<endl;
		return;
	}
	double time = abs(a-b)/(v-w);
	if(time<=t){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

}


int32_t main() {

	IOS;
	int test = 1;
	// cin>>test;
	for (int i = 1; i <= test; i++) {
        // cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}
int fast_pow(int x, int y, int p) {
	int res = 1;
	x = x % p;
	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s; cin >> s;
  int n = s.size();
  
  ll ans = 0;
  for(int bit = 0; bit < (1 << n-1); bit++){
    ll sum = 0;
    for(int i = 0; i < n; i++){
      if(bit & (1<<i)){
        sum *= 10;
        sum += s[i] - '0';
        ans += sum;
        sum = 0;
      }else{
        sum *= 10;
        sum += s[i] - '0';
      }
    }
    ans += sum;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
    int n, l, i;
    string t;
    vector<string> s;

    cin >> n >> l;
    for(i = 0; i < n; i++){
        cin >> t;
        s.push_back(t);
    }

    sort(s.begin(), s.end());

    for(i = 0; i < n; i++){
        cout << s[i];
    }
    cout << endl;
}

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


int main()
{
    int n, ans = 0;
    cin >> n;
    int l[n];

    rep(i, n) cin >> l[i];

    sort(l, l+n);

    rep(i, n)
    {
        rep(j, i)
        {
            rep(k, j)
            {
                if(l[i]!= l[j] &&
                   l[j]!= l[k] &&
                   l[i] < l[j] + l[k]
                )
                    ans++;
            }
        }
    }

    cout << ans << endl;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<long double, long double> p;


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

  int n;
  cin >> n;
  vector<p> v(n);
  map<p, int> mp;
  map<int, int> mp2;
  map<int, int> mp3;

  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }


  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      p tmp1 = v[i];
      p tmp2 = v[j];
      p diff = {tmp1.first-tmp2.first, tmp1.second-tmp2.second};
      mp[diff]++;
      // diff = {-tmp1.first+tmp2.first, -tmp1.second-tmp2.second};
      diff.first *= -1;
      diff.second *= -1;
      mp[diff]++;
    }
  }

  // int res = 0;
  int maxv = -1;
  for(auto a : mp){
    maxv = max(maxv, a.second);
  }

  if(n == 1) cout << 1 << endl;
  else cout << max(n-maxv, 1) << endl;

}


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

using namespace std;

#define INF 1e9
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define repv(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define ll long long int
#define endl "\n"

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

    string s,s1="s",s2="es";
    cin >> s;
    if(s[s.length()-1] != 's')
    	s.append(s1); 
    else
    	s.append(s2);
    cout << s ;
}



Measured memory_bytes: 3664
import sys

t = 10**18


n=int(input())
li = list(map(int,input().split()))

if li.count(0) >= 1:
    print(0)
    sys.exit()

ans = 1
for i in range(n):
    ans = ans*li[i]
    if ans > t:
        print(-1)
        sys.exit()

print(ans)

Measured memory_bytes: 84688
A,B,C,X,Y=$<.read.split.map(&:to_i)

if A+B < C*2
  ret = X*A + Y*B
else
  if X < Y
    ret = X*(C*2) + (C*2 < B ? C*2 : B) * (Y-X)
  else
    ret = Y*(C*2) + (C*2 < A ? C*2 : A) * (X-Y)
  end
end

puts ret


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int answer = B;
        if (A <= 5) {
            answer = 0;
        } else if (6 <= A && A <= 12) {
            answer = answer / 2;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}


int32_t main()
{
    ld a,b,x;
    cin>>a>>b>>x;
    if(fabs(x-a*a*b)<eps) return cout<<fout(10)<<0.0<<nl,0;
    ld l=eps,r=PI/2.0-eps;
    auto it=1000;
    while(it--){
        ld mid=(l+r)/2.0;
        ld th=PI/2.0-mid;
        ld area=0.0;
        if(a*tan(th)<=b) area=a*a*(b-a*tan(th)*0.5);
        else area=a*b*b*tan(mid)*0.5;
        if(area>=x) r=mid;
        else l=mid;
    }
    cout<<fout(10)<<90.0-l*180.0/PI<<nl;
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <type_traits>
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 = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  ll n; std::cin >> n;
  ll div = 1;
  for (ll i = 2; i*i <= n; i++) {
    if (n % i == 0) chmax(div, i);
  }
  ll cdiv = n / div;
  std::cout << div + cdiv - 2 << "\n";
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll n; cin >> n;
  // ll x, y, z; cin >> x >> y >> z;
  // string s; cin >> s;
  vector<string> s(n);
  vector<ll> p(n); REP(i, n) cin >> s[i] >> p[i];
  // ll ans = 0;
  // bool ok = false;
  vector<string> sbuf;
  REP(i, n) {
    char ch[100];
    sprintf(ch, "%-11s%03lld%03lld", s[i].c_str(), 100-p[i], i+1);
    sbuf.push_back(ch);
    //    cout << sbuf[i] << endl;
  }
  sort(sbuf.begin(), sbuf.end());
  REP(i, n) {
    //    cout << sbuf[i] << endl;
    cout << stoi(sbuf[i].substr(14, 3)) << endl;
  }
  // cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()

vector<bool> a(1e9 +7, 0);

int acgt(char c) {
  if(c == 'A') return 1;
  if(c == 'C') return 2;
  if(c == 'G') return 3;
  if(c == 'T') return 4;
}

int order(string ss) {
  int m = 0;
  while(ss.size() > 0) {
    m += acgt(ss.at(0));
    m *= 5;
    ss.erase(0, 1);
  }
  return m;
}      

void insert(string str) {
  a.at(order(str)) = 1;
}

string find(string str) {
  if(a.at(order(str))) return "yes";
  else return "no";
}     

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  string meirei;
  string stri;
  
  rep(i, 0, n) {
    cin >> meirei >> stri;
    if(meirei == "insert") insert(stri);
    else cout << find(stri) << "\n";
  }

}



Measured memory_bytes: 124636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> up(n);
    vector<int> down(n);
    rep(i,n) cin >> up[i];
    rep(i,n) cin >> down[i];
    
    int ans = 0;
    int upnum=0;
    rep(i,n){
        upnum += up[i];
        int downnum = 0;
        for(int j = i; j < n; j++){
            downnum += down[j];
        }
        ans = max(ans,upnum+downnum);
    }
    cout << ans << endl;


    return 0;
}

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

using namespace std;

int N, A, B, used[100], rings[100], G[100][199];

int rec(int pos)
{
	int ret = used[pos] = 1;

	for(int i = 0; i < rings[pos]; i++)
	{
		if(!used[G[pos][i]])
		{
			ret = max(ret, rec(G[pos][i]) + 1);
		}
	}

	used[pos] = 0;

	return ret;
}

int main()
{
	int N, A, B;

	while(true)
	{
		scanf("%d", &N);
 
		if(N == 0) { break; }

		for(int i = 0; i < 100; i++)
		{
			used[i] = rings[i] = 0;
		}

		for(int i = 0; i < N; i++)
		{
			scanf("%d", &A); A--;
			scanf("%d", &B); B--;

			G[A][rings[A]] = B; rings[A]++;
			G[B][rings[B]] = A; rings[B]++;
		}

		int nodes = 0;

		for(int i = 0; i < 100; i++)
		{
			if(rings[i])
			{
				nodes++;
			}
		}

		int ret = 0;

		for(int i = 0; i < 100; i++)
		{
			ret = max(ret, rec(i));

 			if(ret == nodes) break;
		}
 
		printf("%d\n", ret);
	}

	return 0;
}

Measured memory_bytes: 3284
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    rep(i, 5){
	    int n;
	    cin >> n;
        if(n == 0) {
			cout << i+1 << endl;
        	return;
        }
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3604
r,D,x0=map(int,input().split())
x1=r*x0-D
x2=r*x1-D
x3=r*x2-D
x4=r*x3-D
x5=r*x4-D
x6=r*x5-D
x7=r*x6-D
x8=r*x7-D
x9=r*x8-D
x10=r*x9-D
print(x1)
print(x2)
print(x3)
print(x4)
print(x5)
print(x6)
print(x7)
print(x8)
print(x9)
print(x10)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

int main() {
  ll N, A, B; cin >> N >> A >> B;
  vector<ll> X(N); REP(i, N) cin >> X[i];

  ll ans = 0;

  REP(i, N-1){
    ll tmp = (X[i+1]-X[i])*A;
    if( tmp <= B) ans += tmp;
    else ans += B;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
import fractions
A, B, C, D = map(int, input().split())

tmp = max(C, D)


def lcm(a, b):
    return a*b//fractions.gcd(a, b)


E = lcm(C, D)

aC = (A - 1) // C
aD = (A - 1) // D
aE = (A - 1) // E
bC = B // C
bD = B // D
bE = B // E

aS = aC + aD - aE
bS = bC + bD - bE
sum = B - (A - 1) - (bS - aS)

print(sum)


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

int calc(int n, int Max = 0) {
	if (n % 2 == 0) return calc(n / 2, Max + 1);
	return Max;
}

int main() {
	int n;
	cin >> n;
	long a[n];
	long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += calc(a[i]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int n,k; 
int main(){
	cin>>n>>k;
	cout<<(n+1>=k+k?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a[5], wait,temp,max;
	for (int i=0;i<5;i++){
      scanf("%d", &a[i]);
    }
	max = 0;
	wait = 0;
	for (int i=0;i<5;i++){
		temp = a[i]%10;
		if (temp != 0){
          temp =10-temp;
        }
		if (max<temp){
          max=temp;
        }
		wait+=a[i]+temp;
	}
	printf("%d", wait-max);
	return 0;
}

Measured memory_bytes: 128
a,b,c =map(int,input().split())
B=list(map(int,input().split()))
A=[]
for i in range(a):
    array =  list(map(int,input().split()))
    A.append(array)
cont=0
sum =0
for i in range(a):
    sum =0
    for j in range(b):
        sum += A[i][j] * B[j]
    if sum  + c> 0:
        cont +=1
print(cont)

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

int main(){
  long long int n,p,ichi=0,zero,i,k;
  long long int kotae=1;
  cin>>n>>p;
  for(i=0;i<n;i++){
    cin>>k;
    if(k%2==1){
      ichi++;
    }
  }
  zero=n-ichi;
  if(ichi==0&&p==0){
    kotae=pow(2,n);
    cout<<kotae;
    return 0;
  }
  kotae=(int)(pow(2,ichi)/2)*pow(2,zero);
  cout<<kotae;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,n,j,k,o;
	int a[101];
	scanf("%d",&o);
	for(i=0;i<o;i++){
		scanf("%d",&a[i]);
	}
	for(j=0;j<o;j++){
		if(j!=o-1)
		printf("%d ",a[j]);
	}
	printf("%d\n",a[j-1]);
	for(i=1;i<o;i++){
		for(j=0;j<i;j++){
			if(a[i]<=a[j]){
				int temp=a[i];
				for(k=i;k>j;k--){
					a[k]=a[k-1];
				}
				a[j]=temp;
				break;
			}
		}
		for(j=0;j<o;j++){
			if(j!=o-1)
			printf("%d ",a[j]);
		}
		printf("%d\n",a[j-1]);
	}
} 


Measured memory_bytes: 2732
import java.io.*;
import java.util.*;

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

		int n;
		while ((n = sc.nextInt()) != 0) {
			LinkedList<Integer> list = new LinkedList<Integer>();
			int Sum = 0;
			for (int i = 0; i < n; i++) {
				list.add(sc.nextInt());
				Sum += list.getLast();
			}
			Sum-=Collections.max(list);
			Sum-=Collections.min(list);
			int t = Sum / (list.size()-2);
			pw.printf("%d\n", t);
		}
		pw.close();
		sc.close();
	}
}

Measured memory_bytes: 12000
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
min_t = float('inf')

for i in range(N):
    if abs((T - H[i] * 0.006) - A) < min_t:
        min_t = abs((T - H[i] * 0.006) - A)
        ans = i + 1
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    int k[10000]{};
    cin >> N;
    while (N != 0) {
        for (int i = 0; i < N; i++) {
            cin >> k[i];
        }
        int cnt = 0;
        int s = 0;
        for (int i = 0; i < N; i++) {
            if (k[i] >= 2) {
                cnt++;
            }
            if (k[i] >= 1) s++;
        }
        if (cnt == 0) {
            cout << "NA\n";
        } else {
            cout << s + 1 << "\n";
        }
        cin >> N;
    }
    return 0;
}


Measured memory_bytes: 3136
#include "stdio.h"
#include <stdlib.h>
#include <string.h>

#define FOR(i, a, b) for(int i=a; i<=b;i++)

char A[500];
char B[500];

int main(void){
	int num;

	scanf("%s%s", A, B);

	strcat(A, B);

	num = atoi(A);

	FOR(j, 0, 1000){
		if(j*j==num){
			printf("Yes\n");
			return 0;
		}

	}

	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
typedef long long int ll;
typedef vector<int> vint;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

int main() {
    string s;
    cin >> s;
    int be = 0;
    int len = 1;
    int nlen = 1;
    int ans = 0;
    int sl = s.length();
    while(1) {
        if (be + len + nlen > sl) break;
        if (s.substr(be, len) == s.substr(be+len, nlen)) {
            nlen++;
        } else {
            ans++;
            be += len;
            len = nlen;
            nlen = 1;
        }
    }
    ans++;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    int v[25],c[25];
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++)
        cin>>c[i];
    int sum=0;

    for(int i=0;i<n;i++){
        int temp=v[i]-c[i];
        if(temp<0) sum+=0;
        else sum+=temp;
    }
    cout <<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll n,W;cin>>n>>W;
    vl dp(W+1);
    rep(i,n){
        ll v,w;cin>>v>>w;
        rfore(j,w,W)chmax(dp[j],dp[j-w]+v);
    }
    cout<<dp[W]<<endl;
}

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



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

int main(){
  int N;
  cin>>N;
  vector<int> B(N+1,1000000000);
  for(int i=1;i<N;i++){
    cin>>B.at(i);
  }
  vector<int> A(N);
  int sum=0;
  for(int i=0;i<N;i++){
    A.at(i)=min(B.at(i),B.at(i+1));
    sum+=A.at(i);
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
//Volume0-0055
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//declare
		final double EVEN = 0;
		      double a,sum,pre;

        //input
        Scanner sc = new Scanner(System.in);
        while((sc.hasNext())){
        	a = sc.nextDouble();

        	//calculate
        	sum = a;
        	pre = a;
        	for(int i=2;i<=10;i++){
        		if   (i%2 == EVEN){pre *= 2;}
        		else              {pre /= 3;}
        		sum += pre;
        	}

        	//output
        	System.out.println(sum);
        }
	}
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct Edge{
    ll to;
    ll cost;
    Edge(ll to, ll cost): to(to), cost(cost) {}
    Edge(){}
};

struct BellmanFord{
    vector<vector<Edge> > edges;
    vector<ll> dist;
    
    BellmanFord(ll sz){
        edges.resize(sz);
        dist.resize(sz, inf);
    }

    void add_edge(ll a, ll b, ll c){
        edges[a].push_back(Edge(b, c));
    }

    // 計算量 V * E
    vector<ll> calc_shortest_path(ll start){
        dist[start] = 0;
        ll N = dist.size();
        ll loop = N - 1;
        while(loop--){
            FOR(i, 0, N){
                if(dist[i]==inf) continue;
                for(auto edge : edges[i]){
                    chmin(dist[edge.to], dist[i] + edge.cost);
                }
            }
        }

        // negative check
        FOR(i, 0, N){
            if(dist[i]==inf) continue;

            for(auto edge : edges[i]){
                if(dist[i] + edge.cost < dist[edge.to]){
                    // まだ減るなら閉路
                    return vector<ll>();
                }
            }
        }

        return dist;
    }
};

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

    // input
    ll V, E, r;
    cin >> V >> E >> r;

    auto bf = BellmanFord(V);

    FOR(i, 0, E){
        ll a, b, c;
        cin >> a >> b >> c;
        bf.add_edge(a, b, c);
    }

    auto lis = bf.calc_shortest_path(r);
    if(lis.size()==0){
        p("NEGATIVE CYCLE");
    }
    else{
        FOR(i, 0, V){
            if(lis[i]==inf){
                p("INF");
            }else{
                p(lis[i]);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
const int mod=1e9+7;
int main()
{
	int n,m;
	cin>>n>>m;
	while(n&&m)
	{
		vector<int> s1(n);
		vector<int> s2(m);
		int sum1=0;
		int sum2=0;
		for(int i=0;i<n;i++)
			{cin>>s1[i];
				sum1+=s1[i];
			}
		for(int i=0;i<m;i++)
		{
			cin>>s2[i];
			sum2+=s2[i];
		}
		int min=10000;
		int mini,minj;
		int c=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
			{
				if(sum1-s1[i]+s2[j]==sum2-s2[j]+s1[i])
				{
					if(min>s1[i]+s2[j])
						{min=s1[i]+s2[j];
							mini = i;
							minj =j;}
					c=1;

				}
			}
		if(c==0)
			cout<<"-1"<<endl;
		else
		cout<<s1[mini]<<" "<<s2[minj]<<endl;

		cin>>n>>m;
	}
	return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
main(){
  int a,b[100],c=0,i,j,k;
  for(i=0;i<100;i++){
    b[i]=0;
  }
  while(scanf("%d",&a) != EOF){
    b[a-1]++;
  }
  for(i=0;i<100;i++){
    if(b[i]>c){
      c=b[i];
    }
  }
  for(i=0;i<100;i++){
    if(b[i]==c){
      printf("%d\n",i+1);
    }
  }
  return 0;
}

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

void maxHeapify(int a[], int n, int i){
	int l=i*2;
	int r=l+1;
	int larg=i;
	if (l<=n && a[l]>a[larg]){
		larg = l;
	}
	if (r<=n && a[r]>a[larg]){
		larg = r;
	}
	if (larg!=i){
		int t=a[larg];
		a[larg]=a[i];
		a[i]=t;
		maxHeapify(a,n,larg);
	}
}

void buildMaxHeap(int n, int a[]){
	for (int i=n/2;i>=1;i--){
		maxHeapify(a,n,i);
	}
}

int main(){
	int n,i;
	cin >> n;
	int a[n+1];
	for(i=1;i<=n;i++) cin >> a[i];
	buildMaxHeap(n,a);
	for(i=1;i<=n;i++) cout << " " << a[i];
	cout << endl;
	return 0;
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    double x,t;
    cin >> x >> t;
    cout << x / t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
    int N,M;
    cin >> N >> M;
    
    int ans=0;
    if (N==0)
        ans +=0;
    else
        ans += N*(N-1)/2;
    if (M==0)
        ans +=0;
    else
        ans += M*(M-1)/2;

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


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

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if (a+c==2*b){
		cout<<"YES";
	}
	else {
		cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,c;
    float l;
    double pi=3.14159265358979323846;
    cin >> a >> b >> c;
    cout << fixed;
    cout << setprecision(8) << 0.5*a*b*sin(pi*c/180) <<endl;
    cout << setprecision(8) << a+b+sqrt(a*a+b*b-2*a*b*cos(pi*c/180)) <<endl;
    cout << setprecision(8) << b*sin(pi*c/180) <<endl;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main() {
  ll N, D[60]{}, A, ans{};
  cin >> N;
  while (cin >> A) {
    int i = 0;
    while (A) {
      D[i++] += A % 2;
      A >>= 1;
    }
  }  
  for (int i = 59; i >= 0; --i)
    ans = (ans * 2 + D[i] * (N - D[i])) % MOD;
  cout << ans << endl;
}


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

using namespace std;

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

    for (int i = 0; i < 26; i++)
    {
        if (S.find_first_of((char)('a' + i)) == string::npos)
        {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	VEC(int, a, n);
	VEC(int, b, n);
	VEC(int, c, n);

	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));

	int ans = 0;
	REP(i, n) {
		int t = n - (upper_bound(ALL(c), b[i]) - c.begin());
		t *= (lower_bound(ALL(a), b[i]) - a.begin());
		debug(t);
		ans += t;
	}
	OUT(ans)BR;
  
  return 0;
}


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

inline int gi()
{
	long long f=1, x=0; 
	char c=getchar();
	
	while (c<'0' ||c>'9') 
	{
		if (c == '-') 
			f = -1; c = getchar();
	}
	while (c >= '0' && c <= '9')
	{
		x = x * 10 + c - '0', c = getchar();
	}
	return f * x;
}

const int N=103, M=N<<1;

long long n, k;
long long a[N], b[N];

int main()
{
    n = gi(), k = gi();
    for (int i = 1; i <= k; i+=1)
    {
        int d = gi();
        for (int j=1; j<=d; j+=1)
        {
        	a[j] = gi(), ++b[a[j]];
		}
    }
    long long cnt = 0;
    
    for (int i=1; i<=n; i+=1) 
		cnt += (b[i] == 0);
		
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int a[26] = {};
    for(int i=0; i<s.length(); i++){
        a[s[i]-'a']++;
    }

    string ans;
    bool ex = false;
    for(int i=0; i<26; i++){
        if(a[i]) continue;
        ex = true;
        ans = 'a' + i;
        break;
    }

    cout << (ex ? ans : "None") << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

  int main(void) {

    int a, b, c;

    int i, ans;

         scanf("%d %d %d", &a, &b, &c);

         ans = 0;

    for (i = a; i <= b; i++)

if (c % i == 0) ans++;

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

    return 0;

}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

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

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
LL c2(LL a) {
	LL ans = a * (a - 1) / 2;
	return ans;
}
void solve() {
	int N,K;
	cin >> N >>K;
	vector<LL> X(N);
	IN(X);
	LL ans = LINF;
	for (int i = 0; i + K - 1 < N; ++i) {
		chmin(ans, (X[i + K - 1] - X[i]) + min(abs(X[i + K - 1]), abs(X[i])));
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 1024
N,H = map(int,input().split())
A,B = [],[]
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
B.sort(reverse=True)
a = max(A)
ans = 0
for b in B:
    if a<b:
        H-=b
    else:
        H-=a
    ans+=1
    if H<=0:break
print(ans if H<=0 else ans+H//a if H%a==0 else ans+H//a+1)

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

using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  int max = A + B;
  if(max < A - B){
    max = A - B;
  }
  
  if(max < A * B){
    max = A * B;
  }

  cout << max << endl;

}




Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 0

#define MAXN 200001
int a[MAXN];
int h[MAXN];
map<int, long> mp;

int main() {
  int n;
  cin >> n;
  forr(i,0,n-1)
    cin >> h[i];
  forr(i,0,n-1)
    cin >> a[i];
  mp[h[n-1]] = a[n-1];
  forv(i,n-2,0) {
    auto ceil = mp.lower_bound(h[i]);
    long newv = a[i];
    if (ceil != mp.end()) { // h[i] is the highest
      newv += ceil->second;
    }
    auto bot = ceil;
    while (bot != mp.begin()) {
      --bot;
      if (bot->second > newv) {
        ++bot;
        break;
      }
    }
    if (bot != ceil)
      mp.erase(bot, ceil);
    mp[h[i]] = newv;
    if (DBG) {
      cout << "i " << i << ":";
      forall(it,mp)
        cout << it->first << "/" << it->second << " ";
      cout << endl;
    }
  }
  cout << mp.begin()->second;
}


Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	ll x;
	cin >> x;
	
	ll ans = x/500;
	
	x -= 500*ans;

	ans*=1000;

	ans+=x/5*5;

	cout << ans << endl;
}

Measured memory_bytes: 256
N, x = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).sort!

ans = 0
as.each do|a|
  x -= a
  if x > 0
    ans += 1
  elsif x == 0
    ans += 1
    break
  else
    break
  end
end
if x > 0
  ans -= 1
end
puts ans

Measured memory_bytes: 1788
N, M = map(int, input().split())
H = list(map(int, input().split()))
nei = [[] for i in range(N)]
ans = 0

for i in range(M):
    A, B = map(int, input().split())
    nei[A - 1].append(B - 1)
    nei[B - 1].append(A - 1)
    
for i in range(N):
    M = 0
    for j in range(len(nei[i])):
        if M < H[nei[i][j]]:
            M = H[nei[i][j]]
    if H[i] >M:
        ans += 1
print(ans)

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

using namespace std;

const int N = 2048;
int s = 0, n, a[N];
bitset<N*N> dp;

signed main(){
	cin >> n;
	for(int i=0;i<n;++i) cin >> a[i], s += a[i];
	dp[0] = 1;
	for(int i=0;i<n;++i)
		dp = dp | (dp << a[i]);
	for(int i=(s+1)/2;i<=s;++i) if(dp[i]) return cout << i, 0;
	
}

Measured memory_bytes: 5212
// https://beta.atcoder.jp/contests/abc111

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    auto x = n / 100;
    if (n > 100 * x + 10 * x + x) x++;
    auto ans = 100 * x + 10 * x + x;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> res(N, 0);
    for(int i=1; i<N; ++i) {
        int a; cin >> a;
        ++res[a - 1]; 
    }
    for(int i=0; i<N; ++i) cout << res[i] << '\n';
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
int n, k;
vector<int> edge[2002];
int ans;
int search(int now, int dis, int last) {
    int ans = 0;
    if (dis < 0) return 0;
    for (int i = 0; i < edge[now].size(); i ++)
    if (edge[now][i] != last) {
        ans += search(edge[now][i], dis - 1, now);
    }
    return ans + 1;
}
int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i < n; i ++) {
        int x, y;
        scanf("%d %d", &x, &y);
        edge[x].push_back(y); edge[y].push_back(x);
    }
    if (!(k & 1)) for (int i = 1; i <= n; i ++) ans = max(ans, search(i, k / 2, 0));
    else {
        for (int i = 1; i <= n; i ++)
            for (int j = 0; j < edge[i].size(); j ++) {
                ans = max(ans, search(edge[i][j], k / 2, i) + search(i, k / 2, edge[i][j]));
            }
    }
    printf("%d", n - ans);
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.buffer.readline
inf = 10 ** 18

N, M = map(int, input().split())
ABC = [tuple(map(int, input().split())) for _ in range(M)]

negative = [False] * (N + 1)
cost = [inf] * (N + 1)
cost[1] = 0

for loop in range(N):
    update = False
    for a, b, c in ABC:
        if cost[b] > cost[a] - c:
            cost[b] = cost[a] - c
            if loop == N - 1:
                negative[b] = True

ans = -cost[N]
if negative[N]:
    ans = "inf"
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000001
int func(int n){
	return n%2?3*n+1:n/2;
}
int main(){
	int a[MAX]={};
	cin >> a[0];
	int ans=0;
	rep(i,MAX){
		if(i>0)a[i]=func(a[i-1]);
		if(a[i]==4||a[i]==2||a[i]==1){ans=i+4;break;}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int selectionSort(int* A, int N)
{
    int kaisuu = 0;
    for (int i = 0; i < N - 1; i++) {
        int min_j = i;
        for (int j = i + 1; j < N; j++) {
            if (A[j] < A[min_j]) {
                min_j = j;
            }
        }
        if (min_j != i) {
            int tmp = A[i];
            A[i] = A[min_j];
            A[min_j] = tmp;
            kaisuu++;
        }
    }
    return kaisuu;
}

int main(void)
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int kaisuu = selectionSort(A, N);

    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i != N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
    cout << kaisuu << endl;

    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X; cin >> X;
  int ans = 1;
  for(int i = 1; i*i <= X; i++){
    int tmp = i;
    for(int j = 2; j <= 10; j++){
      tmp *= i;
      if(tmp <= X) ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568