akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    ll k;
    cin>>k;
    if(k==0){
        cout<<2<<endl;
        cout<<0<<" "<<0<<" "<<endl;
        return 0;
    }
    if(k==1){
        cout<<2<<endl;
        cout<<0<<" "<<2<<endl;
        return 0;
    }
    if(k<=50){
        cout<<k<<endl;
        for(ll i=1;i<=k;i++){
            if(i==k)cout<<i<<endl;
            else cout<<i<<" ";
        }
    }
    else{
        cout<<50<<endl;
        vector<ll>ans(50);
        k-=50;
        ll num=0;
        if(k>=50)num=k/50,k = k-num*50;
        for(ll i=0;i<50;i++)ans[i]=i+1+num;
        for(ll j=0;j<k;j++)ans[49-j]++;
        for(ll i=0;i<50;i++){
            if(i==49)cout<<ans[i]<<endl;
            else cout<<ans[i]<<" ";
        }
    }
    return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	int n, m;
	bool flag = false;
	
	cin >> n;
	vector<string>u(n + 1);
	FOR(i, 1, n) {
		cin >> u[i];
	}
	cin >> m;
	vector<string>t(m + 1);
	FOR(i, 1, m) {
		cin >> t[i];
	}

	FOR(i, 1, m) {
		FOR(j, 1, n) {
			if (t[i] == u[j]) {
				if (flag==false) {
					cout << "Opened by ";
					flag = true;
				}
				else {
					cout << "Closed by ";
					flag = false;
				}
				
				cout << t[i] << endl;
				break;
			}
			if (j == n) {
				cout << "Unknown ";
				cout << t[i] << endl;
			}
		}
	}

	
}


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

using namespace std;

string s[2];
int dp[52][9];
const int MOD = 1e9 + 7;

