akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    string s;
    cin>>s;
    rep(i,s.size()) s[i]='x';
    cout<<s<<endl;;
}

Measured memory_bytes: 256
#include <stdio.h>
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
int main()
{
    int n,a[101],i,max=0,min=114514;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        max=max(max,a[i]);
        min=min(min,a[i]);
    }
    printf("%d",max-min);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int n,m,p,x,i,sum;
	int t[100];
	
	scanf("%d",&n);
	sum = 0;
	for (i = 0;i < n;i++) {
		scanf("%d",&t[i]);
		sum += t[i];
	}
	
	scanf("%d",&m);
	for (i = 0;i < m;i++) {
		scanf("%d %d",&p,&x);
		printf("%d\n",sum - t[p-1] + x);
	}
	
	
	return 0;
}


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

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

    string s, t;
    cin >> s >> t;
    
    int n = s.size();
    int si = 1, ti = 1;

    vector<int> A(26, 0);
    vector<int> B(26, 0);

    string ss = "", tt = "";
    for(int i = 0; i < n; i++){
        if(A[(int)(s[i] - 'a')] == 0){
            A[(int)(s[i] - 'a')] = si;
            ss += to_string(si);
            si++;
        }else{
            ss += to_string(A[(int)(s[i] - 'a')]);
        }

        if(B[(int)(t[i] - 'a')] == 0){
            B[(int)(t[i] - 'a')] = ti;
            tt += to_string(ti);
            ti++;
        }else{
            tt += to_string(B[(int)(t[i] - 'a')]);
        }
    }

    if(ss == tt){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1812
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, t;
  rd(n, t);
  int mn = 10 ^^ 9;
  foreach (_; 0 .. n) {
    int c, tm;
    rd(c, tm);
    if (tm <= t) {
      mn = min(mn, c);
    }
  }
  if (mn < 10 ^^ 9) {
    writeln(mn);
  } else {
    writeln("TLE");
  }
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

flags = [0] * len(S)
for i in range(len(S) - 1):
    flags[i + 1] = flags[i] + (1 if S[i:i + 2] == "AC" else 0)

for _ in range(Q):
    l, r = map(lambda x: x - 1, map(int, input().split()))
    print(flags[r] - flags[l])


Measured memory_bytes: 7748
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

m = int(input())
if m < 3:
    print(0)
    exit()
k = m // 3
a = 0
for i in range(k):
    c = m - 3 - (2*i)
    a += cmb(c,i,mod)
print(a%mod)


Measured memory_bytes: 10220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int n,d,ans = 0;
    cin>>n>>d;
    vector<int>x(n),y(n);
    rep(i,n)cin>>x[i]>>y[i];

    rep(i,n){
        if(sqrt(pow(x[i],2)+pow(y[i],2)) <= d){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4808
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, M, sum = 0, cnt = 0;
    cin >> N >> M;
    vector<int> A(N);
    for (auto& i : A) {
        cin >> i;
        sum += i;
    }
    for (auto i : A) if (4LL * i * M >= sum) cnt++;
    cout << (cnt >= M ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath> 
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <numeric> 
#include <iomanip>
#include <map> 
#include <stack>
#include <sstream>
#define sz(x) ((int)(x).size())
#define full(a) a.begin(), a.end()
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int MAX = 1e6;
long long max(long long a, long long b) { if (a > b)return a; else return b; }
long long min(long long a, long long b) { if (a < b)return a; else return b; }
const int MAXC = 1e5;


  		     	/*ll n, k;
		std::cin >>  n;
		std::vector <int> v(n);
			for (ll i = 0; i < n; i++)
			{
					std::cin >> v[i];
			}
		std::sort(v.begin(), v.end());*/
/*void sortString(string &str)
{
	sort(str.begin(), str.end());
	cout << str;
}*/


int main() {
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	ld x;
	cin >> x;
	if (x == 0)
	{
		cout << 1;
	}
	if (x == 1)
	{
		cout << 0;
	}
	return 0;

}

	

  



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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  for (int i = 0;  i < S.size(); i++) {
    int next;
    next = ((S.at(i) - 'A') + N)%26;
    S.at(i) = next + 'A';
  }
  cout << S << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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;
}

//Xの点の値をSに足して、次の方向を返す
pairII func(int A[11][11], pairII X, pairII D, string *S) {
	S->push_back(A[X.first][X.second] + '0');

	pairII nextX = make_pair(X.first + D.first, X.second + D.second);
	if (A[nextX.first][nextX.second] != -1) {
		return D;
	}
	//X軸反転
	if (A[nextX.first - D.first][nextX.second] != -1) {
		return make_pair(-D.first, D.second);
	}
	//Y軸反転
	else if (A[nextX.first][nextX.second - D.second] != -1) {
		return make_pair(D.first, -D.second);
	}
	//角
	else {
		return make_pair(-D.first, -D.second);
	}
}

int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;

	vector<int> A;
	ll S[100001];

	cin >> N;

	rep(i, 0, N) {
		int a;
		cin >> a;
		A.push_back(a);
	}

	sort(A.begin(), A.end());
	S[0] = A[0];
	rep(i, 1, N-1) {
		S[i] = S[i - 1] + A[i];
	}

	ll ans = 0;
	rep(i, 0, N - 1) {
		if (S[i] * 2 >= A[i + 1]) {
			ans++;
		}
		else {
			ans = 0;
		}


	}
	cout << ans + 1;
	return 0;

}


Measured memory_bytes: 1528
#include<stdio.h>

int main(){
	
	float n;
	
	while( scanf("%f",&n) != EOF ){
		if(n<=48.00){
			printf("light fly\n");
		}
		else if(n>48.00 && n<=51.00){
			printf("fly\n");
		}
		else if(n>51.00 && n<=54.00){
			printf("bantam\n");
		}
		else if(n>54.00 && n<=57.00){
			printf("feather\n");
		}
		else if(n>57.00 && n<=60.00){
			printf("light\n");
		}
		else if(n>60.00 && n<=64.00){
			printf("light welter\n");
		}
		else if(n>64.00 && n<=69.00){
			printf("welter\n");
		}
		else if(n>69.00 && n<=75.00){
			printf("light middle\n");
		}
		else if(n>75.00 && n<=81.00){
			printf("middle\n");
		}
		else if(n>81.00 && n<=91.00){
			printf("light heavy\n");
		}
		else if(n>91.00){
			printf("heavy\n");
		}
	}
	
return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
   int T; cin>>T;
   double Max=-1.0;
   while(T--){
      int n,m; cin>>n>>m;
      double vrsum=0.0;
      double rsum=0.0;
      while(m--){
         double v,r; cin>>v>>r;
         vrsum+=v*r;
         rsum+=r;
      }
      Max=max(Max,vrsum/rsum);
   }

   int p,q; cin>>p>>q;
   double vrsum=0.0;
   double rsum=0.0;
   while(q--){
      double v,r; cin>>v>>r;
      vrsum+=v*r;
      rsum+=r;
   }
   double x=vrsum/rsum;

   if(Max-x>0.0000001){
      cout<<"YES"<<endl;
   }else{
      cout<<"NO"<<endl;
   }

}




Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)
#define MAX 2000
ll fact[MAX+20];
long long INF = 1LL<<60;
ll mod=1e9+7;
void Init(ll t){
    fact[0]=1;
    rep(i,1,t){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
}
ll c(ll n,ll k){
    ll bunshi=fact[n];
    ll bunbo=fact[n-k]*fact[k]%mod;
    ll ret=bunshi*modinv(bunbo,mod)%mod;
    if(ret<0)ret+=mod;
    return ret;
}
int main( ){
    ll n,blue;
    cin>>n>>blue;
    ll red=n-blue;
    Init(MAX+10);
    rep(i,1,blue+1){
        if(i>=red+2){
            cout<<0<<endl;
            continue;
        }
        ll ans=c(blue-1,i-1)*c(red+1,i);
        ans%=mod;if(ans<0)ans+=mod;
        cout<<ans<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    double x1,y1,x2,y2;
    double d;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
    d=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
    
    printf("%.8lf", sqrt(d));
    
    return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 500005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";


ll n,m;

void initialize(ll arr[]) {
  for(ll i=1;i<=n;i++) {
    arr[i] = i;
  }
}
 
ll root(ll arr[], ll c) {
  while(arr[c] != c) {
    arr[c] = arr[arr[c]];
    c = arr[c];
  }
  return c;
}
 
void unite(ll arr[], ll p, ll q) {
  arr[root(arr, p)] = root(arr, q);
}
 
bool find(ll arr[], ll p, ll q) {
  if(root(arr, p) == root(arr, q)) return true;
  else return false;
}


int main() {
    #ifndef ONLINE_JUDGE  
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    cin>>n>>m;
    ll arr[n+1];
    initialize(arr);
    while(m--) {
        ll c1, c2;
        cin>>c1>>c2;
        unite(arr, c1, c2);
    }
    set<ll> st;
    for(ll i=1;i<=n;i++) {
        st.insert(root(arr, i));
    }
    cout<<st.size()-1;
}

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

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int n, m;
	int a[50], b[50];
	int c[50], d[50];
	
	cin >> n >> m;
	REP(i, n) scanf("%d %d", a + i, b + i);
	REP(i, m) scanf("%d %d", c + i, d + i);
	
	REP(i, n) {
		pii mi = pii(INF, 0);
		
		REP(j, m) chmin(mi, pii(abs(a[i] - c[j]) + abs(b[i] - d[j]), j));
		printf("%d\n", mi.second + 1);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	int n=s.length();
	for(int i=0;i<n;++i) {
		if((i%2==0&&s[i]=='L')||(i%2==1&&s[i]=='R')) {
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) int t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vi vector<ll>
const ll md=1e9 +7;const ll M1=998244353;
ll mod(ll n){return ((n%md)+md)%md;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=res*x;x=x*x;y=y>>1;}return res;}

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

    ll n;cin>>n;
    if(n<2){cs(0);return 0;}
    ll res=1;ll ans=1;ll a1=1;
    f(i,0,n){
        res=mod(res*10);
        ans=mod(ans*8);
        a1=mod(a1*9);
    }res=mod(res+ans-2*a1);
    cs(res);
}

Measured memory_bytes: 3648
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <vector>

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

using namespace std;

const int N = 1000010;

struct point {
    int x, y;
    point() {}
    point(int x, int y) : x(x), y(y) {}
    point operator +(const point& t) const {
        return point(x + t.x, y + t.y);
    }
    point operator -(const point& t) const {
        return point(x - t.x, y - t.y);
    }
};

int n;
vector<point> ps;

point perp(point p) {
    return point(-p.y, p.x);
}

int dot(point p, point q) {
    return p.x * q.x + p.y * q.y;
}

int side(point p1, point p2, point q) {
    int d = dot(q - p1, perp(p2 - p1));
    return d < 0 ? -1 : !!d;
}

double solve() {
    vector<bool> visited(n, false);

    double ans = 0.0;
    point now(0, 0);
    while (true) {
        int nexti = -1;
        point next;
        for (int i = 0; i < n; ++i) {
            if (visited[i])
                continue;
            if (nexti < 0 || side(now, next, ps[i]) > 0 || side(now, next, ps[i]) == 0 &&
                hypot(next.x - now.x, next.y - now.y) > hypot(ps[i].x - now.x, ps[i].y - now.y)) {
                nexti = i;
                next = ps[i];
            }
        }

        if (nexti == -1)
            return ans;

        ans += hypot(next.x - now.x, next.y - now.y);
        visited[nexti] = true;
        now = next;
    }
}

int main(){
    while (cin >> n, n) {
        ps.clear();
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            ps.push_back(point(x, y));
        }
        printf("%.1f\n", solve());
    }
}

Measured memory_bytes: 1244
#include<cstdio>
#include<iostream>
#include<deque>
#include<vector>
using namespace std;
int main()
{
	int t;
	deque<int>que;
	cin >> t;
	while (t--)
	{
		int a;
		cin >> a;
		if (a == 0)//插入 0头1尾
		{
			int b, c;
			cin >> b >> c;
			if (b == 0)
			{
				que.push_front(c);
			}
			else
			{
				que.push_back(c);
			}
		}
		if (a == 1)
		{
			int b;
			cin >> b;
			cout << que.at(b)<<endl;
		}
		if (a == 2)
		{
			int b;
			cin >> b;
			if (b == 0)
				que.pop_front();
			else que.pop_back();
		}
	}
}


Measured memory_bytes: 4516
// Aizu Vol-10 1044: CamelCase
// 2017.8.18 bal4u@uu

#include <stdio.h>
#include <ctype.h>

char n[130], t[10];
char ans[130];

int main()
{
	char *p, *q;

	while (scanf("%s%s", n, t) && t[0] != 'X') {
		p = n, q = ans;
		if (t[0] == 'U') {
			*q++ = toupper(*p++);
			while (*p) {
				while (*p && *p != '_') *q++ = *p++;
				if (*p == '_' && *(p + 1)) *q++ = toupper(*(p + 1)), p += 2;
			}
		} else if (t[0] == 'L') {
			*q++ = tolower(*p++);
			while (*p) {
				while (*p && *p != '_') *q++ = *p++;
				if (*p == '_' && *(p + 1)) *q++ = toupper(*(p + 1)), p += 2;
			}
		} else {
			*q++ = tolower(*p++);
			while (*p) {
				while (*p && !isupper(*p)) *q++ = *p++;
				if (isupper(*p)) *q++ = '_', *q++ = tolower(*p++);
			}
		}
		*q = 0;
		puts(ans);
	}
	return 0;
}

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



int main() {
	int n;
	int hantei = 0;
	int i, j;
	scanf("%d", &n);
	for (i = 1; i < 10; i++) {
		for (j = 1; j < 10; j++) {
			if (n == i*j)
				hantei = 1;
		}
	}
	if (hantei == 1)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#B
N,K = map(int,input().split())

c = [0]*N
for i in range(2*K):
    if i%2 == 0:
        d = int(input())
    else:
        A = list(map(int,input().split()))
        for a in A:
            c[a-1]+=1
            
print(c.count(0))



Measured memory_bytes: 9176
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}


char s[maxn];
int main(void) {
    FAST_IO;
    
    scanf("%s", s);
    int n = strlen(s);
    list<char> q;
    for (int i = 0; i < n; i++) {
        q.push_back(s[i]);
    }
    int Q;
    int cnt = 0;
    scanf("%d", &Q);
    while (Q--) {
        int t, f;
        char c[3];
        scanf("%d", &t);
        if (t == 1) {
            cnt++;
        } else {
            // if (cnt % 2) {
            //     q.reverse();
            // }
            // cnt = 0;
            scanf("%d %s", &f, c);

            if (f == 1 && (cnt & 1) == 0) q.push_front(c[0]);
            else if (f == 1) q.push_back(c[0]);
            if (f == 2 && (cnt & 1) == 0) q.push_back(c[0]);
            else if (f == 2) q.push_front(c[0]);
        }
    }
    if (cnt % 2) {
        q.reverse();
    }
    for (auto & x: q) {
        printf("%c", x);
    }
    puts("");
    
    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>
using namespace std;

namespace {

}

int main()
{
	string s, t;

	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	if (*s.begin() < *(t.end() - 1)) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		if (s.size() > t.size()) {
			cout << "No" << endl;
			return 0;
		}

		for (int i = 0; i < s.size(); ++i) {
			if (s[i] > t[t.size() - 1 - i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		if (s.size() == t.size()) {
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
	}

	return 0;
}


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

typedef long long ll;

int X, Y, A, B, C;
vector<ll> p, q, r;

int main()
{
    scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
    for(int i=0; i<A; ++i){ ll x; scanf("%lld", &x); p.push_back(x); }
    for(int i=0; i<B; ++i){ ll x; scanf("%lld", &x); q.push_back(x); }
    for(int i=0; i<C; ++i){ ll x; scanf("%lld", &x); r.push_back(x); }
    sort(p.begin(), p.end(), [&](ll a, ll b){ return a>b; });
    sort(q.begin(), q.end(), [&](ll a, ll b){ return a>b; });
    sort(r.begin(), r.end(), [&](ll a, ll b){ return a>b; });
    while(p.size() > X) p.pop_back();
    while(q.size() > Y) q.pop_back();
    int i = 0, xi=X-1, yi=Y-1;
    while(i<C && (xi>=0 || yi>=0)){
        ll tmpx=9999999999, tmpy=9999999999;
        if(xi>=0) tmpx = p[xi];
        if(yi>=0) tmpy = q[yi];
        if(tmpx<tmpy && tmpx<r[i]){ p[xi] = r[i]; ++i; --xi; continue; }
        if(tmpx>=tmpy && tmpy<r[i]){ q[yi] = r[i]; ++i; --yi; continue; }
        break;
    }
    ll ans = 0;
    for(auto x : p) ans += x;
    for(auto y : q) ans += y;
    printf("%lld\n", ans);
}

Measured memory_bytes: 3316
/*
AizuOnline A2508
Title King's Inspection
*/
#include <stdio.h>
#include <string.h>
//Global data section
int n;
int k[100];
char s[101];
//
char num2alpha(int x)
{
        if(x<26)
                return('a'+x);
        else
                return('A'+(x-26));
}
main()
{
        int i,len;
        char cn;

        while(EOF!=scanf("%d",&n) && n)
        {
                for(i=0;i<n;i++)  
                        scanf("%d ",&k[i]);
                scanf("%s",s);

                len=strlen(s);
                for(i=0;i<len;i++)
                {
                        if(islower(s[i]))
                                cn = s[i]-'a';
                        else 
                                cn = s[i]-'A'+26;
                        //printf("%d %d:",cn,cn-k[i % n]);
                        printf("%c",num2alpha((52+cn-k[i % n])%52));
                }
                        printf("\n");
        }
        return(0);
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    ll N,all;
    all=0;
    ll A[100005],y[100005];
    cin >> N;
    rep(i,N){
        cin >> A[i+1];
        all+=A[i+1];
    }
    ll hanbun =all/2;
    ll except=0;
    for(int i=2;i<N;i=i+2){
        except+=A[i];
    }
    y[1]=hanbun-except;
    for(int i=2;i<=N;i++){
        y[i]=A[i-1]-y[i-1];
    }
    for(int i=0;i<N;i++){
        cout << 2*y[i+1] << endl;
    }

}



Measured memory_bytes: 2944
N, W = map(int, input().split())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
inf = 10**10
V = 0
for a in range(N):
	V += A[a][1]
dp = [inf for v in range(V+1)]
dp[0] = 0
for p in range(N):
	for q in range(V - A[p][1], -1, -1):
		dp[q + A[p][1]] = min(dp[q + A[p][1]], dp[q] + A[p][0])
# print(dp)
ans = 0
for b in range(V+1):
	if (dp[b] <= W):
		ans = b
print(ans)

Measured memory_bytes: 45124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define rep(i,n) for(int i = 0; i < n; i++)
#define MSG(a) cout << #a << " " << a << endl;
template<class T, class C> pair<T,C> mp(T a, C b){ return make_pair(a, b);}

int main()
{
	int n, k;
	while(cin >> n >> k && n)
	{
		vint card(n), pool;
		rep(i,n) cin >> card[i];
		sort(card.begin(), card.end());
		
		do
		{
			int x = 0;
			rep(i,k) x = x * (static_cast<int>(card[i] / 10) > 0 ? 100 : 10) + card[i];
			pool.push_back(x);
		}
		while(next_permutation(card.begin(), card.end()));
		sort(pool.begin(), pool.end());

		pool.erase(unique(pool.begin(), pool.end()), pool.end());

		cout << pool.size() << endl;
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> S(N+1,0);
    for (int i=1;i<=N;i++){
        long long a;
        cin >> a;
        S[i]=S[i-1]+a;
    }
    sort(S.begin(),S.end());
    long long ans=0;
    long long p=0;
    long long cnt=0;
    for(int i=0;i<=N;i++){
        if(p!=S[i]){
            p=S[i];
            ans+=cnt*(cnt-1)/2;
            cnt=0;
        }
        cnt++;
    }
    ans+=cnt*(cnt-1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>


using namespace std;
long int digitos(long int n){
    long int x,y;

    x = n%10; 
    

    y = (n - x)/10;
    

    if (y < 1){
          return x;
          }
    else {
          return x + digitos(y); 
         }
    }
int main(){
    long long int somado;
    long int r;
    cin >> somado;
    
    
    r = digitos(somado);
    if(somado%r==0){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007

int main(){
	int N; cin>>N;
	set<string> s;
	rep(i,0,N){
		string a; cin>>a;
		s.insert(a);
	}
	cout<<s.size();
	
	
}

Measured memory_bytes: 19204
import sys
S=sys.stdin.readlines()
def Binit(B,siz):
  while len(B)<siz+1:
    B.append(0)
  while len(B)>siz+1:
    del B[-1]
  for i in range(siz+1):
    B[i]=0
  B.append(siz)

def Badd(B,a,x):
  z=a
  while z<=B[-1]:
    B[z]+=x
    z+=(z&(-z))

def Bsum(B,a):
  r=0
  z=a
  while z>0:
    r+=B[z]
    z-=(z&(-z))
  return r

def Bssum(B,a,b):
  return Bsum(B,max(a,b))-Bsum(B,min(a,b)-1)

BIT=[]
N,Q=map(int,S[0].split())
Binit(BIT,N+1)
A=list(map(int,S[1].split()))
for i in range(N):
  Badd(BIT,i+1,A[i])
a,b,c=0,0,0
for i in range(Q):
  a,b,c=map(int,S[i+2].split())
  if a:
    print(Bssum(BIT,b+1,c))
  else:
    Badd(BIT,b+1,c)

Measured memory_bytes: 198964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll k, x;
    cin >> k >> x;
    if(500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
/* long long or int */
/* xx 396*/

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

const int maxn=1e5+100;

typedef long long ll;

ll val[maxn],a[maxn];
ll n,sum=0;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>n;
	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<n;i++) a[i]=a[i]<<1;
	for(ll i=n-2;i>=0;i-=2) sum+=a[i]-a[i-1];
	val[0]=(a[n-1]-sum)>>1;
	for(ll i=0;i<n-1;i++){
		val[i+1]=a[i]-val[i];
	}
	for(ll i=0;i<n;i++) cout<<val[i]<<" ";
	return 0;
}

Measured memory_bytes: 2944
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
aika = bika = bijyo = 0
for i in range(n):
    if p[i] <= a:aika += 1
    elif p[i] > b:bijyo += 1
    else:bika += 1
print(min(aika,bijyo,bika))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    sorted_a = sorted(a)
    a_max = max(a)
    a_second = sorted_a[-2]

    for ai in a:
        if ai == a_max:
            print(a_second)
        else:
            print(a_max)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14112
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
const int MAXV = 1e5 + 5;
const int MAXM = 1 << 9;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int a[MAXM][MAXV];
int n, m, r, q, v[MAXN], w[MAXN];
int query(int x, int y) {
	if (x <= m) return a[x][y];
	else {
		int ans = query(x / 2, y);
		if (y >= w[x]) chkmax(ans, v[x] + query(x / 2, y - w[x]));
		return ans;
	}
}
int main() {
	read(n), m = (1 << 9) - 1, r = 1e5;
	for (int i = 1; i <= n; i++)
		read(v[i]), read(w[i]);
	for (int i = 1; i <= m; i++) {
		int f = i / 2;
		for (int j = 1; j <= r; j++) {
			a[i][j] = a[f][j];
			if (j >= w[i]) chkmax(a[i][j], v[i] + a[f][j - w[i]]);
		}
	}
	read(q);
	for (int i = 1; i <= q; i++) {
		int x, y; read(x), read(y);
		printf("%d\n", query(x, y));
	}
	return 0;
}


Measured memory_bytes: 205456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; //=2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; //=9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int[] t = readNums();
		int m = readNum();
		int[] p = new int[m];
		int[] x = new int[m];
		for (int i=0; i<m; i++) {
			int[] ia = readNums();
			p[i] = ia[0] - 1;
			x[i] = ia[1];
		}
		long sum = 0;
		for (int i=0; i<n; i++) {
			sum += t[i];
		}
		for (int i=0; i<m; i++) {
			long ans = sum - t[p[i]] + x[i];
			pln(ans);
		}
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}
	long plong(String s) {
		return Long.parseLong(s);
	}
	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	int readNum() {
		String line = readLine();
		return pint(line);
	}
	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}
	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i=0; i<flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}
	void p(char c) {
		_out.print(c);
	}
	void pln(char c) {
		_out.println(c);
	}
	void p(double d) {
		_out.print(d);
	}
	void pln(double d) {
		_out.println(d);
	}
	void p(long l) {
		_out.print(l);
	}
	void pln(long l) {
		_out.println(l);
	}
	void p(String s) {
		_out.print(s);
	}
	void pln(String s) {
		_out.println(s);
	}
	static BufferedReader _in;
	static PrintWriter _out;
	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end-start) + "ms");
		}
	}
}


Measured memory_bytes: 8404
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				scan.close();
				break;
			}

			for(int i = 0; i < H; i++){ //縦の列の繰り返し
				if(i%2 == 0){
					for(int s=0; s<W; s++){ //偶数列の横の行の繰り返し
						if(s%2 == 0)
							System.out.print("#");
						else
							System.out.print(".");
					}
				}else{
					for(int t=0; t<W; t++){ //奇数列の横の行の繰り返し
						if(t%2 == 0)
							System.out.print(".");
						else
							System.out.print("#");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 32056
fun main(args: Array<String>){
    val line: String = readLine() as String
    val nm=line.split(" ")
    val n = nm[0].toInt()
    val k = nm[1].toInt()
    var count:Long = 0
    for(b in k+1..n){
        count+=(n/b)*(b-k)
        if(n%b-k+1>0){
            count +=( n%b-k+1)
        }
    }
    if(k==0)count-=n
    print(count)
}

Measured memory_bytes: 37868
using System;
class abc123b{
  static void Main(){
    var p=new int[5];
    for(int i=0;i<5;i++){
      p[i]=int.Parse(Console.ReadLine());
    }
    
    var min=999;
    var last=0;
    
    for(int i=0;i<5;i++){
      int d=p[i]%10;
      if(d!=0&&d<min){
        last=i;
        min=d;
      }
    }
    var result=0;
    
    for(int i=0;i<5;i++){
      if(i!=last){
        result+=p[i];
        double c10=Math.Ceiling(Convert.ToDouble(result)/10)*10;
        result=Convert.ToInt32(c10);
      }
    }
    result+=p[last];
    Console.WriteLine(result);
    return;
  }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define iiii pair<int, pii>
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
	int x = 0, p = 1; char c = getchar();
	while (c <= 32) c = getchar();
	if (c == 45) p = -p, c = getchar();
	while (c > 32) x = x * 10 + c - 48, c = getchar();
	return x * p;
}
using namespace std;
//ruogu_alter
const int s = 0;
const int t = 1;
const int N = 2e5 + 5;
struct edge {
	int to, val, rev;
};
vector<edge> g[N];
int qu[N], iter[N], dis[N];
int sz = 2, n, a[N], b[N], toa[N], tob[N]; 
bool vis[N];
inline void addedge(int x, int y, int z) {
	g[x].emplace_back((edge){y, z, g[y].size()});
	g[y].emplace_back((edge){x, 0, g[x].size() - 1});
}
bool bfs() {
	int st = 0, ed = 1;
	memset(dis, -1, sizeof(dis));
	dis[s] = 0; qu[0] = s;
	while (st < ed) {
		int u = qu[st++];
		rep(i, g[u].size()) {
			edge e = g[u][i];
			if (e.val && dis[e.to] == -1) {
				dis[e.to] = dis[u] + 1;
				qu[ed++] = e.to;
			}
		}
	}
	return dis[t] >= 0;
}
int dfs(int x, int val) {
	if (x == t) return val;
	while (iter[x] < g[x].size()) {
		edge &e = g[x][iter[x]];
		if (e.val && dis[e.to] > dis[x]) {
			int ans = dfs(e.to, min(val, e.val));
			if (ans) {
				e.val -= ans;
				g[e.to][e.rev].val += ans;
				return ans;
			}
		}
		++iter[x];
	}
	return 0;
}
int dinic() {
	int ans = 0;
	while (bfs()) {
		memset(iter, 0, sizeof(iter));
		int f;
		while (f = dfs(s, INF)) ans += f;
	}
	return ans;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = getint(); 
	rep(i, n) a[i] = getint();
	rep(i, n) b[i] = getint();
	rep(i, n) if (!vis[i]) {
		int x = i;
		while (!vis[x]) {
			vis[x] = true;
			toa[x] = sz;
			x = a[x];
		}
		++sz;
	}
	memset(vis, 0, sizeof(vis));
	rep(i, n) if (!vis[i]) {
		int x = i;
		while (!vis[x]) {
			vis[x] = true;
			tob[x] = sz;
			x = b[x]; 
		}
		++sz;
	}
	int res = n;
	rep(i, n) {
		if (a[i] == i && b[i] == i) --res;
		else if (a[i] == i) addedge(s, tob[i], 1);
		else if (b[i] == i) addedge(toa[i], t, 1);
		else {
			addedge(toa[i], tob[i], 1);
			if (a[i] == b[i]) addedge(tob[i], toa[i], 1);
		}
	}
	cout << res - dinic() << endl;
	return 0;
}


Measured memory_bytes: 17280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 0

int main(){

	lli n,m;
	cin>>n>>m;
	map<lli,vector<lli>> g;
	REP(i,m){
		lli tmpA,tmpB;
		cin>>tmpA>>tmpB;
		g[tmpA].push_back(tmpB);
		g[tmpB].push_back(tmpA);
	}

	queue<lli> q;
	queue<lli> f;

	q.push(1);
	f.push(1);
	lli ansCnt=0;
	while(q.size()){
		lli top = q.front();
		lli topF = f.front();
		q.pop();
		f.pop();
		lli flag=0;
		for(auto &e:g[top]){
			if(DEBUG)cout<<e<<" ";
			if(DEBUG)cout<<topF<<" "<< (1<<(e-1))<<endl;
			if((topF & 1<<(e-1)) == 0){
				if(DEBUG)cout<<topF<<" "<< (1<<(e-1))<<endl;
				q.push(e);
				f.push(topF|1<<(e-1));
				flag=1;
			}
		}
		if(flag==0){
			lli ansFlag=0;
			REP(i,n){
				if((topF & (1<<i)) ==0){
					ansFlag=1;
					break;
				}
			}
			if(ansFlag==0){
				ansCnt++;
			}
		}
	}

	cout<<ansCnt<<endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    string S;
    int n, k;
    cin >> n >> k >> S;
    vector<int> vec;
    int cnt = 1;
    rep (i, 1, n) {
        if (S[i - 1] != S[i]) {
            vec.push_back (cnt);
            cnt = 1;
        } else {
            cnt++;
        }
    }
    vec.push_back (cnt);
    int l = vec.size();
    if (l < 2 * k + 1) {
        cout << n - 1 << "\n";
        return 0;
    }
    //累積和
    int sum2 = 0;
    int s[l + 1] = {};
    rep (i, 0, l) {
        s[i + 1] = s[i] + vec[i];
        sum2 += vec[i] - 1;
    }
    //計算
    int ans = 0;
    rep (i, 0, n - 2 * k) {
        int sum;
        sum = s[i + 2 * k + 1] - s[i] - 1 + sum2 -
              (s[i + 2 * k + 1] - s[i] - k * 2 - 1);
        // cout << i << " " << sum << "\n";
        ans = max (ans, sum);
    }
    cout << ans << "\n";
}

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

int main() {
  
  int n;
  cin>>n;
  int AC=0,WA=0,TLE=0,RE=0;
  
  
  for(int i=0 ;i<n;i++){
    string c;
    cin>>c;
  
    if(c=="AC"){
     AC++;
    }
    else if(c=="WA"){
     WA++;
    }
    else if(c=="TLE"){
     TLE++;
    }
    else if(c=="RE"){
     RE++;
    }
}
    cout<<"AC x "<< AC <<endl;
    cout<<"WA x "<< WA <<endl;
    cout<<"TLE x "<< TLE <<endl;
    cout<<"RE x "<< RE <<endl;
 }
    
  


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
typedef long long ll;
typedef pair<ll,ll> P;
struct edge{ll to,cost;};
ll N,M,C,a,b,c;
vector<edge> G[MAX];
ll d[MAX];

void dijkstra(){
  for(int i=0;i<MAX;i++)d[i]=(1LL<<60);
  d[1]=0;
  priority_queue< P , vector<P> , greater<P> > Q;
  Q.push(P(0,1));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    ll pos=p.second,cost=p.first;
    if(d[pos]<cost)continue;
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(d[e.to]>cost+e.cost){
        d[e.to]=cost+e.cost;
        Q.push(P(d[e.to],e.to));
      }
    }
  }  
}

int main(){
  ll sum=0;
  scanf("%lld %lld %lld",&N,&M,&C);
  for(int i=0;i<M;i++){
    scanf("%lld %lld %lld",&a,&b,&c);
    sum+=c;
    G[a].push_back((edge){b,c});
    G[b].push_back((edge){a,c});
  }
  dijkstra();
  map<ll,ll> mp;
  for(int i=1;i<=N;i++){
    for(int j=0;j<(int)G[i].size();j++){
      edge e=G[i][j];
      if(i<e.to)mp[ max(d[i],d[e.to]) ]+=e.cost;
    }
  }
  ll ans=sum;
  map<ll,ll> :: iterator it;
  for(it=mp.begin();it!=mp.end();it++){
    ll X=it->first,D=it->second;
    sum-=D;
    ans=min(ans,X*C+sum);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 18768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template <typename T>
struct BIT
{
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    void add(int i, T x = 1)
    {
        for (i++; i <= n; i += i & -i)
        {
            d[i] += x;
        }
    }
    T sum(int i)
    {
        T x = 0;
        for (i++; i; i -= i & -i)
        {
            x += d[i];
        }
        return x;
    }
    T sum(int l, int r)
    {
        return sum(r - 1) - sum(l - 1);
    }
};

BIT<int> bit[30];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    // std::ifstream in("E/in/02-small-00");
    // std::cin.rdbuf(in.rdbuf());
    REP(i, 30)
    {
        bit[i] = BIT<int>(500010);
    }
    int N;
    cin >> N;
    string S;
    cin >> S;
    REP(i, N)
    {
        int tmp = S[i] - 'a';
        bit[tmp].add(i);
    }
    int Q;
    cin >> Q;
    vi q;
    REP(i, Q)
    {
        int a, b;
        char c;
        int d;
        cin >> a;
        if (a == 1)
        {
            cin >> b >> c;
            bit[S[b - 1] - 'a'].add(b - 1, -1);
            S[b - 1] = c;
            int tmp = c - 'a';
            bit[tmp].add(b - 1);
        }
        else
        {
            cin >> b >> d;
            int ans = 0;
            REP(j, 30)
            {
                if (bit[j].sum(d - 1) - bit[j].sum(b - 2) > 0)
                    ans++;
            }
            q.emplace_back(ans);
        }
    }
    REP(i, q.size())
    cout << q[i] << endl;

    return 0;
}


Measured memory_bytes: 118404
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

int main()
{
    string s0,s1,s2;
    cin >> s0 >> s1 >> s2;
    cout << s0[0] << s1[1] << s2[2] << '\n';
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000



void solve_abc105_c() {
	ll N;
	deque<ll> ans;

	cin >> N;

	if (N == 0) {
		cout << "0\n";
		return;
	}

	ll val, i;
	i = 1;
	while(1)
	{
		if (N == 0) {
			break;
		}
		val = N % (ll)pow(-2, i);
		if (val != 0) {
			ans.push_front(1);
			N -= (ll)pow(-2, i-1);
		}
		else {
			ans.push_front(0);
		}
		i++;
	}
	
	rep(i,ans.size()){
		cout << ans[i];
	}
	cout << "\n";
}

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

	solve_abc105_c();

	return 0;
}

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

// time complexity = O(N*K)

int main(){
	
	int n,k;
	cin >> n >> k;
	int h[n+1];
	for(int i=1;i<=n;++i) cin >> h[i];

	int dp[n+1];
	dp[1]=0;

	for(int i=2;i<=n;i++){
		dp[i] = INT_MAX;
		for(int j=1;j<=k && i-j>=1;j++){
			dp[i] = min(dp[i] , dp[i-j] + abs(h[i]-h[i-j]));
		}
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 4388
n = int(input())
s = str(input())
s += s
candidate = [[1,-1],[1,1],[-1,-1],[-1,1]]
result = []
checker = 0
while checker < 4:
    result = candidate[checker]
    for i in range(1, len(s)-1):
        if s[i] == 'o' and result[i] == 1:
            result.append(result[-2])
        elif s[i] == 'x' and result[i] == 1:
            result.append(-result[-2])
        elif s[i] == 'o' and result[i] == -1:
            result.append(-result[-2])
        else:
            result.append(result[-2])
    if result[:n] == result[n:]:
        checker += 10
    else:
        checker += 1
if checker == 4:
    print(-1)
else:
    result = ['S' if x == 1 else 'W' for x in result[:n]]
    print(''.join(result))

Measured memory_bytes: 11196
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
unsigned long long gcd(unsigned long long a, unsigned long long b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
unsigned long long lcm(unsigned long long a, unsigned long long b) {
	return a * b / gcd(a, b);
}
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<int> a(n);
	int cnt=0, now=1;
	rep(i,n){
	    cin>>a[i];
	    if(now==a[i])now++;
	    else cnt++;
	}
	if(cnt==n)cout<<-1<<endl;
	else cout<<cnt<<endl;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int M, D; cin >> M >> D;

	int ans = 0;
	FOR(i, 1, M+1){
		FOR(j, 1, D+1){
			int p = (j/10)*(j%10);
			if(i == p and (j/10) >= 2 and (j%10) >= 2){
				ans++;
			} 
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
const int lim = 51;
const int INF = 1e9;

int H, W;
char maze[lim][lim];
int d[lim][lim];

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

bool isIn(int y, int x){
    return (0 <= y && y < H && 0 <= x && x < W);
}

void dfs(int y, int x){
    rep(i, 4){
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(isIn(ny, nx) && maze[ny][nx] == '.' && d[y][x] + 1 < d[ny][nx]){
            d[ny][nx] = d[y][x] + 1;
            dfs(ny, nx);
        }
    }
    return;
}

int main(){
    cin >> H >> W;
    int cnt = 0;
    rep(i, H){
        rep(j, W){
            cin >> maze[i][j];
            d[i][j] = INF;
            if(maze[i][j] == '.') cnt++;
        } 
    }

    d[0][0] = 1;
    dfs(0, 0);

    if(d[H-1][W-1] != INF){
        cout << (cnt - d[H-1][W-1]) << endl;
    }
    else {
        cout << -1 << endl;
    }

}

Measured memory_bytes: 384
/**
 *    author: Behradm
 *    Created: 18-05-2020 10:01:01
 *    In the Name of God
**/
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5+1;
vector<vector<int>> g;
int depth[maxn], res[maxn];
bool mark[maxn];

void Bfs(int u) {
	mark[u] = true;
	queue<int> q;
	q.push(u);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		mark[v] = true;
		//cerr << " [ " << v << " : " << depth[v] << " ] \n";
		for (int i = 0; i < (int) g[v].size(); i++) {
			int child = g[v][i];
			if (!mark[child]) {
				q.push(child);
				mark[child] = true;
				depth[child] = depth[v] + 1;
				//cerr << " [ " << child + 1 << ", " << v + 1 << " ] \n";
				res[child] = v;
			}
		}
	}
	return;
}

pair<int, int> mini(int L, int R, vector<int> a) {
	if (R - L <= 1)
		return {a[L], depth[a[L]]};

	int mid = (L + R) / 2;
	auto v1 = mini(L, mid, a);
	auto v2 = mini(mid, R, a);
	if (v1.second <= v2.second) {
		return v1;
	} else {
		return v2;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	g.resize(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}

	depth[0] = 0;
	Bfs(0);

	/*cerr << '\n';
	for (int i = 0; i < n; i++)
		cerr << " [ " << i << " : " << depth[i] << " ] \n"; */

	/*for (int i = 0; i < n; i++) {
		if (!mark[i]) {
			cout << "No\n";
			return 0;
		}
	}*/

	cout << "Yes\n";
	for (int u = 1; u < n; u++) {
		/*int res = g[u][0];
		for (int i = 0; i < (int) g[u].size(); i++) {
			int child = g[u][i];
			if (depth[child] <= depth[res]) 
				res = child;
		}*/

		//cout << mini(0, (int) g[u].size(), g[u]).first + 1 << '\n';
		cout << res[u] + 1 << '\n';
	}
	return 0;
}




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

int main(){
  int N,M;
  cin>>N>>M;
  vector<string> A(N),B(M);
  for(string &S:A) cin>>S;
  for(string &S:B) cin>>S;
  for(int i=0;i+M<=N;i++)
    for(int j=0;j+M<=N;j++){
      for(int k=0;k<M;k++)
        for(int l=0;l<M;l++)
          if(A[i+k][j+l]!=B[k][l]) goto home;
      cout << "Yes" << endl;
      return 0;
      home:;
    }
  cout << "No" << endl;
}

Measured memory_bytes: 3588