akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  map <ll, ll> score;
  rep(i, n) {
    ll a;
    cin >> a;
    if (score.count(a)) {
      score.at(a)++;
    } else {
      score[a] = 1;
    }
  }
  ll m;
  cin >> m;
  bool flag = 1;
  rep(i, m) {
    ll a;
    cin >> a;
    if (score.count(a)) {
      if (!score.at(a)) {
        flag = 0;
      } else {
        score.at(a)--;
      }
    } else {
      flag = 0;
    }
  }
  if (flag) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 12800
n, m = map(int, input().split())
if n >= 2:
  if m >= 2:
    print((n-2) * (m-2)) 
  else:
    print((n-2) * m)
else:
  if m >= 2:
    print(n * (m-2)) 
  else:
    print(n * m) 

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

int main(void) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    int dx = x2 - x1, dy = y2 - y1;
    x3 = x2 - dy; y3 = y2 + dx;
    x4 = x3 - dx; y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	double r;
	cin >> r;
	cout << 2 * r * 3.14159265358979323846;
}


Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#include<new>
#include<float.h>
#include<ctype.h>
#include<cfloat>
#include<cmath>
#include<cctype>
#include<errno.h>
#include<cerrno>
#include<memory>
#include<memory.h>
#include<assert.h>
#include<cassert>
#include<deque>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qui queue<int>
#define vit vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define ct continue
#define ms multiset
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define ppf pop_front()
using namespace std;
int main()
{
	string s;
	cin>>s;
	int u=0;
	if(s[0]!='A'){
		cout<<"WA"<<endl;
		return 0;
	}
	fo(i,0,s.sz){
		if(s[i]>='A'&&s[i]<='Z'&&s[i]!='A'&&s[i]!='C'){
			cout<<"WA"<<endl;
			return 0;
		}
		if(s[i]=='C'){
			u++;
			if(u>1||i<2||i==s.sz-1){
				cout<<"WA"<<endl;
				return 0;
			}
		}
	}
	if(u<1){
		cout<<"WA"<<endl;
		return 0;
	}
	cout<<"AC"<<endl;
	return 0;
}


Measured memory_bytes: 256
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll n,k,s=0,m=1e9+7;
    cin>>n>>k;

    for(ll i=k;i<=(n+1);i++){
        s=(s+(n*i-i*(i-1)+1))%m;
    }
    cout<<s;
}

