akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		int n = sc.nextInt();
		int k = sc.nextInt();

		List<List<Integer>> edges = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			edges.add(new ArrayList<Integer>());
		}

		int[] a = new int[n - 1];
		int[] b = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			edges.get(a[i]).add(b[i]);
			edges.get(b[i]).add(a[i]);
		}

		int ret = Integer.MAX_VALUE;
		if (k % 2 == 0) {
			for (int i = 0; i < n; i++) {
				int root = i;
				int[] used = new int[n];
				Arrays.fill(used, -1);
				Deque<Integer> st = new ArrayDeque<>();
				st.push(root);
				used[root] = 0;
				int cnt = 0;
				while (!st.isEmpty()) {
					int e = st.pop();

					for (int ne : edges.get(e)) {
						if (used[ne] >= 0) {
							continue;
						}
						st.push(ne);
						used[ne] = used[e] + 1;
						if (used[ne] > k / 2) {
							cnt++;
						}
					}
				}
				ret = Math.min(ret, cnt);
			}
		} else {
			for (int i = 0; i < n - 1; i++) {
				int[] used = new int[n];
				Arrays.fill(used, -1);
				Deque<Integer> st = new ArrayDeque<>();
				st.push(a[i]);
				st.push(b[i]);
				used[a[i]] = 0;
				used[b[i]] = 0;
				int cnt = 0;
				while (!st.isEmpty()) {
					int e = st.pop();

					for (int ne : edges.get(e)) {
						if (used[ne] >= 0) {
							continue;
						}
						st.push(ne);
						used[ne] = used[e] + 1;
						if (used[ne] > k / 2) {
							cnt++;
						}
					}
				}
				ret = Math.min(ret, cnt);
			}
		}

		pr.println(ret);

		pr.close();
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
//					it = Arrays.asList(br.readLine().split(" ")).iterator();
					it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22708
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int a = scan.nextInt();
        long result = 1;
        long[] c = new long[a];
        long b = (long) Math.pow(10,18);

        for (int i = 0; i < a; i++) {
            c[i] = scan.nextLong();

        }

        Arrays.sort(c);
        if (c[0] == 0) {
            System.out.println(0);
            scan.close();
            return;
        }

            for (int j = 0; j < a; j++) {
                if (result > b/c[j]) {
                    System.out.println(-1);
                    scan.close();
                    return;
                }
                result *= c[j];
            }

            System.out.println(result);
            scan.close();

    }

}

Measured memory_bytes: 61704
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll ans=a[0]-1;
  ll x=2;
  REP(i,1,n){
    if(a[i]==x){
      x=a[i]+1;
      continue;
    }
    ans+=max((a[i]+x-1)/x-1,0LL);
  }
  cout << ans << endl;
