akhauriyash/Code-Regression huggingface dataset:
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	static class State implements Comparable<State>{
		int v, cost1, cost2, ticket, count;
		State(int v, int cost1, int cost2, int ticket, int count){
			this.v=v;
			this.cost1=cost1;
			this.cost2=cost2;
			this.ticket=ticket;
			this.count=count;
		}
		public int compareTo(State s) {
			if(this.cost2==s.cost2) return this.cost1-s.cost1;
			return this.cost2-s.cost2;
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int n=sc.nextInt();
				int m=sc.nextInt();
				if(n+m==0) break;
				int[][] edge=new int[n+1][n+1];
				int[][][] dis=new int[n+1][2][2];//頂点と残りのチケット＝最小コスト
				for(int i=0; i<m; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					int c=sc.nextInt();
					edge[a][b]=edge[b][a]=c;
				}
				PriorityQueue<State> pq=new PriorityQueue<>();
				int INF=Integer.MAX_VALUE;
				for(int i=1; i<=n; i++) {
					dis[i][1][1]=dis[i][1][0]=dis[i][0][0]=INF;
				}
				pq.add(new State(1, 0, 0, 1, 0));
				while(!pq.isEmpty()) {
					State s=pq.poll();
					if(dis[s.v][s.ticket][s.count]<=s.cost1) continue;
					dis[s.v][s.ticket][s.count]=s.cost1;
					//if(s.v==n) break;
					for(int i=1; i<=n; i++) {
						if(edge[s.v][i]==0) continue;
						if(s.ticket==1 && s.count==0) {
							pq.add(new State(i, s.cost1+edge[s.v][i], s.cost2, s.ticket, s.count+1));
							pq.add(new State(i, s.cost1+edge[s.v][i], s.cost1+edge[s.v][i], s.ticket, s.count));
						}
						else if(s.ticket==1 && s.count==1) {
							pq.add(new State(i, s.cost2, s.cost2, 0, 0));
						}
						else {
							pq.add(new State(i, s.cost1+edge[s.v][i], s.cost1+edge[s.v][i], s.ticket, s.count));
						}
					}
				}
				System.out.println(Math.min(dis[n][1][1], Math.min(dis[n][0][0], dis[n][1][0])));
				
			}

		}
	}
}


Measured memory_bytes: 45328
n,m = map(int,input().split())
A = list()
for i in range(m):
    a = int(input())
    A.append(a)
dp = [0]*(n+1)
dp[0] = 1
if 1 in A:
  del A[0]
else:
  dp[1] = 1
for i in range(2,n+1):
    if len(A) != 0:        
        if i != A[0]:
            dp[i] = dp[i-2] + dp[i-1]
            dp[i] = dp[i]%1000000007
        else:
          del A[0]
    else:
        dp[i] = dp[i-2] + dp[i-1]
        dp[i] = dp[i]%1000000007
print(dp[-1]%1000000007)


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

using namespace std;

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

  int n;
  cin >> n;
  unordered_set<int> cnts;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (cnts.find(a) == cnts.end()) {
      cnts.insert(a);
    } else {
      cnts.erase(a);
    }
  }
  cout << cnts.size() << "\n";
}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=100010;
int n,m,k;
struct node{
    int tot=1;
    int edge[MAXN*2],nxt[MAXN*2],hd[MAXN];
    inline void add_edge(int u,int v)
    {
        edge[tot]=v,nxt[tot]=hd[u],hd[u]=tot++;
    }
}g1,g2;
int f[MAXN];
int find(int x)
{
    if(f[x]==x) return f[x];
    return f[x]=find(f[x]);
}
inline void Union(int u,int v)
{
    u=find(u),v=find(v);
    if(u!=v) f[u]=v;
}
bool book[MAXN];
vector<int> d[MAXN];
int sum[MAXN];
int main()
{
    read(n),read(m),read(k);
    for(register int i=1;i<=n;i++) f[i]=i;
    for(register int i=1;i<=m;i++)
    {
        int u,v;
        read(u),read(v);
        g1.add_edge(u,v),g1.add_edge(v,u);
        Union(u,v);
    }
    for(register int i=1;i<=k;i++)
    {
        int u,v;
        read(u),read(v);
        g2.add_edge(u,v),g2.add_edge(v,u);
    }
    for(register int i=1;i<=n;i++) d[find(i)].push_back(i);
    for(register int i=1;i<=n;i++)
    {
        int tot=0;
        for(vector<int>::iterator it=d[i].begin();it!=d[i].end();it++) book[*it]=1,tot++;
        for(vector<int>::iterator it=d[i].begin();it!=d[i].end();it++)
        {
            int x=*it;
            int cnt=0;
            for(int j=g1.hd[x];j;j=g1.nxt[j])
            if(book[g1.edge[j]]) cnt++;
            for(int j=g2.hd[x];j;j=g2.nxt[j])
            if(book[g2.edge[j]]) cnt++;
            sum[x]=tot-cnt-1;
        }
        for(vector<int>::iterator it=d[i].begin();it!=d[i].end();it++) book[*it]=0;
    }
    for(register int i=1;i<=n;i++) write(sum[i]),putchar(' ');
    putchar('\n');
	return 0;
}


