akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template <typename T>
class avl_tree {
	struct node {
		T val;
		node *ch[2];
		int dep, size;
		node(T v, node* l = nullptr, node* r = nullptr) : val(v), dep(1), size(1) {
			ch[0] = l; ch[1] = r;
		}
	};
	int depth(node *t) { return t == nullptr ? 0 : t->dep; }
	int count(node *t) { return t == nullptr ? 0 : t->size; }
	node *update(node *t) {
		t->dep = max(depth(t->ch[0]), depth(t->ch[1])) + 1;
		t->size = count(t->ch[0]) + count(t->ch[1]) + 1;
		return t;
	}
	node *rotate(node *t, int b) {
		node *s = t->ch[1 - b];
		t->ch[1 - b] = s->ch[b];
		s->ch[b] = t;
		t = update(t);
		s = update(s);
		return s;
	}
	node *fix(node *t) {
		if (t == nullptr) return t;
		if (depth(t->ch[0]) - depth(t->ch[1]) == 2) {
			if (depth(t->ch[0]->ch[1]) > depth(t->ch[0]->ch[0])) {
				t->ch[0] = rotate(t->ch[0], 0);
			}
			t = rotate(t, 1);
		}
		else if (depth(t->ch[0]) - depth(t->ch[1]) == -2) {
			if (depth(t->ch[1]->ch[0]) > depth(t->ch[1]->ch[1])) {
				t->ch[1] = rotate(t->ch[1], 1);
			}
			t = rotate(t, 0);
		}
		return t;
	}
	node *insert(node *t, int k, T v) {
		if (!t) return new node(v);
		if (t->val == v) return t;
		int c = count(t->ch[0]), b = (k > c);
		t->ch[b] = insert(t->ch[b], k - (b ? (c + 1) : 0), v);
		update(t);
		return fix(t);
	}
	node *erase(node *t) {
		if (!t) return t;
		if (!t->ch[0] && !t->ch[1]) return nullptr;
		if (!t->ch[0] || !t->ch[1]) return t->ch[!t->ch[0]];
		return fix(update(new node(find(t->ch[1], 0)->val, t->ch[0], erase(t->ch[1], 0))));
	}
	node *erase(node *t, int k) {
		if (!t) return nullptr;
		int c = count(t->ch[0]);
		if (k < c) {
			t->ch[0] = erase(t->ch[0], k);
			t = update(t);
		}
		else if (k > c) {
			t->ch[1] = erase(t->ch[1], k - (c + 1));
			t = update(t);
		}
		else {
			t = erase(t);
		}
		return fix(t);
	}
	node *find(node *t, int k) {
		if (!t) return t;
		int c = count(t->ch[0]);
		return k < c ? find(t->ch[0], k) : k == c ? t : find(t->ch[1], k - (c + 1));
	}
	int cnt(node *t, T v) {
		if (t == nullptr) return 0;
		if (t->val < v) return count(t->ch[0]) + 1 + cnt(t->ch[1], v);
		if (t->val == v) return count(t->ch[0]);
		return cnt(t->ch[0], v);
	}
	node *root;
public:
	avl_tree() : root(nullptr) {}
	int size() {
		return count(root);
	}
	void insert(T val) {
		root = insert(root, cnt(root, val), val);
	}
	void erase(T val) {
		if (count(val)) root = erase(root, cnt(root, val));
	}
	T find(int k) {
		return find(root, k)->val;
	}
	bool count(T val) {
		node *t = find(root, cnt(root, val));
		return t && t->val == val;
	}
	int count_lower(T val) {
		return cnt(root, val);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int q;
	cin >> q;
	avl_tree<int> rbt;
	while (q--) {
		int com, x;
		cin >> com >> x;
		if (com == 0) {
			rbt.insert(x);
			printf("%d\n", rbt.size());
		}
		else if (com == 1) {
			puts(rbt.count(x) ? "1" : "0");
		}
		else {
			rbt.erase(x);
		}
	}
	return 0;
}



Measured memory_bytes: 12536
#include <bits/stdc++.h>
using namespace std;
int a[1000001];
int main()
{
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<4;i++)
	{
		a[0]=i&1;
		a[1]=(i>>1)&1;
		for(int j=2;j<n;j++)
			a[j]=a[j-1]^a[j-2]^(s[j-1]=='x');
		bool flag=true;
		for(int i=0;i<n;i++)
		{
			int t=(i-1+n)%n;
			int k=(i+1+n)%n;
			if(a[k]!=a[i]^a[t]^(s[i]=='x'))
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			for(int i=0;i<n;i++)
			{
				if(a[i])
					cout<<'W';
				else
					cout<<'S';
			}
			return 0;
		}
	}
	cout<<"-1";

	return 0;
}

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

using namespace std;

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
typedef long long ll;
char s[120];