return 0;}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main() {
    int N;
    cin >> N;
    vector<int> D(13,0);

    rep(i,N) {
        int d;
        cin >> d;
        D[d]++;
    }
    vector<int> A(1,0);

    for (int i=1; i<=11; i++) {
        if (D[i]==2) {
            A.push_back(i);
            A.push_back(24-i);
        }
        else if (D[i]>2) {
            A.push_back(i);
            A.push_back(i);
        }
    }

    if (D[0]>0) A.push_back(0);
    if (D[12]==1) A.push_back(12);
    if (D[12]>1) {
        A.push_back(12);
        A.push_back(12);
    }

    int ans = 0;

    for (int bit = 0; bit < (1<<11); ++bit) {
        vector<int> S;
        S = A;
        for (int i=0; i<11; i++) {
            if (D[i+1]!=1) {
                continue;
            }
            else if (bit & (1<<i)) {
                S.push_back(24-(i+1));
            }
            else {
                S.push_back(i+1);
            }
        }
        sort(S.begin(),S.end());
        int tmp = 24;
        rep(i,S.size()-1) {
            tmp = min(tmp,S[i+1]-S[i]);
        }
        tmp = min(tmp,24-S.back());
        ans = max(ans, tmp);

    }
    cout << ans << endl;
    //cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>

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

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  cin >> N;
  if(N%2==0){
    string s;
    cin >> s;
    if(s.substr(0,N/2) == s.substr(N/2,N/2)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

#define DEBUG
#ifdef DEBUG
#include <iostream>
#include <iomanip>

void dbg_impl() {
  std::cerr << '\n';
}

template <class Head, class... Tail>
void dbg_impl(const Head& head, const Tail&... tail) {
  std::cerr << ' ' << head;
  dbg_impl(tail...);
}

struct dbg_setup {
  dbg_setup() {
   std::cerr << std::boolalpha;
   std::cerr << std::fixed << std::setprecision(5);
  }
} debug_setup;

#define debug(...)\
  do {\
    std::cerr << std::setw(5) << __LINE__ << "  | ";\
    std::cerr << "[" << #__VA_ARGS__ << "]:";\
    dbg_impl(__VA_ARGS__);\
  } while (false)

#else
#define debug(...) 0
#endif

int main() {
  long long N;
  std::cin >> N;
  int ans = 0;
  auto check = [&](long long x) {
    long long use = N;
    while (use % x == 0) {
      use /= x;
    }
    return use % x == 1;
  };
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      // debug(i, N / i);
      long long j = N / i;
      if (i != 1 && check(i)) ++ans;
      if (i != j && j != 1 && check(j)) ++ans;
    }
  }
  long long M = N - 1;
  for (long long i = 1; i * i <= M; ++i) {
    if (M % i == 0) {
      // debug(i, M / i);
      ++ans;
      if (M / i != i) {
        ++ans;
      }
    }
  }
  std::cout << ans - 1 << '\n';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
int x[55], y[55];
map<pii, int> mm;


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read();
    rep(i, 1, n) {
        x[i] = read(), y[i] = read();
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (i != j) {
                int xx = x[j] - x[i];
                int yy = y[j] - y[i];
                mm[{xx, yy}]++;
            }
        }
    }
    int mx = 0;
    for (auto ele : mm) {
        prln(ele.second);
        if (ele.second > mx) mx = ele.second;
    }
    // mx --;
    prln(mx);
    cout << n - mx << endl;

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 384
#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)
#define LL long long
#define Fi first
#define Se second
using namespace std;
static const LL INF = 1LL<<61LL;
typedef pair<int,int> PII;

//PII V[100];
int N,L;
int Le,Ri;
int x,w;

int main(){
    cin>>L>>N;
    rep(i,N){
        cin>>x>>w;
        if(x>0)Ri+=abs(x*w);
        else if(x<0)Le+=abs(x*w);
        else if(x==0)continue;
    }
    if(Le<Ri){
        cout<<Ri-Le<<endl;
        rep(i,Ri-Le){
            cout<<-1<<" "<<1<<endl;
        }
    }
    else if(Le>Ri){
        cout<<Le-Ri<<endl;
        rep(i,Le-Ri){
            cout<<1<<" "<<1<<endl;
        }
    }
    else cout<<0<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int h, w;
	cin >> h >> w;
	V<string> s(h);
	rep(i, h)cin >> s[i];

	map<char, int> mp;
	rep(i, h)rep(j, w)mp[s[i][j]]++;

	bool ok = true;

	if (h % 2 == 0 && w % 2 == 0) {
		for (auto x : mp)if (x.second % 4)ok = false;
		cout << (ok ? "Yes" : "No") << endl;
	}
	else if (h % 2 == 0 || w % 2 == 0) {
		int ev;
		if (h % 2)ev = w;
		else ev = h;
		int cnt = 0;
		for (auto x : mp) {
			if (x.second % 2)ok = false;
			if (x.second % 4)cnt++;
		}
		if (ok && cnt <= ev / 2)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		int cnto = 0, cnte = 0;
		for (auto x : mp) {
			if (x.second % 2)cnto++;
			else if (x.second % 4)cnte++;
		}
		if (cnto==1&&cnte<=h/2+w/2)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

typedef long long lint;

int main(){
    int N,K;
    cin >> N >> K;
    lint a[100000];
    lint sum=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i]>0) sum+=a[i];
    }

    lint pmin,nmax;
    int ip=0,in=0;
    lint sump=0,sumn=0;
    for(int i=0;i<K;i++){
        if(a[i]>0) sump+=a[i];
        else sumn+=a[i];
    }
    pmin=sump;
    nmax=sumn;
    for(int i=K;i<N;i++){
        if(a[i-K]>0) sump-=a[i-K];
        else sumn-=a[i-K];
        if(a[i]>0) sump+=a[i];
        else sumn+=a[i];

        if(pmin>sump){
            pmin=sump;
            ip=i-K+1;
        }
        if(nmax<sumn){
            nmax=sumn;
            in=i-K+1;
        }
    }
    if(pmin<-nmax) cout << (sum-pmin) << endl;
    else cout << (sum+nmax) << endl;

    return 0;
}//

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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

