akhauriyash/Code-Regression huggingface dataset:
from collections import deque
def BFS(n, graph): #隣接リストのグラフが連結かどうかを判定する。連結でなければ1を返す。
  q = deque()
  q.append(0)
  searched = {0}
  while q:
    current = q.popleft()
    for v in graph[current]: #currentと隣接じている点のリスト
      if v not in searched:
        searched.add(v)
        q.append(v)
  
  if len(searched) != n:
    return 1
  else:
    return 0
  
n, m = map(int, input().split())
graph = [[] for _ in range(n)]
edges = []
ans = 0

for i in range(m):
  a, b = map(int, input().split())
  edges.append([a-1, b-1])
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)

import copy
for edge in edges:
  g = copy.deepcopy(graph) #普通のcopyだとうまくいかない
  #辺edgeの削除を行う
  g[edge[0]].remove(edge[1])
  g[edge[1]].remove(edge[0])
  ans += BFS(n, g) #辺の削除により非連結になるならばその辺は橋

print(ans)

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

int main()
{
	int n, u, v;
	cin>>n;
	int maxu = -1, maxv;
	
	for(int i=0;i<n;i++){
		cin>>u>>v;
		if(maxu<u) maxu = u, maxv = v;
	}
	
	cout<<(maxu+maxv)<<endl;
		
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char ch;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    sort(aa,aa+n);
    rep(i,n){
        if(aa[i]==aa[i+1]){
            i++;
        }else{
            cnt++;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 11276
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

void dump(vector<int> v) {
    int n = v.size();
    if (n > 0) {
        rep(i, n - 1) cout<<v[i]<<" ";
        cout<<v[n - 1];
    }
    cout<<endl;
}

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

    int n, q;
    cin>>n>>q;
    vector<vector<int>> v(n);
    rep(i, q) {
        int j, t, x;
        cin>>j;
        switch (j)
        {
        case 0:
            cin>>t>>x;
            v[t].push_back(x);
            break;
        case 1:
            cin>>t;
            dump(v[t]);
            break;
        default:
            cin>>t;
            v[t].clear();
            break;
        }
    }
}


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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (h > w) swap(h, w);
    ll x = (w + 1) / 2;
    ll y = w - x;
    ll t = (h + 1) / 2;
    cout << x * t + y * (h - t) << endl;
    
    return 0;
}



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

int main(){
	int a,b;
	char op;
	while(true){
		cin >> a >> op >> b;
		if(op=='?') break;
		else if(op=='+') cout << a+b <<endl;
		else if(op=='-') cout << a-b <<endl;
		else if(op=='/') cout << a/b << endl;
		else if(op=='*') cout << a*b << endl;
	}	
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ios
	ll n,ans=0;
	ll x[105],y[105],h[105];

	cin>>n;

	for(int i=1;i<=n;i++)
	cin>>x[i]>>y[i]>>h[i];

	for(ll i=0;i<=100;i++)
	{
		for(ll j=0;j<=100;j++)
		{
			set<ll>s;
			ans=10000000000;
			for(ll k=1;k<=n;k++)
			{
				if(h[k]==0)
				ans=min(ans,abs(x[k]-i)+abs(y[k]-j));
				else
				s.insert(h[k]+abs(x[k]-i)+abs(y[k]-j));
			}

			if(s.size()==1&&(*s.begin())<=ans&&(*s.begin())>=1)
			{
				cout<<i<<" "<<j<<" "<<(*s.begin());
				return 0;
			}
			
		}

	}
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long X, long long T){
    cout << (((N-1) / X)+1) * T << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long T;
    scanf("%lld",&T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
string st;
int main(){
	cin >> st;
	if (st.size() % 2 == 1){
		puts("No"); return 0;
	}
	for (int i = 0; i < st.size(); i+=2){
		if (st[i] == 'h' && st[i+1] == 'i'){
			continue;
		}
		puts("No"); return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

struct Trie {
	uint32_t sum = 0;
	bool exist = false;
	Trie * next[26];
	Trie() {
		REP(i, 26) next[i] = nullptr;
	}
};
Trie * root = nullptr;

void insert(const string & s) {
	auto cur = root;
	REP(i, s.size()) {
		cur->sum++;
		if (cur->next[s[i]-'a'] == nullptr) cur->next[s[i] - 'a'] = new Trie;
		cur = cur->next[s[i] - 'a'];
	}
	cur->exist = true;
}

struct CTrie {
	uint32_t sum = 0, len = 1;
	bool exist = false;
	CTrie * next[26] = {};
};

CTrie * compress(Trie * cur) {
	ll cnt = 0;
	REP(i, 26) if (cur->next[i]) cnt++;
	if (cnt == 1 && !cur->exist) {
		REP(i, 26) if (cur->next[i]) {
			auto c = compress(cur->next[i]);
			c->len++;
			return c;
		}
	} 
	auto nc = new CTrie;
	nc->exist = cur->exist;
	REP(i, 26) if (cur->next[i]) {
		auto c = compress(cur->next[i]);
		nc->next[i] = c;
		nc->sum += c->sum + c->exist;
	}
	return nc;
}

ll find(CTrie * cur, ll d, const string & s, const string & ord) {
	if (d == s.size()) return 0;
	ll sum = 0;
	REP(i, 26) {
		if (ord[i] == s[d]) break;
		if (cur->next[ord[i] - 'a']) {
			sum += cur->next[ord[i] - 'a']->sum + cur->next[ord[i] - 'a']->exist;
		}
	}
	return sum + find(cur->next[s[d] - 'a'], cur->next[s[d] - 'a']->len + d, s, ord) + cur->exist;
}


int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	root = new Trie;
	ll n; cin >> n;
	vector<string> s(n);
	REP(i, n) {
		cin >> s[i];
		insert(s[i]);
	}
	auto croot = compress(root);
	croot->len--;
	ll q; cin >> q;
	REP(i, q) {
		ll k; string ord;
		cin >> k >> ord;
		k--;
		cout << find(croot, croot->len, s[k], ord) + 1 << endl;
	}

	return 0;
}

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

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

int main () {
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4) << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
#define use(x) using std::x
use(swap); 

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=50005,G=3,P=998244353;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int pwr(int a,int k){
	int res=1;
	for(;k;k>>=1,a=mul(a,a))
		if(k&1)res=mul(res,a);
	return res;
}
void upd(int &a,int b){ a=add(a,b); }

int n,X,Y,fac[N],inv[N],f[N],tr[N],ans;
char A[N],B[N]; 

void fft(int n,int* x,int f){
	for(int i=0,j=0;i<n;++i){
		if(i<j)swap(x[i],x[j]); 
		for(int l=n>>1;(j^=l)<l;l>>=1);
	}
	for(int s=2;s<=n;s<<=1){
		int m=s>>1;
		int wn=pwr(G,(P-1)/s);
		if(f==-1)wn=pwr(wn,P-2);
		for(int j=0;j<n;j+=s){
			int w=1;
			lop(k,0,m){
				int z=mul(x[j+m+k],w);
				x[j+m+k]=sub(x[j+k],z);
				x[j+k]=add(x[j+k],z);
				w=mul(w,wn);
			}
		}
	}
	if(f==-1){
		int y=pwr(n,P-2);
		lop(i,0,n)x[i]=mul(x[i],y);
	}
}

void mul(int n,int *a,int m,int *b,int *c){
	static int p,A[N],B[N];
	for(p=1;p<n+m-1;p<<=1);
	lop(i,0,p)A[i]=B[i]=0;
	lop(i,0,n)A[i]=a[i];
	lop(i,0,m)B[i]=b[i];
	fft(p,A,1),fft(p,B,1);
	lop(i,0,p)A[i]=mul(A[i],B[i]);
	fft(p,A,-1);
	lop(i,0,n+m-1)c[i]=A[i];
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%s%s",A,B); 
	n=strlen(A); 
	lop(i,0,n){
		if(A[i]!=B[i])++X;
		if(A[i]=='1'&&B[i]=='1')++Y;
	}
	X/=2;
	fac[0]=1; rep(i,1,n)fac[i]=mul(fac[i-1],i); 
	inv[1]=1; rep(i,2,n)inv[i]=mul(P-P/i,inv[P%i]);
	inv[0]=1; rep(i,1,n)inv[i]=mul(inv[i-1],inv[i]); 
	f[0]=1;
	rep(k,0,Y)tr[k]=inv[k+1];
	for(int k=X;k;k>>=1,mul(Y+1,tr,Y+1,tr,tr)){
		if(k&1)mul(Y+1,f,Y+1,tr,f);
	}
	rep(fre,0,Y){
		int z=mul(fac[X],mul(fac[Y],mul(fac[X+Y],f[Y-fre])));
		ans=add(ans,z);  
	}
	printf("%d\n",ans); 
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  ll ans = 700 + 100 * count(s.begin(), s.end(), 'o');
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3540
using System;
using System.Linq;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            var count = new[] { 0, 0, 0, 0, 0 };
            foreach(var c in Console.ReadLine()) {
                count[c == 'K' ? 0 : c == 'U' ? 1 : c == 'P' ? 2 : c == 'C' ? 3 : 4] += 1;
            }
            Console.WriteLine(count.Take(4).Min());
        }
    }
}

Measured memory_bytes: 20152
#include <stdio.h>
#define N 100

int main(){

  int temp;
  int n;
  int i, j;
  int A[N];
  int count;

  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);    
  }
  
 count=0; 
  /* bubble_sort */
  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      if(A[j-1] > A[j]){ /* 前の要素の方が大きかったら交換 */
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	count++;
      }
    }
  }
  
  for(i=0; i<n; i++){
    if(i == n - 1) printf("%d", A[i]);
    else printf("%d ", A[i]);
  }
  
  printf("\n");
  printf("%d", count);
  printf("\n");
  
  return 0;
}



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