int main()
{
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    cin >> s[0];
    cin >> s[1];
    for (int c = 0; c < 9; c++){
        int cl1 = c / 3;
        int cl2 = c % 3;
        dp[0][c] = ((s[0][0] == s[1][0]) == (cl1 == cl2));
    }
    for (int i = 1; i < n; i++){
        for (int c = 0; c < 9; c++){
            int cl1 = c / 3;
            int cl2 = c % 3;
            if ((s[0][i] == s[1][i]) != (cl1 == cl2)) continue;
            for (int c1 = 0; c1 < 9; c1++){
                int cl3 = c1 / 3;
                int cl4 = c1 % 3;
                if ((s[0][i] == s[0][i - 1]) != (cl1 == cl3)) continue;
                if ((s[1][i - 1] == s[1][i]) != (cl4 == cl2)) continue;
                dp[i][c] = (dp[i][c] + dp[i - 1][c1]) % MOD;
            }
        }
    }
    int ans = 0;
    for (int c = 0; c < 9; c++){
        ans = (ans + dp[n - 1][c]) % MOD;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAX_k 9

int n, k;
int A[10001];

int func(int a){
    int i, j, n1, m;
n1=a;
while(n1!=0){
        m = n1%10;
        for (j=0; j<k; j++)
            if (m==A[j]) return 1;
            n1/=10;
}
    return 0;
}

int main(){
    int i;
    scanf("%d %d", &n, &k);
    for (i=0; i<k; i++)
        scanf("%d", &A[i]);

    i=n;
    while (1)
    {
        if(func(i)==0)break;
        else
        {
            i++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
void solve(){
    int k;
    cin >> k;
    string ans;
    for(int i = 0; i < k; i++){
        ans += "ACL";
    }
    cout << ans << '\n';
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        solve();
    }
}

Measured memory_bytes: 34576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    int n;
        cin >> n;
    vec a(n), b(n), c(n);
        for(int i=0; i<n; i++) cin >> a.at(i);
        for(int i=0; i<n; i++) cin >> b.at(i);
        
        for(int i=0; i<n; i++) c.at(i) = i+1;
    int cnt=1, ac=-1, bc=-1;
        do{
            if(ac==-1)
                for(int i=0; i<n; i++){
                    if(a.at(i)!=c.at(i)) break;
                    if(n-1==i) ac = cnt;
                }
            if(bc==-1)
                for(int i=0; i<n; i++){
                    if(b.at(i)!=c.at(i)) break;
                    if(n-1==i) bc = cnt;
                }
            if(ac!=-1 && bc!=-1) break;
            cnt += 1;
        }while(next_permutation(c.begin(), c.end()));
        cout << abs(ac-bc) << endl;

        
}

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

int main()
{
    int a;
    cin >> a;

    cout <<  a + a*a + a*a*a  <<  endl;
    return 0;
}


Measured memory_bytes: 3632
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<int> b(n);
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++){
        if(i + 1 < b[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> ans;
    bool f = true;
    while(true){
        for(int i = b.size() - 1; i >= 0; i--){
            if(b[i] == i + 1){
                ans.push_back(i + 1);
                b.erase(b.begin() + i);
                break;
            }
            if(i == 0) f = false;
        }
        if(b.size()==0) break;
        if(f == false) break;
    }
    if(!f){
        cout << -1 << endl;
        return 0;
    }

    for(int i = ans.size() - 1; i >= 0; i--){
        cout << ans[i] << endl;
    }
}

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>
using namespace std;
int main(){
    int n,r;
    cin >> n;
    if(n%2==0){
        cout << n/2  << endl;
    }
    else{
        cout << (n+1)/2 << endl;
    }
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
	fastio();
	ll N;
	cin>>N;
	dd ar[N];
	cn(ar,N);
	dd ans[N+1][N+1];
	for(ll i=0;i<=N;i++)
	{
		for(ll j=0;j<=N;j++)
		{
			ans[i][j]=0.0;
		}
	}
	ans[0][0]=1.0;
	for(ll i=1;i<=N;i++)
	{
		ans[i][0]=ans[i-1][0]*(1-ar[i-1]);
	}
	ans[1][1]=ar[0];
	for(ll i=2;i<=N;i++)
	{
		for(ll j=1;j<i;j++)
		{
			ans[i][j]=(ans[i-1][j-1]*ar[i-1]+ans[i-1][j]*(1-ar[i-1]));
		}
		ans[i][i]=ans[i-1][i-1]*ar[i-1];
	}
	dd sum=0.0;
	for(ll i=N/2+1;i<=N;i++)
		sum+=ans[N][i];
	cout<<fixed<<showpoint;
	cout<<setprecision(12);
	cout<<sum<<endl;
}	


Measured memory_bytes: 70656
N = gets.to_i

cities = []
N.times do |c|
  city = gets.chomp.split(" ").map(&:to_i)
  cities << city
end

length = 0
perm = cities.permutation(N).to_a
perm.each do |routes|
  routes.each_cons(2) do |r1, r2|
    length += Math.sqrt((r2[0]-r1[0])**2+(r2[1]-r1[1])**2)
  end
end

p length/perm.length

Measured memory_bytes: 8700
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)





int main() {
	ll n, m,ans=0,a,b,c;
	map<ll, ll> dic;

	in(n);
	in(m);
	rep(i, 0, n) {
		in(a);
		dic[a]++;
	}

	rep(i, 0, m) {
		in(b);
		in(c);
		dic[c] += b;
	}
	
	auto itr = dic.end();
	itr--;

	while(true) {
		if (n > itr->second) {
			ans += itr->first * itr->second;
			n -= itr->second;
		}
		else {
			ans += itr->first * n;
			break;
		}
		itr--;
	} 

	outn(ans);

	return 0;

}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int table[20][20];
		for(int i = 0; i < n; i++){
			int sum=0;
			for(int j = 0; j < n; j++){
				cin>>table[i][j];
				sum+=table[i][j];
			}
			table[i][n]=sum;
		}
		for(int j = 0; j <= n; j++){
			//table[n]
			int sum=0;
			for(int i = 0; i < n; i++){
				sum+=table[i][j];
			}
			table[n][j]=sum;
		}
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				printf("%5d",table[i][j]);
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define MAX_DIST 1LL<<60


class Dijkstra{
public:
    struct edge{
        ll to;
        ll cost;
    };
    ll vertex;
    vector<vector<edge>> graph;
    vector<ll> dist;
    vector<ll> hist;

    Dijkstra(ll n){
        vertex = n;
        graph = vector<vector<edge>>(n);
        dist = vector<ll>(n);
        hist = vector<ll>(n,-1);
    };

    void dijkstra(ll s){
        priority_queue<pll, vector<pll>, greater<pll>> que;
        fill(dist.begin(), dist.end(), MAX_DIST);
        dist[s] = 0;
        que.push(pll(0, s));

        while (!que.empty()){
            pll p = que.top();  //cost/to
            que.pop();
            ll v = p.second;
            if (dist[v] < p.first) continue;
            for (ll i = 0; i < graph[v].size(); i++) {
                edge e = graph[v][i];
                if (dist[e.to] > dist[v] + e.cost && !(dist[e.to] == MAX_DIST && dist[v] == MAX_DIST)){
                    dist[e.to] = dist[v] + e.cost;
                    hist[e.to] = v;
                    que.push(pll(dist[e.to], e.to));
                }
            }
        }

    }

    void addEdge(ll from, ll to, ll cost) {
        edge e;
        e.to = to;
        e.cost = cost;
        graph[from].push_back(e);
    }

};


int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> l(m), r(m), c(m);
    for(int i = 0; i < m; i++){
        cin >> l[i] >> r[i] >> c[i];
        l[i]--; r[i]--;
    }
    Dijkstra d(n);
    for(int i = 0; i < m; i++){
        d.addEdge(l[i],r[i],c[i]);
        d.addEdge(r[i],l[i],c[i]);
    }
    for(int i = 0; i < n-1; i++){
        d.addEdge(i+1, i, 0);
    }

    d.dijkstra(0);
    if(d.dist[n-1] == 1LL<<60){
        cout << -1 << endl;
    }else{
    cout << d.dist[n-1] << endl;

    }
    return 0;
}


Measured memory_bytes: 15608
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] s = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int N = s[0];
		int M = s[1];

		Map<Integer, Integer> map = new HashMap<Integer, Integer>();

		int ans=0;

		for (int i = 0; i < N; i++) {
			int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
			for (int j = 1; j < line.length; j++) {
				if (map.containsKey(line[j])) {
					map.put(line[j], map.get(line[j])+1);
				}else {
					map.put(line[j], 1);
				}
			}
		}

		for (Integer ite : map.keySet()) {
			if (map.get(ite) == N) {
				ans++;
			}
		}

		System.out.println(ans);


	}
}