ll x1, y11, cx, cy;
int n,m;
vector<ll> x,y;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m; x.resize(n), y.resize(m);
	F0R(i,n) cin >> x[i];
	F0R(i,n) cx = (cx+x[i]-x[0]) % MOD;
	
	F0R(i,m) cin >> y[i];
	F0R(i,m) cy = (cy+y[i]-y[0]) % MOD;
	
	F0R(i,n) {
		x1 = (x1+cx) % MOD;
		if (i != n-1) cx = ((cx-(x[i+1]-x[i])*(n-1-i)) % MOD+MOD) % MOD;
	}
	F0R(i,m) {
		y11 = (y11+cy) % MOD;
		if (i != m-1) cy = ((cy-(y[i+1]-y[i])*(m-1-i)) % MOD+MOD) % MOD;
	}
	cout << (x1*y11) % MOD;
}

Measured memory_bytes: 1792
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 1e6 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

int cnt[N] , st[N];

void solve()
{
    int n;
    cin >> n ;
    rep(i , n){
        int x;
        cin >> x;
        cnt[x]++;
    }
    rep(i , N) st[i] = true; 
    for(int i = 1; i < N ; ++i){
        if(cnt[i] > 1) st[i] = false;
        else if(!cnt[i]) continue ;
        for(int j = 2 * i ; j < N ; j += i){
            st[j] = false; 
        }
    }
    int ans = 0 ;
    rep(i , N){
        if(cnt[i] && st[i]) ans += cnt[i];
    }
    cout << ans ;
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 19248
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) cin >> s[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == "E869120") ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3340
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

const ll mod = 1e9+7;

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

    vector<bool> a(n+1, true);
    REP(i, m){
        int s;
        cin >> s;
        a[s] = false;
    }

    vector<ll> dp(n+1, 0);

    dp[0] = 1;
    if(a[1]) dp[1] = 1;

    for(int i = 2; i <= n; ++i){
        if(a[i-1]) dp[i] += dp[i-1];
        if(a[i-2]) dp[i] += dp[i-2];
        dp[i] %= mod;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<regex>

using namespace std;

int gcd(int a,int b){
    int tmp,r;
    if(a<b){
        tmp = b;
        b = a;
        a = tmp;
    }
    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;

    }
    return b;
}
int gcd(int a,int b,int c){
    return gcd(gcd(a,b),c);
}