Measured memory_bytes: 3672
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=INF; cin>>n;
    vector<ll> a(n,0),sum(n,0);
    rep(i,n){
        cin>>a[i];
        sum[i]=a[i];
        if(i==0) continue;
        sum[i]+=sum[i-1];
    }
    rep(i,n-1) ans=min(ans,abs(sum[i]-(sum.back()-sum[i])));
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
using namespace std;
int n,t;
int main(){
	cin>>n>>t;n--;
	long long ans=t;
	int bef,now;
	cin>>bef;
	while(n--){
		cin>>now;
		ans+=min(t,now-bef);
		bef=now;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  if(a%2==b%2) cout<<(b-a)/2<<endl;
  else{
    ll c=a-1+(b-a+1)/2;
    ll d=n-b+(b-a+1)/2;
    cout<<min(c,d)<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
s = input()
l = 0
r = n - 1
cnt = 0

while l<r:
    while s[l] == 'R' and l < r:
        l += 1
    while s[r] == 'W' and l < r:
        r -= 1
    if l>=r:
        break
    cnt += 1
    l += 1
    r -= 1

print(cnt)


Measured memory_bytes: 9468
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<int> v;
bool ans[maxn];
int main(){
	IOS;
	int a,b;
	cin>>a>>b;
	if(a<=b){
		cout<<"Impossible"<<endl;
		return 0;
	}
	int n=a+b;
	REP(i,n){
		if(!SZ(v)) v.pb(i);
		else{
			cout<<"? "<<v.back()<<' '<<i<<endl;
			string ret;
			cin>>ret;
			if(ret[0]=='N'){
				v.pop_back();
			}
			else{
				v.pb(i);
			}
		}
	}
	int good=v.back();
	ans[good]=1;
	REP(i,n) if(i!=good){
		cout<<"? "<<good<<' '<<i<<endl;
		string ret;
		cin>>ret;
		if(ret[0]=='Y') ans[i]=1;
	}
	cout<<"! ";
	REP(i,n) cout<<ans[i];
	cout<<endl;

	return 0;
}


Measured memory_bytes: 724
#include<iostream>
#include<string>
#include<algorithm>
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; }
const long long INF=1LL<<60;

int main(){
    string s,t;
    cin>>s>>t;
    int sl=(int)s.size();
    int tl=(int)t.size();

    int dp[3010][3010];
    for(int i=0;i<=sl;++i){
        for(int j=0;j<=tl;++j){
            dp[i][j]=0;
        }
    }

    for(int i=0;i<sl;++i){
        for(int j=0;j<tl;++j){
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i+1][j]);
            chmax(dp[i+1][j+1],dp[i][j+1]);
        }
    }

    string ans="";
    while(sl>0&&tl>0){
        if(dp[sl][tl]==dp[sl-1][tl]) --sl;
        else if(dp[sl][tl]==dp[sl][tl-1]) --tl;
        else{
            ans=s[sl-1]+ans;
            --sl; --tl;
        }

    }

    cout<<ans<<endl;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL n, m;
  cin >> n >> m;
  LL ans = 0;
  if(n==1&&m==1){
    ans=1;

  }
  else if (n == 1 || m == 1) {
    ans = n * m - 2;
  } else {
    ans= (n - 2) * (m - 2);
  }
  cout<<ans<<endl;

  return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main()
{
	int h, w;
	cin >> h >> w;

	vector<string> s(h);
	rep(i, 0, h) cin >> s[i];

	queue<pair<pii, int>> que;
	rep(i, 0, h) rep(j, 0, w){
		if(s[i][j] == '#'){
			que.push({{i, j}, 0});
		}
	}

	int ans = 0;
	while(!que.empty()){
		auto q = que.front();
		que.pop();
		auto p = q.first;
		chmax(ans, q.second);

		int dx[] = {1, -1, 0, 0};
		int dy[] = {0, 0, 1, -1};
		rep(i, 0, 4){
			int nx = p.second + dx[i];		
			int ny = p.first + dy[i];

			if(nx < 0 or nx >= w or ny < 0 or ny >= h) continue;
			if(s[ny][nx] == '.'){
				s[ny][nx] = '#';
				que.push({{ny, nx}, q.second+1});
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 25524
#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, p[200009], q[200009], c[200009], dist[300009]; vector<int> g[300009]; map<pair<int, int>, vector<int> > d;
void add_edge(int a, int b) {
	g[a].push_back(b);
	g[b].push_back(a);
}
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> p[i] >> q[i] >> c[i]; p[i]--, q[i]--;
		d[make_pair(p[i], c[i])].push_back(i);
		d[make_pair(q[i], c[i])].push_back(i);
		add_edge(p[i], i + N);
		add_edge(q[i], i + N);
	}
	for (pair<pair<int, int>, vector<int> > i : d) {
		for (int j = 1; j < i.second.size(); j++) {
			add_edge(i.second[j - 1] + N, i.second[j] + N);
		}
	}
	fill(dist, dist + N + M, 1012345678); dist[0] = 0;
	priority_queue<pair<int, int> > que; que.push(make_pair(0, 0));
	while (!que.empty()) {
		int u = que.top().second; que.pop();
		for (int i : g[u]) {
			int ds = dist[u] + (u >= N && i >= N ? 0 : 1);
			if (dist[i] > ds) {
				dist[i] = ds;
				que.push(make_pair(-ds, i));
			}
		}
	}
	cout << (dist[N - 1] == 1012345678 ? -1 : dist[N - 1] / 2) << endl;
	return 0;
}

Measured memory_bytes: 65656
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define int long long
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld ",a)
using namespace std;
signed main()
{
	int n;
	int k;
	cin >> n >> k;
	int ans = 0;
	rep(i, 1, n)
	{
		if (i >= k)
			ans += n - i;
	}
	rep(i, k+1, n)
	{
		ans += ((n - k) / i-1)*(i-k);
		ans += min((n - (n - k) / i*i-k) +1, i - k);
	}
	cout << ans;
}











Measured memory_bytes: 256
fun main(args: Array<String>) {

    var input = readLine()
    var n:Int = Integer.parseInt(input)

    input = readLine(); 
    val mArray = input?.split(" ");
    val numbers = Array<Int>(n,{0});

    for(i in mArray!!.indices){
        numbers[Integer.parseInt(mArray[i])-1] += 1;
    }

    for(i in numbers){
        println(i);
    }
}

Measured memory_bytes: 69384
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 998244353;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};

vector<ll> a[300];
ll N, M;
char c[8][8];

int main() {

	cin >> N >> M;
	ll sum = 0;
	rep(i, N) {
		rep(j, M) {

			cin >> c[i][j];
			if (c[i][j] == '#')
				sum += 1;
		}
	}

	if (sum == N + M - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct node{
	int r,index;
	bool operator<(const node &p)const
	{
		return r<p.r;
	}
}a[100005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].r;
		a[i].index=i+1;
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
		cout<<a[i].index<<" "; 
	return 0;
} 

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main()
{
    int n, a[105], m, s = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(a[i] > a[j])
            {
                m = a[i];
                a[i] = a[j];
                a[j] = m;
            }
        }
    }

    for(int i = 0; i < n; i++)
    {
        if(i % 2 == 0)
            s = s + a[i];
        if(i % 2 == 1)
            s = s - a[i];
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);

		while(true){
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			if ((m==-1) && (f==-1) && (r==-1)) break;
			if ((m==-1) || (f==-1)) System.out.println("F");
			else if ((m + f) >= 80) System.out.println("A");
			else if ((m + f) >= 65) System.out.println("B");
			else if ((m + f) >= 50) System.out.println("C");
			else if ((m + f) >= 30) {
				if (r >= 50) System.out.println("C");
				else System.out.println("D");
			}
			else System.out.println("F");
		}
		
	}

}