Measured memory_bytes: 36480
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 10000000
char s[MAXN];
int main()
{
	int d;
	scanf("%s",s);
	int len=strlen(s);
	scanf("%d",&d);
	for(int i=0;i<len;i+=d)
		printf("%c",s[i]);
}

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

constexpr int64_t MOD = 1e9 + 7;

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

    vector<bool> broken(n+1, false);
    for (int i=0; i<m; i++) {
        int a;
        cin >> a;
        broken[a] = true;
    }

    vector<int64_t> dp(n+1);
    dp[0] = 1, dp[1] = 1 - broken[1];
    for (int i=2; i<=n; i++) {
        if (broken[i]) continue;
        dp[i] = (dp[i-1] + dp[i-2]) % MOD;
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#define res(x,y) (x==-1?INF:(x+y))
#define min(x,y) (x<y?x:y)

int INF=9999999;
int main(){
	int n,dp[2][5001][2],i,j,cost;
	memset(dp,-1,sizeof(dp));
	scanf("%d",&n);
	dp[1][0][1]=dp[1][1][0]=0;
	for(i=0;i<n-1;i++){
		scanf("%d",&cost);
		for(j=0;j<=n/2;j++){
			dp[i&1][j][0]=min((j?res(dp[(i+1)&1][j-1][0],0):INF),(j?res(dp[(i+1)&1][j-1][1],cost):INF));
			dp[i&1][j][1]=min(res(dp[(i+1)&1][j][1],0),res(dp[(i+1)&1][j][0],cost));
		}
	}
	printf("%d\n",min(dp[0][n/2][0],dp[0][n/2][1]));	
}


/*

m h
- 0
0 -
- -
- -


- 0
1 




*/

Measured memory_bytes: 796
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;

ll A,B;

ll GCD(ll P,ll Q){return Q? GCD(Q,P%Q):P;}
int main(){
	scanf("%lld%lld",&A,&B);
	ll C=GCD(A,B),Vans=0;
	for(ll i=2;i*i<=C;i++){
		if(C%i==0){
			Vans++;
			while(C%i==0) C/=i;
		}
	}
	if(C>1) Vans++;
	printf("%lld\n",Vans+1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

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

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);


  double N;
  cin>>N;
  vector<int> vec(N);
  double sum=0;
  for(int i=0;i<N;i++){
    cin>>vec[i];
    sum+=vec[i];
  }

vsort(vec);
  int sum1=0;
  int sum2=INF;
  for(int i=1;i<100;i++){
    for(int j=0;j<N;j++){
      sum1+=(vec[j]-i)*(vec[j]-i);
      
    }
    //cout<<i<<endl;
    sum2=min(sum1,sum2);
    sum1=0;
  }
  cout<<sum2<<endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    fast_io();

    int n,k,q; std::cin >> n >> k >> q;
    std::vector<int> sankasha(n,0);
    for(int i=0; i<q; i++){
        int ai; std::cin >> ai;
        sankasha[ai-1]++;
    }

    for(int i=0; i<n; i++){
        if(sankasha[i]>q-k) std::cout << "Yes" << "\n";
        else std::cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
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;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int a[3];
    int su = 0;
    REP(i,3){
        cin >> a[i];
        su += a[i];
    }
    if(su >= 22){
        cout << "bust" << endl; 
    }
    else cout << "win" << endl;

}

Measured memory_bytes: 256
#include <iostream>

int main() {

  char b;

  std::cin >> b;
  if (b == 'A') {
    std::cout << 'T' << std::endl;
  } else if (b == 'T') {
    std::cout << 'A' << std::endl;
  } else if (b == 'C') {
    std::cout << 'G' << std::endl;
  } else if (b == 'G') {
    std::cout << 'C' << std::endl;
  }
  return 0;
}

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

char ope[3] = {'+','-','*'};

int calc(int x, int s, int y) {
  if(ope[s] == '+') return x+y;
  if(ope[s] == '-') return x-y;
  if(ope[s] == '*') return x*y;
}

int main() {
  
  int arr[4];
  while(cin>>arr[0]>>arr[1]>>arr[2]>>arr[3] && arr[0]) {
    sort(arr,arr+4);
    do {
      for(int i=0; i<3; i++) {
	for(int j=0; j<3; j++) {
	  for(int k=0; k<3; k++) {
	    int temp = calc(calc(calc(arr[0], i, arr[1]), j, arr[2]), k, arr[3]);
	    if(temp == 10) {
	      cout << "(("<<arr[0]<<ope[i]<<arr[1]<<")"<<ope[j]<<arr[2]<<")"<<ope[k]<<arr[3]<<endl;
	      goto EXIT;
	    }
	    
	    temp = calc(calc(arr[0], i, arr[1]), j, calc(arr[2], k, arr[3]));
	    if(temp == 10) {
	      cout << "("<<arr[0]<<ope[i]<<arr[1]<<")"<<ope[j]<<"("<<arr[2]<<ope[k]<<arr[3]<<")"<<endl;
	      goto EXIT;
	    }
	  }
	}
      }
    } while(next_permutation(arr, arr+4));
    
    cout << 0 << endl;
    
  EXIT:;
  }
  
  return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

vector<int> primes(0);
void prime_number(int N){
    vector<int> tmp(N+1,1);
    tmp[0]=tmp[1]=0;
    for(int i=2; i<=N; i++){
        if(tmp[i]==1){
            primes.push_back(i);
        }
        for(long long j= (long long) i*i; j<=N; j+=i){
            tmp[j]=0;
        }
    }
}

vector<int> factorize(int x){
    vector<int> ret(primes.size(),0);
    for(int i=0; i<primes.size(); i++){
        int p=primes[i];
        while(x%p==0){
            x/=p;
            ret[i]++;
        }
    }
    if(x!=1){
        primes.push_back(x);
        ret.push_back(1);
    }
    return ret;
}

int main(){
    int N, K;
    cin >> N >> K;

    vector<int> A(N,0);
    int sum_=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum_+= A[i];
    }

    deque<int> factor;
    for(int i=30000; i>=1; i--){
        if(i*i>sum_){
            continue;
        }
        if(sum_%i==0){
            factor.push_front(sum_/i);
            factor.push_back(i);
        }
    }

    for(auto it=factor.begin(); it!=factor.end(); it++){
        int i=*it;
        int tmp1=0;
        int tmp2=0;
        priority_queue<int, vector<int>, less<int> > que1;
        priority_queue<int, vector<int>, less<int> > que2;

        for(int j=0; j<N; j++){
            int r =A[j]%i;
            if(r<i-r){
                tmp1+=r;
                que1.push(r);
            }else{
                tmp2+=i-r;
                que2.push(i-r);
            }
        }

        int diff=tmp1-tmp2;
        if(diff>0){
            int cnt =diff/i;
            for(int j=0; j<cnt; j++){
                int x=que1.top();
                que1.pop();
                tmp1-=x;
            }
        }else{
            int cnt=-diff/i;
            for(int j=0; j<cnt; j++){
                int x=que2.top();
                que2.pop();
                tmp1+=i-x;
            }
        }
        if(tmp1<=K){
            cout << i << endl;
            return 0;
        }
    }


}

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

#define int long long int 


int32_t main()
{
  
   int n;
   cin>>n;
   vector<vector<int>> g(n);
   for(int i=1;i<n;i++)
   {
     int u,v;
     cin>>u>>v;
     u--;
     v--;
     g[u].push_back(v);
    g[v].push_back(u);
   }

   vector<int> color(n,-1);
   color[0]=1;
   color[n-1]=0;

   stack<pair<int,int>> s;
   s.push({0,0});
   vector<int> path(n,-1);
   while(!s.empty())
   {
     auto [child,parent]=s.top();
     s.pop();

     if(path[child]>=0)
     continue;
     path[child]=parent;
     for(auto i:g[child])
     {
       s.push({i,child});
     }
   }

   int cur=n-1;
   vector<int> common_path;


   while(cur!=0)
   {
     cur=path[cur];
     if(cur!=0)
     common_path.push_back(cur);
   }

  // for(auto i:path)
  //  cout<<i<<" ";
  //  cout<<endl;
  //  for(auto i:common_path)
  //  cout<<i<<" ";
  //  cout<<endl;

   int f_turn=(common_path.size()+1)/2;
   int s_turn=(common_path.size())/2;
   for(int i=0;i<common_path.size();i++)
   {
     color[common_path[i]]=i>=s_turn;
   }
  
   auto dfs=[&](int c,int init)
   {

     stack<int> str;
     str.push(init);
     int ans=0;
     vector<bool> seen(n,0);
     while(!str.empty())
     {

       int ele=str.top();
       str.pop();
        if(color[ele]!= -1 &&color[ele]!=c)
        continue;
        if(seen[ele])
        continue;

        ans+=color[ele]==-1;
        color[ele]=c;
        seen[ele]=true;
        for(auto i:g[ele])
        {
          if(!seen[i])
          str.push(i);
          
        }
       
        }
        return ans;
   };
   f_turn+=dfs(1,0);
   s_turn+=dfs(0,n-1);

   if(f_turn==s_turn)
   s_turn++;

   cout<<(f_turn>s_turn?"Fennec":"Snuke")<<endl;

}

Measured memory_bytes: 12636
N = int(input())
S = input()
e = [0]
w = [0]
for l, r in zip(S[:N-1], S[::-1]):
  nw = w[-1] + (1 if l == 'W' else 0)
  ne = e[-1] + (1 if r == 'E' else 0)
  e.append(ne)
  w.append(nw)
print(min([a + b for a, b in zip(e, w[::-1])]))

Measured memory_bytes: 41936
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n),v(n);
	for(int i=0;i<n;i++)
	cin>>w[i]>>v[i];
	ll sum=accumulate(v.begin(),v.end(),(ll)0);
	vector<ll> dp(sum+1,INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=sum-v[i];j>=0;j--){
			dp[j+v[i]]=min(dp[j+v[i]],w[i]+dp[j]);
		}
	}
	for(int i=sum;i>=0;i--){
		if(dp[i]<=W){
			cout<<i<<endl;
			break;
		}
	}