int main() {
	cin>>s; int k; cin>>k;
	int len = strlen(s);
	ll res = 0;
	int l = 0, lc = 0, bg = 0;
	for(int i = 0; i < len; i++) {
		if(s[i] == lc) ++l;
		else {
			if(l && !bg) bg = l;
			res += 1LL * k * (l >> 1);
			lc = s[i];
			l = 1;
		}
	}
	if(l == len)
		res = 1LL * k * len >> 1;
	else {
		if(s[len - 1] == s[0]) {
			res -= 1LL * (bg >> 1) * (k - 1);
			res += 1LL * ((bg + l) >> 1) * (k - 1) + (l >> 1);
		} else res += 1LL * (l >> 1) * k;
	}
	print(res), pc('\n');
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

//#define int long long

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

char s[100010], s0[100010], s1[100010];
int main() {
    cin >> s;
    int n;
    rep(i, 100010) {
        if (s[i] == '\0') {
            n = i;
            break;
        }
    }
    rep(i, n) {
        if (i % 2 == 0) {
            s0[i] = '0';
            s1[i] = '1';
        } else {
            s0[i] = '1';
            s1[i] = '0';
        }
    }
    int cnt0 = 0;
    int cnt1 = 0;
    rep(i, n) {
        if (s[i] != s0[i]) {
            cnt0++;
        }
        if (s[i] != s1[i]) {
            cnt1++;
        }
    }
    cout << min(cnt0, cnt1);

    /* --------------------------------- */
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  char a[110];
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  for(int i = 0; i < N; i++){
    if(a[i] == 'Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  
  cout << "Three" << endl;
}
    
    
    
    
 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int sx,sy,tx,ty;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    for(int i=0;i<ty-sy;i++)printf("U");
    for(int i=0;i<tx-sx;i++)printf("R");
    for(int i=0;i<ty-sy;i++)printf("D");
    for(int i=0;i<tx-sx;i++)printf("L");
    printf("L");
    for(int i=0;i<ty-sy+1;i++)printf("U");
    for(int i=0;i<tx-sx+1;i++)printf("R");
    printf("D");
    printf("R");
    for(int i=0;i<ty-sy+1;i++)printf("D");
    for(int i=0;i<tx-sx+1;i++)printf("L");
    printf("U");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

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

  if( x % 11 == 0 ) cout << x / 11 * 2 << endl;
  else if( x % 11 > 6 ) cout << x / 11 * 2 + 2 << endl;
  else cout << x / 11 * 2 + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  
  sort(S.begin(), S.end());
  
  if (S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int N, X;
    int m[110];
    cin >> N >> X;
    FOR(i, 1, N+1) cin >> m[i];

    int num = N;
    FOR(i, 1, N+1) X -= m[i];
    sort(m+1, m+N+1);
    num += X / m[1];
    
    cout << num << endl;

    return 0;
}

/*****************************************************************************/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

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

int main() {
  vector<string> s(3);
  vector<int> vec(3),cnt(3);
  int n=0;
  rep(i,3){
    cin>>s[i];
    n+=s[i].size();
    cnt[i]=s[i].size();
  }
  int x=0;
  rep(i,n){
    if(cnt[x]==vec[x]){
      cout<<(char)(x+'A')<<endl;
      return 0;
    }
    x=s[x][vec[x]++]-'a';
  }
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d){
    cout << "Left";
  }
  else if(a+b==c+d){
    cout << "Balanced";
  }
  else{
    cout << "Right";
  }
}


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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long



using namespace std;
// #define PI 3.14159265358979323846
// cout << fixed << setprecision(20);

int main(int argc, char const* argv[])
{
    char c;
    cin >> c;
    if (isupper(c)) {
        cout << "A" << endl;
    }
    else {
        cout << "a" << endl;
    }
    return 0;
}



Measured memory_bytes: 3560
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define N_MAX 200001
#define Q_MAX 200001

void solv()
{
	int N, Q; scanf("%d%d", &N, &Q);
	pair<int, pair<int, int> > kouzi[N_MAX];
	for (int i = 0; i < N; i++){
		int s, t, x; scanf("%d%d%d", &s, &t, &x);
		kouzi[i].first = x;
		kouzi[i].second = make_pair(s, t);
	}

	sort(kouzi, kouzi + N);

	set<pair<int,int> > s;
	for (int i = 0; i < Q; i++){
		int d; scanf("%d", &d);
		s.insert(make_pair(d,i));
	}

	int ret[Q_MAX];
	fill(ret, ret + Q, -1);
	for (int i = 0; i < N; i++){
		int x = kouzi[i].first;
		set<pair<int, int> >::iterator begin = s.lower_bound(make_pair(kouzi[i].second.first - x, 0));
		set<pair<int, int> >::iterator end = s.lower_bound(make_pair(kouzi[i].second.second - x, 0));

		for (set<pair<int, int> >::iterator itr = begin; itr != end; itr++){
			ret[itr->second] = x;
		}
		s.erase(begin, end);
	}

	for (int i = 0; i < Q; i++){
		printf("%d\n", ret[i]);
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define pb push_back
#define long long long
#define pll pair < long , long >
#define vll vector < pll >
#define ml map < long , long >
#define mll map < pll , long >
#define x first
#define y second
#define vl vector < long >
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int N;  // limit for array size  // array size
long x1,yy1,x2,y2,n,i,j=0,mx,Mx,my,My,q,x[200005],y[200005];
int t[400005]={0};

void modify(int p, int value) {  // set value at position p
  for (t[p += N] = value; p > 1; p >>= 1) t[p>>1] = max(t[p],t[p^1]);
}

int query(int l, int r) {  // sum on interval [l, r)
  int res = 0;
  for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = max(res,t[l++]);
    if (r&1) res = max(res,t[--r]);
  }
  return res;
}
int main()
{
    io
    vll v;
    cout<<fixed<<setprecision(20);
    ml mpx,mpy;
    ml :: iterator it;
    cin>>x1>>yy1>>x2>>y2>>n;
    if(x1>x2)
    {
        swap(x1,x2);
        swap(yy1,y2);
    }
    double ans=100*(abs(y2-yy1)+abs(x2-x1)),dd;
    mpx[x1]=1;
    mpx[x2]=1;
    mpy[yy1]=1;
    mpy[y2]=1;
    mx=min(x1,x2);
    my=min(yy1,y2);
    Mx=max(x1,x2);
    My=max(yy1,y2);
    for(i=0;i<n;++i)
    {
        cin>>x[i]>>y[i];
        if(x[i]>Mx || x[i]<mx || y[i]>My || y[i]<my) continue;
        mpx[x[i]]=1;
        mpy[y[i]]=1;
        v.pb({x[i],y[i]});
        j++;
    }
    n=j;
    j=0;
    for(it=mpx.begin();it!=mpx.end();it++)
    it->y=j++;
    j=0;
    for(it=mpy.begin();it!=mpy.end();it++)
    it->y=j++;
    for(i=0;i<n;++i)
    {
        v[i].x=mpx[v[i].x];
        v[i].y=mpy[v[i].y];
    }
    N=mpy.size();
    if(yy1>y2)
    {
        for(i=0;i<n;++i)
        v[i].y=N-v[i].y;
        yy1=N-yy1;
        y2=N-y2;
    }
    sort(v.begin(),v.end());
    x1=mpx[x1];
    x2=mpx[x2];
    yy1=mpy[yy1];
    y2=mpy[y2];
    for(i=n-1;i>=0;--i)
    {
        q=query(v[i].y,N+1);
        modify(v[i].y,q+1);
    }
    dd=query(0,N+1);
    if(dd==min(Mx-mx,My-my)+1)
    {
        cout<<ans-(dd-1)*4.2920367320510338076867830836025+11.415926535897932384626433832795;
        return 0;
    }
    cout<<ans-dd*4.2920367320510338076867830836025;
    return 0;
}


Measured memory_bytes: 33900
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main(){

  stack <int> sa;
  string m;
  int cnt=0,result=0,high=0,tmp=0,h[20000],i;
  vector <int> amo;

  cin>>m;
  for(i=m.size()-1;i!=-1;i--){
    if(m[i]=='\\') tmp++;
    if(m[i]=='/') tmp--;
    high=max(high,tmp);
    h[i]=high;
  }

  for(i=0;i<m.size();i++){   
    if(m[i]=='\\'){
      sa.push(i);
    } else if(m[i]=='/' && !sa.empty()) {
      cnt+=i-sa.top();
      sa.pop();
      if(sa.empty()){
	amo.push_back(cnt);
	result+=cnt;
	cnt=0;
      }
    }
    if(i<m.size()-1) if(h[i+1]-h[i]) sa.pop();
  }
  if(amo.empty()) cout<<"0"<<endl<<"0"<<endl;
  else{
    cout<<result<<endl<<amo.size()<<" ";
    for(i=0;i<amo.size()-1;i++) cout<<amo[i]<<" ";
    cout<<amo[amo.size()-1]<<endl;
  }
  return 0;

}



Measured memory_bytes: 3336
import java.util.*;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		Long D2 = (long) Math.pow(D, 2);
		Integer cnt = 0;
		  
		for(int i=0; i<N; i++){
			int tmp1 = sc.nextInt();
			int tmp2 = sc.nextInt();
			Long tmpD = (long) Math.pow(tmp1, 2);
			tmpD += (long) Math.pow(tmp2, 2);
			if(tmpD <= D2){
				cnt++;
			}
		}

        System.out.println(cnt);
		return;
	}
}


Measured memory_bytes: 60536
#include <iostream>
#include <set>
#include <string>
#include <vector>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> S;
  set<string> SS;
  for(int i = 0; i < N; i++) {
  	string s;
    cin >> s;
    S.push_back(s);
    SS.insert(s);
  }
  if (SS.size() != S.size()) {
  	cout << "No" << endl;
    return 0;
  }
  for(int i = 0; i < N - 1; i++) {
  	if (S[i].back() != S[i + 1][0]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

#define NEW(p,n) {p = malloc(n * sizeof(p[0]));}

typedef int* vector;

vector make_vector(int n)
{
    vector v;
    NEW(v,n);
    for(int i = 0; i < n; i++)
    {
        v[i] = 0;
    }
    return v;
}

int max(int n, vector v)
{
    int ret = 0;
    for(int i = 0; i < n; i++)
    {
        if (v[i] > ret) ret = v[i];
    }
    return ret;
}

int sum(int n, vector v)
{
    int ret = 0;
    for(int i = 0; i < n; i++)
    {
        ret += v[i];
    }
    return ret;
}

int main()
{
    int N;
    vector L;

    scanf("%d",&N);
    L = make_vector(N);
    for(int i = 0; i < N; i++)
    {
        int tmp = 0;
        scanf("%d",&tmp);
        L[i] = tmp;
    }
    if (max(N,L) < sum(N,L) - max(N,L)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

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

int main() 
{
    int N, M;
    cin >> N >> M;
    unsigned long long money = 0;
    vector<pair<unsigned long long, int>> v(N);

    for (int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());

    for (int i = 0; i < N; i++) 
    {
        if ( M <= 0 ) break;

        int m = min(M, v[i].second);
        M -= m;
        money += v[i].first * m;
    }   
    cout << money << endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A==B && B==C) {
    cout <<"No" << endl;
  }
  
  else if (A!=B && B!=C && A!=C) {
    cout <<"No" << endl;
  }
  
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string S,T;
int A,B;
string U;

int main(void){
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    
    if(U == S) A--;
    if(U == T) B--;
    
    cout << A << " " << B;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N],b[N];
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int ac=0,wa=0,n,m,t;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    string s;
    cin>>n>>m;
    while(m--){
        cin>>t>>s;
        if(a[t]==0){
            if(s=="WA") b[t]++;
            else ac++,a[t]=1,wa+=b[t];
        }
    }
    cout<<ac<<' '<<wa<<endl;
    return 0;
}


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

vector<ll> w(301);
vector<vector<ll>> DP(301,vector<ll> (301,-1));

ll inf=1e18;

ll dp(ll l,ll h) {
  if(DP[l][h]>-1) {
    return DP[l][h];
  }
  if(h-l<=1) {
    return 0;
  }
  ll res=0;
  for(ll i=l+1;i<h;i++) {
    res=max(res,dp(l,i)+dp(i,h));
  }
  if(dp(l+1,h-1)==(h-l-2)&&abs(w[l]-w[h-1])<=1) {
    res=h-l;
  }
  return DP[l][h]=res;
}

int main() {
  while(1) {
    ll n;
    cin >> n;
    if(n==0) {
      break;
    }
    for(ll i=0;i<n;i++) {
      cin >> w[i];
    }
    for(ll i=0;i<=n;i++) {
      for(ll j=0;j<=n;j++) {
        DP[i][j]=-1;
      }
    }
    cout << dp(0,n) << endl;
  }
}


Measured memory_bytes: 3460
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 5e3 + 1;
int n;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    if(n < s.length())
        s = s.substr(0, n) + "...";
    cout << s;
    return 0;
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MN 2500000
inline int read()
{
	int x=0,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-'0';ch=getchar();}
	return x*f;
}
int n,m,ans,p[MN+5],inv[MN+5];
inline int C(int n,int m){return m>n?0:1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
    n=read();m=read();
    p[0]=p[1]=inv[0]=inv[1]=1;
    for(int i=2;i<=MN;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<=MN;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    if(n==2) return 0*printf("%d\n",m+1);
    for(int i=0;i<=m;i+=2) if(m-i<=n)
    {
        int t=i/2+m;
        ans=(ans+1LL*C(n,m-i)*C(t+n-1,n-1))%mod;
        ans=(ans+1LL*C(n,m-i)*(mod-(m-i))%mod*C(t-m+n-1,n-1))%mod;
        ans=(ans+1LL*C(n,m-i)*(mod-(n-(m-i)))%mod*C(t-m+n-2,n-1))%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 19712
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int l = scanner.nextInt();

        long[][] a = new long[n][m];
        long[][] b = new long[m][l];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                a[i][j] = scanner.nextInt();
            }
        }
        for(int i = 0; i < m; i++){
            for(int j = 0; j < l; j++){
                b[i][j] = scanner.nextInt();
            }
        }
        long product;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < l; j++){
                product = 0;
                for(int k = 0; k < m; k++){
                    product += a[i][k]*b[k][j];
                }
                if(j != l-1)System.out.print(product+" ");
                else System.out.println(product);
            }
        }
    }
}



