akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
FACE ck[6]={TOP,BOTTOM,FRONT,BACK,LEFT,RIGHT};

class UnionFind
{
public:
	vector<int> data;
	UnionFind(int size):data(size, -1){}
	
	bool unionSet(int x, int y)
	{
		x = root(x); y=root(y);
		if(x != y)
		{
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	
	int root(int x)
	{
		return data[x] < 0 ? x:data[x]=root(data[x]);
	}
};

class Dice
{
public:
	Dice(string m[6])
	{
		f[TOP]=0; f[FRONT]=1; f[LEFT]=2;
		f[RIGHT]=3; f[BACK]=4; f[BOTTOM]=5;
		
		for(int i=0; i<6; i++)
			val[i]=m[i];
	}
	
	void rotated(FACE a, FACE b, FACE c, FACE d)
	{
		int tmp = f[a];
		f[a]=f[b];
		f[b]=f[c];
		f[c]=f[d];
		f[d]=tmp;
	}
	
	vector<Dice> all_rotate()
	{
		vector<Dice> t;
		for(int i=0; i<6; (i&1?rotateY():rotateX()), i++)
		for(int j=0; j<4; rotateZ(), j++)
			t.push_back(*this);
			
		return t;
	}
	
	void rotateX() { rotated(TOP, BACK, BOTTOM, FRONT); }
	void rotateY() { rotated(TOP, LEFT, BOTTOM, RIGHT); }
	void rotateZ() { rotated(FRONT, RIGHT, BACK, LEFT); }
	
	string GetVal(FACE fe) { return val[f[fe]]; }

	
	int f[6];
	string val[6];
};

bool isequal(vector<Dice>& a, vector<Dice>& b)
{
	for(int k=0; k<a.size(); k++) 
	for(int j=0; j<b.size(); j++)
	{
		bool g=true;
		for(int i=0; i<6; i++)
		{
			if(a[k].GetVal(ck[i])!=b[j].GetVal(ck[i]))
			{
				g=false;
				break;
			}
		}
		if(g) return true;
	}
	
	return false;
}

int main()
{
	int N;
	while(cin >> N, N)
	{
		vector<Dice> d;
		for(int i=0; i<N; i++)
		{
			string s[6];
			for(int j=0; j<6; j++)
				cin >> s[j];
				
			d.push_back(s);
		}
		
		vector<vector<Dice> > face;
		for(int i=0; i<d.size(); i++)
			face.push_back(d[i].all_rotate());
		
		int ans=0;
		UnionFind uf(N);
		
		for(int i=0; i<N; i++)
		for(int j=i+1; j<N; j++)
		{
			if(i==j) continue;
			if(isequal(face[j], face[i]))
			{
				if(uf.unionSet(i,j))
					ans++;
			}
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 984
S=list(input())
l=0
while l!=len(S):
  l=len(S)
  if S[-1]=='m' and S[-2]=='a' and S[-3]=='e' and S[-4]=='r' and S[-5]=='d':
    del S[-5:]
  if len(S)==0:
    break
  if S[-1]=='e' and S[-2]=='s' and S[-3]=='a' and S[-4]=='r' and S[-5]=='e':
    del S[-5:]
  if len(S)==0:
    break
  if S[-1]=='r' and S[-2]=='e' and S[-3]=='s' and S[-4]=='a' and S[-5]=='r' and S[-6]=='e':
    del S[-6:]
  if len(S)==0:
    break
  if S[-1]=='r' and S[-2]=='e' and S[-3]=='m' and S[-4]=='a' and S[-5]=='e' and S[-6]=='r' and S[-7]=='d':
    del S[-7:]
  if len(S)==0:
    break

if len(S)==0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 4084
#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

#define int long long
int n,d,a;
pii p[200010];int att[200010];
//priority_queue<pii,vector<pii>,greater<pii>>pq;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>d>>a;
	rep(i,n){
		int x,y;
		cin>>x>>y;
		p[i].fi=x;
		p[i].sc=y;
		//pq.push(mp(x,y));
	}
	sort(p,p+n);
	int ans=0ll,cur=0ll,cnt=0ll,r=1ll;
	rep(i,n){
		int x=p[i].fi,y=p[i].sc;
		//cout<<x<<" "<<y<<endl;
		y-=a*cnt;
		int t=0ll;
		if(y>0){
			t=(a+y-1)/a;
			cnt+=t;
			ans+=t;
		}
		while(r<n&&p[r].fi-p[i].fi<=d*2)r++;r--;
		att[r]+=t;
		cnt-=att[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4992
from collections import defaultdict
N, M = map(int, input().split())
prefs = [list(map(int, input().split())) for _ in range(M)]
dict = defaultdict(list) 
result_dict = defaultdict(list) 
count = 1

for pref in prefs:
    dict[pref[0]].append([pref[1], count])
    count += 1

for k, v in dict.items():
    dict[k] = sorted(v)

for k, v in dict.items():
    for i in range(len(v)):
        result_dict[v[i][1]] = '{0:06d}'.format(k) + '{0:06d}'.format(i+1)

for v in result_dict.values():
    print(v)

Measured memory_bytes: 70132
import sys

input = sys.stdin.readline


def main():
    A, B, C, D, E, F = map(int, input().split())

    max_concentration = 0
    ans = (100 * A, 0)
    for a in range(0, F + 1, 100 * A):
        for b in range(0, F - a + 1, 100 * B):
            water = a + b
            if water == 0:
                break
            for c in range(0, F - water + 1, C):
                for d in range(0, F - water - c + 1, D):
                    sugar = c + d
                    if sugar > (water // 100) * E:
                        break
                    concentration = (100 * sugar) / (water + sugar)
                    if concentration > max_concentration:
                        max_concentration = concentration
                        ans = (water + sugar, sugar)

    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, arr[105], op[105];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &arr[i]);
	}
	for(int t = n; t > 0; t--){
		bool ok = false;
		for(int i = t; i >= 1; i--){
			if(arr[i] == i){
				op[t] = i;
				for(int j = i; j < t; j++){
					arr[j] = arr[j + 1];
				}
				ok = true;
				break;
			}
		}
		if(!ok){
			printf("-1\n");
			return 0;
		}
	}
	for(int i = 1; i <= n; i++){
		printf("%d\n", op[i]);
	}
	return 0;
}


Measured memory_bytes: 256
"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(str(var))
def outln(var): sys.stdout.write(str(var)+"\n")
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


dp = dd(int)
for i in range(int(data())):
    dp[data()] += 1
outln(len(dp))


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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int c = 0, l, r, d;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++) if (i % d == 0) c++;
  cout << c << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = 0;
    ll tmp = n/(a+b);
    ans += a*tmp;
    n -= (tmp*(a+b));
    ans += min(n, a);

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

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) (int)arr.size()

using namespace std;
using ll = long long;
const ll MOD = 998244353;
const ll INF = 1e9 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }




int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
		//  ======= FAST I/O =========
	fastio;
	//  ==========================
	int n,q;
	string str;
	cin >> n;
	cin >> str;
	set<int> s[26];
	for (int i = 0; i < n; ++i) {
		s[str[i] - 'a'].insert(i + 1);
	}
	cin >> q;
	while (q--) {
		int t, l, r;
		char to;
		cin >> t;
		if (t == 1) {
			cin >> l >> to;
			if (str[l - 1] != to) {
				s[str[l - 1] - 'a'].erase(l);
				s[to - 'a'].insert(l);
			}
			str[l - 1] = to;
		}
		else {
			cin >> l >> r;
			int ans = 0;
			for (int i = 0; i < 26; ++i) {
				auto it = s[i].lower_bound(l);
				if (it != s[i].end() && *it <= r)
					++ans;
			}
			cout << ans << "\n";
		}
	}
	return 0;
}


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

int main(){
    int a,n,ans,count,answer;
  	ans=0;
  	answer=0;
    //string s,t;
    cin >> n;
    //vector<int> h(n);
    cin >> count;
    rep(i,n-1){
        cin >> a;
        if(count >= a){
            answer++;
        }else{
            ans = max(ans,answer);
            answer=0;
        }
        count = a;
    }
    ans = max(ans,answer);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define int long long
int const maxn = 1e5 + 5;
int a[maxn];
int tree[4 * maxn];

void build(int i, int l, int r) {
    if (r - l == 1) tree[i] = a[l];
    else {
        int m = (r + l) / 2;
        build(2 * i + 1, l, m);
        build(2 * i + 2, m, r);
        tree[i] = max(tree[2 * i + 1], tree[2 * i + 2]);
    }
}

int gett(int i, int l, int r, int lq, int rq) {
    if (lq >= r || l >= rq) return 0;
    if (lq <= l && r <= rq) return tree[i];
    int m = (r + l) / 2;
    return max(gett(2 * i + 1, l, m, lq, rq), gett(2 * i + 2, m, r, lq, rq));
}

main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    build(0, 1, n + 1);
    for (int i = 1; i <= n; ++i) {
        int start_l = -1, stop_l = -1;
        int start_r = -1, stop_r = -1;
        int lef = 0, righ = i;
        while (righ - lef > 1) {
            int mid = (righ + lef) / 2;
            int x = gett(0, 1, n + 1, mid, i);
            if (x > a[i]) lef = mid;
            else righ = mid;
        }
        start_l = lef;
        lef = 0, righ = start_l;
        while (righ - lef > 1) {
            int mid = (righ + lef) / 2;
            int x = gett(0, 1, n + 1, mid, start_l);
            if (x > a[i]) lef = mid;
            else righ = mid;
        }
        stop_l = lef;
        lef = i, righ = n + 1;
        while (righ - lef > 1) {
            int mid = (righ + lef) / 2;
            int x = gett(0, 1, n + 1, i + 1, mid + 1);
            if (x > a[i]) righ = mid;
            else lef = mid;
        }
        start_r = righ;
        lef = start_r, righ = n + 1;
        while (righ - lef > 1) {
            int mid = (righ + lef) / 2;
            int x = gett(0, 1, n + 1, start_r + 1, mid + 1);
            if (x > a[i]) righ = mid;
            else lef = mid;
        }
        stop_r = righ;
        //cout << start_l << " " << stop_l << " " << start_r << " " << stop_r << '\n';
        ans += a[i] * ((i - start_l) * (stop_r - start_r) + (start_r - i) * (start_l - stop_l));
    }
    cout << ans << '\n';
    return 0;
}



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

struct st { int p, b, c; };
bool operator<(st a, st b) { return a.c>b.c; }
unordered_map<int, vector<int>>E[100000];
vector<int>G[100000];
unordered_map<int, int>d[100000];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		int p, q, c; scanf("%d%d%d", &p, &q, &c); p--; q--;
		E[p][c].push_back(q); E[q][c].push_back(p);
		G[p].push_back(c); G[q].push_back(c);
	}
	priority_queue<st>que;
	d[0][0] = 0; que.push({ 0,0,0 });
	while (!que.empty()) {
		st p = que.top(); que.pop();
		if (d[p.p][p.b] != p.c)continue;
		if (d[p.p].find(0) == d[p.p].end() || d[p.p][0] > p.c) {
			d[p.p][0] = p.c;
			que.push({ p.p,0,p.c });
		}
		if (p.b == 0) {
			for (int v : G[p.p]) {
				if (d[p.p].find(v) == d[p.p].end() || d[p.p][v] > p.c + 1) {
					d[p.p][v] = p.c + 1;
					que.push({ p.p,v,p.c + 1 });
				}
			}
			continue;
		}
		for (int v : E[p.p][p.b]) {
			if (d[v].find(p.b) == d[v].end() || d[v][p.b] > p.c) {
				d[v][p.b] = p.c;
				que.push({ v,p.b,p.c });
			}
		}
	}
	int Min = INT_MAX;
	for (auto p : d[n - 1])Min = min(Min, p.second);
	if (Min == INT_MAX)puts("-1");
	else printf("%d\n", Min);
}