//	for(int i=0;i<dp.size();i++)
//	cout<<dp[i]<<" ";
}

Measured memory_bytes: 3944
#include <stdio.h>


int main(){

	int W,H,N;

	scanf("%d %d %d",&W,&H,&N);

	int x[N],y[N],a[N],i;

	for(i=0;i<N;i++){
		scanf("%d %d %d",&x[i],&y[i],&a[i]);
	}

	int xl=0,xr=W,yu=H,yl=0;

	for(i=0;i<N;i++){
		if(a[i]==1)
			if(xl<x[i])
				xl=x[i];
		if(a[i]==2)
			if(xr>x[i])
				xr=x[i];
		if(a[i]==3)
			if(yl<y[i])
				yl=y[i];
		if(a[i]==4)
			if(yu>y[i])
				yu=y[i];
	}

	int sum=(xr-xl)*(yu-yl);
	if((xr-xl)>0&(yu-yl)>0)
		printf("%d\n",sum);
	else
		printf("0\n");



	return 0;
}

Measured memory_bytes: 128
while True:

    N,M = map(int,input().split())

    if N == 0 and M == 0:
        break
    
    ans = 0
    
    di = []
    vi = []

    for i in range(0,N):
        d,v = map(int,input().split())
        di.append(d)
        vi.append(v)
        
    for i in range(1,M+1):
        max = 0
        for j in range(0,N):
            if di[j] == i and max < vi[j]:
                max = vi[j]
        ans+=max

    print(ans)
    



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

