akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


void solve() {
    int n; scanf("%d", &n); if (n == 0) exit(0);
    ll mo, d, h, mn, id;
    char c;

    ll res = 0;
    bool in = false;
    ll cur = -1;
    map<ll, vector<ll>> mimos;
    vector<ll> god(1600);
    map<ll, ll> mp;
    for (int i = 0; i < n; i++) {
        scanf("%lld/%lld %lld:%lld %c %lld", &mo, &d, &h, &mn, &c, &id);
        ll t = h * 60 + mn;
        ll p = mo * 32 + d;
        if (cur != p) {
            for (int i = 0; i + 1 < 1600; i++) god[i + 1] += god[i];
            for (auto& p : mimos) {
                vector<ll>& imos = p.second;
                ll t = 0;
                for (int i = 0; i < 1600; i++) {
                    if (i) imos[i] += imos[i - 1];
                    if (imos[i] and god[i]) {
                        //cout << id<<" "<<i / 60 << " " << i % 60 << " " << imos[i] << endl;
                        t++;
                    }
                }
                mp[p.first] += t;
            }
            mimos.clear();
            god.clear(); god.resize(1600);
        }
        cur = p;
        if (id > 0) {
            if (mimos.count(id)) {
                if (c == 'I') mimos[id][t]++;
                else mimos[id][t]--;
            }
            else {
                mimos[id].resize(1600);
                if (c == 'I') mimos[id][t]++;
                else mimos[id][t]--;
            }
        }
        else {
            if (c == 'I') god[t]++;
            else god[t]--;
        }
    }
    for (int i = 0; i + 1 < 1600; i++) god[i + 1] += god[i];
    for (auto& p : mimos) {
        vector<ll>& imos = p.second;
        ll t = 0;
        for (int i = 0; i < 1600; i++) {
            if (i) imos[i] += imos[i - 1];
            if (imos[i] and god[i]) {
                //cout << id << " " << i / 60 << " " << i % 60 << " " << imos[i] << endl;
                t++;
            }
        }
        mp[p.first] += t;
    }
    mimos.clear();
    god.clear(); god.resize(1600);
    for (auto p : mp) chmax(res, p.second);;
    printf("%lld\n", res);
}
int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */
    int kkt = 89;
    while (kkt) {
        solve();
    }
    return 0;
}


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

int main(){ 
  int N;
  cin >> N;
  vector<Int> A(N);
  rep(i,N) cin >> A[i];
  
  sort(A.begin(),A.end());
  
  bool flag = true;
  rep1(i,N-1) {
    if (A[i-1]==A[i]) flag = false;
  }
  
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;

}


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

using namespace std;

int main() 
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    int k, n; cin >> k >> n;
    
    vector<int> crd(n);
    
    for (int i = 0; i < n; ++i)
        cin >> crd[i];
    
    vector<int> res;
        
    for (int k = 0; k < n - 1; ++k)
        res.push_back(abs(crd[k] - crd[k + 1]));
        
    if (!crd[0])
        res.push_back(k - crd.back());
    else
        res.push_back(k - crd.back() + crd[0]);

    sort(res.begin(), res.end());
    int a = 0;
    
    for (int s = 0; s < n - 1; ++s)
        a += res[s];
    
    cout << a;
}

Measured memory_bytes: 2168
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 2e5 + 100;





signed main() {
	speed;	
	int n, m;
	cin >> n >> m;
	int sum = 0;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	sort(rall(a));
	bool ans = true;
	for (int i = 0; i < m; ++i) {
		if (a[i] * 4 * m < sum) {
			ans = false;
			break;
		}
	}
	cout << ((ans) ? "Yes" : "No");
	return 0;
}


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


int main() {
	int n,m;
	int **elm;
	int *vec;
	int res;
	
	cin>>n>>m;
	
	elm = new int*[m];
	for(int i=0;i<m;++i){
		elm[i] = new int[n];
	}
	
	vec = new int[m];
	
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			cin>>elm[j][i];
		}
	}
	
	for(int i=0;i<m;++i){
		cin>>vec[i];
	}
	
	for(int i=0;i<n;++i){
		res=0;
		for(int j=0;j<m;++j){
			res += elm[j][i]*vec[j];
		}
		cout<<res<<endl;
	}
}

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