Measured memory_bytes: 26372
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];
            var N = Sarray()[0];
            var an = Sarray();
            var ml = new List<KeyValuePair<int, int>>() {
                new KeyValuePair<int, int>(0,0),
                new KeyValuePair<int, int>(1,0),
                new KeyValuePair<int, int>(0,1),
                new KeyValuePair<int, int>(-1,0),
                new KeyValuePair<int, int>(0,-1),
            };
            var ans = new int[H,W];
            var src = new List<int>();
            for(var i=0;i<N;i++)
            {
                for(var j=0;j<an[i];j++)
                {
                    src.Add(i+1);
                }
            }
            var mi = 0;
            var x = 0;
            var y = 0;
            foreach (var s in src)
            {
                while(true)
                {
                    var mv = ml[mi];
                    if(x+mv.Value < 0||y + mv.Key < 0 || W<=x + mv.Value || H<=y + mv.Key || ans[y + mv.Key, x + mv.Value] !=0)
                    {
                        mi++;
                        mi = mi % 5;
                        continue;
                    }
                    ans[y + mv.Key, x + mv.Value] = s;
                    x += mv.Value;
                    y += mv.Key;
                    break;
                }
            }
            for(var i=0;i<H;i++)
            {
                for(var j=0;j<W;j++) Write($"{ans[i,j]} ");
                WriteLine();
            }

        }
    }
}

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

int N,K,T,U,V,L,D[205];

double solve()
{
	double res = 0, rem = 0;
	int stock = 0;

	for(int i=1; i<=N+1; i++)
	{
		int dist = D[i] - D[i-1];
		while( (dist > rem * V) && stock) { rem += T; stock--; }


		if(rem* V < dist)
		{
			res += rem;
			dist -= rem * V;

			res += 1.0*dist / U;
			rem = 0;
		}
		else
		{
			res += 1.0*dist / V;
			rem -= 1.0*dist / V;
		}


		if(stock == K) rem = T;
		else stock++;


	}

	return res;
}

int main()
{

	cin >> N >> K >> T >> U >> V >> L;

	D[0] = 0, D[N+1] = L;
	for(int i=0; i<N; i++)
		cin >> D[i+1];

	cout.setf(ios::fixed);
	cout.precision(10);
	cout << solve() << endl;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) 