Measured memory_bytes: 10624
s=list(input())
n=len(s)
s1=s[0:int((n-1)/2)]
s2=s[int((n+3)/2)-1:n]
if s==list(reversed(s)) and s1==list(reversed(s1)) and s2==list(reversed(s2)):
    print('Yes')
else:
    print('No')

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

const int N = 900005;
const int mod = 1e9 + 7;

#define int long long

int n, m, k, res;
int prd[N], inv[N], pw3[N], f[N];

int C(int k, int n) {
	if (n < k || n < 0 || k < 0) return 0;
	return prd[n] * inv[k] % mod * inv[n - k] % mod; 
}

int pw(int x, int y) {
	if (!y) return 1;
	int ret = pw(x, y >> 1); ret = ret * ret % mod;
	if (y & 1) ret = ret * x % mod; return ret;
}

void prepare() {
	prd[0] = 1;
	for (int i = 1; i < N; ++i) prd[i] = prd[i - 1] * i % mod;
	inv[N - 1] = pw(prd[N - 1], mod - 2);
	for (int i = N - 1; i >= 1; --i) inv[i - 1] = inv[i] * i % mod;
	pw3[0] = 1;
	for (int i = 1; i < N; ++i) pw3[i] = 3LL * pw3[i - 1] % mod;
}

signed main() {
	cin >> n >> m >> k;
	prepare();
	f[0] = 1; 
	int L = 0, R = 0;
	for (int i = 1; i <= m + k; ++i) {
		int l = max(0LL, i - k), r = min(m, i);
		f[i] = f[i - 1] * 2 + C(L - 1, i - 1) - C(R, i - 1);
		if (l == L + 1) f[i] -= C(l - 1, i);
		if (r == R + 1) f[i] += C(r, i);
		f[i] %= mod; if (f[i] < 0) f[i] += mod;
		L = l, R = r;
		// cout << f[i] << ' ' << l << ' ' << r << '\n';
	}
	for (int i = 0; i <= m + k; ++i) {
		res = (res + f[i] * pw3[m + k - i] % mod * C(i, n - 1 + i)) % mod;
	}
	cout << res;
}

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

#define LEN 100005

typedef struct pp
{
	char chName[10];
	int nTime;
} Pair;

Pair PIn[LEN];
int nHead, nTail, n;

Pair dequeue()
{
	Pair PTemp = PIn[nHead];
	nHead = (nHead + 1) % (n + 2);
	return PTemp;
}

void enqueue(Pair in)
{
	PIn[nTail] = in;
	nTail = (nTail + 1) % (n + 2);
}

int main()
{
	int q, nCT = 0;
	Pair PTemp;
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; ++i)
	{
		scanf("%s %d", PIn[i].chName, &PIn[i].nTime);
	}
	nHead = 0;
	nTail = n;
	while (nHead != nTail)
	{
		PTemp = dequeue();
		if (PTemp.nTime <= q)
		{
			nCT += PTemp.nTime;
			printf("%s %d\n", PTemp.chName, nCT);
		}
		else
		{
			nCT += q;
			PTemp.nTime -= q;
			enqueue(PTemp);
		}
	}
	return 0;
}


Measured memory_bytes: 2512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

#define pi 3.141592653589793238462643

int main()
{
	double a,b,h,m;
	cin >> a >> b >> h >> m;
	double the=360/60*m;
	double the2=360*(h*60+m)/(12*60);
	the-=the2;
	if(the<0)the=(-1)*the;

	double ans=a*a+b*b-2*a*b*cos(the*pi/180);
	cout << fixed << setprecision(10) << sqrt(ans) << endl;



}

Measured memory_bytes: 3624
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑



