akhauriyash/Code-Regression huggingface dataset:
//kruskal tree
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int i,j,k,m,n,q;
	double x,y,z,r;
	for(;scanf("%d",&n),n;){
		vector<vector<double> >v;
		for(i=0;i<n;i++)scanf("%lf%lf%lf%lf",&x,&y,&z,&r),v.push_back({x,y,z,r});
		for(i=0;i<n;i++)parent[i]=i;
		for(q=m=i=0;i<n;i++)for(j=i+1;j<n;j++){
			for(x=k=0;k<3;k++)x+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
			x=sqrt(x)-v[i][3]-v[j][3];
			if(x<=0){if(unite(i,j))q++;}
			else a[m]=i,b[m]=j,node[m].first=x,node[m++].second=m;
		}
		sort(node,node+m);
		for(x=i=0;i<m&&q<n;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first,q++;
		printf("%.3f\n",x);
	}
}

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

int main(){
  int a, b;
  cin >> a >> b;
  int sum = 1;
  int cnt = 0;
  while(sum < b){
    --sum;
    sum += a;
    ++cnt;
  }

  cout << cnt << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    long long ans=0;
    int N=1<<(n-1);
    for(int i=0;i<N;i++){
        long long bi=0;
        long long c = s[0]-'0';
        for(int j=1;j<n;j++){
            if(i&(1<<j-1)){
                bi+=c;
                c=0;
            }
            c*=10;
            c+=s[j]-'0';
        }
        ans+=bi+c;
    }
    cout<<ans;
}

Measured memory_bytes: 256
input = gets.split
arr = []

input.each { |i|
    case i
    when '+'
        arr.push(arr.pop + arr.pop)
    when '-'
        arr.push(-arr.pop + arr.pop)
    when '*'
        arr.push(arr.pop * arr.pop)
    else
        arr.push(i.to_i)
    end
}
puts arr

Measured memory_bytes: 6100
#include<iostream>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> pii;

int main(){
	int n,d1,d2,num;
	while(cin>>n,n){
		pii patient[n];
		rep(i,n){
			cin>>num>>d1>>d2;
			patient[i]=pii(d1+d2,num);
		}
		sort(patient,patient+n);
		cout<<patient[n-1].second<<" "<<patient[n-1].first<<endl;
	}	
	return 0;
}

Measured memory_bytes: 1240
/*   _ _ _                     
    | | | | ___  ___           
    | | | || . ||  _|          
    |_____||_  ||_|  _____     
             |_|    |_____|  */