int main()
{
    int a,b,c,n,sum=0,max;
    cin >> n;    
    for (int i = 1; i <= n;++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            for (int k = 1; k <= n; ++k)
            {
                sum += gcd(i,j,k);
            }
            
        }
        
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <cassert>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;

  cout << fixed;
  cout << setprecision(12);

  if ((x == w and y == h) or (x == 0 and y == h) or (x == w and y == 0) or (x == 0 and y == 0)) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  double tx = w / 2, ty = h / 2;

  if (x == tx and y == ty) {
    cout << (h * w) / 2 << " " << 1 << endl;
    return 0;
  }

  if (x < tx and y > ty) {
    double cx = x + tx;
    if (cx / tx == y / ty) {
      cout << (h * w) / 2 << " " << 0 << endl;
      return 0;
    }
  } else if (x > tx and y < ty) {
    double cy = y + ty;
    if (x / tx == cy / ty) {
      cout << (h * w) / 2 << " " << 0 << endl;
      return 0;
    }   
  }

  if (x / tx == y / ty) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  if ((x == 0 or x == w or y == 0 or y == h)) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  {
    cout << (h*w) / 2 << " " << 0 << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
c = list(map(int, input().split()))
dp = [0 for i in range(n+1)] # iまで選んだ時の純利益の最大
for i in range(n):
    dp[i+1] = max(dp[i], dp[i]+a[i]-c[i])
print(dp[n])

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

int main() {
	double a, b;
	cin >> a >> b;
	printf("%.6f\n", a*b / 3.305785);
	return 0;
}

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

using namespace std;

int grid[3][3];
char visit[3][3];

int main(){
    memset(visit, 0, sizeof(visit));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin>>grid[i][j];
        }
    }

    int n;
    cin>>n;
    for(int i = 0; i < n; i++){
        int x;
        cin>>x;
        for(int  k = 0; k < 3; k++){
            for(int l = 0; l < 3; l++){
                if(grid[k][l] == x) visit[k][l] = 1; 
            }
        }
    }
    bool ok = false;
    if(visit[0][0] && visit[1][1] && visit[2][2]) ok = true;
    if(visit[0][0] && visit[0][1] && visit[0][2]) ok = true;
    if(visit[1][0] && visit[1][1] && visit[1][2]) ok = true;
    if(visit[2][0] && visit[2][1] && visit[2][2]) ok = true;
    if(visit[0][0] && visit[1][0] && visit[2][0]) ok = true;
    if(visit[0][1] && visit[1][1] && visit[2][1]) ok = true;
    if(visit[0][2] && visit[1][2] && visit[2][2]) ok = true;
    if(visit[0][2] && visit[1][1] && visit[2][0]) ok = true;
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
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
 
n,k=map(int,input().split())
mod=10**9+7

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

if n<=k-1:
  print(cmb(2*n-1,n-1,mod))
else:
  ans=0
  for i in range(min(n,k+1)):
    ans+=cmb(n,i,mod)*cmb(n-(n-i)+n-i-1,n-i-1,mod)
    ans%=mod
  print(ans%mod)

Measured memory_bytes: 118892
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int r, D, x;
  cin >> r >> D >> x;
  vi ans(10);
  ans[0] = r * x - D;
  rep(i, 1, 10) {
    ans[i] = r * ans[i-1] - D;
  }

  fore(x, ans) cout << x << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <cstdio>
# include <cstring>
using namespace std;
char c[110];
int main() {
//	freopen("1.in","r",stdin);
	scanf("%s",c);
	printf("%c%d%c",c[0],strlen(c)-2,c[strlen(c)-1]);
	return 0;
}

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

int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i =0;i< N;i++) {
    cin >> vec.at(i);
}
bool ans = true;;

for (int i =0;i<N;i++) {
if (vec.at(i)%2 == 0) {
    if (vec.at(i) % 3 !=0 && vec.at(i) % 5 != 0) {
ans = false;
break;
    }
}
}
if (ans == 1) {
    cout << "APPROVED" << endl;
} else {
    cout << "DENIED" << endl;
}

}


Measured memory_bytes: 256
// AtCoder150 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

double dmax(double x, double y){
    if(x < y) return y;
    return x;
}

int main(void)
{
    int i,j,n;

    char t[200001];

    scanf("%s", t);

    int l = strlen(t);
    for(i=0;i<l; i++){
        if(t[i] == '?') t[i] = 'D';
    }

    printf("%s", t);
   
    return 0;

}