int main(){
  long long n,i,j;
  cin >> n;
  vector<long long> a(n),b(n),c(n);
  for(i=0;i<n;++i){
    cin >> a[i];
  }
  for(i=0;i<n;++i){
    cin >> b[i];
  }
  for(i=0;i<n;++i){
    cin >> c[i];
  }
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  long long ans=0;
  for(j=0;j<n;++j){
    long long bid=b[j];
    long long aid=lower_bound(a.begin(),a.end(),bid)-a.begin();
    long long cid=c.end()-upper_bound(c.begin(),c.end(),bid);
    ans+=aid*cid;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const num = Number(input[0][0].slice(-1));
  const hon = [2, 4, 5, 7, 9];
  const pon = [0, 1, 6, 8];

  if (hon.includes(num)) {
    return "hon";
  }

  if (pon.includes(num)) {
    return "pon";
  }

  return "bon";
};

console.log(main(read()));


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

int cnt[100005];

int main() {
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  int c=0;
  for (int i=1; i<n; i++) {
    if (s[i-1]=='A'&&s[i]=='C') c++;
    cnt[i]=c;
  }
  for (int i=0; i<q; i++) {
    int l,r;
    cin>>l>>r;
    l--;r--;
    cout<<cnt[r]-cnt[l-1]-(s[l-1]=='A'&&s[l]=='C'? 1:0)<<endl;
  }

  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[2005][2005];   // dp[i][j] 前 i 个人放了 j 个左边的
ll n,ma;
struct stu
{
    ll pos,w;
}a[2004];
bool cmp(stu u,stu v)
{
    return u.w<v.w;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i].w);
        a[i].pos=i;
    }
    sort(a+1,a+n+1,cmp);
    //for(int i=1;i<=n;i++) dp[i][i]=a[1].w*abs(a[1].pos-i);  // 枚举最小的挪到每一个位置
    for(int len=1;len<=n;len++)
    {
        for(int i=1;i+len-1<=n;i++)
        {
            int j=i+len-1;
            // 前 len 个数最大的为 a[len].w，枚举a[len]放的位置
            dp[i][j]=max(dp[i+1][j]+a[len].w*abs(a[len].pos-i),  // 放左边
                         dp[i][j-1]+a[len].w*abs(a[len].pos-j)); // 放右边
        }
    }
    cout<<dp[1][n];
    return 0;
}


Measured memory_bytes: 26324
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int n,x,sum=0,ans=0;;
    cin>>n>>x;
    vector<int>a(10000000);
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(sum<=x){
            ans++;
        }
    }
    ans++;
    
    cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 39296
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[200001];
  for(int i=0;i<n;i++)
   {int x;
    cin>>x;
    x--;
    a[x]=i;}
  long long cnt=0;
  long long mx=0;
  for(int i=1;i<n;i++){
    if(a[i]>a[i-1])
	  cnt++;
	else
	  cnt=0;
  mx=max(mx,cnt);
      }
  cout<<n-(mx+1);
return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000009
#define pb push_back
#define ll long long int
#define db double
#define all(v) v.begin(),v.end()

using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/




ll dp[100005];

int main(){
    IOS;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll a[n+1];
        memset(dp,false,sizeof(dp));
        FOR(i,n)cin>>a[i];
        for(int i=1;i<=k;i++){
            for(int j=0;j<n;j++){
                if(i-a[j]<0)
                break;
                if(dp[i-a[j]]==false){
                    dp[i]=true;
                    break;
                }
            }
        }
        if(dp[k]==true)
        cout<<"First\n";
        else
        cout<<"Second\n";

        
    }
    return 0;
} 


Measured memory_bytes: 4400
#include<stdio.h>
int main(){

 int W,H,x,y,r;

	scanf("%d",&W);
	scanf("%d",&H);
	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&r);

	if(0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

return 0;
}

Measured memory_bytes: 1816
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

int hi[90][10] = {};

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    rep(i,90)
    {
        int sd = 0 , cn = i;
        rep(j,10)
        {
            string l = to_string(cn);
            for(auto i : l)
                sd += (i-'0');
            cn++;
            hi[i][j] = sd;
        }
    }
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

int vis[10000001];

void solve() 
{   
    string s , t ;
    cin >> s >> t;
    int n = s.length() , ans = 0;
    rep(i,n)
        if(s[i]!=t[i])
            ans++;
    cout << ans << endl;
}   

Measured memory_bytes: 3836
h,n=map(int,input().split())
H=[]
A=[]
for i in range(n):
    a,b=map(int,input().split())
    H.append([a,b])
    A.append(a)