// Time : 19/10/18
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
int main(){
#ifdef Wqr_
    freopen("in.txt","r",stdin);
#endif
    //std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    string in;
    cin >> in;
    if(in[0] == 'S') printf("Cloudy\n");
    if(in[0] == 'R') printf("Sunny\n");
    if(in[0] == 'C') printf("Rainy\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(int i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

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

  int ans = 1001001001;
  rep(i,x+1) ans=min(ans,c*2*i+a*(x-i)+b*(max(y-i,0)));
  rep(i,y+1) ans=min(ans,c*2*i+a*(max(x-i,0))+b*(y-i));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3556
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

struct edge
{
	int to, cost;
	edge(int to, int cost)
		: to(to), cost(cost) {}
};
typedef vector<vector<edge> > graph;
void add_edge(graph& g, int a, int b, int cost)
{
	g[a].push_back(edge(b, cost));
	g[b].push_back(edge(a, cost));
}
void add_dir_edge(graph& g, int a, int b, int cost)
{
	g[a].push_back(edge(b, cost));
}
vector<int> dijkstra(const graph& g, int s)
{
	const int _INF = 1e9;
	typedef pair<int, int> pint;

	vector<int> dis(g.size(), _INF);
	priority_queue<pint, vector<pint>, greater<pint> > q;

	dis[s] = 0;
	q.push(pint(0, s));
	while (!q.empty())
	{
		pint t = q.top(); q.pop();
		int cur = t.second, d = t.first;

		if (d > dis[cur])
			continue;

		for (int i = 0; i < g[cur].size(); ++i)
		{
			const edge& e = g[cur][i];
			int next_d = d + e.cost;
			if (next_d < dis[e.to])
			{
				dis[e.to] = next_d;
				q.push(pint(next_d, e.to));
			}
		}
	}

	return dis;
}

int main()
{
	int n, m;
	while (cin >> n >> m, n | m)
	{
		graph cost(m), time(m);
		for (int i = 0; i < n; ++i)
		{
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			--a, --b;

			add_edge(cost, a, b, c);
			add_edge(time, a, b, t);
		}

		vector<int> min_cost[128], min_time[128];
		for (int i = 0; i < m; ++i)
		{
			min_cost[i] = dijkstra(cost, i);
			min_time[i] = dijkstra(time, i);
		}

		int k;
		cin >> k;
		while (k--)
		{
			int p, q, r;
			cin >> p >> q >> r;
			--p, --q;
			int res = r == 0 ? min_cost[p][q] : min_time[p][q];
			cout << res << endl;
		}
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;

struct edge{ int b; LL c; edge *nxt; }e[210000], *le(e);
edge *head[110000];
void add(int u, int v, int c){ le->b = v, le->c = c, le->nxt = head[u], head[u] = le++; }

int f[110000];
LL pot[110000], pm[110000];
int inf = 1234567890;
LL INF = 1LL<<60;

LL ma, mpot;
void dfs(int x){
	ma = min(ma, pm[x]+pot[x]);
	mpot = max(mpot, pot[x]);
	FEC(p,x) if (f[p->b] == -1){
		f[p->b] = x;
		pot[p->b] = pot[x]+p->c;
		dfs(p->b);
	}
}

int R, C, m;
bool ans = true;

struct res{ int r, c, v; }inp[110000];
bool cmp(res x, res y){ return x.r < y.r || x.r == y.r && x.c < y.c; }

void work() {
	sort(inp+1, inp+m+1, cmp);
	REP(i,C) pm[i] = inf, head[i] = NULL;
	REP(i,m) pm[inp[i].c] = min(pm[inp[i].c], (LL)(inp[i].v));

	REP(i,m-1) if (inp[i].r == inp[i+1].r) {
		add(inp[i].c, inp[i+1].c, inp[i].v-inp[i+1].v);
		add(inp[i+1].c, inp[i].c, inp[i+1].v-inp[i].v);
	}
	FOR(i,1,C) f[i] = -1, pot[i] = -INF;
	FOR(i,1,C) if (f[i] == -1){
		ma = INF, mpot = -INF;
		f[i] = i; pot[i] = 0; dfs(i);
		if (ma < mpot) ans = false;
	}
	FOR(i,1,C) FEC(p,i) {
		if (pot[p->b] != pot[i]+p->c) ans = false;
	}
}
int main(){
	scanf("%d%d%d", &R, &C, &m);
	REP(i,m) scanf("%d%d%d", &inp[i].r, &inp[i].c, &inp[i].v);
	work();
	REP(i,m) swap(inp[i].r, inp[i].c);
	swap(R, C);
	le = e;
	work();
	if (ans) printf("Yes\n"); else printf("No\n");
	return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define ll long long

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

ll mod = 1000000007;

int main()
{
    ll n;
    cin >> n;
    if (n == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        ll a = 1, b = 1, c = 1;
        for (int i = 0; i < n; i++)
        {
            a *= 10;
            a %= mod;
            c *= 9;
            c %= mod;
            b *= 8;
            b %= mod;
        }
        if (a - 2 * c + b >= 0)
        {
            cout << (a - 2 * c + b) % mod << endl;
        }
        else
        {
            cout << mod + ((a - 2 * c + b) % mod) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll
//struct edge {int to,cost;};

signed main(){
    string s;
    cin >> s;
    int a[4] = {};
    REP(i,LEN(s)){
        if(s[i]=='N') a[0]++;
        if(s[i]=='W') a[1]++;
        if(s[i]=='S') a[2]++;
        if(s[i]=='E') a[3]++;
    }
    bool rullonz = true;
    REP(i,4){
        if(a[i]==0&&rullonz){
            rullonz = a[(i+2)%4]==0; 
        }
    }
    puts(rullonz?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin); i < (end); i++)
#define _irep3(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);

  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  cin >> h;

  vector<ll> dp(N, INF);
  dp[0] = 0;
  // dp[1] = abs(h[0] - h[1]);
  rep(i, 0, N - 1) {
    rep(j, K) {
      if (i - j >= 0)
        dp[i + 1] = min(abs(h[i - j] - h[i + 1]) + dp[i - j], dp[i + 1]);
    }
  }
  out(dp[N - 1]);
}


Measured memory_bytes: 1792
//....SARANSH GUPTA....\\

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define mod 1000000007

int main()
{
    FIO

    string s;
    cin>>s;
    int count=0,maxm=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
        count++;
        else
        {
            maxm=max(maxm,count);
            count=0;
        }
    }
    maxm=max(maxm,count);
    cout<<maxm<<endl;
    
}

Measured memory_bytes: 3608
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;

alias M = Tuple!(int, "t", int, "d");

int[10^^5*2] TS;
M[10^^5*2] QS;

void main()
{
    auto nq = readln.split.to!(int[]);
    auto N = nq[0];
    auto Q = nq[1];
    foreach (int i, c; readln.chomp.to!(char[])) {
        TS[i] = c-65;
    }
    foreach (i; 0..Q) {
        auto td = readln.chomp.to!(char[]);
        QS[i] = M(td[0] - 65, td[2] == 'L' ? -1 : 1);
    }
    int r;
    int i;
    foreach_reverse (q; QS) {
        if (i < N && q.t == TS[max(i, 0)] && q.d < 0) {
            if (i < 0) i = 1;
            else ++i;
        }
        if (i > 0 && i-1 < N && q.t == TS[i-1] && q.d > 0) --i;
    }
    r += max(i, 0);
    i = N;
    foreach_reverse (q; QS) {
        if (i > 0 && q.t == TS[min(i-1, N-1)] && q.d > 0) {
            if (i > N) i = N-1;
            else --i;
        }
        if (i > 0 && i < N && q.t == TS[i] && q.d < 0) ++i;
    }
    r += (N-min(i, N));
    writeln(N-r);
}

Measured memory_bytes: 6140
//
// Created on 2020/04/25.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = 0;
    int n;
    cin>>n;
    int last;
    int now;
    int next;
    cin>>last;
    cin>>now;
    for (int i = 2; i < n; ++i) {
        cin>>next;
        if((last < now && now < next)||(last > now && now > next)){
            ans ++;
        }
        last = now;
        now = next;
    }

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



Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){
    while(1){
        int k,sum=0;
        cin >> k;
        int n = k*(k-1)/2;
        vector<int> c(n);
        if(k==0) break;
        for(int i=0;i<n;i++){
        cin >> c[i];
        sum += c[i];
        }
    cout << sum/(k-1) << endl;
    }
}



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

int main() {
  int64_t n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= 3500; i++) {
    for (int j = 1; j <= 3500; j++) {
      if (4*i*j-n*i-n*j > 0) {
        if (((n*i*j) >= (4*i*j-n*i-n*j))&&((n*i*j)%(4*i*j-n*i-n*j) == 0)) {
          ans = (n*i*j)/(4*i*j-n*i-n*j);
          cout << i << ' ' << j << ' ' << ans << endl;
          break;
        }
      }
    }
    if (ans > 0) {
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

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

    cout << (m < n ? "No" : "Yes");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int a,b;
	cin >> a >> b;
	if(a >= 13) cout << b << endl;
	else if(a >= 6) cout << b/2 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,t,count=0,max=0;
 int a[100000]={};
 cin>>n>>t;
 for(int i=0;i<n;i++)cin>>a[i];

 int min=a[0];
 for(int i=1;i<n;i++){
  if(a[i]<min)min=a[i];
  if(a[i]-min>max){
   max=a[i]-min;
   count=0;
  }
  else if(a[i]-min==max)count++;
 }
 cout<<count+1<<endl;
 return 0;
}

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

int main() {
  int A,B;
  char op;
  cin >> A >> op >> B;
  int ans;
  if(op=='+') ans = A + B;
  if(op=='-') ans = A - B;
  cout << ans << endl;
}


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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    ll dif = 1;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(a[i]%dif == 0){
            res += a[i]/dif-1;
        }else{
            res += a[i]/dif;
        }
        if(a[i]==dif || dif==1){
            dif++;
        }
    }
    std::cout << res << std::endl;
}


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

int main() {
	int x1, y1, x2, y2;
    cin >> x1>> y1>> x2>> y2;
    
  	int nessx = x2 - x1,nessy = y2 - y1;
  	
  	cout << x2-nessy << " " << y2+nessx << " " << x1-nessy << " " << y1+nessx;
  	
  return 0;
}



Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int seconds, s, m, h;
        Scanner sc = new Scanner(System.in);
        seconds = sc.nextInt();
        h = seconds / 3600;
        m = (seconds % 3600) / 60;
        s = seconds % 60;
        System.out.println( h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                    3.14159265359
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

const int N=1e4+10;
const int M=1e3+10;
int dp[M][2*N];

int main()
{
    fastio;
    int h,n;cin>>h>>n;
    int nn=n+1;
    int a[nn],b[nn];
    rep(i,1,nn)cin>>a[i]>>b[i];
    rep(i,0,M)
        rep(j,0,2*N)
            dp[i][j]=INT_MAX-1e6;

    rep(i,0,M)dp[i][0]=0;

    rep(i,1,nn)
        rep(j,1,2*N)
            dp[i][j]=min(dp[i-1][max(0ll,j-a[i])]+b[i],min(dp[i][max(0ll,j-a[i])]+b[i],dp[i-1][j]));

    rep(i,1,nn)
        for(int j=2*N-2;j>=1;j--)
            dp[i][j]=min(dp[i][j],dp[i][j+1]);

    int ans=INT_MAX;
    rep(i,1,nn)
        ans=min(ans,dp[i][h]);

    cout<<ans;
}


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

int main(void)
{
	vector<int> D(3);
	cin >> D[0] >> D[1] >> D[2];
	sort(D.begin(), D.end());

	int min = D[0] + D[1];
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import product
from collections import deque
import numpy as np
inputs = open(0).readlines()
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, rows in zip(range(h), grid):
            for j, val in zip(range(w), rows):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, rows)) for rows in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

h, w = map(int, inputs[0].split())
grid = Grid(inputs[1:], function=lambda x: int(x == '#'))

def dfs(root):
    count = 1
    stack = [root]
    while stack:
        x, y = stack.pop()
        grid[y, x] = 0
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            if grid.is_valid_xy(x+dx, y+dy) and grid[y+dy, x+dx]:
                stack.append((x+dx, y+dy))
                count += 1
    return count

def bfs(root):
    count = 1
    queue = deque([root])
    while queue:
        x, y = queue.popleft()
        grid[y, x] = 0
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            if grid.is_valid_xy(x+dx, y+dy) and grid[y+dy, x+dx]:
                queue.append((x+dx, y+dy))
                count += 1
    return count  

ans = 'Yes'
for i, j in product(range(h), range(w)):
    if grid[i, j]:
        if dfs((j, i)) == 1:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 12432
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
from math import gcd

N=int(input())
A=list(map(int,input().split()))

M=10**6

D=[-1]*(M+1)
D[0]=D[1]=1
for i in range(2,int(M**0.5)+1):
    if D[i]!=-1:
        continue
    for j in range(i*2,M+1,i):
        if D[j]==-1:
            D[j]=i

f=[False]*(M+1)

for x in A:
    l=[]
    while x>1:
        if f[x]==True:
            break
        if D[x]>1:
            l.append(D[x])
            x//=D[x]
        else:
            l.append(x)
            x=1
    else:
        for y in l:
            f[y]=True
        continue
    break
else:
    print('pairwise coprime')
    exit()

tmp=A[0]
for x in A[1:]:
    tmp=gcd(tmp,x)
    if tmp==1:
        print('setwise coprime')
        exit()
else:
    print('not coprime')


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

int main() {
  std::string s;
  cin >> s;
  std::vector<int> a;
  std::vector<int> z;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'A'){
      a.push_back(i + 1);
    }
    if(s.at(i) == 'Z'){
      z.push_back(i + 1);
    }
  }
  sort(std::begin(a), std::end(a));
  sort(std::begin(z), std::end(z));
  reverse(std::begin(z), std::end(z));

  cout << z.at(0) - a.at(0) + 1 << endl;
}

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

using namespace std;
typedef long long int ll;

#define endl '\n'


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

    ll l,r;
    cin>>l>>r;

    ll i = l%2019;

    ll j = r%2019;
    ll ans = INT_MAX;
    if((r-l+1)>=2019){
        cout<<0<<endl;return 0;
    }
    else{
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){
                ans = min(ans,(i*j)%2019);
            }
        }
    }

    cout<<ans<<endl;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}