int main(){
  int N;
  int M;
  cin >> N >> M;
  int a;
  int takahashi=0;
  for(int i=0; i<M; i++){
    cin >> a;
    takahashi = takahashi + a;
  }
  int ans = N - takahashi;
  if(ans < 0){
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	if(a+b==c||a+c==b||b+c==a){cout<<"Yes";}
	else{cout<<"No";}
} 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int, int> pll;
bool visited[100005];
const int max_N = 1e5 + 10;

int a, b, c, d, e, k;


int main(void) {
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;


	int M=10;
	if (a % 10 != 0) M = min(M, a % 10);
	if (b % 10 != 0) M = min(M, b % 10);
	if (c % 10 != 0) M = min(M, c % 10);
	if (d % 10 != 0) M = min(M, d % 10);
	if (e % 10 != 0) M = min(M, e % 10);



	while (a % 10 != 0) {
		a++;
	}
	while (b % 10 != 0) {
		b++;
	}
	while (c % 10 != 0) {
		c++;
	}
	while (d % 10 != 0) {
		d++;
	}
	while (e % 10 != 0) {
		e++;
	}

	cout << a+b+c+d+e-(10-M) << endl;



	return 0;
}


Measured memory_bytes: 256
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n=int(input())
c=collections.Counter(prime_factorize(n))
d=list(c.values())
s=0
x=1
for i in d:
  while i>=x*(x+1)/2:
    s+=1
    x+=1
  x=1
print(s)

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str,one=".,!? ",ans,seven="pqrswxyz";
		cin>>str;
		for(int j=0,co=0,num=0;j<=str.size();j++){
			if(num==str[j]-'0')co++;
			else{
				if(num==1)ans+=one[co%5];
				else if(num==7||num==9)ans+=seven[co%4+num/9*4];
				else if(num==8)ans+=co%3+'t';
				else if(num>1)ans+=co%3+'a'+3*(num-2);
				co=0;
				num=str[j]-'0';
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b) <= d && abs(b-c)<=d)){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int out[300000] = {};
int main() {
	int k, n; cin >> k >> n;
	if (k == 1) {
		rep(i, (n + 1) / 2) {
			if (i > 0)cout << " ";
			cout << 1;
		}
		cout << endl;
	}
	else if(k%2==0){
		cout << k / 2;
		rep(i, n - 1) {
			cout << " " << k;
		}
		cout << endl;
	}
	else {
		rep(i, n) {
			out[i] = (k + 1) / 2;
		}
		int t = n / 2;
		rep(a, t) {
			if (out[n-1])out[n-1]--;
			else {
				int chk;
				per(i, n) {
					if (out[i]) {
						chk = i; break;
					}
				}
				if (out[chk] > 1) {
					out[chk]--;
					Rep(i, chk + 1, n) {
						out[i] = k;
					}
				}
				else {
					out[chk] = 0;
				}
			}
		}
		rep(i, n) {
			if (!out[i])continue;
			if (i > 0)cout << " ";
			cout << out[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  N = N % 500;
  N = N - A;

  if (N <= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define INF (1LL<<50LL)

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

int main() {
	int v,e,r;
	cin >> v >> e >> r;
	G graph(v);
	for(int i = 0; i < e; i++) {
		int s,t,d;
		cin >> s >> t >> d;
		P p1(t,d);
		//P p2(s,d);
		graph[s].push_back(p1);
		//graph[t].push_back(p2);
	}
	vector<ll> ds(v,INF);
	vector<bool> arrived(v);
	priority_queue<P,vector<P>,greater<P> > q;
	P start(0,r);
	ds[r] = 0;
	q.push(start);
	while(!q.empty()) {
		P p = q.top();	q.pop();
		ll cost = p.first;
		ll now = p.second;
		if(arrived[now]) continue;
		arrived[now] = true;
		//cout << now << "," << cost << endl;
		for(int i = 0; i < graph[now].size(); i++) {
			P e = graph[now][i];
			ll next = e.first;
			ll d = e.second;
			ll new_cost = cost+d;
			if(ds[next]>new_cost) {
				ds[next] = new_cost;
				P new_edge(new_cost,next);
				q.push(new_edge);
			}
		}
	}
	for(int i = 0; i < v; i++) {
		if(ds[i] == INF) cout << "INF" << endl;
		else cout << ds[i] << endl;
	}
}



Measured memory_bytes: 19388
import math
a,b,x=map(int,input().split())
t=0
if x>=a*a*b/2:
  c=2*x/a/a-b
  t=math.degrees(math.atan((b-c)/a))
else:
  c=2*x/a/b
  t=math.degrees(math.atan(b/c))


print(t)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int n,x2=0,x4=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]%2==0) x2++;
        if(a[i]%4==0) x4++;
    }
    x2-=x4;
    if(n/2 <= x4+x2/2) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) {
	return s == string(s.rbegin(), s.rend());
}

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

	int D0; cin>>D0;
	if(D0==0)
		dist[0]++;
	else {
		cout<<0<<endl;
		return 0;
	}

	for(int i=1; i<N; i++) {
		int D; cin>>D;
		dist[D]++;
	}

	if(dist[0]!=1) {
		cout<<0<<endl;
		return 0;
	}

	ll result=1LL;
	int reachPoint=1+dist[1];
	for(int i=1; reachPoint<N; i++) {
		for(int j=0; j<dist[i+1]; j++) {
			result*=dist[i];
			result%=998244353;
		}
		reachPoint+=dist[i+1];
	}

	cout<<result<<endl;
}


Measured memory_bytes: 640
def lcs_hs(s1, s2):
    from bisect import bisect_left

    s2 = s2[::-1]
    lis, result = [], 0
    append = lis.append

    for c in s1:
        i = s2.find(c)+1
        while i:
            j = bisect_left(lis, -i)
            if j >= result:
                append(-i)
                result += 1
            else:
                lis[j] = -i
            i = s2.find(c, i)+1

    return result


print(*(lcs_hs(input(), input()) for _ in [0]*int(input())), sep="\n")



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

#define int long long int
#define mod 1000000007

signed main()
{
    int n,i,k,g,j;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int dp[k+1];
    int psum[k+1]={0};
    for(i=0;i<n;i++) dp[i]=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<=k;j++)
        {
            if(j==0) {dp[j]=1;continue;}
            if(i==0) {
            if(j<=a[i]) dp[j]=1;
            else dp[j]=0;
            }
            else
            {
                dp[j]=psum[j];
                if(j-a[i]-1>=0) dp[j]=((dp[j]%mod)-(psum[j-a[i]-1]%mod) + mod)%mod;
            }
        }
        psum[0]=dp[0];
        for(j=1;j<=k;j++) psum[j]=((dp[j]%mod)+(psum[j-1]%mod))%mod;
    }
    cout<<dp[k]%mod;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] p = new int[N];
        for (int i = 1; i <= N; i++) {
            p[i-1] = scan.nextInt();
        }
        long answer = 0;
        for (int i = 1; i <= N; i++) {
            if (p[i-1] != i) {
                continue;
            }
            answer += 1;
            if (i < N) {
                p[i - 1] = p[i];
                p[i] = i;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 52128
N=int(input())
l=list(map(int,input().split()))
l[0]-=1

if N==1:
    print("Yes")
else:
    for i in range(N-1):
        if l[i]<l[i+1]:
            l[i+1]-=1
            continue
        elif l[i]>l[i+1]:
            print("No")
            break
        else:
            pass
    else:
        print("Yes")

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    vector<string> S(N);
    REP(i, N) cin >> S[i];

    string T;
    cin >> T;

    int bef = 0, aft = 0;
    REP(i, N) {
        string s1, s2;
        s1 = s2 = S[i];

        REP(j, s1.size()) {
            if(s1[j] == '?') s1[j] = 'z';
            if(s2[j] == '?') s2[j] = 'a';
        }
        if(s1 >= T) aft++;
        if(s2 <= T) bef++;
    }
    
    for(int i = N - aft + 1; i <= bef; i++) {
        cout << i << " ";
    }
    cout << bef + 1 << endl;
    
    return 0;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5;

ll n, a, b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0)
    {
        cout << (b - a) / 2;
    }
    else
    {
        cout << min(min((b - 1), n - a), min(a + (b - a - 1) / 2, n - b + 1 + (n - (a + n - b + 1)) / 2));
    }
    return 0;
}