#define X first
#define Y second 
#define nl '\n'
#define AC return 0
#define pb(a) push_back(a) 
#define mst(a,b) memset(a, b, sizeof a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define scd(a) scanf("%lld", &a)
#define scdd(a,b) scanf("%lld%lld", &a, &b)
#define scs(s) scanf("%s", s)
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const int N = 1e6+10, M = 2e6+10, mod = 1e9+7, inf = 0x3f3f3f;
ll a[N]; 


int main()
{
	IOS;
	int x;
	cin>>x;
	cout<<1-x<<nl;
	
	AC;
} 

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> vec(n + 1, vector<int>(m + 1));
    for (int i = 1; i <= n; i++) {
        cin >> vec.at(i).at(0);
        for (int j = 1; j <= m; j++) cin >> vec.at(i).at(j);
    }
    int casemoney, ans = 1200000;
    vector<int> eachsum;
    bool tf = false, casetf;
    for (int bit = 0; bit < (1 << n); bit++) {
        casemoney = 0;
        eachsum = vector<int>(m + 1, 0);
        for (int i = 1; i <= n; i++) {
            if(bit & (1 << (i-1))){
                casemoney += vec.at(i).at(0);
                for (int j = 1; j <= m; j++) eachsum.at(j) += vec.at(i).at(j);
            }
        }
        casetf = true;
        for(int j = 1; j <= m; j++) {
            if(eachsum.at(j) >= x) continue;
            else {
                casetf = false;
                break;
            }
        }
        if(casetf) {
            tf = true;
            ans = min(ans, casemoney);
        }
    }

    if (tf) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int T = sc.nextInt();
    int min = (int)Math.pow(10, 9);
    ArrayList<Integer> profit = new ArrayList<Integer>();
    for(int i = 0; i < N; i++) {
      int a = sc.nextInt();
      min = Math.min(min, a);
      profit.add(a - min);
    }
    Collections.sort(profit);
    Collections.reverse(profit);
    int ans = 1;
    int max = profit.get(0);
    for(int i = 1; i < profit.size(); i++) {
      int p = profit.get(i);
      if(max == p) {
        ans++;
      } else {
        break;
      }
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n;
  cin >> n;
  int m[4];
  for (int i = 0; i < 4; i++){
    m[i] = n % 10;
    n /= 10;
  }
  if (m[0] == m[1] && m[1] == m[2]) printf("Yes\n");
  else if (m[1] == m[2] && m[2] == m[3]) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,K;
    cin >> N >> K;
    ll i,j,k;
    i=0;
    j=0;
    ll a[N],m[N],p[N];
    a[0]=0;
    m[0]=0;
    p[0]=0;
    ll tmp;
    for(k=0;k<N;k++){
      cin >> tmp;
      if(tmp<0){
        i++;
        a[i]=-tmp;
      }
      if(tmp>=0){
        j++;
        p[j]=tmp;
      }
    }
    for(k=1;k<=i;k++){
        m[k]=a[i-k+1];
      }
    ll ans=10000000000000000;
    k=0;
    if(K>=j)k=K-j;
    while(k<=K && k<=i){
      if(m[k]+2*p[K-k]<ans)ans=m[k]+2*p[K-k];
      if(2*m[k]+p[K-k]<ans)ans=2*m[k]+p[K-k];
      k++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int a,b,c;
long long ans=0;
inline int whh(int x){
	int sum=0;
	while(x){
		sum+=x%10;
		x/=10;
		if(sum>c)return 0;
	}
	if(sum<b)return 0;
	return 1;
}
int main(){
	cin>>a>>b>>c;
	for(int i=1;i<=a;i++){
		if(!whh(i))continue;
		else ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n, m = map(int, input().split())
cand = defaultdict()
for i in range(n):
    x = list(map(int, input().split()))
    for j in range(1, x[0] + 1):
        if x[j] in cand.keys():
            cand[x[j]] += 1
        else:
            cand[x[j]] = 1
count = 0
for index, key in enumerate(cand):
    if cand[key] == n:
        count += 1
print(count)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;
const double PI = acos(-1);

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

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

void solve() {
    lli a, b;
    cin >> a >> b;
    lli g = gcd(a, b);
    lli lcm = (a * b) / g;
    cout << lcm << endl;
}

int main()
{
    IOS;
    //comment it out

    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++) {
        //cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

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

    bool dp[100001];
    fill_n(dp, 100001, false);
    for(int i = 1; i <= k; ++i){
        for(int j = 0; j < n; ++j){
            if(i-a[j] >= 0) dp[i] |= !dp[i-a[j]];
        }
    }

    if(dp[k]) ppp("First");
    else ppp("Second");

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll unsigned long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

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

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << "\n";
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << "\n";
	}
}

void executeCode() {
	ll n;
	cin >> n;
	map<ll, ll> mp;
	while(n % 2 == 0) {
		mp[2]++;
		n /= 2;
	}
	for(ll i = 3 ; i <= sqrt(n) ; i += 2) {
		while(n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if(n > 2) {
		mp[n]++;
	}
	ll ans = 0;
	for(auto m : mp) {
		ans += floor(((sqrt(1 + (8 * m.second))) - 1) / 2);
	}
	cout << ans << "\n";
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 3668
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: u64,
        w: u64,
    };

    if w >= s {
        println!("unsafe")
    } else {
        println!("safe")
    }
}


Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iterator>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i, a, cont, next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i, a, b, step) repfn(i, a, i < b, i + step)
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int rndup1000(int x) {
  int mod = x % 1000;
  if (mod)
    return x - mod + 1000;
  else
    return x;
}

int main(int argc, char **argv)
{
  int n;
  int debt = 100000;
  cin >> n;
  while (n--) {
    debt = rndup1000((debt/100)*105);
  }
  cout << debt << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ttl=0,cho=0,eik=0,don=0;
    while(true){
        vi a(3);for(int i=0;i<3;i++)cin>>a[i];
        sort(a.begin(),a.end());
        if(a[0]+a[1]<=a[2]){
            printf("%d %d %d %d\n",ttl,cho,eik,don);
            return 0;
        }
        ttl++;
        if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])cho++;
        else if(a[0]*a[0]+a[1]*a[1]>a[2]*a[2])eik++;
        else don++;
    }
    return 0;
}


Measured memory_bytes: 3304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long T = sc.nextLong();
        long[] t = new long[N];
        for (int i = 0; i < N; i++) {
            t[i] = sc.nextLong();
        }

        long sum = 0;
        for (int i = 1; i < N; i++) {
            sum += Math.min(t[i] - t[i - 1], T);
        }
        System.out.println(sum + T);
    }

}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(const ll n){

	ll all=(1LL<<n)-1;
	vec<ll> ok(n,all),ng(n,0);

	map<string,ll> mp;//name2num
	ll id=n-1;
	vec<ll> st(n);//軍事的強さ

	auto name=[&](string t)->ll{
		if(mp.find(t)==mp.end()){
			mp[t]=id;
			id--;
		}
		return mp[t];
	};

	auto add=[&](ll a,ll b){
		ok[a]^=(1LL<<b);
		ng[a]|=(1LL<<b);
	};

	REP(i,n){
		string s;
		cin>>s;
		ll a = name(s);
		cin>>st[a];
		ll c;
		cin>>c;
		REP(j,c){
			string d;
			cin>>d;
			ll b=name(d);
			add(a,b);
		}
	}

	ll l=n/2;
	ll r=n-l;

	ll left=(1LL<<l);
	Array dp(left,0);
	REP(bit,left){
		bool flag = true;
		ll con=0;
		REP(i,l){
			if((bit>>i)&1){
				chmax(dp[bit],dp[bit^(1LL<<i)]);
				con = dp[bit^(1LL<<i)]+st[i];
				if(bit&ng[i]) flag=false;
			}
		}
		if(flag) chmax(dp[bit],con);
	}

	ll right=(1LL<<r);
	ll ans=0;
	Array dpr(right,0);
	REP(bit,right){
		bool flag = true;
		ll mask=left-1;
		REP(i,r){
			if((bit>>i)&1){
				chmax(dpr[bit],dpr[bit^(1LL<<i)]+st[i+l]);
				mask&=ok[i+l];
				if(bit&(ng[i+l]>>l)) flag=false;
			}
		}
		if(flag && ((1LL<<n-1-l)&bit)) chmax(ans,dp[mask]+dpr[bit]);
	}
	cout<<ans<<en;
}

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

	ll n;
	while(cin>>n){
		if(n==0) break;
		solve(n);
	}
    //solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 19448
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
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); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, K;
vec a;
bool dp[5010][5010];
vector<int> b, c;