a_max=max(A)
dp=[10**10]*(h+a_max+1)
dp[0]=0
for i in range(1,h+a_max+1):
    for j in range(n):
        if i-H[j][0]<0:
            dp[i]=min(dp[i],H[j][1])
        else:
            dp[i]=min(dp[i],dp[i-H[j][0]]+H[j][1])
print(min(dp[h:h+a_max+1]))

Measured memory_bytes: 42348
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	string s;
	cin >> s;
	int ans = INF;
	s += 'a';
	for (int i = 0; i < 26; i++) {
		char c = 'a' + i;
		int cnt = 0, now = -1;
		s[s.size() - 1] = c;
		rep(j, s.size()) {
			if (s[j] == c) {
				cnt = max(cnt, j - now - 1);
				now = j;
			}
		}
		ans = min(cnt, ans);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];
			int k = vs[1];
			int[] point = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int r = point[0];  // ｸﾞｰ
			int s = point[1];  // ﾁｮｷ
			int p = point[2];  // ﾊﾟｰ
			string t = Console.ReadLine();

			long[,] dp = new long[k, 3];
			for (int i = 0; i < n; i++) {
				int j = i % k;
				long[] tmp = new long[3];
				if (i >= k) {
					tmp[0] = Math.Max(dp[j, 1], dp[j, 2]);
					tmp[1] = Math.Max(dp[j, 0], dp[j, 2]);
					tmp[2] = Math.Max(dp[j, 0], dp[j, 1]);
				}
				dp[j, 0] = tmp[0] + (t[i] == 's' ? r : 0);
				dp[j, 1] = tmp[1] + (t[i] == 'p' ? s : 0);
				dp[j, 2] = tmp[2] + (t[i] == 'r' ? p : 0);
			}
			long ans = 0;
			for (int i = 0; i < k; i++) {
				ans += Math.Max(dp[i, 0], Math.Max(dp[i, 1], dp[i, 2]));
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 17632
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int x, t;
    cin >> x >> t;

    OUT(max(0, x - t));
    return 0;
}



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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, n){
    	cin >> a[i];
    }
    sort(a, a+n, greater< ll > ());
    if(k >= n){
    	cout << 0 << endl;
    }
    else{
    	ll s = 0;
    	fo(i, k, n-1){
    		s += a[i];
    	}
    	cout << s << endl;
    }
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
s=input()

if s=="SUN":
  print(7)
elif s=="MON":
  print(6)
elif s=="TUE":
  print(5)
elif s=="WED":
  print(4)
elif s=="THU":
  print(3)
elif s=="FRI":
  print(2)
else:
  print(1)

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var swr = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(swr);
            var n = int.Parse(Console.ReadLine());
            var a = 1000000000 + 7;
            long ans = 1;
            for (; n > 0; n--)
            {
                ans = ((ans * n) % a);
            }
            Console.WriteLine(ans);
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

bool Possible(int a, int b, int c)
{
    for (auto i = 0; i < b; i += 1) {
        if ((a * i) % b == c) {
            return true;
        }
    }
    return false;
}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    cout << (Possible(a, b, c) ? "YES" : "NO") << "\n";
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    //int z ;
    //cin >> z;
    cin >> s ;
    int n = s.size();
    int occ[100001][27]={0};
    map<char,int>mp;
    for(int i = 0 ; i < n ;  i++)
    {
        if(i+1-mp[s[i]]+1 <=3 && mp[s[i]]!=0)
        {
            cout << mp[s[i]] << " " << i+1;
            return 0;
        }
        mp[s[i]]=i+1;
        /*if(i)
        {
            for(int j  = 0 ; j <26;j++)
            {
                occ[i+1][j]+=occ[i][j];
            }
        }
        occ[i+1][s[i]-'a']++;
        */
    }
    /*int x;
    bool flag=false;
    for(int i = 1 ; i <=n-2 ; i++)
    {
            x=0;
            for(int c = 0 ; c < 26 ; c++)
            {
                x=max(x , occ[i+2][c]-occ[i-1][c] );
            }
            if(x*2 > 3 )
            {
                cout << i << " " << i+2 ;
                return 0;
            }
    }
    */
    cout << -1 << " " << -1 ;
    return 0;
}