Measured memory_bytes: 256
x = int(input())
flg = 0
while flg == 0:
    lo_flg = 1
    mx  = int(x**0.5)
    for i in range(2, mx+1):
        if x % i == 0:
            lo_flg = 0
            break
    flg = lo_flg
    if flg == 0:
        x+=1
print(x)


Measured memory_bytes: 38384
n,m,q = list(map(int,input().split()))
query = [list(map(int,input().split())) for _ in range(q)]
ans = 0

import itertools
for con in itertools.combinations_with_replacement(list(range(m)),n):
    tmp = 0
    for i in query:
        a,b,c,d = i
        if con[b-1] - con[a-1] == c:
            tmp += d
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int arr[3][3];
bool bingo[3][3];

int main(){
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++) cin>>arr[i][j];
	}
	int n;
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(arr[i][j]==a) bingo[i][j] = true;
			}
		}
	}
	
	bool bing = false;
	for(int i=0; i<3; i++){
		int ret = 0;
		int ret2 = 0;
		for(int j=0; j<3; j++){
			ret+=bingo[i][j];
			ret2+=bingo[j][i];
		}
		if(ret==3) bing = true;
		if(ret2==3) bing = true;
	}
	if((bingo[0][0]+bingo[1][1]+bingo[2][2])==3) bing = true;
	if((bingo[2][0]+bingo[1][1]+bingo[0][2])==3) bing = true;
	if(bing) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3628