Measured memory_bytes: 53972
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

bool ch(string s,string t)
{
	for(int i=0;i<s.length();i++)
	{
		if(s==t)
			return true;
		char c=s[0];
		s=s.substr(1,s.length()-1);
		s.push_back(c);
	}
	return false;
}


int main()
{
	string s,t;
	cin>>s>>t;
	cout<<(ch(s,t)?"Yes":"No")<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct edge{int to,cost;};
int n,m,N,a[200010],b[200010],c[200010],d[500010];
vector<edge>v[500010];
map<P,int>mp;
int dijkstra(int s,int t){
    priority_queue<P,vector<P>,greater<P>>q;
    q.push({0,s});
    fill(d,d+N,INF);
    d[s]=0;
    while(!q.empty()){
        P p=q.top();
        q.pop();
        if(d[p.se]!=p.fi)continue;
        for(edge e:v[p.se]){
            if(d[e.to]>p.fi+e.cost){
                d[e.to]=p.fi+e.cost;
                q.push({d[e.to],e.to});
            }
        }
    }
    if(d[t]==INF)return -1;
    return d[t];
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--,b[i]--,c[i]--;
        mp[{a[i],c[i]}]=0;
        mp[{b[i],c[i]}]=0;
    }
    rep(i,n)mp[{i,-1}]=0;
    for(auto &p:mp){
        p.se=N;
        N++;
    }
    int s=mp[{0,-1}],t=mp[{n-1,-1}];
    rep(i,m){
        v[mp[{a[i],c[i]}]].pb({mp[{b[i],c[i]}],0});
        v[mp[{b[i],c[i]}]].pb({mp[{a[i],c[i]}],0});
        v[mp[{a[i],c[i]}]].pb({mp[{a[i],-1}],0});
        v[mp[{b[i],c[i]}]].pb({mp[{b[i],-1}],0});
        v[mp[{a[i],-1}]].pb({mp[{a[i],c[i]}],1});
        v[mp[{b[i],-1}]].pb({mp[{b[i],c[i]}],1});
    }
    cout<<dijkstra(s,t)<<endl;
    return 0;
}