Measured memory_bytes: 3724
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define fo(x,a,b) for(register int x=a;x<=b;x++)
#define dfo(x,a,b) for(register int x=a;x>b;x--)
//using namespace std;
int min(int x,int y) {return(x<y?x:y);}
int cnt[60][3],sum[60][3],n,m;
char ch[60][60];
int main ()
{
//	freopen("rus.in","r",stdin);
//	freopen("rus.out","w",stdout);

	scanf("%d%d",&n,&m);
	fo(i,1,n)
	{
		scanf("%s",ch[i]+1);
		fo(j,1,m)
		{
			if (ch[i][j]=='W') cnt[i][0]++;
			if (ch[i][j]=='B') cnt[i][1]++;
			if (ch[i][j]=='R') cnt[i][2]++;
		}
		sum[i][0]=sum[i-1][0]+cnt[i][0];
		sum[i][1]=sum[i-1][1]+cnt[i][1];
		sum[i][2]=sum[i-1][2]+cnt[i][2];
	}
	int ans=2147483647;
	fo(i,1,n-2)
	{
		fo(j,i+1,n-1)
		{
			int k=n;
			ans=min(ans,sum[i][1]+sum[i][2]+sum[j][0]+sum[j][2]+sum[k][0]+sum[k][1]
			-sum[i][0]-sum[i][2]-sum[j][0]-sum[j][1]);
		}
	}
	printf("%d\n",ans);

	return 0;
}




Measured memory_bytes: 3236
import java.util.*;

public class Main {
    static ArrayList<Integer>[] graph;
    static long[] score;
    static boolean[] visited;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        graph = new ArrayList[n + 1];
        score = new long[n + 1];
        visited = new boolean[n + 1];
        for (int i = 1; i <= n; i++) {
            graph[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            graph[a].add(b);
            graph[b].add(a);
        }
        for (int i = 0; i < q; i++) {
            score[sc.nextInt()] += sc.nextInt();
        }
        calc(1, 0);
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <=n; i++) {
            if (i != 1) {
                sb.append(" ");
            }
            sb.append(score[i]);
        }
      System.out.println(sb);
    }
    
    static void calc(int idx, long add) {
        if (visited[idx]) {
            return;
        }
        visited[idx] = true;
        score[idx] += add;
        for (int x : graph[idx]) {
            calc(x, score[idx]);
        }
    }
    
}


Measured memory_bytes: 224636
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
int n, x[N], y[N], f[N<<1], sz[N<<2][2];
int find(int x)
{
	if(x==f[x]) return x;
	return f[x] = find(f[x]);
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1; i<N*2; i++) f[i] = i;
 	for(int i=1; i<=n; i++) 
 	{
 		cin >> x[i] >> y[i];
 		f[find(x[i])] = find(y[i]+N);
	}
	for(int i=1; i<N*2; i++) sz[find(i)][i/N]++;
	ll ans = 0;
	for(int i=1; i<N*2; i++) 
	{
		ans += 1ll*sz[i][0]*sz[i][1];
	}
	ans -= n;
	cout << ans;
	return 0;
}


Measured memory_bytes: 4480
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))