N = input()
n = int(N[-1])

hon_list = [2, 4, 5, 7, 9]
pon_list = [0, 1, 6, 8]
bon_list = [3]

if n in hon_list:
  print('hon')
elif n in pon_list:
  print('pon')
elif n in bon_list:
  print('bon')
else:
  print('false')

Measured memory_bytes: 9184
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = s.substring(5,7);
    //System.out.println(t);
    if(t.compareTo("04")<=0){
      System.out.println("Heisei");
    }else{
      System.out.println("TBD");
    }
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>  
#define lli long long 
using namespace std; 
long long mod=1e9+7;
// lli power(lli x, lli y,lli m=mod) 
// {
//     lli res = 1;  
   
//     while (y > 0) 
//     { 
//         if (y & 1) 
//             res = (res*x)%m; 
//         y = y>>1; 
//         x = (x*x)%m;  
//     }
//     if(res<0)
//        res+=m; 
//     return res; 
// }
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
int main() 
{ 
    // fact[0]=1;
    // for(int i=1;i<=2000005;i++)fact[i]=(i*fact[i-1])%mod;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        long long a,b,c,d;cin>>a>>b>>c>>d;
        long long ans=a*c;
        ans=max(ans,a*d);
        ans=max(ans,b*c);
        ans=max(ans,b*d);
        cout<<ans<<"\n";
    }
    return 0; 
} 

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll h,a;
   cin>>h>>a;
   
   cout<<(h+a-1)/a;
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int n,m,c=0;
    int i;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&m);
        c=c^m;
    }
    if(c==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N=1e5+20;
int n,a[N];
long long s,odd,ans[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),s+=a[i];

	for(int i=1;i<n;i+=2) odd+=a[i];
	odd<<=1;
	ans[n]=s-odd;
	for(int i=n-1;i>=1;i--)
		ans[i]=2*a[i]-ans[i+1];
	for(int i=1;i<=n;i++) printf("%lld ",ans[i]);
}

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

