akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;

ll A[100010];

int main() {
  int N;
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll ans = 0;
  for (auto i = 0; i < N; i++) {
    ll pair = A[i]/2;
    ans += pair;
    A[i] -= pair * 2;
    if (i < N-1) {
      ll cnt = min(A[i], A[i+1]);
      ans += cnt;
      A[i] -= cnt;
      A[i+1] -= cnt;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
const int N = 8;

bool check(vector< vector<bool> > &v, int y, int x){
    if(y < 0 || x < 0 || y >= N || x >= N || !v[y][x]) return false;
    return true;
}

char isSame(vector< vector<bool> > &v, int y, int x){
    if(check(v, y, x) && check(v, y + 1, x) && check(v, y, x + 1) && check(v, y + 1, x + 1)) return 'A';
    if(check(v, y, x) && check(v, y + 1, x) && check(v, y + 2, x) && check(v, y + 3, x)) return 'B';
    if(check(v, y, x) && check(v, y + 1, x) && check(v, y + 2, x) && check(v, y + 3, x)) return 'B';
    if(check(v, y, x) && check(v, y, x + 1) && check(v, y, x + 2) && check(v, y, x + 3)) return 'C';
    if(check(v, y, x) && check(v, y + 1, x) && check(v, y + 1, x - 1) && check(v, y + 2, x - 1)) return 'D';
    if(check(v, y, x) && check(v, y, x + 1) && check(v, y + 1, x + 1) && check(v, y + 1, x + 2)) return 'E';
    if(check(v, y, x) && check(v, y + 1, x) && check(v, y + 1, x + 1) && check(v, y + 2, x + 1)) return 'F';
    if(check(v, y, x) && check(v, y, x + 1) && check(v, y + 1, x - 1) && check(v, y + 1, x)) return 'G';
    return 'n';
}

char allCheck(vector< vector<bool> > &v){
    REP(i, N) REP(j, N) if(v[i][j]) return isSame(v, i, j);
}

int main(){
    vector< vector<char> > tmp(N, vector<char>(N));
    while(cin >>tmp[0][0]){
        REP(i, N){
            REP(j, N){
                if(i == 0 && j == 0) continue;
                cin >>tmp[i][j];
            }
        }
        vector< vector<bool> > v(N, vector<bool>(N));
        REP(i, N) REP(j, N) v[i][j] = (tmp[i][j] == '1'? true : false);
        cout <<allCheck(v) <<endl;
    }
    return 0;
}

Measured memory_bytes: 1184
s = input()

s1 = s.replace("eraser", 'xxx')
s2 = s1.replace("erase", 'xxx')
s3 = s2.replace("dreamer", 'xxx')
s4 = s3.replace("dream", 'xxx')

s5 = s4.strip('x')

if (s5 == ''):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

#define sqr(x) ((x)*(x))

int main() {
	int a, b, c;
	
	while(cin >> a >> b >> c, a || b || c) {
		int n;
		double m;
		cin >> n;

		m = min(sqrt(sqr(a)+sqr(b)),min(sqrt(sqr(b)+sqr(c)),sqrt(sqrt(c)+sqr(a))));

		for(int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			if(m < tmp * 2)
				cout << "OK" << endl;
			else
				cout << "NA" << endl;
		}
	}

	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int c[] = new int[4];
		Arrays.fill(c, 0);

		for (int i = 0; i < n; i++) {
			String s = sc.next();

			if ("AC".equals(s)) {
				c[0]++;
			} else if ("WA".equals(s)) {
				c[1]++;
			} else if ("TLE".equals(s)) {
				c[2]++;
			} else {
				c[3]++;
			}
		}

		System.out.println("AC x  " + c[0]);
		System.out.println("WA x  " + c[1]);
		System.out.println("TLE x  " + c[2]);
		System.out.println("RE x  " + c[3]);

		sc.close();
	}

}


Measured memory_bytes: 59076
# -*- coding: utf-8 -*-
m, d = map(int, input().split())

if d < 22:
    print(0)
    exit()

count = 0

for m in range(1, m + 1):
    for n in range(22, d + 1):
        a = list(map(int, str(n)))
        if m == a[0] * a[1] and a[0] >= 2 and a[1] >= 2:
            count += 1

print(count)

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

int main()
{
    int s,w;
    cin >> s >> w;
    cout << ((s<=w)?"unsafe":"safe") << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;


int main(){
    priority_queue<int> q;
    char s[10];
    int n;
    while(1){
        cin>>s;
        if(s[0]=='i'){
            cin>>n;
            q.push(n);
        }else if(s[1]=='x'){
            cout<<q.top()<<endl;q.pop();
        }else{
            break;
        }
    }
    
    return 0;
}




Measured memory_bytes: 6876
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (c it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(x...) " [" #x ": " << (x) << "] "

using ld = long double;
using ll = long long;

constexpr int mod = 1000 * 1000 * 1000 + 7;
constexpr int odw2 = (mod + 1) / 2;

void OdejmijOd(int& a, int b) { a -= b; if (a < 0) a += mod; }
int Odejmij(int a, int b) { OdejmijOd(a, b); return a; }
void DodajDo(int& a, int b) { a += b; if (a >= mod) a -= mod; }
int Dodaj(int a, int b) { DodajDo(a, b); return a; }
int Mnoz(int a, int b) { return (ll) a * b % mod; }
void MnozDo(int& a, int b) { a = Mnoz(a, b); }
int Pot(int a, int b) { int res = 1; while (b) { if (b % 2 == 1) MnozDo(res, a); a = Mnoz(a, a); b /= 2; } return res; }
int Odw(int a) { return Pot(a, mod - 2); }
void PodzielDo(int& a, int b) { MnozDo(a, Odw(b)); }
int Podziel(int a, int b) { return Mnoz(a, Odw(b)); }
int Moduluj(ll x) { x %= mod; if (x < 0) x += mod; return x; }

template <typename T> T Maxi(T& a, T b) { return a = max(a, b); }
template <typename T> T Mini(T& a, T b) { return a = min(a, b); }

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int last = -1;
  int dp[2] = {0, 0};
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    int tmp[2] = {0, 0};
    tmp[0] = min(dp[0] + (last == x), dp[1]);
    tmp[1] = min(dp[0], dp[1]) + 1;
    last = x;
    dp[0] = tmp[0];
    dp[1] = tmp[1];
  }
  cout << min(dp[0], dp[1]) << endl;
  return 0;
}


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

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

using namespace std;

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

    int K;
    cin >> K;
    cout << K / 2 * (K - K / 2) << '\n';
}

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

using namespace std;

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 string s;
 cin >> s;
 if (s.back() == 's') s += "es";
 else s += "s";
 cout << s << '\n';
 return 0;
}


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