void solve(long long N, long long K, std::vector<long long> l)
{
    RSORT(l);
    int ans = 0;
    for (int i = 0; i < K; i++)
    {
        ans += l[i];
    }

    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> l(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &l[i]);
    }
    solve(N, K, std::move(l));
    return 0;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan= new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		HashSet h=new HashSet();
		int d=a+b;
		h.add(d);
		int e=b+c;
		h.add(e);
		int h1=c+a;
		h.add(h1);
		System.out.println(Collections.min(h));
		

	}

}


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

#define int long long int
#define ps push_back
#define mod 1000000007
#define fi first
#define so second
#define pii pair<int,int>
#define TT int tt;cin>>tt;for(int cc=1;cc<=tt;cc++)

signed main()
{
    double n;
    cin>>n;
    double f = 2*22*n;
    f/=7.0;
    cout<<fixed<<f<<setprecision(10);
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  for (int i = 0; i < M; i++) {
    cin >> p.at(i) >> S.at(i);
  }
  vector<int> c(N), w(N);
  for (int i = 0; i < M; i++) {
    if (S.at(i) == "AC") {
      c.at(p.at(i) - 1) = 1;
    }
    else {
      if (c.at(p.at(i) - 1) == 0) {
        w.at(p.at(i) - 1) += 1;
      }
    }
  }
  int ans1 = 0;
  for (int i = 0; i < N; i++) {
    ans1 += c.at(i);
  }
  int ans2 = 0;
  for (int i = 0; i < N; i++) {
    ans2 += c.at(i) * w.at(i);
  }
  cout << ans1 << " " << ans2 << endl;
}


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