long long int a[3][3] = { { 0, 0, 0 }, { 0, 1, 1 }, { 0, 1, 2 } };

long long int b[3][3] = { { 0, 1, 2 }, { 1, 1, 2 }, { 2, 2, 2 } };

pair< long long int, long long int > kansu( string s, long long int n, long long int p, long long int q, long long int r ) {

  long long int k = 1;
  bool f = false;
  bool c = 0;

  while( true ) {

    //    cout << "n = " << n << " : k = " << k << " : c = " << c << endl;

    if ( s[n] == ')' ) break;
    if ( s[n] == '0' ) {
      k = 0;
      if ( f == true ) {
	k = 2 - k;
	f = false;
      }
    }else if ( s[n] == '1' ) {
      k = 1;
      if ( f == true ) {
	k = 2 - k;
	f = false;
      }
    }else if ( s[n] == '2' ) {
      k = 2;
      if ( f == true ) {
	k = 2 - k;
	f = false;
      }
    }else if ( s[n] == 'P' ) {
      k = p;
      if ( f == true ) {
	k = 2 - k;
	f = false;
      }
    }else if ( s[n] == 'Q' ) {
      k = q;
      if ( f == true ) {
	k = 2 - k;
	f = false;
      }
    }else if ( s[n] == 'R' ) {
      k = r;
      if ( f == true ) {
	k = 2 - k;
	f = false;
      }
    }else if ( s[n] == '-' ) {
      if ( f == true ) {
	f = false;
      }else {
	f = true;
      }
    }else if ( s[n] == '*' ) {
      pair< long long int, long long int > w = kansu( s, n + 1, p, q, r );
      k = a[k][ w.first ];
      n = w.second;
      break;
    }else if ( s[n] == '+' ) {
      pair< long long int, long long int > w = kansu( s, n + 1, p, q, r );
      k = b[k][ w.first ];
      n = w.second;
      break;
    }else if ( s[n] == '(' ) {
      pair< long long int, long long int > w = kansu( s, n + 1, p, q, r );
      k = w.first;
      n = w.second;
      if ( f == true ) {
	k = 2 - k;
	f = false;
      }
    }
    n++;

  }

  return make_pair( k, n );

}