bool C(const int &m) {
  m0(dp);
  dp[0][0] = true;
  b = c;

  for (int i = 0; i < N; i++) {
    if (i != m) b.push_back(a[i]);
  }

  for (int i = 0; i < N - 1; i++) {
    for (int k = 0; k <= K; k++) {
      if (!dp[i][k]) continue;
      dp[i + 1][k] = true;
      if (k + b[i] <= K) dp[i + 1][k + b[i]] = true;
    }
  }

  int tmp = 0;
  for (int i = 0; i <= K; i++) {
    if (dp[N - 1][i]) {
      tmp = a[m] + i;
      if (tmp >= K) break;
    }
  }
  return (tmp < K) || (K <= tmp - a[m]);
}

signed main() {
  cin >> N >> K;
  a.resize(N);

  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    a[i] = min(tmp, K);
  }

  sort(ALL(a));

  int ok = -1, ng = N + 1;
  for (int i = 0; i < 50; i++) {
    int mid = (ok + ng) / 2;
    if (C(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << min(ng, N) << endl;
  return 0;
}


Measured memory_bytes: 24960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	public static void main(String args[]) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String text[] = line.split(" ");
		int N = Integer.parseInt(text[0]);
		int L = Integer.parseInt(text[1]);
		
		String s[] = new String[N];
		
		int count = 0;
		while(count < N ){
			s[count] =  br.readLine();
//			System.out.println(count + ":" + s[count]);
			count ++;
		}
//		System.out.println("call");
		
		//s[1]が大きけりゃtrue
//		System.out.println(s[1].compareTo(s[2])>0);
		//S1~Snを辞書順に並び替えるー＞バブルソート！
		count = 0;
		while(count < N){
			for(int i = 0; i < N-1 ; i++){
				if(s[i].compareTo(s[i + 1]) > 0){
					swap(s, i , i+ 1);
				}
			}
			count++;
		}
		String ans = "";
		for(int i = 0; i < N; i++){
			ans += s[i];
		}
		System.out.println(ans);
	}
	//a番目とb番目の要素を交換
	static String[] swap(String[] txt, int a, int b){
		String s = txt[a];
		txt[a] = txt[b];
		txt[b] = s;
		return txt;
	}
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n, m;
    cin >> n >> m;

    REP(i, m) {
        ll a;
        cin >> a;
        n -= a;
    }

    if (n < 0) MSG(-1)
    else MSG(n)
}


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

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int MAX = 1000;
	
	int[] month = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();sc.nextLine();
			if(n == 0) break;
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			int[] ans = new int[MAX];
			for(int i=0;i<n;i++) {
				String[] sp = sc.nextLine().split("[/ :]");
//				debug(sp);
				
				if(sp[4].equals("I")) {
					int id = Integer.parseInt(sp[5]);
					int t = ( month[Integer.parseInt(sp[0])-1] + Integer.parseInt(sp[1]) ) * 24 * 60 + Integer.parseInt(sp[2]) * 60 + Integer.parseInt(sp[3]);
					map.put(id, t );
				}
				
				else {
					int id = Integer.parseInt(sp[5]);
					int t = ( month[Integer.parseInt(sp[0])-1] + Integer.parseInt(sp[1]) ) * 24 * 60 + Integer.parseInt(sp[2]) * 60 + Integer.parseInt(sp[3]);
					if(id == 0) {
						for(Map.Entry<Integer, Integer> entry: map.entrySet()) if(entry.getKey() != 0){
							ans[entry.getKey()] += t - max(map.get(id), map.get(entry.getKey()));
						}
					}
					else {
						if(map.containsKey(0)) {
							ans[id] += t - max(map.get(id), map.get(0));
						}
					}
					map.remove(id);
				}
			}
			
			int ret = 0;
			for(int i=0;i<MAX;i++) ret = max(ans[i], ret);
			System.out.println(ret);
		}
	}
	
	class V {
		int t, id;
		V(int t, int id) {
			this.t = t;
			this.id = id;
		}
		
		public int hashCode() {
			return t * id;
		}
		
		public boolean equals(Object o) {
			if(o instanceof V) {
				V v = (V) o;
				return t == v.t && id == v.t;
			}
			return false;
		}
	}
	
	

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

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 63624
N = int(input())
adj_list = [ [] for _ in range(N+1) ]
for _ in range(N):
  lst = list(map(int,input().split()))
  node = lst[0]
  if lst[1] != 0:
    adj_list[node] = lst[2:]