long long h[100000];
long long dp[100000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    dp[0]=0;
    cin >> h[0];
    for(int i = 1; i < n; i++)
    {
        cin >> h[i];
        if(i > 1) dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
        else dp[1] = abs(h[0]-h[1]);
    }
    cout << dp[n-1];
    
    return 0;
}
 
/*
1
3 2
1 4 2
1 2
3 3
3 4
*/

Measured memory_bytes: 1792
//点(x_i, y_i) (x_i are distinct, y_i are distinct)を選ぶ問題になって、これは愚直DPでO(N^2). 座標圧縮＋BIT高速化でO(NlogN)
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;

int mod = 1000000007;

struct BIT {
	int n;
	int bit[200001];
	
	void init(int n) {
		int i;
		this->n = n;
		rep(i, n + 1) bit[i] = 0;
	}
	
	void add(int pos, int x) {
		for (int i = pos; i <= n; i += i & -i) {
			bit[i] += x;
			bit[i] %= mod;
		}
	}
	
	int sum(int pos) {
		int ret = 0;
		for (int i = pos; i > 0; i -= i & -i) {
			ret += bit[i];
			ret %= mod;
		}
		return ret;
	}
};

void press(vector<P> &ps) {
	vector<int> sx;
	vector<int> sy;
	int i;
	
	rep(i, ps.size()) {
		sx.push_back(ps[i].first);
		sy.push_back(ps[i].second);
	}
	sort(sx.begin(), sx.end());
	sx.erase(unique(sx.begin(), sx.end()), sx.end());
	sort(sy.begin(), sy.end());
	sy.erase(unique(sy.begin(), sy.end()), sy.end());
	
	rep(i, ps.size()) {
		ps[i].first = lower_bound(sx.begin(), sx.end(), ps[i].first) - sx.begin();
		ps[i].second = lower_bound(sy.begin(), sy.end(), ps[i].second) - sy.begin() + 1;	//BITが1-indexedなので1足しておく
	}
}

bool compare(P &a, P &b) {
	return a.first == b.first ? a.second > b.second : a.first < b.first;
}

int n, m;
int x[100000];
int y[100000];
BIT bit;

signed main() {
	int i;
	
	cin >> n >> m;
	rep(i, n) cin >> x[i];
	rep(i, m) cin >> y[i];
	
	int INF = 1e+10;
	vector<P> ps;
	rep(i, n) {
		int right = lower_bound(y, y + m, x[i]) - y;
		if (right == m || right == 0) continue;
		ps.push_back(P(x[i] - y[right - 1], y[right] - x[i]));
	}
	ps.push_back(P(-INF, -INF));
	ps.push_back(P(INF, INF));
	sort(ps.begin(), ps.end(), compare);
	ps.erase(unique(ps.begin(), ps.end()), ps.end());
	press(ps);
	
	//x昇順, y降順で点を見る, 貰うDP
	bit.init(ps.size());
	bit.add(1, 1);
	
	int w;
	for (i = 1; i < ps.size(); i++) {
		w = bit.sum(ps[i].second - 1);
		if (i == ps.size() - 1) { break; }
		bit.add(ps[i].second, w);
	}
	cout << w << endl;
	return 0;
}

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