int main() {

  while( true ) {

    string s;
    cin >> s;

    if ( s == "." ) break;

    s = s + ")";

    long long int ans = 0;

    for ( long long int p = 0; p < 3; p++ ) {
      for ( long long int q = 0; q < 3; q++ ) {
	for ( long long int r = 0; r < 3; r++ ) {

	  if ( kansu( s, 0, p, q, r ).first == 2 ) ans++;

	}
      }
    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1204
using System;
//using System.Collections;
//using System.Collections.Generic;
using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
      while (true)
      {
        var s = Console.ReadLine().Split();
        if (s[0] == "0" && s[1] == "0") break;
        int H = int.Parse(s[0]);
        int W = int.Parse(s[1]);
        for (int i = 0; i < H; i++)
        {
          for (int j = 0; j < W; j++)
          {
            Console.Write("#");
          }
          Console.WriteLine();
        }
        Console.WriteLine();
      }
    }
  }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int s, k, cnt = 0;
  cin >> k >> s;

  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      if (0 <= s - i - j && s - i - j <= k) cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>k;
    rep(i,n){
        cin>>a;
        if(a>=k)ans++;
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int a[3], b = 0, c = 100;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
		if (a[i] > b)b = a[i];
		if (a[i] < c)c = a[i];
	}
	cout << b - c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_map>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

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

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

int main() {
	int N; cin >> N;
	map<string, int> mp;

	int m = 1;

	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		if (mp.find(s) == mp.end()) {
			mp.insert({s, 1});
		}
		else {
			mp[s]++;
			chmax(m, mp[s]);
		}
	}

	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->second == m) {
			cout << itr->first << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 25344
<?php
  
$group1 = [1,3,5,7,8,10,12];
$group2 = [4,6,9,11];

$items = explode(' ',trim(fgets(STDIN)));

$count1 = count(array_intersect($items,$group1));
$count2 = count(array_intersect($items,$group2));

echo $count1 == 2 || $count2 == 2 ? 'Yes' : 'No';

?>

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

#define pb push_back
#define mod 998244353
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, s;
int dp[4000][4000];
integer calc[4000][4000];


int solve(int idx, int sum) {
    if (sum > s) {
        return 0;
    }
    if (sum == s) {
        return n - idx + 1;
    }
    if (idx == n) {
        return 0;
    }
    if (calc[idx][sum] != -1) return dp[idx][sum];
    int ans = 0;
    if (sum == 0) {
        int tmp = solve(idx + 1, sum);
        if (tmp > 0) ans += tmp;
        ans %= mod;
        tmp = ((idx + 1) * solve(idx + 1, ar[idx])) % mod;
        if (tmp > 0) ans += tmp;
        ans %= mod;
    } else {
        int tmp = solve(idx + 1, sum);
        if (tmp > 0) ans += tmp;
        ans %= mod;
        tmp = solve(idx + 1, sum + ar[idx]);
        if (tmp > 0) ans += tmp;
        ans %= mod;
    }
    calc[idx][sum] = 1;
    return dp[idx][sum] = ans;
}

integer main() {
    ios_base::sync_with_stdio(false);


    cin >> n >> s;
    for (int i = 0; i < n; i++){
        cin >> ar[i];
    }
    memset(calc, -1, sizeof calc);
    cout << solve(0, 0) << endl;
//    cout << solve(0, 0) << endl;

}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	long long ans = 0;
	ans += min(a, c);
	c -= min(a, c);
	ans += 2 * min(b, c);
	int val = min(b, c);
	c -= val;
	b -= val;
	ans += b;
	if(c > 0) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
while(n=gets.to_i)>0
a=[b=[x=0,0]]
p=a*n
n.times{w=0;m=gets
n.times{|j|h,w=p[j][0]+1,w+1;m[j]==?*&&h=w=0
a[j]=[h,s=[h,w,p[j-1][1]+1].min]
x<s&&x=s}
p,a=a,[b]}
p x
end

Measured memory_bytes: 6120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s1=0,s2=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i+=2)
    {
       s1+=v[i]; 
    }
    for(int i=1;i<n;i+=2)
    {
        s2+=v[i];
    }
    cout<<abs(s1-s2)<<"\n";
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
 