visited = [False] * (N+1)
arrived = [-1] * (N+1)
left = [-1] * (N+1)

time = 0
def dfs(node):
  global time

  arrived[node] = time
  visited[node] = True

  for nei in adj_list[node]:
    if not visited[nei]:
      time += 1
      dfs(nei)
  else:
    time += 1
    left[node] = time

for i in range(1, N+1):
  if not visited[i]:
    time += 1
    dfs(i)

for i in range(1, N+1):
  print(i, arrived[i], left[i])


Measured memory_bytes: 5656
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        double a, b, c, d, e, f, result1, result2;
        
        while(scan.hasNext()){
            a=scan.nextDouble();
            b=scan.nextDouble();
            c=scan.nextDouble();
            d=scan.nextDouble();
            e=scan.nextDouble();
            f=scan.nextDouble();
            result1=Math.round((b*f-c*e)/(b*d-a*e)*1000)*0.001;
            result2=Math.round((c*d-a*f)/(b*d-a*e)*1000)*0.001;
            System.out.printf("%.3f"+" "+"%.3f",result1,result2);
            System.out.println();
        }
    }
}


Measured memory_bytes: 27988
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

class UFT {
private:
  vi data, rnk;

public:
  UFT(const int &size)
    : data(size), rnk(size) {
    iota(all(data), 0);
  }