Measured memory_bytes: 84848
#include <stdio.h>
#include <stdbool.h>

int createX(int n, int x) {
    int cnt = 0;

    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            for(int k = j + 1; k <= n; k++) {
                if(i + j + k == x) {
                    cnt++;    
                }
            }
        }
    }

    return cnt;
}

int main(void) {
    int n, x;
    int result[100];
    int resultNum;
    int i;

    for(i = 0; scanf("%d %d", &n, &x), !(n == 0 && x == 0); i++) {
        result[i] = createX(n, x);
    }
    resultNum = i;

    for(i = 0; i < resultNum; i++) {
        printf("%d\n", result[i]);
    }

    return 0;
}


Measured memory_bytes: 2056
n,k=map(int,input().split())
r,s,p=map(int,input().split())
d={"r":p,"s":r,"p":s}
t=input()
ans=0
for i in range(k):
	bef=None
	for c in t[i::k]:
		if c==bef:
			bef = None
			pass
		else:
			ans+=d[c]
			bef=c
print(ans)


Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N,A,B;
	cin>>N>>A>>B;
	if((A-B)%2==0)
		cout<<"Alice"<<endl;
	else
		cout<<"Borys"<<endl;
	return 0;
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  cin>>N;
  vector<int> L(N);
  rep(i,N)
    cin>>L[i];
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  int answer=0;
  int b=0;
  rep(i,N-2){
    for( int j=i+1;j<N-1;j++){
      for( int k=j+1;k<N;k++){
        if(L[k]<=L[i]-L[j]){
          if(k==j+1){
            b=1;
          }
            break;
        }
        else
          answer++;
      }
        if(b==1){
          b=0;
          break;
        }
    }
  }
  cout<<answer;
}

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