int main() {
    ll n; cin>>n;
    ll a = n ,b = 1;
    rep(i,1,10)
    {
        if(n%i==0)
        {
            a = i;
            b = n/i;
        }
    }
    if(a>9||b>9)cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}
/*
1
5 1
1 2
2 3
3 4
3 5
2 2 5 2
*/


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

using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  ll sum = 0;
  for (int bit = 0; bit < (1 << (s.size() - 1)); bit++) {
    vector<int> v;
    int pre = -1;
    rep(i, s.size() - 1) {
      if (bit & (1 << i)) {
        sum += stoll(s.substr(pre + 1, i - pre));
        pre = i;
      }
    }
    sum += stoll(s.substr(pre + 1, s.size() - 1 - pre));
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){
  int n,m,s[10],c[10],i,j,ma,mi,tes[3];
  
 scanf("%d",&n);
 scanf("%d",&m);
 for(i=0;i<m;i++){
   scanf("%d",&s[i]);
   scanf("%d",&c[i]);
 }
  if(n==1){
    ma=9;
    mi=0;
  }else{
    ma=pow(10,n)-1;
    mi=pow(10,n-1);
  }
  for(i=mi;i<=ma;i++){
    tes[0]=i/(int)pow(10,n-1);
      if(n>=2) tes[1]=(i-tes[0]*(int)pow(10,n-1))/(int)pow(10,n-2);
      if(n>=3) tes[2]=(i-tes[0]*(int)pow(10,n-1)-tes[1]*(int)pow(10,n-2));
    for(j=0;j<m;j++){
      if(tes[s[j]-1]!=c[j]) break;
    }
    if(j==m){
      printf("%d",i);
      return 0;
    }
  }
  printf("-1");
  return 0;
}

    
    