int main() {
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9){
        cout << -1 << endl;
    }else{
        cout << a * b << endl;
    }
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = n-1; i >= (0); i--)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,W;
  cin>>n>>W;
  vector<ll> w(n),v(n);
  rep(i,n) cin>>w[i]>>v[i];
  ll dp[W+1];
  memset(dp,0,sizeof(dp));
  rep(i,n) Rep(j,W+1){
    if(j>=w[i]) dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
  }
  cout<<dp[W]<<endl;
}

Measured memory_bytes: 1024
S = input()

ans = 0
if S == "RRR":
    ans = 3
elif S[:2] == "RR" or S[1:] == "RR":
    ans = 2
elif S[0] == "R" or S[1] == "R" or S[2] == "R":
    ans = 1

print(ans)

Measured memory_bytes: 9004
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  }

}

Measured memory_bytes: 19436
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		PriorityQueue<Job> que1 = new PriorityQueue<>((x, y) -> x.day - y.day);
		PriorityQueue<Job> que2 = new PriorityQueue<>((x, y) -> y.s - x.s);
		for (int i = 0; i < n; i++) {
			que1.add(new Job(sc.nextInt(), sc.nextInt()));
		}
		long ans = 0;
		for (int i = 1; i <= m; i++) {
			while (!que1.isEmpty()) {
				if (que1.peek().day == i) {
					que2.add(que1.poll());
				} else {
					break;
				}
			}
			if (que2.isEmpty()) {
			} else {
				ans += que2.poll().s;
			}
		}
		System.out.println(ans);
	}
}