int main() {
  int a,b,c,d;
  std::cin >> a >>b>>c>>d;
  if (a+b > c+d) std::cout << "Left" << '\n';
  else if (a+b==c+d) std::cout << "Balanced" << '\n';
  else std::cout << "Right" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char a[100011];
	int n,i,j;
	scanf("%s",a);
	for(i=0;i<strlen(a)-1;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<i+1<<" "<<i+2<<"\n";
			return 0;
		}
	}
	for(i=0;i<strlen(a)-2;i++)
	{
		if(a[i]==a[i+2])
		{
			cout<<i+1<<" "<<i+3<<"\n";
			return 0;
		}
	}
	cout<<"-1 -1\n";
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;

int main(void){
  static const double pi=3.141592653589793;

  double a,b,angle;
  double c,surface,circ,height;
  cin>>a>>b>>angle;
  surface=a*sin(angle*pi/180.0)*b/2;
  c=sqrt(a*a+b*b-2*a*b*cos(angle*pi/180.0));
  height=b*sin(angle*pi/180);
  circ=a+b+c;
  cout<<setprecision(8) <<surface<<endl;
  cout<<setprecision(8) <<circ<<endl;
  cout<<setprecision(8) <<height<<endl;
  return 0;

}



Measured memory_bytes: 3508
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
const long long mod = 1000000007;
//const long long mod = 998244353;
int main() {
	int N,M;
	scanf("%d", &N);
	scanf("%d", &M);
	printf(M < N ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
 
int N;
int arr[450];
ll psum[100005];
ll dp[450][450];
const ll INF=1e18+7107;
 
ll solve(int L,int R)
{
    ll &ret=dp[L][R];
    if(ret!=-1)return ret;
    if(L==R)return 0LL;
    ret=INF;
    for(int K=L;K<R;K++)
        ret=min(ret,solve(L,K)+solve(K+1,R)+psum[R]-psum[L-1]);
    
    return ret;
 
}
 
 
int main()
{
    cin>>N;
    for(int i=1;i<=N;i++)
        cin>>arr[i];
    for(int i=1;i<=N;i++)
        psum[i]=psum[i-1]+1LL*arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(1,N);
}

Measured memory_bytes: 1920
def make_postorders pre_nodes, in_nodes, post_nodes
  m = pre_nodes.shift
  i = in_nodes.index(m)
  l_ins = (0 <= i - 1) ? in_nodes.slice(0..(i - 1)) : []
  r_ins = (i + 1 <= in_nodes.length - 1) ? in_nodes.slice((i + 1)..(in_nodes.length - 1)) : []

  make_postorders pre_nodes, l_ins, post_nodes unless l_ins.empty?
  make_postorders pre_nodes, r_ins, post_nodes unless r_ins.empty?
  post_nodes << m

  return post_nodes
end

n = gets.chomp.to_i
preorders = gets.chomp.split(' ').map(&:to_i)
inorders = gets.chomp.split(' ').map(&:to_i)
nodes = make_postorders preorders, inorders, []
puts nodes.join(' ')


Measured memory_bytes: 6876
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
	    int x = IO.GetInt();
	    
	    bool isPrime = IsPrime(x);
	    while(!isPrime){
	        x++;
	        isPrime = IsPrime(x);
	    }
	    
	    
	    Console.WriteLine(x);
	    
	}
	
	static bool IsPrime(int x){
	    if(x==2)return true;
	    for(int i=2;i<Math.Sqrt((double)x);i++){
	        if(x%i==0)return false;
	    }
	    return true;
	}
    
}