int main(){
	int tax8, tax10;
	cin >> tax8 >> tax10;
	
	
	int price1 = tax8 / 0.08;
	int price2 = tax10 / 0.1;
	
	if (price1 == price2){
		cout << price1;
		return 0;
	}
	
	
	for (int i = 0; i < tax10 * 15; i++){
		int test1 = i * 0.08;
		int test2 = i * 0.1;
		if (test1 == tax8 && test2 == tax10){
			cout << i;
			return 0;
		}
	}
	
	cout << "-1";
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 1e+9
using namespace std;

int main(){
	int m,n,p[10000],c[500],e[500];
	static int dp[501][20001] = {};
	cin >> m >> n;
	for(int i = 0;i < m;i++) cin >> p[i];
	for(int i = 0;i < n;i++) cin >> c[i] >> e[i];
	for(int i = 0;i <= n;i++) for(int j = 10000;j <= m + 10000;j++) dp[i][j] = INF;
	sort(p,p + m,greater<int>());
	for(int i = 1;i < m;i++) p[i] += p[i - 1];
	dp[0][10000] = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= m;j++){
			dp[i][j + 10000] = min(dp[i - 1][j + 10000],dp[i - 1][j + 10000 - c[i - 1]] + e[i - 1]);
		}
	}
	int ma = 0;
	for(int i = 1;i <= m;i++){
		//cout << p[i - 1] << " " << dp[n][i + 10000] << endl;
		ma = max(ma,p[i - 1] - dp[n][i + 10000]);
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 24732
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int[] h=new int[2000];
        int[] w=new int[2000];
        int i=0;
        while(true){
            h[i]=scan.nextInt();
            w[i]=scan.nextInt();
            if(h[i]==0&&w[i]==0){
                break;
            }
            for(int j=0;j<h[i];j++){
                for(int k=0;k<w[i];k++){
                    System.out.printf("#");
                }
                System.out.println();
            }
            System.out.println();
            i++;
        }
    }
}


Measured memory_bytes: 58876
N = int(input())
data = input().split()
data = data[:N]

for i in range(N):
	data[i] = int(data[i])

count = 0
while(1):
	for i in range(N):
		if(data[i] % 2 != 0):
			print(count)
			exit()
		else:
			data[i] /= 2
	count += 1