Measured memory_bytes: 1928
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , m , k;
cin>>n>>m>>k;
calfac(n+1);
int ans = 0;
for(int x = 0 ; x <= k ; x++){
int z = 0;
	 z = (z%mod +  ((calc(n-1 , x)%mod)*(m%mod) + mod) + mod)%mod;
	 z = (z%mod*Mod(m-1 , n-x-1 , mod) + mod)%mod;
	 ans = (ans + z + mod)%mod;
}
cout<<ans<<endl;
}



Measured memory_bytes: 5148
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int mod = 1000003;
inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
int fac[mod],ifac[mod];
inline void init(int n){
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=power(fac[n],mod-2);
	Dow(i,n-1,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
inline void solve(){
	int x=read(),d=read(),n=read();
	if (d==0){
		printf("%d\n",power(x,n));
		return;
	}
	int k=1ll*x*power(d,mod-2)%mod;
	if (k+n-1>=mod) return puts("0"),void(0);
	int ans=1ll*power(d,n)*fac[n+k-1]%mod*ifac[k-1]%mod;
	printf("%d\n",ans); 
}

int main(){
	init(mod-1);
	int T=read();
	while (T--) solve();
}

Measured memory_bytes: 11588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 50 + 10;
const int M = 50 * 50 + 10;
int a[N];
ll dp[N][M], new_dp[N][M];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, tar;
    cin >> n >> tar;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= M - 1; k++) {
                new_dp[j][k] += dp[j][k];
                if (j >= 1 && k >= a[i]) {
                    new_dp[j][k] += dp[j - 1][k - a[i]];
                    if (j * tar == k) {
                        ans += dp[j - 1][k - a[i]];
                    }
                }
            }
        }
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= M - 1; k++) {
                dp[j][k] = new_dp[j][k];
                new_dp[j][k] = 0;
            }
        }
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int d[101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	sort(d,d+n);
	int cnt=1;
	for(int i=1;i<n;i++){
		if(d[i-1]!=d[i])cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n;
    string s;
    cin>>n>>s;
    each(c, s) {
        c += n;
        if(c > 90) {
            c -= 26;
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
//for (int i = 0; i < N; i++){}

typedef pair<int, int> P;
char a[55][55];
int dis[55][55];
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,1,-1};

int H, W;
int gx, gy;
int wall = 0;

int bfs(int sy, int sx){
    //pair型のキュー
    queue<P> que;

    //キューにスタート地点を追加
    que.push(P(sy, sx));

    bool flag = false;
    while(!que.empty()){
        P p = que.front(); que.pop();
        //ゴールに到達している場合、break
        if(p.first == gy && p.second == gx){
            flag = true;
            cout << (H*W - dis[gy][gx] - wall - 1) << endl;
            break;
        }
        for(int i = 0; i < 4; i++){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(a[ny][nx] == '.'){
                dis[ny][nx] = dis[p.first][p.second] + 1;
                que.push(P(ny, nx));
                a[ny][nx] = '#';
            }
        }
    }
    if(flag == false) cout << -1 << endl;
}

int main() {
    cin >> H >> W;
    gy = H - 1;
    gx = W - 1;

    string x;
    for(int i = 0; i < H; i++){
        cin >> x;
        for(int j = 0; j < W; j++){
            a[i][j] = x[j];
            if(a[i][j] == '#'){
                wall++;
            }
        }
    }
    bfs(0, 0);
}

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

using namespace std;

int main() {
   string n;
   cin >> n;
   cout << (n[0]=='9' || n[1]=='9' ? "Yes" : "No") << endl;
}

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

const int N = 300;

int n, a[N];

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


Measured memory_bytes: 256
K,T = map(int,input().split())
a = list(map(int,input().split()))

pred = -1
ans = 0
a = [ (a[i],i) for i in range(T)]
while max(a)[0] > 0:
    a.sort()
    m,i = a[-1]
    flg = False
    for j in range(T-1,-1,-1):
        if pred != a[j][1] and a[j][0] > 0:
            a[j] = a[j][0]-1,a[j][1]
            pred = a[j][1]
            flg = True
            break
    if not flg:
        a[-1] = a[-1][0]-1,a[-1][1]
        ans += 1
        

print(ans)


Measured memory_bytes: 3192
#region using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Convert;
#endregion

class Program
{
    static void Main()
    {
        int a = ToInt32(ReadLine());
        int b = ToInt32(ReadLine());
        int c = ToInt32(ReadLine());
        int d = ToInt32(ReadLine());
        WriteLine(Math.Min(a,b) + Math.Min(c,d));
        ReadKey();
    }
}


Measured memory_bytes: 11348
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, M;
	string S;
	static long long COUNT[200000][2] = {};
	static vector<pair<long long, long long> > INPUT;
	static vector<long long> V[200000];
	static bool used[200000] = {};
	queue<long long> Q;
	cin >> N >> M >> S;
	for (int i = 0; i < M; i++) {
		long long A, B;
		cin >> A >> B;
		A--, B--;
		if (A > B) swap(A, B);
		INPUT.push_back({ A, B });
	}
	sort(INPUT.begin(), INPUT.end());
	INPUT.erase(unique(INPUT.begin(), INPUT.end()), INPUT.end());
	for (int i = 0; i < INPUT.size(); i++) {
		long long A = INPUT[i].first, B = INPUT[i].second;
		if (A == B) {
			V[A].push_back(B);
			COUNT[A][S[B] - 'A']++;
		}
		else {
			V[A].push_back(B);
			V[B].push_back(A);
			COUNT[A][S[B] - 'A']++;
			COUNT[B][S[A] - 'A']++;
		}
	}
	for (int i = 0; i < N; i++) {
		if (COUNT[i][0] == 0 || COUNT[i][1] == 0) Q.push(i);
	}
	while (!Q.empty()) {
		long long P = Q.front();
		Q.pop();
		if (used[P]) continue;
		used[P] = true;
		for (long long NP : V[P]) {
			if (!used[NP]) {
				COUNT[NP][S[P] - 'A']--;
				if (COUNT[NP][S[P] - 'A'] == 0) Q.push(NP);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (!used[i]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 18800
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	int n;
	while (n = readln.chomp.to!int, n) {
		auto x = readln.chomp.split;
		bool l, r, pl, pr, s = 1;
		int cnt;
		foreach (i; 0..n) {
			if (x[i] == "lu") {
				l = 1;
			} else if (x[i] == "ld") {
				l = 0;
			} else if (x[i] == "ru") {
				r = 1;
			} else  {
				r = 0;
			}
			if (l != pl || r != pr) {
				if (l == s && r == s) {
					cnt++;
					s = !s;
				}
			}
			pl = l;
			pr = r;
		}
		cnt.writeln;
	}
}

Measured memory_bytes: 1580
//ysh_gpta
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
typedef long long ll;
#define vb vector<bool>
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define mkp make_pair
#define pb push_back
#define INF 1000000000000000
#define MOD 1000000007
#define ff first
#define ss second
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//ll gcd( ll a, ll b ){if(b==0) return a; else return gcd( b, a%b );}
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}
ll n,m;
void printArray(vi &v){for(int i=1;i<=n;i++) cout<<v[i]<<" "; cout<<endl; }

vi dp(100005,0);
vb vis(100005,false);
vi in_degree(100005,0);


void dfsUtil(vvi &adj,int i){
    vis[i]=true;
    for(int j=0;j<adj[i].size();j++){
        dp[adj[i][j]] = max(dp[adj[i][j]],dp[i]+1);
        in_degree[adj[i][j]]--;
        if(in_degree[adj[i][j]]==0)
        dfsUtil(adj,adj[i][j]);
    }
}
void dfs(vvi adj){
    for(int i=1;i<=n;i++){
        if(!vis[i] && in_degree[i]==0){
            dfsUtil(adj,i);
        }
    }
}

int main(){
   FastIO
   cin>>n>>m;
   vvi adj(n+1);
   for(int i=1;i<=m;i++){
       int a,b;
       cin>>a>>b;
       adj[a].pb(b);
       in_degree[b]++;
   }
   dfs(adj);
//    printArray(dp);
   cout<<*max_element(dp.begin(),dp.end());
   return 0;
}

Measured memory_bytes: 17408
s = input()
n = int(input())

hanten=0
s1=""
s2=""
for i in range(n):
    Q = input()
    if int(Q[0])==1:
        hanten+=1 
    elif int(Q[0])==2 :
        if hanten%2 == int(Q[2])-1 :
            s1= s1+Q[4]
        else:
            s2= s2+Q[4]

s1 = s1[::-1]
s = s1+s+s2

if hanten%2 :
    s = s[::-1]
print(s)        





Measured memory_bytes: 10036
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, dp[47][47][47], res;
bool is[47][47];
char s[47];
int dfs(int l, int r, int pos)
{
	if (dp[l][r][pos] != -1)return dp[l][r][pos];
	if (l == pos && pos == r)return dp[l][r][pos] = 1;
	dp[l][r][pos] = 0;
	for (int i = l; i < pos; i++)
		for (int j = pos + 1; j <= r; j++)
			for (int x = l; x <= i; x++)
				for (int y = j; y <= r; y++)if (is[x][y])
					dp[l][r][pos] += dfs(l, i, x) * dfs(i + 1, j - 1, pos) * dfs(j, r, y);
	return dp[l][r][pos];
}
signed main()
{
	cin >> n;
	n *= 2;
	for (int i = 1; i <= n; i++)
	{
		cin >> s + 1;
		for (int j = 1; j <= n; j++)
			is[i][j] = s[j] - '0';
	}
	memset(dp, -1, sizeof dp);
	for (int i = 2; i <= n; i++)
		if (is[1][i])
			res += dfs(2, n, i);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c;
  string s, t;
  cin >> a;
  co(a*a*a);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <atcoder/lazysegtree>
#include <atcoder/modint>

template <typename Monoid>
Monoid Multiply(Monoid left, Monoid right) {
  return left *= right;
}
template <typename Monoid>
Monoid Identity() {
  return {};
}
template <typename Monoid, typename Operator>
Monoid Apply(Operator op, Monoid monoid) {
  return op(monoid);
}
template <typename Monoid, typename Operator>
using SegmentTree = atcoder::lazy_segtree<
  Monoid, Multiply, Identity, Operator, Apply, Multiply, Identity>;

struct Monoid {
  atcoder::modint998244353 value = 0;
  int width = 0;
  Monoid& operator*=(const Monoid& right) {
    value = table_[right.width] * value + right.value;
    width += right.width;
    return *this;
  }

  static void InitializeTable(int N) {
    table_.resize(N + 1);
    table_[0] = 1;
    for (int w = 1; w <= N; ++w) {
      table_[w] = 10 * table_[w - 1];
    }
  }

 private:
  static std::vector<atcoder::modint998244353> table_;
};
std::vector<atcoder::modint998244353> Monoid::table_;

struct Operator {
  int D = 0;
  Monoid operator()(const Monoid& monoid) const {
    if (D == 0) return monoid;
    return {table_[D][monoid.width], monoid.width};
  }
  Operator& operator*=(const Operator& old) {
    if (D == 0) {
      D = old.D;
    }
    return *this;
  }

  static void InitializeTable(int N) {
    for (int d = 0; d < 10; ++d) {
      table_[d].resize(N + 1);
      table_[d][1] = d;
      for (int w = 2; w <= N; ++w) {
        table_[d][w] = 10 * table_[d][w - 1] + d;
      }
    }
  }

 private:
  static std::vector<std::vector<atcoder::modint998244353>> table_;
};
std::vector<std::vector<atcoder::modint998244353>> Operator::table_(10);

int main() {
  int N, Q;
  std::cin >> N >> Q;
  Monoid::InitializeTable(N);
  Operator::InitializeTable(N);
  SegmentTree<Monoid, Operator> segment_tree(std::vector<Monoid>(N, {1, 1}));
  for (int i = 0; i < Q; ++i) {
    int L, R, D;
    std::cin >> L >> R >> D;
    segment_tree.apply(L - 1, R, {D});
    std::cout << segment_tree.all_prod().value.val() << std::endl;
  }
  return 0;
}


Measured memory_bytes: 18496
import sys

n=int(sys.stdin.readline())
a=sys.stdin.readline()
b=sys.stdin.readline()
c=sys.stdin.readline()


cnt = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        cnt = cnt + 1
    else:
        cnt = cnt + 2
print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=10000;
int main()
{
	int n;
	int T;
	double temp,bz;
	double mini=9999999.0;
	int an=0;
	cin>>n>>T>>bz;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		double 	temp=T-a*0.006;
		double  t=fabs(temp-bz);
		if(mini>t){
			mini=t;
			an=i+1;
		}
	}
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  Sushil Sekhar Satapathy
 *    created: 30.Jul.2020 18:38:25
 *
 *    Only the ladder is real!! The climb is all there is.
 *
**/

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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define vi vector<int>
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6+5;
int A[N];

int solve(pint P[], int n, int d)
{
    int i, dist, cnt=0;
    for(i=0;i<n;i++)
    {
        dist = P[i].first*P[i].first + P[i].second * P[i].second;
        if(dist <= d*d)
            cnt++;
    }
    return cnt;
}

int32_t main()
{
    //code
	IOS;
	//#ifndef ONLINE_JUDGE
    //freopen("alchemy_input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif

    int t,n,m,a,b,x,y,i,j,z;
    //cin>>t;
    t=1;
    while(t--)
    {
        int d;
        cin>>n>>d;
        pint P[n];
        for(i=0;i<n;i++)
            cin>>P[i].first>>P[i].second;
        cout<<solve(P, n, d)<<endl;
    }

	return 0;
}


Measured memory_bytes: 6780
// /*
// power code taken from geeks for geeks
// */

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 200001
using namespace std;
typedef long long ll;
typedef long double ld;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


bool comp(ll a, ll b){
    return a>b;
}

void swap(ll& s1, ll &s2){
    ll temp=s1;
    s1=s2;
    s2=temp;
}
ll gcd(ll a, ll b){
    if(b==0){
        return a;
    }
    return gcd(b, a%b);
}



void solve(){
    ll a,b;
    cin>>a>>b;
    ll c,d;
    cin>>c>>d;
    bool f=0;
    while(a>0 && c>0){
        if(f==0){
            c-=b;
        }
        else{
            a-=d;
        }
        f=!f;
    }
    if(f==0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}


int main(){


    #ifndef ONLINE_JUDGE 

    // For getting input from input.txt file 
    freopen("input.txt", "r", stdin); 

    // Printing the Output to output.txt file 
    freopen("output.txt", "w", stdout); 
    #endif 


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t=1;
    
    // cin>>t;
    
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define llu unsigned long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra
ll mod=1e9+7;
// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
ll INF = (1<<30LL);
int main(){
    // IOS;  
      int n;
      ll ww;
      cin>>n>>ww;
      ll w[n+4];
      ll v[n+4];
      for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
      int sum=0;
    for(int i=1;i<=n;i++)
      sum+=v[i];
      ll dp[n+4][sum+4];
      for(int i=0;i<=n;i++){
        if(i==0)
        {
        for(int j=0;j<=sum;j++){
          if(j==0)
            dp[i][j]=0;
          else
            dp[i][j]=INF;
        }
       }
       else
       {
        for(int j=0;j<=sum;j++){
          if(j>=v[i]){
            dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
          }          
          else
             dp[i][j]=dp[i-1][j];
        }   
      }
     }
     ll ans=0;
     for(int i=0;i<=sum;i++){
      if(dp[n][i]<=ww)
        ans=i;
     }
     cout<<ans<<endl;
 }
 

Measured memory_bytes: 79616