ll a, b, ans = INF;
int main() {
	cin >> a >> b;

	if (b - a >= 2019) { cout << 0 << endl; return 0; }
	a %= 2019; b %= 2019;
	for (int i = a; i < b; ++i) {
		for (int j = a + 1; j <= b; ++j) {
			ans = min(ans, (ll)(i*j) % 2019);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;
const int mod=1e9+7;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;cin >> n;
    string s,ans,res,res2; cin >> s;
    if(n%2==1) ans="No";
    rep(i,0,s.size()/2) res+=s[i];
    rep(i,s.size()/2,s.size()) res2+=s[i];
    if(res==res2) ans="Yes";
    else ans="No";   
    cout << ans << endl;
 } 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int Price(int x, int y, int b, int p) {
	int ret = x * b + y * p;
	if (b >= 5 && p >= 2) ret *= 0.8;
	return ret;
}

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		int x, y, b, p; cin >> x >> y >> b >> p;
		int price = Price(x, y, b, p);
		if (b < 5 && p < 2) price = min(price, Price(x, y, 5, 2));
		else if (b < 5) price = min(price, Price(x, y, 5, p));
		else if (p < 2) price = min(price, Price(x, y, b, 2));
		cout << price << endl;
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
	

	
	int min = 0;
	int a, b, m;
	int a_min, b_min;
	cin >> a >> b >> m;
	auto aa = vector<int>(a);
	auto bb = vector<int>(b);
	auto cc = vector<int>(m);
	auto xx = vector<int>(m);
	auto yy = vector<int>(m);

	cin >> aa[0];
	a_min = aa[0];
	for (int i = 1; i < a; i++)
	{
		cin >> aa[i];
		if (aa[i] < a_min)
		{
			a_min = aa[i];
		}
	}
	cin >> bb[0];
	b_min = bb[0];
	for (int i = 1; i < b; i++)
	{
		cin >> bb[i];
		if (bb[i] < b_min)
		{
			b_min = bb[i];
		}
	}
	for (int i = 0; i < m; i++)
	{
		cin >> xx[i] >> yy[i] >> cc[i];
	}

	min = a_min + b_min;

	for (int i = 0; i < m; i++)
	{
		if (aa[xx[i] - 1] + bb[yy[i] - 1] - cc[i] < min)
		{
			min = aa[xx[i] - 1] + bb[yy[i] - 1] - cc[i];
		}
	}

	cout << min << endl;
	
	return 0;

}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main{

	final String[] WORD1 = {"lu","ru","ld","rd"};
	final String[] WORD2 = {"ru","lu","rd","ld"};
	final int[] VALUE1 = {1,1,0,0};
	final int[] VALUE2 = {0,0,1,1};

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

	void run() {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int index = 0; int count = 0; int state = 1;
			index = sc.nextInt();
			
			if (index == 0) {
				break;
			} else if (index == 1) {
				for(int i = 0; i < index; i++){
					String str = sc.next();
				}
				System.out.println(count);
				continue;
			}
			
			String[] a = new String[index];
			String str = "";
			for (int i = 0; i < index; i++) {
				a[i] = sc.next();
			}

			for(int i = 0; i < index - 1; i++){
				for(int j = 0; j < 4; j++){
					if (a[i].equals(WORD1[j]) && state == VALUE1[j]) {
						if(a[i + 1].equals(WORD2[j])) {
							count++;
							state = VALUE2[j];
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 27064
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs( );
void dfs_visit( int );
int M[N][N],color[N];
int n,d[N],f[N],timelap=0;

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

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      M[i][j] = 0;
    }
  }


  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d",&u,&k);
    u--;

    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;

      M[u][v] = 1;
    }
  }

  dfs();
 
  return 0;
}


void dfs( ){
  int u;

  for( u = 0 ; u < n ; u++ ){
    color[u] = WHITE;
  }

  for( u = 0 ; u < n ; u++ ){
    if( color[u] == WHITE ) dfs_visit(u);
  }

  for( u = 0 ; u < n ; u++ ){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}


void dfs_visit( int u ){
  int v;

  color[u] = GRAY;
  d[u] = ++timelap;

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

    if( M[u][v] == 0 ) continue;

    if( color[v] == WHITE ) dfs_visit(v);
  }

  color[u] = BLACK;
  f[u] = ++timelap;
}

 

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    int dx = x2-x1, dy = y2-y1;
    cosp(x2-dy);cosp(y2+dx);cosp(x1-dy);cosp(y1+dx);printf("\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;
using P = pair<Int, Int>;
constexpr Int mod = 998244353;

template <class M> class segment_tree{
public:
	typedef typename M::value_type value_type;
	size_t n;
	vector<value_type> v;
	value_type e = M::unit();
	segment_tree(size_t size){
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		for(size_t i=1; i<n+size; ++i) v[i] = e;
	}
	segment_tree(vector<value_type> a){
		size_t size = a.size();
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		for(size_t i=0; i<size; ++i) v[n+i] = a[i];
		for(size_t i=n-1; i>0; --i) v[i] = M::operate(v[2*i], v[2*i+1]);
	}
	void point_update(size_t k, value_type val){
		k += n;
		v[k] = val;
		k >>= 1;
		while(k > 0){
			v[k] = M::operate(v[2*k], v[2*k+1]);
			k >>= 1;
		}
	}
	void point_operate(size_t k, value_type lval){
		k += n;
		v[k] = M::operate(lval, v[k]);
		k >>= 1;
		while(k > 0){
			v[k] = M::operate(v[2*k], v[2*k+1]);
			k >>= 1;
		}
	}
	value_type range_get(size_t l, size_t r){ // [l, r)
		value_type lres = e;
		value_type rres = e;
		l += n;
		r += n;
		while(l < r){
			if(l & 1){
				lres = M::operate(lres, v[l]);
				++l;
			}
			if(r & 1){
				--r;
				rres = M::operate(v[r], rres);
			}
			l >>= 1;
			r >>= 1;
		}
		return M::operate(lres, rres);
	}
	value_type operator[](size_t k){
		return v[k+n];
	}
};
struct plus_monoid{
	using value_type = Int;
	static value_type unit(){
		return 0;
	}
	static value_type operate(value_type l, value_type r){
		return l + r;
	}
};
Int powmod(Int a, Int n){
	Int res = 1;
	for(; n>0; n>>=1){
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}
vector<Int> s = {6, 7, 9, 11, 13, 14, 15};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<P> v(n);
	for(auto &i:v) cin >> i.first >> i.second;
	vector<Int> xs, ys;
	for(auto i:v){
		xs.push_back(i.first);
		ys.push_back(i.second);
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	ys.erase(unique(ys.begin(), ys.end()), ys.end());
	for(auto &i:v){
		i.first = lower_bound(xs.begin(), xs.end(), i.first)-xs.begin();
		i.second = lower_bound(ys.begin(), ys.end(), i.second)-ys.begin();
	}
//	for(Int i=0; i<n; ++i)
//		cout << v[i].first << " " << v[i].second << "\n";
	sort(v.begin(), v.end());
	Int ans = n * powmod(2, n-1) % mod;
	segment_tree<plus_monoid> d(n), u(vector<Int>(n, 1));
//	cout << ans << "\n";
	for(Int i=0; i<n; ++i){
		Int w[4];
		w[0] = d.range_get(0, v[i].second);
		w[3] = u.range_get(v[i].second+1, n);
		w[1] = i - w[0];
		w[2] = n-i-1 - w[3];
//		cout << i << "\n";
//		cout << w[0] << " " << w[1] << " " << w[2] << " " << w[3] << "\n";
		for(auto j:s){
			Int tmp = 1;
			for(Int k=0; k<4; ++k)
				if((j>>k) & 1)
					tmp = tmp * (powmod(2, w[k]) + mod - 1) % mod;
			ans = (ans + tmp) % mod;
		}
		d.point_operate(v[i].second, 1);
		u.point_operate(v[i].second, -1);
//		cout << i << " " << ans << "\n";
	}
	cout << ans << "\n";
}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
  	if(a>= 10 || b>=10) OUT("-1");
  	else OUT(a*b);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const long long  mod = 1000000007;


int main(){
  int h,w;
  cin >> h >> w;
  map<char,int> mp;

  rep(i,h){
    rep(i,w){
      char c;
      cin >> c;
      mp[c]++;
      mp[c] %= 4;
    }
  }

    int cnt2 = 0;
    int cnt13 = 0;
    for(auto p : mp){
      if(p.second == 2) cnt2++;
      if(p.second == 1 || p.second == 3) cnt13++;
    }

  if(h%2==0 && w%2==0) {
    if(cnt2>0 || cnt13>0){
      cout << "No" << endl;
      return 0;
    }
  }

  else if(h%2 == 1 && w%2 == 1){
    if(cnt2 > (w/2+h/2) || cnt13 > 1){
      cout << "No" << endl;
      return 0;
    }
  }

  else{
    if(w%2 != 0) swap(w,h);
    if(cnt2>w/2 || cnt13>0){
      cout <<"No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   ll a;
   double b;
   cin >> a >> b;
   // ?for(int i=0;i<10;i+?+){
   ll c = (b*(100.1));
  // cout << c << '\n';
   ll ans = (c*a)/100;
   cout << ans << '\n';
 
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


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

int main() {

	ll n; cin >> n;
	map<ll, ll> mp;
	for (ll i = 0; i < n; i++) {
		ll a; cin >> a;
		mp[a]++;
	}
	ll squareLength = -1;
	ll rectangleFirst = -1;
	ll rectangleSecond = -1;
	for (auto u : mp) {
		if (4 <= u.second) {
			squareLength = max(squareLength, u.first);
			rectangleSecond = max(rectangleSecond, u.first);
			rectangleFirst = max(rectangleFirst, u.first);
		}
		else if (2 <= u.second) {
			rectangleSecond = rectangleFirst;
			rectangleFirst = max(rectangleFirst, u.first);			
		}
	}
	ll ans;
	if (squareLength == -1) {
		if (rectangleFirst == -1 || rectangleSecond == -1) ans = 0;
		else ans = rectangleFirst * rectangleSecond;
	}
	else {
		if (rectangleFirst == -1 || rectangleSecond == -1) {
			ans = squareLength * squareLength;
		}
		else {
			ans = max(squareLength * squareLength, rectangleFirst * rectangleSecond);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) cin >> d[i];
    sort(d.begin(), d.end());
    int mid = n / 2;
    int dis = d[mid] - d[mid - 1];
    cout << dis << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
ll f[105];
f[0]=2;
f[1]=1;
rep(i,2,n)
{
	f[i]=f[i-1]+f[i-2];
}
ol(f[n]);
return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <cmath>

int main() {
  int A, B;
  std::cin >> A >> B;
  const auto MAX = std::max(A, B);
  int K;
  for(int i = 0; i < MAX; ++i) {
    if(std::abs(A-i) == std::abs(B-i)) {
      K = i;
      break;
    }
  }
  if(K < MAX) { std::cout << K << std::endl; }
  else { std::cout << "IMPOSSIBLE" << std::endl; }
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N, P = map(int,input().split())
S = list(input())

if P == 5:
    ans = 0
    for i in range(N):
        if S[i] == '5' or S[i] == '0':
            ans += i+1
elif P == 2:
    ans = 0
    for i in range(N):
        if int(S[i]) % 2 == 0:
            ans += i+1
else:
    M = defaultdict(int)
    before = 0
    S = S[::-1]
    for i in range(N):
        now = (int(S[i])*(pow(10, i+1, P)) + before) % P
        before = now
        M[now] += 1
    M[0] += 1
    ans = 0
    for value in M.values():
        ans += value*(value-1)//2
print(ans)

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M;
signed main() {
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}


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

int W, H, m[1000][1000];
int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1}, dy[] = {1, 1, 1, 0, -1, -1, -1, 0};


int main()
{
  cin >> H >> W;
  queue<int> up1, up2, bks;
  for(int y = 0; y < H; y++)
  {
    for(int x = 0; x < W; x++)
    {
      char c;
      cin >> c;
      if(c == '.')
      {
        m[y][x] = -1;
      }
      else
      {
        m[y][x] = c - '0';
        up1.push(x);
        up1.push(y);
      }
    }
  }
  int ans = 0;
  while(!(up1.empty() && up2.empty()))
  {
    queue<int> *upp1, *upp2;
    if(up1.empty())
    {
      upp2 = &up1;
      upp1 = &up2;
    }
    else
    {
      upp1 = &up1;
      upp2 = &up2;
    }
    while(!upp1->empty())
    {
      int x = upp1->front(); upp1->pop();
      int y = upp1->front(); upp1->pop();
      if(m[y][x] == -1)
        continue;
      int c = 0;
      for(int i = 0; i < 8; i++)
      {
        int tx = x + dx[i], ty = y + dy[i];
        if(m[ty][tx] == -1)
          c++;
      }
      if(c < m[y][x])
        continue;
      bks.push(x);
      bks.push(y);
    }
    if(bks.empty())
      break;
    while(!bks.empty())
    {
      int x = bks.front(); bks.pop();
      int y = bks.front(); bks.pop();
      if(m[y][x] == -1)
        continue;
      m[y][x] = -1;
      for(int i = 0; i < 8; i++)
      {
        int tx = x + dx[i], ty = y + dy[i];
        if(m[ty][tx] != -1)
        {
          upp2->push(tx);
          upp2->push(ty);
        }
      }
    }

    ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 13060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
typedef long long ll;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

typedef vector<int> vi;

int main() {
    int M,N;
    while(cin>>M>>N && M){
        vi P(M),C(N),E(N);
        rep(i,M)cin>>P[i];
        rep(i,N)cin>>C[i]>>E[i];
        sort(all(P));
        P.insert(P.begin(), 0);
        vi sum(M+1);
        rep(i,M) sum[i+1]=sum[i]+P[i+1];
        static int dp[555][11111];
        memset(dp,0,sizeof(dp));
        rep(j,N){
            rep(i,M){
                dp[j+1][i] = max(dp[j+1][i], dp[j][i]);
                int x = min<int>(i + C[j], M);
                dp[j+1][x] = max(dp[j+1][x], dp[j][i] + sum[x] - sum[i] - E[j]);
            }
        }
        int ans=0;
        rep(i,555)rep(j,11111)ans=max(ans,dp[i][j]);
        cout << ans << endl;
    }
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if(A >= K){
    cout << K << endl;
  }
  else if(A + B >= K && A < K){
    cout << A << endl;
  }
  else{
    cout << A - (K - (A + B)) << endl;
  }
}


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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    map<string,int> m;
    int n,mx=1; string s;

    cin>>n;
    while (n--) {
        cin>>s;
        if (m.count(s))
            mx = max(mx, ++((m.find(s))->second));
        else
            m.emplace(s,1);
    }

    cerr<<endl;
    for (auto &x:m) {
        if (x.second==mx)
        cout<<(x.first)<<endl;
    }
}


Measured memory_bytes: 23808
#include <stdio.h>
#include <string.h>
int main(void) {
  int K;
  char S[101];
  scanf("%d", &K);
  scanf("%s", S);
  int len = strlen(S);

  if (len <= K) {
    printf("%s\n", S);
  } else {
    for (int i = 0; i < K; i++) {
      printf("%c", S[i]);
    }
    printf("...\n");
  }
  return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
int kind[5] = {' ','A','C','G','T'};

vector<int>hash[2500000];

int convertion(string s){
  int d = 1;
  int sum = 0;
  for(int i = s.size() - 1;i >= 0;i--){
    for(int j = 1;j < 5;j++){
      if(kind[j] == s[i]){sum += d * j;break;}
    }
    d *= 5;
  }
  return sum;
}

int main(){
  string q,s;
  int n;
  cin >> n;
  while(n--){
    cin >> q >> s;
    if(q == "insert"){
      int sum = convertion(s);
      hash[sum / 100].push_back(sum);
    }
    if(q == "find"){
      int sum = convertion(s);
      bool flag = false;
      for(int i = 0;i < hash[sum / 100].size();i++){
	if(hash[sum / 100][i] == sum){cout << "yes" << endl;flag = true;break;}
      }
      if(!flag)cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 63584
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}




int main(void) {
  ll N, K;
  cin >> N >> K;
  ll x[MAX];
  ll i;
  
  for(i=0; i<N; i++) {
    cin >> x[i];
  }
  
  ll ans=INF;
  for(i=0; i<N-K+1; i++) {
    
    if(x[i]>0) {
      chmin(ans, x[i+K-1]);
    }else if(x[i+K-1]<0) {
      chmin(ans, abs(x[i]));
    }else {
      chmin(ans, abs(x[i])*2+x[i+K-1]);
      chmin(ans, abs(x[i])+x[i+K-1]*2);
    }
    
  }
  
  pt(ans);
}


Measured memory_bytes: 1024
from bisect import bisect_right

N,D,A=list(map(int,input().split()))
monsters=[list(map(int,input().split())) for _ in range(N)]

monsters.sort(key=lambda x: x[0])
xlst=[x for x,_ in monsters]

delta=[0]*(N+1)
csum=0

ans=0

for i in range(N):
    xi,hi=monsters[i]
    csum+=delta[i]
    hi-=csum

    if hi<=0:
        continue

    cnt=(hi+A-1)//A
    ans+=cnt

    csum+=A*cnt
    right=bisect_right(xlst,xi+2*D)
    delta[right]-=A*cnt

print(ans)

Measured memory_bytes: 129612
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 100005

//#define debug_printf printf
#define debug_printf(...) {}

int n;
int A[MAX_N];

int main()
{
  int i;
  pair<int, int> p[MAX_N+5];
  int ans = 0;

  scanf("%d", &n);
  for (i=1; i<=n; i++) {
    scanf("%d", &A[i]);
    p[i] = make_pair(A[i],i);
  }
  sort(p+1, p+n+1);

  for (i=1; i<=n; i++) {
    debug_printf("%d %d %d\n", i, p[i].first, p[i].second);
    if ((p[i].second % 2) != (i % 2)) {
      ans++;
    }
  }
  printf("%d\n", ans/2);

  return 0;
}


Measured memory_bytes: 2880
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

const int mod = 1000000007;
int N,h[200200],a[200200]; long long B[200200];

long long out(int x)
{
	long long r = 0;
	while (x){
		r = max(r,B[x]);
		x -= x & (-x);
	}
	return r;
}

void in(int x, long long p)
{
	while (x <= N){
		B[x] = max(B[x], p);
		x += x & (-x);
	}
}

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<=N;i++) scanf ("%d",&h[i]);
	for (int i=1;i<=N;i++) scanf ("%d",&a[i]);
	for (int i=1;i<=N;i++){
		long long u = out(h[i]) + a[i];
		in(h[i],u);
	}
	printf ("%lld\n",out(N));

	return 0;
}

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

int main()
{
	double N;

	cin >> N;

	double ans;

	if ((int)N % 2 == 0)
	{
		ans = (double)1 / 2;
	}
	else
	{
		ans = ((int)N / 2 + 1) / N;
	}

	cout << ans << endl;

	return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	FIO();
	int n, w; cin >> n >> w;
	int wt[n], val[n];

	for (int i = 0; i < n; ++i)
	{
		cin >> wt[i] >> val[i];
	}

	int t[n + 1][w + 1];

	for (int i = 0; i < n + 1; ++i)
	{
		for (int j = 0; j < w + 1; ++j)
		{
			if (i == 0 || j == 0)
				t[i][j] = 0;
		}
	}

	for (int i = 1; i < n + 1; ++i)
	{
		for (int j = 0; j < w + 1; ++j)
		{
			if (wt[i - 1] <= j)
				t[i][j] = max(val[i - 1] + t[i - 1][j - wt[i - 1]], t[i - 1][j]);
			else
				t[i][j] = t[i - 1][j];
		}
	}
	cout << t[n][w] << '\n';
	return 0;
}

Measured memory_bytes: 82484
#include<iostream>
using namespace std;
#include<algorithm>
#define REP(i,Z) for(int i=0;i<Z;i++)
int main(){


	int a,b,c,A;	
	cin>>a>>b>>c;
	A=a*4+b*2+c;
	if(A==1||A==6){
	cout<<"Open"<<endl;
	}
	else{
	cout<<"Close"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import sys
sys.setrecursionlimit(10 ** 6)
islands = []
visited_list = []
w_list = []
h_list = []
while True:
    w ,h = map(int,input().split())
    if w == 0 and h == 0:
        break
    w_list.append(w)
    h_list.append(h)
    island = [list(input().split()) for _ in range(h)]
    islands.append(island)
    visited_list.append([[False] * w for _ in range(h)])

dx = [0,1,1, 1, 0,-1,-1,-1]
dy = [1,1,0,-1,-1,-1, 0, 1]

def dfs(island_m ,now_row , now_column , idx):
    if now_row < 0 or h_list[idx] <= now_row or now_column < 0 or w_list[idx] <= now_column or island_m[now_row][now_column] == "0":
        return
    if visited_list[idx][now_row][now_column]:
        return
    visited_list[idx][now_row][now_column] = True
    for i in range(8):
        dfs(island_m,now_row + dx[i] ,now_column + dy[i],idx)


for m in range(len(islands)):
    cnt = 0
    for row in range(h_list[m]):
        for column in range(w_list[m]):
            if not visited_list[m][row][column] and islands[m][row][column] == "1":
                dfs(islands[m] , row , column , m)
                cnt += 1
    print(cnt)


Measured memory_bytes: 8324
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();
		scan.close();
		char sc[]=s.toCharArray();
		char tc[]=t.toCharArray();
		for(int i=0;i<s.length();i++) {
			int cnt=0;
			for(int j=i;j<s.length()+i;j++) {
				if(tc[cnt]==sc[j%s.length()]) {
					cnt++;
					if(cnt==s.length()) {
						System.out.println("Yes");
						break;
					}
				}else break;
			}
			if(cnt==s.length()) {
				break;
			}else if(i==s.length()-1)System.out.println("No");
		}
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll X, K, D;
int main() {
	cin >> X >> K >> D;
	if (abs(X) / D >= K) {
		cout << abs(X) - K * D;
	} else {
		ll num = abs(X) / D;
		ll pos = abs(X) - num * D; 
		num = K - num;
		if (num % 2) cout << abs(pos - D);
		else cout << pos;
	}
	return 0;
}

Measured memory_bytes: 3632
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        O: chars,
        E: chars,
    }
    let mut ans = vec!['a' ;0];
    for i in 0..E.len(){
        ans.push(O[i]);
        ans.push(E[i]);
    }
    if O.len() > E.len(){
        ans.push(O[O.len()-1]);
    }
    for c in ans{
        print!("{}",c);
    }
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;

    vector<ll> x(n);
    rep(i, n)cin >> x[i];

    ll ans = INF;

    rep(i, 101){
        ll cnt = 0;
        rep(j, n)cnt += pow(x[j]-i, 2);
        ans = min(ans, cnt);
    }

    cout << ans;
    
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,unko=0,x=0;
  string aho;
  cin>>n>>aho;
  for(int i;i<n;i++){
    if(aho[i]=='I')
      x++;
    else
      x--;
    unko=max(unko,x);
  }
  cout<<unko<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
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 namespace std;

//ABC136
signed main(void){

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    a[0]--;
    rep(i, n - 1){
        if(a[i] < a[i + 1]){
            a[i + 1]--;
        } else if(a[i] > a[i + 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

}

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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h.at(i);
  
  if (n <= k) cout << 0 << endl;
  else {
    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());
  
    ll a = 0;
    rep(i,n) a += h.at(i);
    rep(i,k) a -= h.at(i);
    
    cout << a << endl;
  }
}

Measured memory_bytes: 1792
s=input()
ans='keyence'
i=0 # index of s
index=0 # index of ans
isCut=0
canRestart=0
restart=0
lenS=len(s)
while i<lenS:
    # print(i,index,end='=>')
    if isCut==1: # 切られたあと
        if index>6: # 7=len(ans)
            if canRestart:
                canRestart=0
                isCut=-1
                i=restartI
                index=restartIndex
            else:
                break
        else:
            if s[i]==ans[index]:
                index+=1
            else:
                if canRestart:
                    canRestart=0
                    isCut=-1
                    i=restartI
                    index=restartIndex
                else:
                    break
    elif isCut==-1: # 切られている途中
        if s[i]==ans[index]:
            # 切り方を変えるときはiとindexを戻す
            restartIndex=index
            restartI=i
            canRestart=1
            isCut=1
            index+=1
    else: # 切られる前
        if s[i]==ans[index]:
            index+=1
        else:
            isCut=-1
    i+=1
    # print(i,index,isCut)
if (index<=6)|(i<lenS)|(isCut==-1): # 7=len(ans)
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3064
a, b, h, m = gets.split.map(&:to_i)
hh = (h * 1.0 + m / 60.0) / 12.0
mm = m / 60.0
sh = Complex(a.to_f, 0.0)
sm = Complex(b.to_f, 0.0)
roth = Complex(Math.cos(2.0 * Math::PI * hh), Math.sin(2.0 * Math::PI * hh))
rotm = Complex(Math.cos(2.0 * Math::PI * mm), Math.sin(2.0 * Math::PI * mm))
puts (sh * roth - sm * rotm).abs

Measured memory_bytes: 14808
#include <stdio.h>
#include <stdlib.h>

#define INF (1000 * 1000 * 99)

struct node_t {
	int y, x;
	int cost;
};

int mofu = 0;
struct node_t nyan[1000 * 1000 * 5];

void qa(int idx) {
	for (;;) {
		int midx = idx;
		int i;
		for (i = 1; i <= 2; i++) {
			int cidx = idx * 2 + i;
			if (cidx < mofu && nyan[midx].cost > nyan[cidx].cost) midx = cidx;
		}
		if (midx == idx) {
			if (idx == 0) break;
			idx = (idx - 1) / 2;
		} else {
			struct node_t temp = nyan[idx];
			nyan[idx] = nyan[midx];
			nyan[midx] = temp;
			idx = midx;
		}
	}
}

void qpush(int y, int x, int cost) {
	nyan[mofu].y = y;
	nyan[mofu].x = x;
	nyan[mofu].cost = cost;
	mofu++;
	qa(mofu - 1);
}

struct node_t qpop(void) {
	struct node_t res;
	if (mofu <= 0) {
		puts("empty");
		exit(2);
	}
	res = nyan[0];
	mofu--;
	if (mofu > 0) {
		nyan[0] = nyan[mofu];
		qa(0);
	}
	return res;
}

int H, W;
int Ch, Cw;
int Dh, Dw;
char S[1024][1024];

int mincost[1024][1024];
char kakutei[1024][1024];

int main(void) {
	int i, j;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	if (scanf("%d%d", &Ch, &Cw) != 2) return 1;
	if (scanf("%d%d", &Dh, &Dw) != 2) return 1;
	for (i = 0; i < H; i++) {
		if (scanf("%1023s", S[i]) != 1) return 1;
		for (j = 0; j < W; j++) mincost[i][j] = INF;
	}
	qpush(Ch - 1, Cw - 1, 0);
	mincost[Ch - 1][Cw - 1] = 0;
	while (mofu > 0) {
		struct node_t cur = qpop();
		int dy, dx;
		if (kakutei[cur.y][cur.x]) continue;
		for (dy = -2; dy <= 2; dy++) {
			for (dx = -2; dx <= 2; dx++) {
				int ny = cur.y + dy, nx = cur.x + dx;
				int ax = abs(dy), ay = abs(dx);
				int waapu = !(ax + ay <= 1);
				int ncost = mincost[cur.y][cur.x] + waapu;
				if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.' && ncost < mincost[ny][nx]) {
					mincost[ny][nx] = ncost;
					qpush(ny, nx, ncost);
				}
			}
		}
	}
	printf("%d\n", mincost[Dh - 1][Dw - 1] < INF ? mincost[Dh - 1][Dw - 1] : -1);
	return 0;
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v

// ABC117 C - Streamline
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> X(m, 0); // 訪れるべき座標一覧(m個)
  rep(i, m) cin >> X[i];
  sort(X.begin(), X.end());

  ll ans = 0;
  if (n >= m) {
    ans = 0; // 最初にコマを置いた時点でクリア
  } else {
    // 数直線上の隣り合う点同士を結ぶ線分を大きい順に並べ、
    // N-1回分断すると、N個の区間ができ、それが答え
    vector<int> diff(m-1,0);
    int base = X[0];
    rep2(i,1,m) {
      diff[i-1] = X[i] - base;
      base = X[i];
    }
    // 大きい順にN-1個の線分をスキップし、残りを合計
    sort(diff.begin(), diff.end(), greater<int>());
    ans = accumulate(diff.begin() + (n-1), diff.end(),0LL);
  }

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


Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    l = [[] for i in range(N)]
    for i in range(M):
        l[A[i] - 1].append(B[i])
        l[B[i] - 1].append(A[i])
    nl = [list(set(x)) for x in l]
    cnt = 0
    for i, v in enumerate(nl):
        flg = True
        for j in v:
            if H[i] <= H[j - 1]:
                flg = False
                break
        if flg:
            cnt += 1
    print(cnt)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39948
N = int(input())
S = []
T = []
answer = 0
START = 0

for i in range(N):
    s,t = input().split()
    t = int(t)
    S.append(s)
    T.append(t)
X = input()

for i in range(N):
    if X == S[i]:
        START = i

for i in range(START+1,N):
    answer = answer + T[i]
print(answer) 


Measured memory_bytes: 3064