Measured memory_bytes: 3060
function main(input) {
	input = input.split("\n");
  	input = input[0].split(" ");
  	let a = parseInt(input[0], 10);
  	let b = parseInt(input[1], 10);
  	let h = parseInt(input[2], 10);
  	let m = parseInt(input[3], 10);
  
	console.log(
    	Math.sqrt(
        	Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(
              2*Math.PI*Math.abs(h/12 + m/60/12 - m/60)
            )
        ).toFixed(20)
    );
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29608
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    string s;
    cin >> s;
    s[0]++;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = [int(elem) for elem in input().split()]

x = x2 - x1
y = y2 - y1

x3 = x2 - y
y3 = y2 + x
x4 = x1 - y
y4 = y1 + x
print(x3, y3, x4, y4)

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

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e6 + 5;


int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int n = 0, m = 0;
	cin >> n >> m;
	vector<int> a;
	int number = 0;
	for(int i = 0; i < n; ++i){
		int k = 0;
		cin >> k;
		for(int j = 0; j < k; ++j){
			cin >> number;
			a.push_back(number);
		}
	}
	sort(a.begin(), a.end());
	int cnt = 1;
	int ans = 0;
	for(int i = 0; i < a.size(); ++i){
		if(a[i] == a[i+1]){
			++cnt;
		}
		else{
			if(cnt == n){
				++ans;
			}
			cnt = 1;
		}
	}
	cout << ans << endl;

    return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if (N % 10 == 3){
    cout << "bon" << endl;
  } else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8){
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

int main(){

int N;
cin>>N;
priority_queue<ll> Q;
for(int i=0; i<N; i++){
    ll A;
    cin>>A;
    Q.push(A);
}
bool Same=false;
ll Now;
ll Past;
Past=Q.top();
Q.pop();
for(int i=0; i<N-1; i++){
    Now=Q.top();
    Q.pop();
    if(Now==Past){
        Same=true;
        break;
    }
    Past=Now;
}
cout<<(Same?"NO":"YES")<<endl;
return 0;


}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll x,n;cin>>x>>n;
    ll a[n];
    map<ll,ll>mp;
    f(i,0,n){cin>>a[i];mp[a[i]]++;}
    ll y=x;ll z=x;
    while(1){
        if(mp.find(y)==mp.end()){cout<<y;break;}
        else if(mp.find(z)==mp.end()){cout<<z;break;}
        else {y--;z++;}
    }
    return 0;  
} 





Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a[10000000]={};
  int n,b,m=0,sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b;
    a[b+1]++;
    a[b-1]++;
    a[b]++;
    m=max(m,b+1);
  }
  for(int i=0;i<m;i++){
    sum=max(sum,a[i]);
  }
  cout<<sum<<"\n";
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y){
    if (Y >= 2 * X && Y <= 4 * X && Y % 2 == 0)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  ll all = b - a + 1;
  a--;
  ll c_diff = b/c - a/c;
  ll d_diff = b/d - a/d;
  ll cdgcd = c*d/gcd(c,d);
  ll gcd_diff = b/cdgcd - a/cdgcd;
  cout << all - c_diff - d_diff + gcd_diff << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<long long int> 
#define pb push_back
#define f(i,x,n) for (i=x;i<n;i++)


void solve(){
    int d,t,s;
    cin >> d >> t >>  s ;
    if((ll)s*t>=d){
        cout << "Yes"<<endl;
        return;
    }
    else
    {
        cout << "No"<<endl;
        return;
    }
}
int main(){
	ios_base::sync_with_stdio(false); 
     	cin.tie(NULL);
	int t=1;
	while(t--)
	solve();	
	
}


Measured memory_bytes: 3648
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main implements Runnable{
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    public void run() {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        long T[] = new long[N];

        for(int i = 0; i < N; i++) {
            T[i] = scan.nextLong();
        }

        scan.close();


        long result = T[0];

        for (int i = 1; i < N; i++) {
            result = lcm(result, T[i]);
        }


        os.println(result);
    }

    public static long gcd(long x, long y){

        if (x < y) {
            long t = x;
            x = y;
            y = t;
        }

        while (y > 0) {
            long r = x % y;
            x = y;
            y = r;
        }

        return x;

    }

    public static long lcm(long x, long y) {

        return x / gcd(x, y) * y;

    }
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b) a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b) a=b;}

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

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