  int root(const int &x) {
    return data[x] == x ? x : data[x] = root(data[x]);
  }

  bool same(const int &a, const int &b) {
    return root(a) == root(b);
  }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    if (rnk[a] < rnk[b]) swap(a, b);
    data[b] = a;
    if (rnk[a] == rnk[b]) rnk[a]++;
  }
};
void solve() {
  int n, m;
  cin >> n >> m;
  UFT uf(n + m);
  rep(i, n) {
    int k;
    cin >> k;
    while (k--) {
      int l;
      cin >> l;
      l--;
      uf.unite(i, n + l);
    }
  }
  bool b = true;
  loop(i, 1, n) b &= uf.same(i - 1, i);
  cout << (b ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int n, m;
int d[100010];

int main()
{
	read(n, m);
	for(;m--;){
		int a, b; read(a, b);
		++d[a]; ++d[b];
	}
	for(int i=1; i<=n; ++i) if(d[i]&1) puts("NO"), exit(0);
	puts("YES");
    return 0;
}


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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)

const int mod = 1000000007;

ll h, w, a, b;

ll f[200010];
ll mi[200010];

ll po(ll x, ll r) {
	ll re = 1LL;
	ll temp = x;
	while (r != 0LL) {
		if (r & 1)re = (re*temp) % mod;
		temp = (temp*temp) % mod;
		r >>=1;
	}
	return re;
}

void prep() {
	f[0] = 1LL;
	for (int i = 1; i <= 200000; i++) {
		f[i] = (f[i - 1] * i) % mod;
	}
	mi[200000] = po(f[200000], mod - 2);
	for (int i = 200000 - 1; i >= 0; i--) {
		mi[i] = (mi[i + 1] * (i + 1)) % mod;
	}
}


int main() {
	cin >> h >> w >> a >> b;
	prep();
	ll ans = 0LL;
	for (int i = b; i < w; i++) {
		ll t1, t2;
		t1 = f[h - 1LL - a + i] * mi[i] % mod * mi[h - a - 1LL] % mod;
		t2 = f[w - 1LL + a - i - 1LL] * mi[w - 1LL - i] % mod * mi[a - 1LL] % mod;
		ans = ( ans + (t1 * t2 % mod) ) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h> 
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

string s;
int main() {
	cin >> s;
	int n = s.size();
	int d = n-7;
	for (int i = 0; i+d <= n; i++) {
		string t = "";
		for (int j = 0; j < i; j++) t += s[j];
		for (int j = i+d; j < n; j++) t += s[j];
		if(t == "keyence") return 0*puts("YES"); 
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256