Measured memory_bytes: 79156
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;

int main() {
	int N; cin >> N;
	map<int, int>m;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		m[a]++;
	}

	int ans = 0;
	for (auto a : m) {
		if (a.first > a.second)ans += a.second;
		else ans += a.second - a.first;
	}

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

Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M,Q;
int A[51],B[51],C[51],D[51];
int E[51];
int ans=0;

void dfs(vector<int> v){
	int res=0;
	if(v.size()==N){
		REP(i,Q){
			if(v[B[i]]-v[A[i]]==C[i]){
				res+=D[i];
			}
		}
		ans=max(ans,res);
		return;
	}
	for(int i=v.back();i<=M;i++){
		vector<int> c=v;
		c.push_back(i);
		dfs(c);
	}
}

signed main(){
	cin>>N>>M>>Q;
	REP(i,Q){
		cin>>A[i]>>B[i]>>C[i]>>D[i];
		A[i]--,B[i]--;
	}
	for(int i=1;i<=M;i++){
		dfs({i});
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3524
#include <iostream>

int main(int argc, char const* argv[])
{
  int count = 0,hoken,max,answer,temp,now_buy;
  std::cin >> count;
  std::cin >> now_buy;
  max = now_buy;
  answer = max - now_buy;
  for(auto i = 0;i < count - 1 ; i++)
  {
    std::cin >> temp;
    if(i == 0 && now_buy > temp)
    {
      hoken = now_buy;
      now_buy = temp;
      answer = now_buy - hoken;
      continue;
    }
    if(answer < 0 && now_buy > temp)
    {
      hoken = now_buy;
      now_buy = temp;
      if(answer < now_buy - hoken)
      {
        answer = hoken - now_buy;
      }
      continue;
    }
    if(now_buy > temp)
    {
      now_buy = temp;
    }
    else if(answer < temp - now_buy)
    {
      answer = temp - now_buy;
    }
  }
  std::cout << answer << std::endl;
  return 0;
}

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

int main(){
	char N[4];
	int X=0, Y=0;
	for(int k=0; k<4; k++){
		cin>>N[k];
	}
	char aux=N[0];
	char aux1=N[1];
	for(int i=0; i<3; i++){
		if (N[i]==aux){
			X=X+1;
		}
	}	
	for(int j=1; j<4; j++){
		if (N[j]==aux1){
			Y=Y+1;
		}
	}
	if(Y>=3 or X>=3){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int age;
    cin>>age;
    if(age==1)
    {
        cout<<"Hello World\n";
    }
    else if(age==2)
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#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 << "Right" << endl;
  }
  else if ( A+B > C+D ){
    cout << "Left" << endl;
  }
  
  else{
    cout << "Balanced" << endl;
  }
}


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

int main(){
  int a[128] = {}, i = 0, x, y;
  char in[100];
  while(scanf("%s", in) != EOF){
    switch(*in){
    case '+':
      x = a[--i];
      y = a[--i];
      a[i++] = y + x;;
      break;
    case '-':
      x = a[--i];
      y = a[--i];
      a[i++] = y - x;
      break;
    case '*':
      x = a[--i];
      y = a[--i];
      a[i++] = y * x;
      break;
    default:
      a[i++] = atoi(in);
      break;
    }
  }
  printf("%d\n", a[--i]);
  return 0;
}



Measured memory_bytes: 2040
/*                          The four Truths of Life

                                    CKMKB
                                    PKMKB

                                    CKMKC
                                    PKMKC
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;
//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> n;
		//ll arr[n]; for (i = 0; i < n; i++) {cin >> arr[i];}


		while (n--)
		{
			cin >> str;

			if (str == "AC")
				flag++;
			else if (str == "WA")
				sum++;
			else if (str == "TLE")
				cnt++;
			else
				ans++;
		}

		cout << "AC x " << flag;
		ln
		cout << "WA x " << sum;
		ln
		cout << "TLE x " << cnt;
		ln
		cout << "RE x " << ans;







		ln
	}
	return 0;
}


Measured memory_bytes: 3656
f (x,y) '(' = (x+1,y)
f (x,y) ')' 
  | x == 0 = (x,y+1)
  | otherwise = (x-1,y)
main = do
  getLine
  s <- getLine
  let (x,y) = foldl f (0,0) s
  putStrLn $ replicate y '(' ++ s ++ replicate x ')'

Measured memory_bytes: 508
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin>>s;
  
  reverse(ALL(s));
  
  cout<<s<<endl;
  
  return 0;
}


Measured memory_bytes: 3040
import sys
from collections import Counter
n,t = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
_max = 0
res = []
for a in a_ls[::-1]:
    _max = max(a, _max)
    res.append(_max - a)
ct = Counter(res)
print(ct[max(res)])


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

using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	    unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      	    cout<<"#x "<<x<<"\n";
#define trace(x,y)  	    cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          	    cout<<"\n";


bool SBF(const pair <int,int>& a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair <int,int>& a, const pair<int,int>& b){return a.S<b.S;}


const long double PI  = 3.1415926535;
const long long   mod = 1e9+ 7; 
const int 	  mxN = 1000;













void solve(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string v = "", h = "";
    for(int i=sy; i<ty;i++)v+='U';
    for(int i=sx; i<tx;i++)h+='R';
    string u = "", hi="";
    for(int i=ty; i>sy;i--)u+='D';
    for(int i=tx; i>sx;i--)hi+='L';
    cout<<v<<h<<u<<hi;
    v = 'L' + v;
    v = v + 'U';
    h = h + 'R';
    h = h + 'D';
    u = 'R' + u;
    u = u + 'D';
    hi= hi +'L';
    hi= hi + 'U';
    cout<<v<<h<<u<<hi<<"\n";


}
int main(){
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int x,n;
    cin >> x >> n;
    set<int> si;
    rep(i,n){
        int x;
        cin >> x;
        si.insert(x);
    }
    int a = 0;
    while(1){
        if(si.find(x-a)==si.end()){
            cout << x-a << endl;
            return 0;
        }
        if(si.find(x+a)==si.end()){
            cout << x+a << endl;
            return 0;
        }
        a++;
    }
    return 0;
}

Measured memory_bytes: 3644
n = int(input())
a = [-1]
b = [-1]
for _ in range(n):
	ai,bi = map(int,input().split())
	a.append(ai)
	b.append(bi)
a = sorted(a)
b = sorted(b)
count = 0
if n%2 == 1:
	count = b[(n+1)//2] - a[(n+1)//2] + 1
else:
	a1 = a[n//2]
	b1 = b[n//2]
	a2 = a[n//2+1]
	b2 = b[n//2+1]
	count += 2*(b1-a2)+1
	count += (a2-a1)
	count += (b2-b1)
print(count)

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

int N, n;
pair<int, int>p[300000];
bool ok(int t) {
	priority_queue<int>Q; ll sum = 0;
	for (int i = n - 1; i >= n - t + 1; i--) {
		Q.push(p[i].second); sum += p[i].second;
	}
	if (p[n - t].first*(ll)t >= sum + p[n - t].second)return 1;
	for (int i = n - t; i > 0; i--) {
		if (!Q.empty() && Q.top() > p[i].second) {
			sum -= Q.top() - p[i].second; Q.pop();
			Q.push(p[i].second);
		}
		if (p[i - 1].first*(ll)t >= sum + p[i - 1].second)return 1;
	}
	return 0;
}
int main() {
	scanf("%d", &n);
	rep(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		p[i] = { b,a };
	}
	sort(p, p + n);
	int a = 0, b = n;
	while (a != b) {
		int t = (a + b) / 2;
		if (b - a == 1)t = b;
		if (ok(t))a = t;
		else b = t - 1;
	}
	printf("%d\n", a);
}

Measured memory_bytes: 8336
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n & 1) {
    cout << "No" << endl;
    return 0;
  }
  string l = s.substr(0, s.length() / 2);
  string r = s.substr(s.length() / 2, s.length() / 2);
  cout << (l == r ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %

		mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}

int main()
{
	fastio;
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c) {
		cout << "Yes" << endl;
	}
	else if (a == c && a != b) {
		cout << "Yes" << endl;
	}
	else if (b == c && c != a)
	{
		cout << "Yes" << endl;

	}
	else
	{
		cout << "No" << endl;
	}
}







Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int[] N = nextInts();
		Arrays.sort(N);
		
		String ans = "NO";
		if(N[0]==N[1]&&N[0]==5&&N[2]==7)
			ans="YES";
		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21076
using System;

	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			bool result = true;
			for (int i =1; i < s.Length; i++)
			{
				if (s[i - 1] == s[i])
				{
					result = false;
					break;
				}
				
			}
			if (result)
			{
				Console.WriteLine("Good");

			}
			else
			{
				Console.WriteLine("Bad");
			}

		}
	}



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

int main()
{
	long long k,a[100010],l=2,r=3;
	cin >> k;
	for (long long i=1;i<=k;++i) {
		cin >> a[i];
	}
	if (a[k]!=2) {
		puts("-1");
		return 0;
	}
	for (int i=k-1;i;--i) {
		long long tmp = l;
		if (tmp%a[i]) tmp += a[i]-(l%a[i]);
		if (tmp<l || tmp>r) {
			puts("-1");
			return 0;
		}
		l = tmp;
		tmp = r;
		if (tmp%a[i]) tmp -= (r%a[i]);
		if (tmp<l || tmp>r) {
			puts("-1");
			return 0;
		}
		r = tmp+a[i]-1;
	}
	cout << l << ' ' << r << endl;
	return 0;
}

Measured memory_bytes: 1024
import math
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
d1,d2,d3,d_inf=0,0,0,[]
for i in range(n):
    d1 += abs(x[i]-y[i])
    d2 += abs(x[i]-y[i])**2
    d3 += abs(x[i]-y[i])**3
    d_inf.append(abs(x[i]-y[i]))
print(d1)
print(d2**(1/2))
print(d3**(1/3))
print(max(d_inf))


Measured memory_bytes: 5696
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<int, int>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;
 
int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans=0;
    ll x[100010];
    cin>>x[0];
    for(int i=1;i<n;i++){
        cin>>x[i];
        ans+=min((x[i]-x[i-1])*a,b);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
listS=[]
listH=[]
listC=[]
listD=[]
for i in range(n):
    list1 = input().split()
    a = str(list1[0])
    b = int(list1[1])
    if a=='S':
        listS.append(b)
    elif a=='H':
        listH.append(b)
    elif a=='C':
        listC.append(b)
    elif a=='D':
        listD.append(b)

list2 = ['S', 'H', 'C', 'D']
for j in list2:
    if j == 'S':
        for k in range(1, 14):
            if k not in listS:
                print(j, k)
    elif j == 'H':
        for k in range(1, 14):
            if k not in listH:
                print(j, k)
    elif j == 'C':
        for k in range(1, 14):
            if k not in listC:
                print(j, k)
    elif j == 'D':
        for k in range(1, 14):
            if k not in listD:
                print(j, k)


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

int main(){
	int n,m;
	int t[109];
	int x[109];
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		t[i]=a;
		x[i]=a;
		sum+=a;
	}
	cin>>m;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		x[a]=t[a]-b;
		cout<<sum-x[a]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int main() {
	int H, W, N; cin >> W >> H >> N;
	int sy, sx; cin >> sx >> sy; sy--; sx--;
	vector<int> L(N);
	vector<vector<int> > py(N), px(N);
	vector<vector<bool> > a(H, vector<bool>(W));
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		int y, x;
		for (int t = 0; t < L[i]; t++) {
			cin >> x >> y; y--; x--;
			py[i].push_back(y);
			px[i].push_back(x);
		}
		a[y][x] = true;
	}
	vector<vector<vector<bool> > > dp(H, vector<vector<bool>>(W, vector<bool>(1<<N)));
	dp[sy][sx][(1<<N) - 1] = true;
	for (int t = 0; t < 45; t++) {
		vector<vector<vector<bool> > > _dp(H, vector<vector<bool>>(W, vector<bool>(1<<N)));
		for (int y = 0; y < H; y++)
			for (int x = 0; x < W; x++)
				for (int S = 0; S < 1<<N; S++) {
					if (!dp[y][x][S]) continue;
					int _S = 0;
					bool ok = true;
					for (int i = 0; i < N; i++)
						if ((S>>i & 1)) {
							if (L[i] <= t) {
								ok = false;
								break;
							}
							if (py[i][t] != y || px[i][t] != x)
								_S += 1<<i;
						}
					if (!ok) continue;
					if (_S == 0) {
						cout << t << endl;
						return 0;
					}
					for (int dy = -1; dy <= 1; dy++)
						for (int dx = -1; dx <= 1; dx++) {
							int _y = y + dy, _x = x + dx;
							if (_y >= 0 && _y < H && _x >= 0 && _x < W && !a[_y][_x])
								_dp[_y][_x][_S] = true;
						}
				}
		dp = _dp;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 1288
#include<stdio.h>
int main(void)
{
  char s[10];
  char t[10];
  int a=0;
  scanf("%s",&s);
  scanf("%s",&t);
  if(s[0]==t[0]) a++;
  if(s[1]==t[1]) a++;
  if(s[2]==t[2]) a++;
  printf("%d",a);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s.at(i);

  vector<vector<int>> d(h, vector<int>(w, -1));
  d.at(0).at(0) = 1;
  queue<pair<int, int>> q;
  q.push({0, 0});
  int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};
  while(!q.empty()){
    auto now = q.front(); q.pop();
    rep(k, 4){
      int ni = now.first + di[k], nj = now.second + dj[k];
      if(nj < 0 || w <= nj || ni < 0 || h <= ni) continue;
      if(s.at(ni).at(nj) == '#' || d.at(ni).at(nj) != -1) continue;
      d.at(ni).at(nj) = d.at(now.first).at(now.second) + 1;
      q.push({ni, nj});
    }
  }
  int wc = 0;
  rep(i, h)rep(j, w)if(s.at(i).at(j) == '.') wc++;
  cerr << d.at(h-1).at(w-1) << " " << wc << endl;
  if(d.at(h-1).at(w-1) == -1){
    cout << -1 << endl;
    return 0;
  }
  int ans = wc - d.at(h-1).at(w-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    long long ans = 1e18;
    long long sum, res;
    
    sum = 0;
    res = 0;
    rep(i, n) {
        sum += a[i];
        if (i % 2) {
            if (sum >= 0) {
                res += (1 + sum);
                sum = -1;
            }
        } else {
            if (sum <= 0) {
                res += (1 - sum);
                sum = 1;
            }
        }
    }
    ans = min(ans, res);
    sum = 0;
    res = 0;
    rep(i, n) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum >= 0) {
                res += (1 + sum);
                sum = -1;
            }
        } else {
            if (sum <= 0) {
                res += (1 - sum);
                sum = 1;
            }
        }
    }
    ans = min(ans, res);
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int dp[3111][3111];
ii par[3111][3111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s,t;
	cin>>s>>t;
	int m=s.length();
	int n=t.length();
	for(int i=1; i<=m; i++) 
    { 
		for(int j=1; j<=n; j++) 
		{ 
			dp[i][j]=0;
			if(dp[i-1][j]>=dp[i][j])
			{
				par[i][j]=mp(i-1,j); dp[i][j]=dp[i-1][j];
			}
			if(dp[i][j-1]>=dp[i][j])
			{
				par[i][j]=mp(i,j-1); dp[i][j]=dp[i][j-1];
			}
			if(s[i-1]==t[j-1]&&dp[i-1][j-1]+1>=dp[i][j]) 
			{
				dp[i][j]=dp[i-1][j-1]+1; par[i][j]=mp(i-1,j-1);
			}
		}
	}
	ii cur = mp(m,n);
	string ans;
	while(cur.fi>0&&cur.se>0)
	{
		ii tmp=par[cur.fi][cur.se];
		if(tmp.fi==cur.fi-1&&tmp.se==cur.se-1) ans+=s[tmp.fi];
		cur=tmp;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<'\n';
}


Measured memory_bytes: 186624
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[][]=new int[n][n];
			int max[]=new int[n];
			int min[]=new int[n];
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					a[i][j]=in.nextInt();
			for(int i=0;i<n;i++)
			{
				Arrays.fill(max, 0);
				Arrays.fill(min, 10000);
			}
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
				{
					max[i]=Math.max(max[i],a[j][i]);
					min[i]=Math.min(min[i], a[i][j]);
				}
			int ans=0;
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<n;j++)
				{
					if(max[i]==min[j])
					{
						ans=max[i];
						break;
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>
#include <bitset>

using namespace std;

int H, W, K;
vector<vector<int>> grid;

int H_MASK_MAX;

int process(const int& mask)
{
	vector<int> cut_h;
	for (int i = 0; i < H - 1; i++)
	{
		if (mask & (1 << i))
		{
			cut_h.push_back(i);
		}
	}
	cut_h.push_back(10);

	vector<int> block_sum(cut_h.size(), 0);

	int cut_count = 0;
	for (int j = 0; j < W; j++)
	{
		int curr_block_idx = 0;
		for (int i = 0; i < H; i++)
		{
			block_sum[curr_block_idx] += grid[i][j];
			if (cut_h[curr_block_idx] == i) curr_block_idx++;
		}

		for (int b = 0; b < block_sum.size(); b++)
		{
			if (block_sum[b] > K)
			{
				cut_count++;

				block_sum.assign(cut_h.size(), 0);
				int curr_block_idx = 0;
				for (int i = 0; i < H; i++)
				{
					if (block_sum[curr_block_idx] == K && grid[i][j]) return -1;

					block_sum[curr_block_idx] += grid[i][j];
					if (cut_h[curr_block_idx] == i) curr_block_idx++;
				}
			}
		}
	}

	return cut_count + cut_h.size() - 1;
}

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

	cin >> H >> W >> K;

	grid.assign(H, vector<int>(W, 0));

	for(int i = 0; i < H; i++)
	{
		string line;
		cin >> line;

		for (int j = 0; j < W; j++)
		{
			grid[i][j] = line[j] - '0';
		}
	}

	H_MASK_MAX = 1 << (H - 1);
	int result = (H - 1) + (W - 1);

	for (int mask = 0; mask < H_MASK_MAX; mask++)
	{
		int curr_result = process(mask);
		if (curr_result >= 0)
		{
			result = min(result, curr_result);
		}
	}

	cout << result;

	return 0;
}

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

int main(){
    int ans=0;
    string s;
    cin >> s ;
    const int n=s.size();
    for(int i=0;i<n/2;i++){
        if(s.at(i)!=s.at(n-1-i)){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  int pre = -1;
  int count = 0;
  rep(i,N) {
    int cur_d = d.at(i);
    if ( cur_d > pre ) {
      count++;
    }
    pre = cur_d;
  }
 
  cout << count << endl;  
}


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

int main() {
  int n;
  cin >> n;
  int a[n], b[n], c[n-1], ans=0;
  for(int i=0;i<n;++i) cin >> a[i];
  for(int i=0;i<n;++i){cin >> b[i];ans+=b[i];}
  for(int i=0;i<(n-1);++i) cin >> c[i];
  for(int i=0;i<(n-1);++i){
    if(a[i+1]-a[i]==1) ans+=c[a[i]-1];
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	string S;
  ll A=0,B=0,C=0,s,t;
  cin>>S;
  rep0(i,S.size()){
    if(S[i]=='a'){A++;}
    if(S[i]=='b'){B++;}
    if(S[i]=='c'){C++;}
    
    
  }
  
  s=min(min(A,B),C);
    t=max(max(A,B),C);

  if(t-s==1||t-s==0){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int a[128] = {0},n,m = 0;
	while(scanf("%d",&n) != EOF){
		a[n]++;
	}
	for (n = 1;n <= 100;n++){
		if(m < a[n]) m = a[n];
	}
	for (n = 1;n <= 100;n++){
		if(a[n] == m) printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

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

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

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

bool hasLoop(vector<vector<int> >& connections, int i, int j) {
    stack<int> toVisit;
    for (int k = 0; k < connections.size(); ++k) {
        if (connections[j][k] == 1 && k != i) {
            toVisit.push(k);
        }
    }

    bool foundLoop = false;
    map<int, int> visited;
    visited[j] = 1;
    while (!toVisit.empty()) {
        int next = toVisit.top();
        toVisit.pop();
        foundLoop = false;
        // cout << "visiting: " << next  << endl;
        visited[next] = 1;
        for (int k = 0; k < connections.size(); ++k) {
            // cout << "visiting: " << next << " isConencted with: " << k << "?" << endl;
            if (connections[next][k] == 1 && visited[k] == 0) {
                // cout << "visiting: " << next << " isConencted with: " << k << "?" <<  "true" <<endl;
                if (k == i) {
                    foundLoop = true;
                    break;
                }
                toVisit.push(k);
            } else {
                // cout << "visiting: " << next << " isConencted with: " << k << "?" <<  "false" <<endl;
            }
        }
        if (foundLoop) {
            break;
        }
    }
    return foundLoop;
}

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

    vector<vector<int> > connections(N, vector<int>(N));

    int i, j;
    repeat(k,M) {
        cin >> i >> j;
        connections[i - 1][j - 1] = 1;
        connections[j - 1][i - 1] = 1;
    }

    int count = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (connections[i][j] != 1) {
                continue;
            }
            if (!hasLoop(connections, i, j)) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[100005]={},q,b[50005]={},ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  cin >> q;
  for(int i=0; i<q; i++) {
    cin >> b[i];
  }
  for(int i=0; i<q; i++) {
    int ite=(lower_bound(a,a+n,b[i])-a);
    if(a[ite]==b[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
const int Max=3e5+1;
const long long Mod=1e9+7;
int cnt=0,M;
long long P[Max*3+10]={},inv[Max*3+10]={},Pow[Max*3+10]={};
inline long long C(int n,int m){return P[n]*inv[n-m]%Mod*inv[m]%Mod;}
int main(){
	P[0]=P[1]=1; for(int i=2;i<=Max*3;i++) P[i]=i*P[i-1],P[i]%=Mod;
	inv[0]=inv[1]=1; for(int i=2;i<=Max*3;i++) inv[i]=inv[Mod%i]*(Mod-Mod/i)%Mod;
	for(int i=2;i<=Max*3;i++) inv[i]=inv[i]*inv[i-1]%Mod;
	Pow[0]=1; for(int i=1;i<=Max*3;i++) Pow[i]=Pow[i-1]*3%Mod;
	int N,M,Q; scanf("%d%d%d",&N,&M,&Q);
	long long Ans=0,Sum1=0,Sum2=0;
	for(int i=N;i<=N+M+Q;i++){
		if(i==N){
			for(int j=0;j<i-N-Q;i++) Sum1+=C(i-N,j);
		    for(int j=max(i-N-Q,0);j<=min(M,i-N);j++) Sum2+=C(i-N,j);
		}else{
            if(i-N-Q-2>=0) Sum1=(Sum1*2%Mod-C(i-1-N,i-N-Q-2)+Mod)%Mod;
            Sum2=(Sum2*2%Mod-C(i-1-N,min(M,i-1-N))+Mod)%Mod;
			if(max(i-N-Q,0)>max(i-N-Q-1,0)) Sum1+=C(i-N,i-N-Q-1),Sum1%=Mod;
			if(min(M,i-N-1)<min(M,i-N)) Sum2+=C(i-N,min(M,i-N)),Sum2%=Mod;
		}
		Ans+=C(i-1,N-1)*Pow[N+M+Q-i]%Mod*(Sum2-Sum1+Mod)%Mod,Ans%=Mod;
//		for(int j=max(i-N-Q,0);j<=min(M,i-N);j++)
//		 Ans+=C(i-1,N-1)*C(i-N,j)%Mod*Pow[N+M+Q-i]%Mod,Ans%=Mod;  
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 21376