Measured memory_bytes: 256
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
void solve()
{
    set<char>s;
    string ss;
    cin>>ss;
    rep0(i,3) s.in(ss[i]);
    if(s.si==1) pr("No");
    else pr("Yes");
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <stack>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
struct Node
{
    int value;
    Node *left, *right;
};
struct Tree
{
    Node *root = nullptr;
    string str = "";
    Tree(string s) : str(s) {}
    Node *getRoot(string target)
    {
        if(target.size() <= 2) return nullptr;
        if(str != target and target.front() == '(' and target.back() == ')')
        {
            target = target.substr(1);
            target.pop_back();
        }
        stack<char> st;
        int num = 0, p, q;
        for(int i = 0; i < (int)target.size(); i++)
        {
            if(st.empty() and target[i] == '[')
            {
                p = i;
                int idx = i + 1;
                while(isdigit(target[idx]))
                {
                    num *= 10;
                    num += target[idx] - '0';
                    idx++;
                }
                q = idx + 1;
            }
            else if(target[i] == ')')
            {
                char ch;
                do { ch = st.top(); st.pop(); }
                while(ch != '(');
            }
            else st.push(target[i]);
        }
        Node *res = new Node;
        res->value = num;
        res->left = getRoot(target.substr(0, p));
        res->right = getRoot(target.substr(q));
        return res;
    }
    void build() { root = getRoot(str); } ;
};
Node *make(Node *A, Node *B)
{
    if(A == nullptr or B == nullptr) return nullptr;
    Node *res = new Node;
    res->value = A->value + B->value;
    res->left = make(A->left, B->left);
    res->right = make(A->right, B->right);
    return res;
}
string create(Node *C)
{
    if(C == nullptr) return "";
    string res = "[" + to_string(C->value) + "]";
    res = "(" + create(C->left) + ")" + res + "(" + create(C->right) + ")";
    return res;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    Tree A(s), B(t);
    A.build(); B.build();
    Node *C = make(A.root, B.root);
    cout << create(C) << endl;
    return 0;
}



Measured memory_bytes: 3512
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	arr := make([]int, N)
	gs := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range arr {
		sc.Scan()
		arr[i], _ = strconv.Atoi(sc.Text())
	}
	for i := 0; i < N; i++ {
		gs[i] = int(math.Abs(float64(X - arr[i])))
	}
	fmt.Println(gcd2(gs))
}

func gcd2(arr []int) int {
	r := arr[0]
	for i := 1; i < len(arr); i++ {
		r = gcd(r, arr[i])
	}
	return r
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

Measured memory_bytes: 3840
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t;
	t=1;
	while(t--)
	{
		LL n;
		cin>>n;
		LL ans[n];
		if(n>=30)
		cout<<"Yes";
		else
		cout<<"No";
		
	
	}
}

Measured memory_bytes: 3636
using namespace std;

#include <bits/stdc++.h>

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int prev = 100007;
    int t;
    for ( int i = 0; i < N; i ++ ){
        if ( i < N - 1 ) cin >> t;
        ans += min( prev, t );
        prev = t;
    }
    cout << ans;
}


Measured memory_bytes: 256
def main():
    a,b,c=map(int,input().split())
    k = int(input())

    for i in range(k):
        if a < b < c:
            break
        elif a >= b:
            b *= 2
        elif b >= c:
            c *= 2

    if a < b < c:
        print('Yes')
    else:
        print('No')
main()

Measured memory_bytes: 9004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();//日数
		int k=sc.nextInt();//パスタの種類が決まっている日数
		int pattern=0;
		int pasta[][] = new int[n][6];
		int menuplan[]=new int[n];
		for(int i=0;i<k;i++){
			int a=sc.nextInt();
			menuplan[a-1]=sc.nextInt();//パスタの種類
		}
		if(menuplan[0]==0){
			pasta[0][1]=1;
			pasta[0][3]=1;
			pasta[0][5]=1;
		}
		else if(menuplan[0]==1){
			pasta[0][1]=1;
		}
		else if(menuplan[0]==2){
			pasta[0][3]=1;
		}
		else if(menuplan[0]==3){
			pasta[0][5]=1;
		}
		for(int i=1;i<n;i++){
			if(menuplan[i]==0){
				pasta[i][0]=pasta[i-1][1]%10000;
				pasta[i][2]=pasta[i-1][3]%10000;
				pasta[i][4]=pasta[i-1][5]%10000;
				pasta[i][1]=(pasta[i-1][2]+pasta[i-1][3]+pasta[i-1][4]+pasta[i-1][5])%10000;
				pasta[i][3]=(pasta[i-1][0]+pasta[i-1][1]+pasta[i-1][4]+pasta[i-1][5])%10000;
				pasta[i][5]=(pasta[i-1][0]+pasta[i-1][1]+pasta[i-1][2]+pasta[i-1][3])%10000;
			}
			else if(menuplan[i]==1){
				pasta[i][0]=pasta[i-1][1]%10000;
				pasta[i][1]=(pasta[i-1][2]+pasta[i-1][3]+pasta[i-1][4]+pasta[i-1][5])%10000;
			}
			else if(menuplan[i]==2){
				pasta[i][2]=pasta[i-1][3]%10000;
				pasta[i][3]=(pasta[i-1][0]+pasta[i-1][1]+pasta[i-1][4]+pasta[i-1][5])%10000;
			}
			else{
				pasta[i][4]=pasta[i-1][5]%10000;
				pasta[i][5]=(pasta[i-1][0]+pasta[i-1][1]+pasta[i-1][2]+pasta[i-1][3])%10000;
			}
		}
		
		for(int i=0;i<6;i++){
			pattern += pasta[n-1][i];
		}
		System.out.println(pattern%10000);
		
		
		
		
	}

}