static class IO
{
    static public string GetString() { return Console.ReadLine(); }
    static public int GetInt() { return int.Parse(Console.ReadLine()); }
    static public long GetLong() { return long.Parse(Console.ReadLine()); }
    static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
    static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
    static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
    static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
}


Measured memory_bytes: 13140
input = input()
a,b,c=map(int,input.split())
if a<b:
    if b<c:
        print(f'{a} {b} {c}')
    else:
        print(f'{a} {c} {b}')
elif b<c:
    if c<a:
        print(f'{b} {c} {a}')
    else:
        print(f'{b} {a} {c}')
elif c<a:
    if a<b:
        print(f'{c} {a} {b}')
    else:
        print(f'{c} {b} {a}')



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

#define ll long long int
#define ull unsigned long long int
#define lld long double
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vull vector<ull>
#define all(v) v.begin(),v.end()
#define mp make_pair
#define bitcount(x) __builtin_popcountll(x)
#define charcount(s,c) count(s.begin(), s.end(), c)
#define each(a,b) memset(a,b,sizeof a) //for b=0/-1, all pos,s for multidim arr too;
#define tofsi(s,c,t) memset(s,c,t) // for char s[n],first t;
#define tofs(s,pos,c,t) fill_n(s.begin()+pos, t, c);
#define fi first
#define se second


ll e_bit=0xAAAAAAAA;
ll o_bit=0x55555555;
lld pi = acos(-1.0);
ll gprime=402653189;
ll pprime=1610612741;
ll dulo=1000000007;

bool is_power2(ll n){
	return (n&&!(n&(n-1)));
}
ll power(ll x, ll y){
    ll temp;
    if( y == 0)
       return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp);
    else
    {
        if(y > 0)
            return (((x*temp))*temp);
        else
            return (temp*temp)/x;
    }
}

long long int mul_inv(long long int n,long long int p,long long int m){
	if(p==1){
		return n%m;
	}
	else if(p%2==0){
		long long int t= mul_inv(n,p/2,m);
		return ((t)*(t))%m;
	}
	else{
		long long int t= mul_inv(n,p/2,m);
		return ((((n%m)*t)%m)*t)%m;
	}
}