int main() {
  int N;
  string res;
  string s;
  cin >> N;
  res="Three";
  for(int i=0;i<N;i++)
  {
    cin >> s;
    if(s=="Y")
    {
      res="Four";
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int solve(int N, char s[]) {
    if (N & 1) return 0;
    for (int i = 0; i < N / 2; i++) {
        if (s[i] != s[i + N / 2]) {
            return 0;
        }
    }
    return 1;
}
 
int main() {
    int N;
    char s[101];
    scanf("%d\n%s", &N, s);
    printf("%s\n", solve(N, s) ? "Yes" : "No");
}


Measured memory_bytes: 256
H, W = map(int, input().split())
answer = 0
if H == 1 or W == 1:
  print(1)
elif  H * W % 2 == 1:
  answer = int(H * W / 2)
  print(answer + 1)
else:
  answer = int(H * W / 2)
  print(answer)

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

int main(){
   int month=1,daily=1,day[13] ={0,31,29,31,30,31,30,31,31,30,31,30,31},date = 0;
   while(1){
    int poi;
    poi = 0;
    cin >> month >> daily;
    if(month == 0) break;
    for(int i = 1;i < month;++i){
       poi += day[i];
    }
    date = (poi + daily + 3) % 7;
    if(date == 0) cout << "Sunday" << endl;
    if(date == 1) cout << "Monday" << endl;
    if(date == 2) cout << "Tuesday" << endl;
    if(date == 3) cout << "Wednesday" << endl;
    if(date == 4) cout << "Thursday" << endl;
    if(date == 5) cout << "Friday" << endl;
    if(date == 6) cout << "Saturday" << endl;
  }
 return 0;
}

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

int main() {
    int a, b; cin >> a >> b;
    cout << 6 - a - b << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
class UF{
public:
	vector<int> par,num;
	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UF(int N):par(N),num(N,1){
		iota(all(par),0);
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return;
		if(num[u]<num[v])swap(u,v);
		num[u]+=num[v];
		par[v]=u;
	}
	bool same(int u,int v){
		return find(u)==find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};
int main(){
    int n,m;
    cin>>n>>m;
    UF uf(n);
    int a,b,ans=0;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }
    for(int i=0;i<n;i++){
        if(uf.find(i)!=i)continue;
        ans++;
    }
    cout<<ans-1<<"\n";
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(void){
	int n;
	string s[2];
	cin >> n;
	cin >> s[0] >> s[1];
	long long ans = 1;
	int mode = (s[0][0] == s[1][0]) ? 1 : 0;
	ans *= mode ? 3 : 6;
	for(int i = mode ? 1 : 2; i < n; ++i){
		if(s[0][i] == s[1][i]){
			if(mode){
				ans *= 2;
			}else{
				ans *= 1;
			}
			mode = 1;
		}else{
			if(mode){
				ans *= 2;
			}else{
				ans *= 3;
			}
			mode = 0;
			i++;
		}
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,y = map(int,input().split())
fl = 0
for i in range(n+1):
  for j in range(n+1):
    if n-i-j>=0 and 10000*(n-i-j)+5000*j+1000*i == y:
      print("{0} {1} {2}".format(n-i-j,j,i))
      fl = 1
      break
  if(fl == 1):
    break
if(fl==0):
  print("-1 -1 -1")


Measured memory_bytes: 40940
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int a, b, c;

int main() {
  cin >> a >> b >> c;
  if(a+b+c >= 22) cout << "bust";
  else cout << "win";
}


Measured memory_bytes: 256
//昔のSolutionは黒歴史ですので気にしないで下さい...
#include <bits/stdc++.h>
using namespace std;

struct Data
{
        string name;
        int time;
        
        Data () {}
        Data ( string name, int time ) : name(name), time(time) {}
};

template < typename T > 
struct Queue
{
        T data[100005];
        int head, tail, length, size;
        Queue () : head(0), tail(0), length(0), size(100000) {}

        void enqueue(T k)
        {
                data[tail] = k, tail = (tail + 1) % size, length++;
        }

        T dequeue()
        {
                int d = head;
                head = (head + 1) % size;
                length--;
                return ( data[d] );
        }

        bool empty()
        {
                return ( length == 0 );
        }
};

int main()
{
        Queue < Data > que;
        int n, q;
        
        cin >> n >> q;
        for ( int i = 0; i < n; i++ ) {
                string name;
                int time;
                cin >> name >> time;
                que.enqueue(Data(name, time));
        }
        
        int times = 0;
        while ( !que.empty() ) {
                Data d = que.dequeue();
                if ( d.time <= q ) {
                        times += d.time;
                        cout << d.name << " " << times << endl;
                } else {
                        times += q;
                        que.enqueue(Data(d.name, d.time - q));
                }
        }

        return ( 0 );
}



Measured memory_bytes: 7052
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
// Practice is the only shortcut to improve
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define PI 2*acos(0.0)
#define pii pair<int,int>
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define coutv(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define cinv(v) for(auto &it:v)cin>>it;
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using ordered_set =tree<T, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;
*/
//sieve bool b[1000005];void primenire(){int i, j;b[0]=true;b[1]=true;for(i=4; i<=1000000; i+=2){b[i]=true;}for(i=3; i<=1001; i+=2){if(!b[i]){for(j=i*i; j<=1000001; j+=2*i){b[j]=true;}}}}
//power ll power(ll a,ll b){if(b==0) return 1LL;if(b&1) return a*power(a,b-1);else return power(a,b/2)*power(a,b/2);}
long long int m(long long int a,long long int b,long long int c)
{
    if(b==0)
        return 1;
    if(b%2==0)
    {
        long long int  tmp=m(a,b/2,c);
        return ((tmp%c)*(tmp%c))%c;
    }
    else
        return ((a%c)*(m(a,b-1,c)%c))%c;
}
//MaxSubarraySum ll mss(vector<ll>v){ll mx=v[0];ll sz=v.size();for(int i=1;i<=sz;i++){ll t=v[i]+v[i-1];if(t>=v[i]) v[i]=t;mx=max(mx,v[i]*1LL);}return mx;}
//combination ll com[1001][1001];void combination(){com[1][1]=1;com[1][0]=1;for(ll i=2; i<=1000; i++){com[i][0]=1;for(ll j=1; j<=i; j++){com[i][j]=com[i-1][j]+com[i-1][j-1];}}}
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

void solve()
{
    ll a;
    cin>>a;
    ll an=0;
    if(a==1)
    {
        cout<<0<<endl;
        return;
    }
    an=m(10,a,mod);
    an%=mod;
    ll t=((2*(m(9,a,mod)%mod))%mod)-(m(8,a,mod)%mod);
    t%=mod;
    an-=t;
    if(an<=0) an+=mod;
    cout<<an<<endl;
}
int main()
{
    rj
    solve();



    return 0;
}



Measured memory_bytes: 3600
import numpy as np
n = int(input())
s1 = list(input())
s2 = list(input())

domino = np.array([s1, s2])
array = []
point = 0
while True:
    col = domino[:, point]
    if col[0] == col[1]:
        array.append(0) # X
        point += 1
    else:
        array.append(1) # Y
        point += 2
    if point >= n:
        break

total = 1
for i in range(len(array)):
    if i == 0:
        if array[i] == 0:
            total *= 3
        else:
            total *= 6
    else:
        if array[i] == 0:
            if array[i-1] == 0:
                total *= 2
            else:
                total *= 1
        else:
            if array[i-1] == 0:
                total *= 2
            else:
                total *= 3
print(total % (10**9 + 7))

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main() {
    nfs
    int i, j, n;
    cin >> n;
    vector <pair<int,int>> dp((1 << n), {0, 0});
    
    for (i = 0; i < (1 << n); i++) {
        cin >> dp[i].ff;
    }

    for (i = 0; i < n; i++) {
        for (int mask = 0; mask < (1 << n); mask++) {
            if (mask & (1 << i)) {
                int a[2] = {dp[mask ^ (1 << i)].ff, dp[mask ^ (1 << i)].ss};
                for (j = 0; j < 2; j++) {
                    if (a[j] > dp[mask].ss) {
                        dp[mask].ss = a[j];
                        if(dp[mask].ss > dp[mask].ff)
                            swap(dp[mask].ff, dp[mask].ss);
                    }
                    else break;
                }
            }
        }
    }

    int out = dp[0].ff + dp[0].ss;
    for (i = 1; i < (1 << n); i++) {
        cout << (out = max(out, dp[i].ff + dp[i].ss)) << " ";
    }
}

Measured memory_bytes: 5396
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		HashMap<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();
	    for(int i = 0; i < n; i++){
	        int a = sc.nextInt();
	        int b = sc.nextInt();
	        if(map.containsKey(a)){
	            map.get(a).add(b);
	        }else{
	            ArrayList<Integer> list = new ArrayList<Integer>();
	            list.add(b);
	            map.put(a, list);
	        }
		}
		
		// 計算
		int sum = 0;
        PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Comparator.reverseOrder());		
        for(int i = 1; i < m + 1; i++){
            if(map.containsKey(i)){
                for(int j : map.get(i)){
                    pq.add(j);
                }
            }
            if(pq.size()>0) sum = sum + pq.poll();
        }

		// 出力
        System.out.println(sum);
		
	}
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    vector<int> d(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> d[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            ans += d[i] * d[j];
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x,int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	long int N, S = 0;
	long int A[100000];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		S += A[i];
	}

	long int D[100000];
	D[0] = 0;
	long int n, b, d = 0;
	for (int i = 1; i < N; i++)
	{
		n = (2 * i) % N;
		b = (2 * (i - 1)) % N;
		D[n] = D[b] + (A[n - 1] - A[b]) * 2;
		d += D[n];
	}

	long int ans[100000];
	ans[0] = (S - d) / N;
	for (int i = 1; i < N; i++)
	{
		ans[i] = ans[0] + D[i];
	}

	for (int i = 0; i < N; i++)
	{
		cout << ans[i] << " ";
	}

	return 0;
}


Measured memory_bytes: 3712