Measured memory_bytes: 19768
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll N;
    scanf("%lld", &N);

    if (N >= 700 && N < 800)
    {
        printf("Yes");
        return 0;
    }

    if (N % 100 >= 70 && N % 100 < 80)
    {
        printf("Yes");
        return 0;
    }

    if (N % 10 == 7)
    {
        printf("Yes");
        return 0;
    }

    printf("No");
}


Measured memory_bytes: 3824
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[56], a1[56];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<n; i++)
    {
        a1[i]= a[i];
    }
    sort(a,a+n);
    int counts=0;
    int c=0;
    for(int i=0; i<n; i++)
    {
        if(a[i]==a1[i])
        {
            c++;
        }
    }
    for(int i=0; i<n; i++)
    {
        if(a[i]==a1[i])
        {
            counts++;
        }
    }
    if(counts==(n-2))
    {
        cout<<"YES"<<endl;
    }
    else if(c==n)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

void dfs(const vector<vi>& graph, vi& d, int edge, int dist) {
    for (const auto& e: graph[edge]) {
        if (d[e] == -1) {
            d[e] = dist + 1;
            dfs(graph, d, e, dist + 1);
        }
    }
}

signed main() {
    int n, u, v;
    cin >> n >> u >> v; --u; --v;

    vector<vi> graph(n, vi());

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b; --a; --b;

        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vi du(n, -1), dv(n, -1);
    du[u] = 0;
    dv[v] = 0;
    dfs(graph, du, u, 0);
    dfs(graph, dv, v, 0);

    if(du[v] == 1) {
        cout << 0;
        return 0;
    }

    int ans = 0;
    rep(i, n) {
        if (du[i] < dv[i]) {
            chmax(ans, dv[i] - 1);
        }
    }

    cout << ans;


    return 0;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

bool contains(vector<int>&vs, int x) {
  for (int v : vs) {
    if (v == x) return true;
  }
  return false;
}

int main() {

  int n; cin >> n;
  while (n--) {
    int x; cin >> x;
    int cx = 0;
    vector<int> history;

    while (x > 9) {
      int nx = 0;
      for (int d = 10; ; d *= 10) {
        int z = x / d;
        int y = x % d;
        if (z == 0) break;
        nx = max(nx, z * y);
      }
      x = nx;
      ++cx;
    }

    cout << cx << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b,c;cin>>a>>b>>c;

  if(a+b>=c)out("Yes")
  else out("No")

  return 0;
}


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

int main(){
  string s;
  long long k;
  cin >> s >> k;
  for(int i=0; i<min((long long)s.size(),k); i++){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int i,x,ct,n,k;
    long double rez=0.0;
    scanf("%d%d",&n,&k);
    for(i=1; i<=n; i++)
    {
        x=i;
        ct=n;
        while(x<k)
        {
            ct*=2;
            x*=2;
        }
        rez+=(long double)1/ct;
    }
    printf("%.10Lf",rez);

    return 0;
}


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

const int mod = 1e9+7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint sum(ll l, ll r) {
    return (l + r) * (r - l + 1) / 2;
}

int main(){
    int n, k;
    cin >> n >> k;
    mint ans = 0;
    for (int i=k; i<=n+1; ++i) {
        ans += sum(n-i+1, n) - sum(0, i-1) + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

#define int long long

string base[4] = {
	"maerd","remaerd","esare","resare"
};


signed main() {
	string S;
	cin >> S;
	string A=S;
	for (int i = 0; i < S.length(); i++) {
		A[i] = S[S.length() - 1 - i];
	}

	for (int i = 0; i < S.length(); i++) {
		int l = 0;
		for (int j = 0; j < 4; j++) {
			int tmp = i;
			int ttmp = 0;
			for (int k = 0; k < base[j].length(); k++) {
				if (A[tmp] != base[j][k]) {
					break;
				}
				ttmp++;
				tmp++;
			}
			if (ttmp == base[j].length()) {
				i = i+ttmp-1;
				l = 1;
				break;
			}
		}
		if (l == 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    if(n>=400&&n<=599)
        cout << "8";
    if(n>=600&&n<=799)
        cout << "7";
    if(n>=800&&n<=999)
        cout << "6";
    if(n>=1000&&n<=1199)
        cout << "5";
    if(n>=1200&&n<=1399)
        cout << "4";
    if(n>=1400&&n<=1599)
        cout << "3";
    if(n>=1600&&n<=1799)
        cout << "2";
    if(n>=1800&&n<=1999)
        cout << "1";  
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type& a){int t=0;for(auto elem:a){if(t)cout<<' ';cout<<elem;++t;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	map<int,int> mp;
	REP(i,n){
		cin>>a[i];
		mp[a[i]]=i%2;
	}
	
	sort(ALL(a));
	int cnt=0;
	REP(i,n){
		if(i%2==mp[a[i]]){
			
		}else{
			cnt++;
		}
	}
	
	cout<<cnt/2<<endl;
}//refering to exp.

Measured memory_bytes: 5376
import math
a,b,h,m = map(int,input().split())
long = m/60*360
short = h*30+(m/60*30)
kakudo = abs(long-short)
if kakudo > 180:
    kakudo = 360-kakudo
ans = math.sqrt(a**2 + b**2 - (2*a*b*math.cos(math.radians(kakudo))))
print(ans)


Measured memory_bytes: 62476
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;

int const inf = 1e9;

template<class T> using PQ_G = priority_queue<T, vector<T>, greater<T>>;

ll dist[111][26];
ll bitcost[1<<8];
typedef tuple<int, int, int> state; // cost, time, pos

typedef tuple<int, ll, int, int> edge;
vector<vector<edge>> g;

int dijkstra(int start, int goal, int H, int S) {
  PQ_G<state> pq;
  pq.emplace(0, 0, start);

  while(!pq.empty()) {
    ll cost, stime; int pos; tie(cost, stime, pos) = pq.top(); pq.pop();

    if(pos == goal) return cost;

    for(auto && e: g[pos]) {
      int b, c, h, r; tie(b, c, h, r) = e;
      ll ntime = stime + h;
      if(ntime > H) continue;
      if(S >> r & 1) {
        if(dist[b][ntime] <= cost) continue;
        dist[b][ntime] = cost;
        pq.emplace(dist[b][ntime], ntime, b);
      }
      else {
        ll ncost = cost + c;
        if(dist[b][ntime] <= ncost) continue;
        dist[b][ntime] = ncost;
        pq.emplace(dist[b][ntime], ntime, b);
      }
    }
  }
  return inf;
}

signed main() {

  int N, M, H, K;
  while(cin >> N >> M >> H >> K && (N|M|H|K)) {
    g.clear();
    g.resize(N);

    rep(i, M) {
      int a, b, c, h, r; cin >> a >> b >> c >> h >> r;
      a --, b --; r --;
      g[a].emplace_back(b, c, h, r);
      g[b].emplace_back(a, c, h, r);
    }

    int start, goal; cin >> start >> goal; start --, goal --;

    rep(i, 1 << 8) bitcost[i] = inf;

    int P; cin >> P;

    rep(i, P) {
      int l, d; cin >> l >> d;
      int S = 0;
      rep(j, l) {
        int k; cin >> k; k--;
        S |= 1 << k;
      }
      bitcost[S] = d;
    }

    bitcost[0] = 0;
    
    rep(S, 1 << K) {
      if(bitcost[S] >= inf) continue;
      rep(T, 1 << K) {
        if(bitcost[T] >= inf) continue;
        bitcost[S|T] = min(bitcost[S|T], bitcost[S] + bitcost[T]);
      }
    }

    ll ans = inf;

    rep(S, 1 << K) {
      rep(i, 100) rep(j, 25)
        dist[i][j] = inf;
      dist[start][0] = 0;
      if(bitcost[S] < inf)
        minimize(ans, dijkstra(start, goal, H, S) + bitcost[S]);
    }

    cout << (ans == inf ? -1 : ans) << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 3304
a,b,c,d =map(int,input().split())
tTurn = 1
while True:
    if tTurn:
        c-=b
        tTurn = 0
        if c<=0:
            print("Yes")
            break
    else:
        a-=d
        tTurn = 1
        if a<=0:
            print("No")
            break

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

const int MAXN = 405, MAXM = 100005;

int n, m, u[MAXM], v[MAXM];
bitset<MAXN> vis[MAXN];
bool alive[MAXN];

inline int read()
{
	int a = 0, c;
	do c = getchar(); while (!isdigit(c));
	while (isdigit(c)) {
		a = a*10+c-'0';
		c = getchar();
	}
	return a;
}

int main()
{
	n = read(), m = read();
	for (int i = 1; i <= m; i++) u[i] = read(), v[i] = read();
	for (int i = 1; i <= n; i++) {
		vis[i][i] = 1;
		alive[i] = 1;
		for (int j = m; j >= 1; j--) {
			if (vis[i][u[j]] && vis[i][v[j]]) { alive[i] = 0; break; }
			else if (vis[i][u[j]]) vis[i][v[j]] = 1;
			else if (vis[i][v[j]]) vis[i][u[j]] = 1;
		}
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i+1; j <= n; j++)
			if (alive[i] && alive[j] && (vis[i]&vis[j]).none())
				cnt++;
	cout << cnt << endl;
	return 0;
}


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


class dice {
public:
	dice(int* a) {
		set(a[0], a[1], a[2], a[3], a[4], a[5]);
	}
	dice(int& a, int& b, int& c, int& d, int &e, int& f) {
		set(a, b, c, d, e, f);
	}
	void turn(int n) {
		if (n < 4)
		{
			turndice(n);
			return;
		}
		switch (n)
		{
		case 'N':
			turndice(0);
			break;
		case 'E':
			turndice(1);
			break;
		case 'S':
			turndice(2);
			break;
		case 'W':
			turndice(3);
			break;
		}

	}

	void turn(const char* str)
	{
		for (size_t i = 0; str[i] != '\0' ; i++)
		{
			turn(str[i]);
		}
	}

	int getcurrent(int n = 0) { return label[n]; }

public:
	int topfronttoright(const int & top, const int & front) {
		char n3[] = { "NES" };
		const char ne[][3] = { "N","N","N","E","EE" };

		for (size_t i = 0; i < 6; i++)
		{
			if (top == getcurrent())
				for (size_t j = 0; j < 4; j++)
				{
					if (front == getcurrent(1))
					{		
						return  getcurrent(2);
					}
					turn(n3);
				}
			turn(ne[i]);
		}

		return 0;
	}

	bool cmper(dice b) {
		char n3[] = { "NES" };
		const char ne[][3] = { "N","N","N","E","EE" };

		for (size_t i = 0; i < 6; i++)
		{
			if (b.getcurrent() == getcurrent())
				for (size_t j = 0; j < 4; j++)
				{
					if (b.getcurrent(1) == getcurrent(1) &&
						b.getcurrent(2) == getcurrent(2) &&
						b.getcurrent(3) == getcurrent(3) &&
						b.getcurrent(4) == getcurrent(4) &&
						b.getcurrent(5) == getcurrent(5) )
					{
						return  true;
					}
					turn(n3);
				}
			turn(ne[i]);
		}

		return false;
	}

private:
	int label[6];

	void set(int& a, int& b, int& c, int& d, int &e, int& f) {
		label[0] = a; 
		label[1] = b; 
		label[2] = c; 
		label[3] = d; 
		label[4] = e; 
		label[5] = f; 
	}
	void turndice(int n)
	{
		int m = (n > 1) ? n - 2 : n + 2;
		int f[] = { 1, 3, 4, 2 };
		int tmp;

		tmp = label[0];
		label[0] = label[f[n]];
		label[f[n]] = label[5];
		label[5] = label[f[m]];
		label[f[m]] = tmp;
	}

};

#define D

#ifdef D
int main(void)
{
	int n;
	cin >> n;
	vector<dice> arr;
	arr.reserve(n);
	int label[6];
	for (size_t i = 0; i < n; i++)
	{
		for (auto &a : label)
			cin >> a;
		dice d(label);
		arr.push_back(d);
	}

	bool flag = true;
	for (size_t i = 0; i < n -1 && flag; i++)
	{
		for (size_t j = i+1; j < n; j++)
		{
			if (arr[i].cmper(arr[j]))
				flag = false;
		}
	}
	if (!flag)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}
#endif // D

Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int gcd(int a, int b) {
	while (b > 0) {
		int c = a % b;
		a = b;
		b = c;
	}
	return a;
}

long long lcm(long long a, long long b) {
	long long old_old_a = a, old_old_b = b;
	long long old_a, old_b;
	while (b != 0) {
		old_a = a;
		a = b;
		old_b = b;
		b = old_a % b;
	}
	long long g = old_b;
	return old_old_a / g * old_old_b;
}

int main()
{
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;

	int g = gcd(n, m);

	int N = n / g;
	int M = m / g;

	for (int i = 0, j = 0; i < n && j < m; i += N, j += M) {
		if (s[i] != t[j]) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << lcm((long long)n,(long long)m) << endl;
}

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

int main() {

    int A[3][3];
    bool bingo[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> A[i][j];
            bingo[i][j] = false;
        }
    }
    int N;
    cin >> N;
    int b[N];
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(A[j][k] == b[i]){
                    bingo[j][k] = true;
                }
            }
        }
    }

    if(bingo[0][0] && bingo[0][1] &&bingo[0][2] ){ cout << "Yes" << endl;}
    else if(bingo[1][0] && bingo[1][1] &&bingo[1][2] ){cout << "Yes" << endl;}
    else if(bingo[2][0] && bingo[2][1] &&bingo[2][2] ){cout << "Yes" << endl;}
    else if(bingo[0][0] && bingo[1][0] &&bingo[2][0] ){cout << "Yes" << endl;}
    else if(bingo[0][1] && bingo[1][1] &&bingo[2][1] ){cout << "Yes" << endl;}
    else if(bingo[0][2] && bingo[1][2] &&bingo[2][2] ){cout << "Yes" << endl;}
    else if(bingo[0][0] && bingo[1][1] &&bingo[2][2] ){cout << "Yes" << endl;}
    else if(bingo[0][2] && bingo[1][1] &&bingo[2][0] ){cout << "Yes" << endl;}
    else {cout << "No" << endl;}

    return 0;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if(s.equals("AAA") || s.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }


        
	}
}

Measured memory_bytes: 21716
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()


if __name__ == '__main__':
    w, h, x, y = map(int, input().split())
    if x == w / 2 and y == h / 2 :
        print(h * w / 2, 1)
    else :
        print(h * w / 2, 0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vii txy(N,vi(3));
    rep(i,N) {
        rep(j,3) {
            cin>>txy[i][j];
        }
    }
    bool ok=true;
    rep(i,N) {
        if((txy[i][1]+txy[i][2])%2!=txy[i][0]%2) ok=false;
    }
    int d=txy[0][1]+txy[0][2];
    if(d>txy[0][0]) ok=false;
    for(int i=1; i<N-1; i++) {
        int diff=abs(txy[i][0]-txy[i+1][0]);
        int a=abs(txy[i][1]-txy[i+1][1]);
        int b=abs(txy[i][2]-txy[i+1][2]);
        int distance=a+b;
        if(distance>diff) ok=false;
    }
    rep(i,N-1) {
        if(txy[i][2]==txy[i+1][2]&&txy[i][1]==txy[i+1][1]) ok=false;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

//print a b: strの a 文字目から b 文字目までを出力する。
//reverse a b: strの a 文字目から b 文字目までを逆順にする。
//replace a b p: strの a 文字目から b 文字目までを p に置き換える。
//ここでは、文字列strの最初の文字を 0 文字目とします。

int main() {
  int N, a, b;
  string s, order, repl;
  cin >> s >> N;
  
  for(int i=0; i<N; i++) {
    cin >> order >> a >> b;
    if(order == "print") {
      cout << s.substr(a, b-a+1) << endl;
    }
    if(order == "reverse") { 
      reverse(s.begin()+a, s.begin()+b+1); 
    }
    if(order == "replace") {
      cin >> repl;
      s.replace(a, b-a+1, repl);
    }
  }
  
  return 0;
}


Measured memory_bytes: 3236
def main():
    n=int(input())
    task=[tuple(map(int,input().split())) for _ in range(n)]
    task.sort(key=lambda x: x[1])
    current = 0
    for a,b in task:
        current += a
        if current > b:
            break
    else:
        print("Yes")
        return
    print("No")
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 37300
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  if(x==2){
    if(y==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
    if(y==1||y==3||y==5||y==7||y==8||y==10||y==12) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

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

	if(n<=k){
		cout<<0<<endl;
		return 0;
	}

	sort(all(h));
	ll sum=0;
	for (int i = 0; i < n-k; i++){
		sum+=h[i];
	}

	cout<<sum<<endl;


	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int n,a,b,c,i,max,min;
	max=-1;
	min=101;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		if(max==b&&min>a){
			min=a;
		}
		if(max<b){
			max=b;
			min=a;
		}
	}
	printf("%d %d\n",min,max);
	return 0;
}

Measured memory_bytes: 1028