bool isprime(ll n){
	if(n==1){
		return false;
	}
	if(n==2){
		return true;
	}
	if(n%2==0){
		return false;
	}
	for(ll i=3;i<=sqrt(n);i+=2){
		if(n%i==0){
			return false;
		}
	}
	return true;
}


// getline(cin,s), cin.ignore() if cin>>p b4;


/*
struct compare {
    bool operator() (pair<int,int> a,pair<int,int> b) const{
        return a.se<b.se;
    }
};
*/


/*
---------------------Priority Queue Compare Operator------------------------

priority_queue<int, std::vector<int>, compare> pq;

*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	/*freopen("fbh.in","r",stdin);
    freopen("B-large.out","w",stdout);*/
	/*float ans;
	std::cout << std::fixed;
    std::cout << std::setprecision(9);
    std::cout << ans;
	*/
	int n,k1;
	cin>>n>>k1;
	vector<pair<ll,ll>>v;
	vll vx,vy;
	set<ll>xs,ys;
	ull ma=5*(1e18);
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		v.pb(mp(x,y));
		xs.insert(x);
		ys.insert(y);
	}
	for(auto i=xs.begin();i!=xs.end();i++){
		vx.pb(*i);
	}
	for(auto i=ys.begin();i!=ys.end();i++){
		vy.pb(*i);
	}
	for(int i=0;i<vx.size();i++){
		for(int j=i+1;j<vx.size();j++){
			for(int k=0;k<vy.size();k++){
				for(int l=k+1;l<vy.size();l++){
					int pr=0;
					for(int q=0;q<v.size();q++){
						ll x=v[q].fi,y=v[q].se;
						if(x>=vx[i]&&x<=vx[j]&&y>=vy[k]&&y<=vy[l])pr++;
					}
					if(pr>=k1){
						ull temp1=(vx[j]-vx[i]),temp2=(vy[l]-vy[k]);
						ma=min(ma,temp1*temp2);
					}
				}
			}
		}
	}
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    ll A, B, AB, X, Y;
    cin >> A >> B >> AB >> X >> Y;
    
    // calculation
    if (X == 1 && Y == 1) {
        if (A + B >= AB*2) {
            cout << AB*2 << "\n";
        } else {
            cout << A+B << "\n";
        }
    } else {
        ll min_yen = 2 * 6 * (ll)pow(10, 8);
        ll a = X, b = Y, ab = 0;
        while (true) {
            min_yen = min(min_yen, a * A + b * B + ab * AB);
            
            a--;
            b--;
            ab += 2;
            
            if (a < 0) a = 0;
            if (b < 0) b = 0;
            
            if (a == 0 && b == 0) {
                min_yen = min(min_yen, a * A + b * B + ab * AB);
                break;
            }
        }
        cout << min_yen << "\n";
        
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#define LINEMAX 1025
char train[60];

typedef struct _two {
	int head;
	int tail;
} TWO_T;

TWO_T maketrain( char str[LINEMAX] )
{
	int medium_stat = 30;
	TWO_T tval;
	tval.head = 30; tval.tail = 30;
	char *p; p = str;

	// 一番最初の文字列が列車の最初の車両としてスタート, 
	// 左・右に進むにつれて列車の構成を変更していく
	while ( *p ) {
		if ( isalpha( *p ) ) {
			train[medium_stat] = *p;
			p++;
		} else { 
			if ( *p == '-' ) {
				medium_stat++;
				if ( medium_stat > tval.tail ) {
					tval.tail = medium_stat;
				}
			} else if ( *p == '<' ) {
				medium_stat--;
				if ( medium_stat < tval.head ) {
					tval.head = medium_stat;
				}
			}
			p += 2;
		}
	}
	return tval;
}


int main()
{
	char str[LINEMAX];
	int num, midium_stat = 30;
	TWO_T tval;

	scanf( "%d", &num );

	for ( int i = 0 ; i < num ; i++ ) {
		memset( train, '0', sizeof( train ) );
		scanf( "%s", str );
		tval = maketrain( str );
		for ( int j = tval.head ; j <= tval.tail ; j++ ) {
			printf( "%c", train[j] );
		}
		printf( "\n" );
	}
	return 0;
}



Measured memory_bytes: 2064
n, K = map(int, input().split())
f = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    ways = []
    for k in range(1,K+1):
        if i - k >= 0:
            ways.append(dp[i - k] + abs(f[i] - f[i - k]))
    dp[i] = min(ways)
print(dp[n - 1])


Measured memory_bytes: 55136
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	println!("ABC{}", v[0]);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#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 sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    string s;
    cin>>s;
    ll ans=0;
    for(auto u:s)
    {
        ans+=(u-'0');
    }
    if(ans%9==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    sum += abs(a[0]);
    rep(i,n-1){
        sum += abs(a[i+1] - a[i]);
    }
    sum += abs(a[n-1]);

    rep(i,n){
        if(i==0){
            cout << sum - (abs(0-a[0]) + abs(a[0] - a[1])) + abs(a[1]) << endl;
            continue;
        }else if(i==n-1){
            cout << sum - (abs(a[n-2] - a[n-1]) + abs(a[n-1])) + abs(a[n-2]) << endl;
            continue;
        }
        cout << sum - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1])) + abs(a[i+1] - a[i-1]) << endl;
    }
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define endl '\n'
#define ll long long
using namespace std;

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

	int n, x, t;
	cin >> n >> x >> t;
	int temp = (n / x) + ((n % x) != 0);
	cout << temp * t;

	return 0;
}