a=[-1*i for i in a]#最大値をとるため＊－１
heapq.heapify(a)#二分木の形にする
for i in range(m):#ｍ回
    ma=heapq.heappop(a)#listから最小（最大）を取り出しその値を記憶するためのma
    ma*=-1#-のままだと-3//2=2になってしまうので計算が合わない
    heapq.heappush(a,-1*(ma//2))#2で割った値に－１を懸けて戻す
print(sum(a)*-1)#https://qiita.com/T_Wakasugi/items/dac6eb77a3cace54f95e



Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define pb push_back
#define vl vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll n,m;
void dfs1(pll st,ll vis[25][25],string grid[],ll dist[25][25])
{
	ll i = st.first;
	ll j = st.second;
	//vis[i][j]=1;
	queue<pll>q;
	q.push(st);
	while(!q.empty())
	{
		pll th = q.front();
		q.pop();
		ll i = th.first;
		ll j = th.second;
		vis[i][j]=1;
		if(i && grid[i-1][j]=='.'  && vis[i-1][j]==0)
		{
			dist[i-1][j]=dist[i][j]+1;
			vis[i-1][j]=1;
			q.push(mp(i-1,j));
		}
		if(j && grid[i][j-1]=='.'  && vis[i][j-1]==0)
		{
			vis[i][j-1]=1;
			dist[i][j-1]=dist[i][j]+1;
			q.push(mp(i,j-1));
		}
		if(j<m-1 && grid[i][j+1]=='.'  && vis[i][j+1]==0)
		{
			vis[i][j+1]=1;
			dist[i][j+1]=dist[i][j]+1;
			q.push(mp(i,j+1));
		}
		if(i<n-1 && grid[i+1][j]=='.'  && vis[i+1][j]==0)
		{
			vis[i+1][j]=1;
			dist[i+1][j]=dist[i][j]+1;
			q.push(mp(i+1,j));
		}			
	}
}
int main()
{
	fast
	cin>>n>>m;
	string grid[25];
	for (int i = 0; i < n; ++i)
	{
		cin>>grid[i];
	}
	ll dist[25][25];
	ll vis[25][25];
	ll ans=0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			memset(vis,0,sizeof(vis));
			memset(dist,-1,sizeof(dist));
			if(grid[i][j]=='.')
			{	
				dist[i][j]=0;
				dfs1(mp(i,j),vis,grid,dist);
				ll ma = 0;
				for (int i1 = 0; i1 < n; ++i1)
				{
					for (int j1 = 0; j1 < m; ++j1)
					{
		//				cout<<dist[i1][j1]<<" ";
						ma = max(dist[i1][j1],ma);
					}
		//			cout<<endl;
				}
		//		cout<<i<<" "<<j<<" sdsds"<<endl;
				ans=max(ans,ma);
			}
		}

	}
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(unsigned long long a,unsigned long long b){
    if(!b)return a;
    return gcd(b,a%b);

}
int main(){
    unsigned long long n,m,c;
    while(cin>>n>>m){
        c = gcd(n,m);
        cout << c << " " << (n*m)/c << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <bits/stdc++.h>
#define rep(k,i,n) for(int i=k;i<n;++i)
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int a;
    double sum=0;
    rep(0,i,n){
        cin>>a;
        sum+=1.0/a;
    }
    cout<<setprecision(10)<<1.0/sum<<endl;
}


Measured memory_bytes: 256
import sys
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_=[0]
b_=[0]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

ans=0
j = m
for i in range(n+1):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j)
print(ans)


Measured memory_bytes: 47376
S=input()
res=0
for st in [S[x:y] for x in range(len(S)+1) for y in range(len(S)+1) if x<=y]:
    for c in st:
        if not c in ('A','C','G','T'):
            break
    else:
        if res<len(st):
            res=len(st)
print(res)


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

int x, n, a, mn, ans;
set <int> st;

int main() {
    cin >> x >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        st.insert(a);
    }
    mn = 1000;
    for (int i = 0; i <= 101; i++){
        if (st.count(i)) continue;
        if (abs(i-x) < mn){
            mn = abs(i-x);
            ans = i;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
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 (b<a) {a=b; return 1;} return 0;}


int main(){
    double l;
    cin >> l;
    double a = l/3;
    double ans = a*a*a;
    printf("%.10f", ans);
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

vector<pair<int,int>> o;

int main(){
  int n,m;
  cin >> n>> m;
  rep(i,m){
    int a,b;
    cin >> a>> b;
    o.push_back(mp(b,a));
  }
  sort(o.begin(),o.end());
  rep(i,m){
    cerr<<o[i].first<<' '<<o[i].second<<' ';
  }
  cerr<<endl;
  int no=0;
  int temp=-INF;
  rep(i,m){
    /*
    if(i==m-1){
      no++;
    }else
    */
    if(o[i].second<=temp){
      continue;
    }else{
      no++;
      temp=o[i].first-1;
      cerr<<temp<<endl;
    
    }
  }
  //int ans=n-1-no;
  cout<<no<<endl;
  return 0;
}

Measured memory_bytes: 1404
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int N = int.Parse(ipt[0]);
    int K = int.Parse(ipt[1]);
    bool[] isHave = new bool[N];
    for (int i = 0; i < N; i++) {
      isHave[i] = false;
    }
    for (int i = 0; i < K; i++) {
      int d = int.Parse(Console.ReadLine());
      ipt = Console.ReadLine().Split(' ');
      for (int j = 0; j < d; j++) {
        int A = int.Parse(ipt[j]);
        isHave[A-1] = true;
      }
    }
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (!isHave[i]) {
        count++;
      }
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 27544
N, A, B = gets.split(' ').map(&:to_i)

count = 0
(0..N).each do |n|
  # num = n.to_s.split('').map(&:to_i).inject(:+)
  num = n.to_s.chars.map(&:to_i).inject(&:+)
  if A <= num && num <= B
    count += n
  end
end

p count


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

vector<ll> ans;
vector<vector<int>> node;

void score(int now, int parent=-1) {
    for (int u : node[now]) {
        if (u == parent) {
            continue;
        }
        ans[u] += ans[now];
        score(u, now);
    }
}

void solve() {
    int n, q;
    cin >> n >> q;
    ans.resize(n);
    node.resize(n);

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        node[a].push_back(b);
        node[b].push_back(a);
    }

    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    score(0);
    rep(i, n) {
        if (i == 0) {
            cout << ans[i];
        } else {
            cout << " " << ans[i];
        }
    }
    cout << endl;
}

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


Measured memory_bytes: 24320
# -*- coding: utf-8 -*-
import sys,math

H,W = map(int,input().split(" "))

def calc(a,b,c):
    tmp = (a[0]*a[1],b[0]*b[1],c[0]*c[1])
    return max(tmp) - min(tmp)

result = H*W

#H
for i in range(H//2+1):
    a = (i,W)
    hh = H-i
    rest = (hh,W)

    result = min([result,calc(a,(hh//2,W),(hh-hh//2,W)),calc(a,(hh,W//2),(hh,W-W//2))])

#W
for i in range(W//2+1):
    a = (H,i)
    ww = W-i
    rest = (H,ww)

    result = min([result,calc(a,(H//2,ww),(H-H//2,ww)),calc(a,(H,ww//2),(H,ww-ww//2))])

print(result)


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


struct dat {
    int w,s; ll val;
    dat(int a, int b, ll c) {
	w=a;s=b;val=c;
    }
    bool operator<(dat o) {
	return w+s<o.w+o.s;
    }
};


int n;
vector<dat> v;

ll dp[1001][10001];



ll solve(int i, int have) {
    assert(have>=0);
    if (i==n) {
	return 0;
    }

    if (~dp[i][have]) return dp[i][have];

    ll &res = dp[i][have] = 0;

    res = solve(i+1, have);

    if (have >= v[i].w) {
	res = max(res, v[i].val + solve(i+1, min(have-v[i].w, v[i].s)));
    }

    return res;
}

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

    memset(dp,-1,sizeof(dp));

    cin>>n;
    for (int i=0; i<n; i++) {
	int w,s,va; cin>>w>>s>>va;
	v.push_back({w,s,va});
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());


    // for (auto p: v) {
    // 	cout<<p.w<<" "<<p.s<<" "<<p.val<<endl;
    // }
    // cout<<endl;



    ll res = 0;
    for (int i=0; i<n; i++) {
	dp[i][v[i].s] = v[i].val+solve(i+1, v[i].s);
	res = max(res, dp[i][v[i].s]);
    }


    cout<<res<<endl;
    
    
    return 0;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for ( int i = 0 ; i < a ; i++ )
int main() {
  vector<int> P (5);
  REP(i,5) {
    cin >> P[i];
  }
  int Q;
  cin >> Q;
  if ( P[4] - P[0] > Q ) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class E { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var q = G();
		int N = q[0], D = q[1];
		var d = G();
		int Q = F();
		q = G();
		var x = new int[N + 1];
		x[0] = D;
		for (var i = 0; i < N; i++) x[i + 1] = Min(x[i], Abs(x[i] - d[i]));
		var y = new int[N + 1];
		y[N] = 1;
		for (var i = N; i > 0; i--) y[i - 1] = y[i] + (y[i] <= d[i - 1] / 2 ? 0 : d[i - 1]);
		foreach (var z in q.Select(w => w-1)) WriteLine(y[z + 1] <= x[z] ? "YES" : "NO");
	}
}

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

int main(void) {
	int n, acc = 0, wac = 0, tlec = 0, rec = 0, i;
	char s[4];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {

		scanf("%s", s);

		if (!strcmp(s, "AC")) {
			acc++;
		}
		else if (!strcmp(s, "WA")) {
			wac++;
		}
		else if (!strcmp(s, "TLE")) {
			tlec++;
		}
		else if (!strcmp(s, "RE")) {
			rec++;
		}
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", acc, wac, tlec, rec);
}


Measured memory_bytes: 1700
#include<stdio.h>

int main(void){
	int k,a,b;
	long long int result = 0;
	long long int TradeBis;

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

	if(a+1<b){
		// コインを交換していく場合
		if(k > a - 1){
			TradeBis = b - a;
			result = a;
			result += (k - a + 1)/2 * TradeBis;
			result += (k - a + 1)%2;
		}
		else{
			result = k + 1;
		}
	}
	else{
		// コインを交換しない場合
		result = k + 1;
	}
	printf("%lld\n",result);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
const int MAX = 100;

int main()
{
	int n, tmp, count = 0;
	int A[MAX];
	cin >> n;
	for(int i = 0; i < n ; i++)
		cin >> A[i];

	for(int i = 0; i < n; i++)
	{
		for(int j = n-1; j >= i+1; j--)
		{
			if(A[j] < A[j-1])
			{
				count++;
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
			}
		}
	}

	for(int i = 0; i < n-1; i++)
	{
		cout << A[i] << ' ';
	}
	cout << A[n-1] << endl;
	cout << count << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 12;
const int MAX_M = 1005;
int dp[MAX_M][1 << MAX_N];

int main2() {
  int N = nextInt();
  int M = nextInt();

  vector<int> as(M), bs(M);
  REP(i, M) {
    int a = nextInt();
    int B = nextInt();
    int b = 0;
    REP(j, B) {
      int x = nextInt() - 1;
      b |= (1 << x);
    }
    as[i] = a;
    bs[i] = b;
  }

  const int INF = 1001001001;
  REP(i, MAX_M) REP(j, 1 << MAX_N) dp[i][j] = INF;
  dp[0][0] = 0;

  for (int m = 0; m < M; m++) {
    for (int s = 0; s < (1 << N); s++) {
      chmin(dp[m+1][s], dp[m][s]);
      chmin(dp[m+1][s | bs[m]], dp[m][s] + as[m]);
    }
  }
  ll ans = dp[M][(1 << N) - 1];
  if (ans < INF / 2)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 16384
#include<stdio.h>
#include<string.h>
#define LEN 100005


typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head,tail,n;

void en(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P de(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a,int b){
  return a < b ? a : b;
}

int main(){
  int elaps = 0, c;
  int i,q;
  P u;
  scanf("%d %d", &n, &q);
  for (i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n+1;


  while (head != tail){
    u = de();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) en(u);
    else{
      printf("%s %d\n" ,u.name, elaps);
    }
  }

  return 0;
}





Measured memory_bytes: 11840
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int solve(int X, int N, vector<int> p)
{
	sort(p.begin(), p.end());

	int ans = 0;
	for (int a = -111; a <= 111; ++a) {
		if (binary_search(p.begin(), p.end(), a)) {
			continue;
		}
		if (abs(X - a) < abs(X - ans)) {
			ans = a;
		}
	}

	return ans;
}

int main()
{
	int X, N;
	cin >> X >> N;
	vector<int> p(N);
	for (auto& x : p) {
		cin >> x;
	}
	cout << solve(X, N, p) << endl;
}


Measured memory_bytes: 3640
def solve(string):
    n, m, *a = map(int, string.split())
    ans = [0] * (n + 1)
    a = set(a)
    ans[0] = 1
    ans[1] = 0 if 1 in a else 1
    num = 1000000007
    for i in range(2, n + 1):
        if i in a:
            continue
        ans[i] = (ans[i - 2] + ans[i - 1]) % num
    return str(ans[-1])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


Measured memory_bytes: 15592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
int N,k,A[MAX],dp[MAX];
int solve(int idx)
{
    if(idx==N)return 0;
    if(idx>N)return 1e9;
    if(dp[idx]!=-1)return dp[idx];
    int res=1e9;
    for(int i=1;i<=k;i++){
        res = min(res,solve(idx+i)+abs(A[idx+i]-A[idx]));
    }
    return dp[idx]=res;
}
int  main ()
{
    memset(dp,-1,sizeof dp);
    cin >> N >> k;
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    cout<<solve(1)<<endl;
    return 0;
}



Measured memory_bytes: 5760
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

const (
	line       int = 3
	pushedFlag int = 0
)

func main() {
	scanner.Split(bufio.ScanWords)
	bingo := make([][]int, line)
	for i := 0; i < line; i++ {
		bingo[i] = scanInts(line)
	}

	n := scanInt()
	pushed := make([]int, n)
	for i := 0; i < n; i++ {
		pushed[i] = scanInt()
	}

	for i := 0; i < line; i++ {
		for j := 0; j < line; j++ {
			for k := 0; k < n; k++ {
				if bingo[i][j] == pushed[k] {
					bingo[i][j] = pushedFlag
					break
				}
			}
		}
	}

	if isBingo(bingo) {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}

func isBingo(bingo [][]int) bool {

	for i := 0; i < line; i++ {
		if bingo[i][0] == bingo[i][1] && bingo[i][0] == bingo[i][2] {
			return true
		}

		if bingo[0][i] == bingo[1][i] && bingo[0][i] == bingo[2][i] {
			return true
		}
	}

	if (bingo[0][0] == bingo[1][1] && bingo[0][0] == bingo[2][2]) ||
		(bingo[2][0] == bingo[1][1] && bingo[2][0] == bingo[0][2]) {
		return true
	}
	return false
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
import math as Math


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    a, b = input().split()
    a = int(a)
    b = int(b.replace(".", ""))
    print(int(a*b//100))


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 61788
#include <bits/stdc++.h>
    using namespace std;
    int main() {
        int n,l,sum=0;
        cin>>n>>l;
        if(l>0){
            int a=2;
            for(int i=1;i<n;i++){
                sum+=l+a-1;
                 a++;
            }
        }
        else{
            int a;
            a=l;
            a=0-a;
            a++;
            int b=1;
            for(int i=0;i<n;i++){
                sum+=l+b-1;
                b++;
            }
            if(a<=n){
                sum-=l+a-1;
            }
            else{
                sum-=l+n-1;
            }
        }
        cout<<sum<<'\n';
    	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  if (N%10 == 9 || N/10 == 9) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    int imos[200010] = {};
    vector<pii> interval[30];
    vector<pii> for_imos;

    rep(i, n) {
        int s, t, ci;
        cin >> s >> t >> ci;
        ci--;
        interval[ci].push_back(MP(s, t));
    }

    rep(i, 30) {
        sort(all(interval[i]));
        interval[i].push_back(MP(INF, INF));
    }

    rep(ci, 30) {
        int l = interval[ci][0].first;

        rep(i, interval[ci].size() - 1) {
            if (interval[ci][i].second != interval[ci][i + 1].first) {
                for_imos.push_back(MP(l, interval[ci][i].second));
                l = interval[ci][i + 1].first;
            }
        }
    }

    for (auto p : for_imos) {
        int s = p.first, t = p.second;
        imos[2 * s - 1]++, imos[2 * t]--;
    }

    rep(i, 200009) {
        imos[i + 1] += imos[i];
    }
    int Max = 0;
    rep(i, 200010) Max = max(Max, imos[i]);
    cout << Max << endl;
    return 0;
}



Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,v;
  string z,w="Yes";
  cin>>x>>y>>z;
  for(v=0;v<x+y+1;v++){
    if(v==x&&z.at(v)!='-'){w="No";break;}
    else if(v!=x&&z.at(v)=='-'){w="No";break;}
  }
  cout<<w<<endl;
}

Measured memory_bytes: 3632
n, x = map(int,input().split())
while (not((n==0)and(x==0))):
    c = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            r = x - (i+j)
            if ((r>=j+1)and(r<=n)):
                c+=1
            #print(r, c)
    print(c)
    n, x = map(int,input().split())



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n,k;
  cin>>n>>k;
  int mx=(n-1)*(n-2)/2;
  if (k > mx) {
    cout << -1 << endl;
  } else {
    int d = mx - k;
    cout << (n-1+d) << endl;
    FOR(i,2,n+1) {
      cout << 1 << ' ' << i << endl;
    }
    FOR(i,2,n+1) {
      FOR(j,i+1,n+1) {
        if (d > 0) {
          cout << i << ' ' << j << endl;
        }
        --d;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Template
{
    public static class Scan
    {
        public static string NextLine => Console.ReadLine();
        public static int NextInt => int.Parse(NextLine);
        public static long NextLong => long.Parse(NextLine);
        public static double NextDouble => double.Parse(NextLine);

        public static string[] StrAry(char separator = ' ') => Console.ReadLine().Split(separator);
        public static int[] IntAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), int.Parse);
        public static long[] LongAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), long.Parse);
        public static double[] DoubleAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), double.Parse);
    }

    internal class Template
    {
        public static void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
        private static void Fill<T>(T[] src, T value, int len) { for (int i = 0; i < len; i++) { src[i] = value; } }

        static void Solve() 
        {            
            Console.WriteLine(Scan.IntAry().Distinct().Count());
        }
        private static void Main()
        {
            Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11232