Measured memory_bytes: 2520
/*
	Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;

#define pii pair < int, int >
#define vi vector < int >
#define vvi vector < vector < int > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	cout << (n/(a+b))*a + min(n%(a+b), a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int y, m, d;
	scanf("%d/%d/%d", &y, &m, &d);
	bool heisei = 0;
	if (y < 2019) heisei = 1;
	else if (y == 2019) {
		if (m < 4) heisei = 1;
		else if (m == 4 && d <= 30) heisei = 1;
	}
	if (heisei) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  long double A, B, N;
  cin >> A >> B >> N;
  // long double ans = 0;
  long double a_b = A / B;

  // long double prev_ans = -1;
  // for (long double x = 1.0; x <= N; x += 1.0) {
  //   ans = max(ans, floor(a_b * x) - A * floor(x / B));
  //   // if (prev_ans != -1) {
  //   //   if (prev_ans > ans) {
  //   //     cout << ans << endl;
  //   //     return 0;
  //   //   }
  //   // }
  //   prev_ans = ans;

  //   cout << setprecision(5) << floor(a_b * x) << ":" << A * floor(x / B)
  //        << endl;
  // }

  long double x = min(N, B - 1);
  cout << floor(a_b * x) - A * floor(x / B) << endl;

  return 0;
}


Measured memory_bytes: 3780
N,A,B,C,D = map(int,input().split())
a= input()
f = 0
s = 0
d = 1
t = []
k = []

f1 = 0
s1 = 0
d1 = 1
t1 = []
k1 = []


for i in a[A-1:C]:
    if i == "." and f ==1:
        k.append(d)
        s = 1
        f = 0
    elif i == ".":s+=1
    
    elif i == "#" and f==0:
        t.append(s)
        d = 1
        f = 1
    elif i == "#":d+=1
else:
    if f==1:
        k.append(d)
    else:
        t.append(s)
for i in a[B-2:D]:
    if i == "." and f1 ==1:
        k1.append(d1)
        s1 = 1
        f1 = 0
    elif i == ".":s1+=1
    
    elif i == "#" and f1==0:
        t1.append(s1)
        d1 = 1
        f1 = 1
    elif i == "#":d1+=1
else:
    if f1==1:
        k1.append(d1)
    else:
        t1.append(s1)
# print(t,k)
# print(t1,k1)
if C < D :
    if len(k) == sum(k) and  len(k1) == sum(k1):
        print("Yes")
    else:
        print("No")
else:
    if len(k) == sum(k) and any([i > 2 for i in t1]) :
        print("Yes")
    elif len(k) == sum(k) and t1[-1] >1:
        print("Yes")
    else:
        print("No")




Measured memory_bytes: 5520
#include<stdio.h>
#include<string.h>
char *replace(char* m,int a,int b){
	char p[1024];
	int i=0;
	scanf("%s",p);
	for(int j=a;j<=b;j++){
		m[j]=p[i];
		i++;
	}
	return m;
}
char *reverce(char* m,int a,int b){
	char s[1024];
	int t=a+b;
	strcpy(s,m);
	for(int i=a;i<=b;i++){
		s[t-i]=m[i];
	}
	strcpy(m,s);
	return m;
}
void print(int s,int e,char* st){
	for(int i=s;i<=e;i++){
		printf("%c",st[i]);
	}
	printf("\n");
	return;
}

int main(void)
{
	char str[1024];
	int q;
	scanf("%s",str);
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		char cmd[8];
		int a,b;
		scanf("%s%d%d",cmd,&a,&b);
		if(strcmp(cmd,"print")==0){
			print(a,b,str);
		}else if(strcmp(cmd,"reverse")==0){
			reverce(str,a,b);
		}else if(strcmp(cmd,"replace")==0){
			replace(str,a,b);
		}
	}
    return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
//#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for(int i = K; i <= N + 1; i++) {
        ans = (ans + (N * 2 - i + 1) * i / 2 - i * (i - 1) / 2 + 1) % mod;
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=LINF,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,q,mi,k,anss[ohara],cntt=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>k>>q;
      rep(i,n)cin>>a[i];
      rep(i,n){
        mi=a[i];
        ll cmp[4000]={},anss[4000]={};
        cnt=0;
        rep(j,n){
          if(mi>a[j]||j==n-1){
            if(j==n-1&&mi<=a[j])cmp[cnt++]=a[j];
            if(cnt>=k){
              sort(cmp,cmp+cnt);
              rep(l,cnt-k+1)anss[cntt++]=cmp[l];
              cnt=0;
            }
            cnt=0;
          }
          else cmp[cnt++]=a[j];
        }
        sort(anss,anss+cntt);
        if(cntt>=q){
        ans=min(ans,anss[q-1]-mi);
        }
        cntt=0;
      }
      if(n==1||n==k)Cout(0);
      else{
      if(ans<0)ans=0;
      Cout(ans);
      }
    
       
return 0;
}


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

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 25136
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

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

        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            Map<Integer, List<Integer>> map = new HashMap<>();
            for (int i = 0; i < n; i++) {
                map.put(i, new ArrayList<>());
            }
            for (int i = 0; i < n - 1; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;
                map.get(a).add(b);
                map.get(b).add(a);
            }
            System.out.println(check(map) ? "Fennec" : "Snuke");
        }
    }

    static int dist;
    static int idxA, idxB;

    private static boolean check(Map<Integer, List<Integer>> map) {
        int n = map.size();
        dist = -1;
        idxA = -1;
        idxB = -1;

        boolean[] used = new boolean[n];
        dfs(map, 0, 0, used);

        Arrays.fill(used, false);
        used[idxB] = true;
        int cntA = dfs2(map, idxA, used);
        int cntB = n - cntA;

        return cntA > cntB;
    }

    private static int dfs2(Map<Integer, List<Integer>> map, int curIdx, boolean[] used) {
        int res = 1;
        used[curIdx] = true;
        for (int toIdx : map.get(curIdx)) {
            if ( used[toIdx] ) {
                continue;
            }
            res += dfs2(map, toIdx, used);
        }
        return res;
    }

    private static boolean dfs(Map<Integer, List<Integer>> map, int curIdx, int curDist, boolean[] used) {
        int n = map.size();
        if ( curIdx == n - 1 ) {
            dist = curDist;
            return true;
        }
        used[curIdx] = true;

        for (int toIdx : map.get(curIdx)) {
            if ( used[toIdx] ) {
                continue;
            }
            boolean res = dfs(map, toIdx, curDist + 1, used);
            if ( res ) {
                if ( curDist == dist / 2 ) {
                    idxA = curIdx;
                    idxB = toIdx;
                }
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 124288
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    string s;
    cin >> s;
    string ans;

    int mintmp = 200010;
    int maxtmp = 0;
    for(int i=0;i<s.size();i++){
        if( s[i] == 'A'){
        mintmp = min(mintmp,i);
        }
        if( s[i] == 'Z'){
        maxtmp = max(maxtmp,i);
        }
    }

    cout << maxtmp - mintmp+1 << endl;

    return 0;
}

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

int main(){
   int n,A,B;
   string S;
   cin>>n>>A>>B;
   cin>>S;
   int all=0,c=0;
   for(int i=0;i<n;i++){
       if(all<A+B){
           if(S[i]=='a'){all++; cout<<"Yes"<<endl;}
           else if(S[i]=='b'){
               if(c<B){ all++; cout<<"Yes"<<endl; c++;}
               else cout<<"No"<<endl;
           }
           else cout<<"No"<<endl;
       }
       else cout<<"No"<<endl;
   }
   return 0;
}

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

using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  int n=s.length();
  map<char,bool> m;
  map<char,char> p;
  map<char,bool> q;
  map<char,char> r;
  bool flag=true;
  for(int i=0;i<n;i++){
    if(m[s[i]]){
      if(p[s[i]]!=t[i]){
        flag=false;
        break;
      }
    }
    else{
      p[s[i]]=t[i];
      m[s[i]]=true;
    }
  }
  for(int i=0;i<n;i++){
    if(q[t[i]]){
      if(r[t[i]]!=s[i]){
        flag=false;
        break;
      }
    }
    else{
      r[t[i]]=s[i];
      q[t[i]]=true;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 776
#include <cstdio>
using namespace std;
int N, A[200000], m1, m2;
int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    if(A[i] > m1) {m2 = m1; m1 = A[i];}
    else if(A[i] > m2) m2 = A[i];
  }
  for(int i = 0; i < N; i++) {
    if(A[i] == m1) printf("%d\n", m2);
    else printf("%d\n", m1);
  }
}

Measured memory_bytes: 2304
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

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

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll X;
  cin >> X;

  ll sum = 0;
  ll ans = 1;
  for (;;) {
    sum += ans;
    if (X <= sum) {
      break;
    }
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
program main
implicit none
integer :: i, j, k
integer :: n
integer , allocatable :: a(:), b(:)

read(*,*) n
allocate( a(n) )
do i = 1 ,n
   read(*,*) a(i)
end do
call heapsort( n , a )
j = 1
k = 0
do i = 2, n
   if( a(i-1) /= a(i) ) then
      if( mod(j,2) == 1 ) then
         k = k + 1
      end if
      j = 0
   end if
   j = j+1
end do
if( mod(j,2) == 1 ) then
   k = k+1
end if
write(*,'(i0)') k
stop
contains
subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
  
  integer ::i,k,j,l
  integer :: t

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        end if
     end if
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        end if
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        end if
     end do
     array(i)=t
  end do
end subroutine heapsort
end program main


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,zx,xc,pas;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	c=1;
	if((b-1)%(a-1)==0) pas=(b-1)/(a-1); else pas=(b-1)/(a-1)+1;
	cout<<pas;
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << "\n";
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if(y >= 0) {
    if(x > y || x < 0 && abs(x) < y){
      x = -x;
      ans++;
    }
  } else {
    if(x < 0 && x > y || x > 0 && x > abs(y)){
      x = -x;
      ans++;
    }
  }
  ans += abs(abs(y)-abs(x));
  x += abs(abs(y)-abs(x));
  if(x != y) {
    ans++;
    x = -x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

			String inputLine;
			while ((inputLine = br.readLine()) != null) {

				final String[] inputs = inputLine.split(" ");

				final Integer a = Integer.valueOf(inputs[0]);
				final String op = inputs[1];
				final Integer b = Integer.valueOf(inputs[2]);

				if(op.equals("?")) {
					break;
				}

				switch(op) {
				case "+":
					System.out.println(a + b);
					break;
				case "-":
					System.out.println(a - b);
					break;
				case "*":
					System.out.println(a * b);
					break;
				case "/":
					System.out.println(a / b);
				}
			}
		}
	}
}


Measured memory_bytes: 24260
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <regex>
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pl4 = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpl4 = vector<pl4>;
using vvpl4 = vector<vpl4>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back()
#define sz size()
#define be begin()
#define en end()
#define asn assign
#define emp empty()
#define ft front()
#define bk back()
#define clr clear()
#define ins insert
#define era erase

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).be,(a).en)
#define rSORT(a) sort((a).rbegin(),(a).rend())
#define UNIQUE(a) (a).erase(unique((a).be,(a).en),(a).en)
#define PREVP(a) prev_permutation((a).be,(a).en)
#define NEXTP(a) next_permutation((a).be,(a).en)
#define BINS(a,b) binary_search((a).be,(a).en,(b))
#define LOWB(a,b) (lower_bound((a).be,(a).en,(b))-(a).be)
#define UPB(a,b) (upper_bound((a).be,(a).en,(b))-(a).be)
#define CNT(a,b) count((a).be,(a).en,b)
#define SUM(a) accumulate((a).be,(a).en,0)
#define REV(a) reverse((a).be,(a).en)
#define REGS(a,b) regex_search((a),regex(b))
#define REGM(a,b) regex_match((a),regex(b))
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define say(a) cout <<(a);
#define sal(a) cout <<(a)<<endl;
#define sak cout <<endl;
#define dbg(a) cout <<(#a)<<": "<<(a)<<endl;
#define a2l(a) ((ll)(a-97))
#define A2l(a) ((ll)(a-65))
#define l2a(a) ((char)(a+97))
#define l2A(a) ((char)(a+65))
#define DigN2(a) ((llabs(a)==0)?(1):((ll)(log2(double(llabs(a))))+1))
#define DigN10(a) ((llabs(a)==0)?(1):((ll)(log10(double(llabs(a))))+1))
#define Dig2(a,b) (((a)>>(b))&1)
#define Pow2(a) (1<<(a))

#define int ll

const ll MOD = 1e9+7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll min(ll a, ll b){if(a>=b) return b;if(a<b) return a;}
ll max(ll a, ll b){if(a>=b) return a;if(a<b) return b;}

ll SalV(vll v){
    say("{");
    FOR(i,0,v.sz-1){
        say(v[i]);
        if(i!=v.sz-1) say(",");
    }
    sal("}")
}

ll DigS10(ll n){
    ll m=0;
    FOR(i,0,DigN10(n)-1){
        m+=(ll)((llabs(n)%(ll)(pow(10.0,(double)(i+1))))/(ll)(pow(10.0,(double)i)));
    }
    return m;
}

ll isP(ll n){
    if(n<=1) return 0;
    FOR(i,2,(ll)sqrt(n)){
        if(n%i==0) return 0;
    }
    return 1;
}

signed main() {

    ll N,M;
    cin >>N>>M;
    vll hu(N,0);
    ll aa,bb;
    FOR(i,0,M-1){
        cin >>aa>>bb;
        if(aa==1) hu[bb]++;
        if(bb==N) hu[aa]++;
    }
    rSORT(hu);
    if(hu[0]!=2) say("IM");
    sal("POSSIBLE");

}

Measured memory_bytes: 1792