Measured memory_bytes: 3624
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

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

template <typename T> // 0<1<2<3<4
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <typename T> // 0>1>2>3>4
using pq_dsc = priority_queue<T>;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> d(n);

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

  return 0;
}


Measured memory_bytes: 640
#include<algorithm>
            #include <iostream>
            #include <string>
            using namespace std;
            int main(){
              string s;
              cin >> s;
              sort(s.begin(),s.end());
              string t;
              cin >> t;
              sort(t.begin(), t.end());
              reverse(t.begin(), t.end());
              if (s<t)cout<<"Yes"<< endl;
              else cout<<"No"<<endl;
            }

Measured memory_bytes: 384
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def SI(): return list(input().split())
##################################################
def main(A,B):
    if A==B:
        return '='
    if A>B:
        return '>'
    if A<B:
        return '<'
    
A,B = SI()
print(main(A,B))

Measured memory_bytes: 3952
x, y = map(int, input().split())
ans = 0
if x == 1:
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000

if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000

if x == y == 1:
    ans += 400000
print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct E {
    int u, v, w;
};

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

    int n = 20, m = 0;
    E e[60];

    while (l < 1 << (n - 1)) n--;

    for (int i = 0; i < n - 1; i++) {
        e[m++] = { i, i + 1, 0 };
        e[m++] = { i, i + 1, 1 << i };
    }

    for (int i = 0; i < n - 1; i++) {
        if (l & 1 << i) {
            l ^= 1 << i;
            e[m++] = { i, n - 1, l };
        }
    }

    cout << n << ' ' << m << endl;
    for (int i = 0; i < m; i++) {
        cout << e[i].u + 1 << ' ' << e[i].v + 1 << ' ' << e[i].w << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	while(cin>>a>>b>>c,a+1||b+1||c+1){
		int d=7200;
		int f=a*3600+b*60+c;
		d-=f;
		printf("%.2d:%.2d:%.2d\n",d/3600,d%3600/60,d%3600%60);
		d*=3;
		printf("%.2d:%.2d:%.2d\n",d/3600,d%3600/60,d%3600%60);
	}
}

Measured memory_bytes: 3108
#include<cstdio>

using namespace std;

int main(){
	int h, w; scanf("%d %d", &h, &w);
	for(int i = 0; i < h; i++){
		char c[101]; scanf("%s", c);
		printf("%s\n%s\n", c, c);
	}
	return 0;
}

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll big = 10e12 + 11 ;

int  main (  ) {

    FASTIO ;

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

    vector < int > v( n ) , gap;

    ll  ans1 , ans2 ;

    for( int i =0 ; i <n ; i++ ) cin >>  v[ i ] ;

    for( int i = 1 ; i < n ; i++ ){
        gap.pb( v[ i ] - v[ i - 1 ] ) ;
    }

    gap.pb( v[ 0 ] + ( k - v[ n - 1 ]) ) ;

    sort( gap.begin( ) , gap.end( ) ) ;

    ll  ans = 0 , len = gap.size( ) ;

    for( int i = 0; i < len - 1 ; i++ ){
        ans += gap[ i ] ;
    }

    cout <<   ans  ;

    return  0 ;
}



Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

#define ll long long
using namespace std;

int main()
{
	int N;
  cin>>N;
  string S[100];
  for(int i=0; i<N; ++i)
  	cin>>S[i];
  int ans=1;
  for(int i=1; i<N; ++i)
  	if(S[i-1].back() != S[i][0])
  		ans=0;
  for(int i=0; i<N; ++i)
  	for(int j=i+1; j<N; ++j)
  		if(S[i]==S[j])
  			ans=0;
  if(ans==0)
  	cout<<"No"<<endl;
  else
  	cout<<"Yes"<<endl;
  return 0;
}

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

namespace ABC060_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NT[0];
            var T = NT[1];
            var t = Console.ReadLine().Split().Select(int.Parse).ToArray();

            long sum = 0;
            long p = t[0];
            for (int i = 1; i < N; i++)
            {
                if (t[i] - p >= T)
                {
                    sum += T;
                }
                else
                {
                    sum += t[i] - p;
                }
                p = t[i];
            }

            sum += T;
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 30432