class Job {
	int day;
	int s;

	public Job(int day, int s) {
		this.day = day;
		this.s = s;
	}
}


Measured memory_bytes: 68120
#include <stdio.h>
#define MAX 100
#define INF 5000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int c[MAX];
int M[MAX][MAX];
int d[MAX];
int p[MAX];
int n;
void dijkstra(int);
void dijkstraInit();

int main(){
  int i,j;
  int k;
  int c;
  int u;
  int v;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INF;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }

  dijkstraInit();
  dijkstra(0);
  for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]==INF){
      d[i]=-1;
    }
    printf("%d\n",d[i]);
  }

  return 0;
}

void dijkstraInit(){
  int i;
  for(i=0;i<n;i++){
    c[i]=WHITE;
    d[i]=INF;
  }
}

void dijkstra(int s){
  int i=0;
  int u;
  int min;
  int k=0;
  
  d[s]=0;
  p[s]=-1;

  while(1){
    min=INF;
    for(i=0;i<n;i++){
      if(c[i]!=BLACK && d[i]<min){
	min=d[i];
	u=i;
      }
    }

    if(min==INF) break;
    
    c[u]=BLACK;

    for(i=0;i<n;i++){
      if(c[i]!=BLACK && M[u][i]!=INF){
	if(d[u]+M[u][i] < d[i]){
	  d[i]=d[u]+M[u][i];
	  p[i]=u;
	  c[i]=GRAY;
	  k=i;
	}
      }
    }
  }
}



Measured memory_bytes: 2108
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
i = 1
ans = a[0]
c = 1
while c < n - 1:
    k = min(2, n - 1 - c)
    c += k
    ans += a[i] * k
    i += 1
print(ans)


Measured memory_bytes: 31612
table=[[[0]*10 for i in range (3)]for k in range (4)]
n=int(input())

for i in range(n):
    house_id,floor,room,add=map(int,input().split())
    table[house_id-1][floor-1][room-1]+=add
    
for i in range(4):
    if i!=0:
        print("#"*20)
    
    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end="")
        print()


Measured memory_bytes: 5628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int N,M;
int P[1000];
int main()
{
	while(true){
		scanf("%d%d",&N,&M);
		if(N==0&M==0)break;
		for(int i=0;i<N;i++)scanf("%d",&P[i]);
		sort(P,P+N);reverse(P,P+N);
		int ans=0;
		for(int i=0;i<N;i++){
			if(i%M!=M-1)ans+=P[i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1208