akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int N, K, ans;
vector<int> h;
void solve() {
    cin >> N >> K;
    ans = 999999999;
    h.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    for (int i = 0; i < N - K + 1; i++) {
        ans = min(ans, h[i + (K - 1)] - h[i]);
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 640
h, w, k = map(int, input().split())
L = [list(input()) for _ in range(h)]

flag = 1
count = 0
ans = []

for i, row in enumerate(L):
    count += 1
    flag = 0
    line = [0] * w

    for j, col in enumerate(row):
        if col == '#':
            if flag:
                count += 1
            line[j] = count
            flag = 1
        else:
            line[j] = count
    if not flag:
        count -= 1
        line = None
    ans.append(line)


def fillnone(ls, ind):
    for i in range(ind, h):
        if ls[i] is not None:
            ls[ind] = ls[i]
            break
    else:
        for i in range(ind, -1, -1):
            if ls[i] is not None:
                ls[ind] = ls[i]
                break



for i, elm in enumerate(ans):
    if elm is None:
        fillnone(ans, i)

for elm in ans:
    print(*elm)



Measured memory_bytes: 8272
#include "iostream"
#include <vector>
#include <cstdlib>

using namespace std;
void mondai1();
void mondai2();

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

void mondai1() {
	int aTob, bToc,fare;
	cin >> aTob >> bToc;
	
	fare = aTob + bToc/2;

	cout << fare;
	
}

void mondai2() {
	vector<int> h;
	int n, t, a,htmp,average,diff,point;
	int minDiff = 1000000000;
	int x;
	
	cin >> n; //建設予定地の候補数
	cin >> t >> a;
	for (int i = 0; i < n; i++) {
		cin >> htmp;
		h.push_back(htmp);
	}


	point = 100;
	for (int i = 0; i < h.size(); i++) {
		average = 1000 *t - h[i] *6;//平均温度
		diff = average - 1000 * a; //平均温度と理想の温度の差

		if (minDiff > abs(diff)) {
			minDiff = abs(diff);
			point = i;
		}

		
	}
	cout << point + 1;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    int d[N];
    ll c[N];
    for(int i = 0; i < N; i++) cin >> d[i] >> c[i];

    ll keta = 0;
    ll sum = 0;
    for(int i = 0; i < N; i++){
        keta += c[i];
        sum += d[i] * c[i];
    }

    //cout << keta << endl << sum << endl;

    ll val = keta * 9LL + sum;

    cout << ((val - 18LL) + 8LL) / 9LL << endl;
    return 0;
}


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

int main(){
	int d;
	cin >> d;
	if(d==25){
		cout<<"Christmas";
	}else if(d==24){
		cout<<"Christmas Eve";
	}else if (d==23){
		cout<<"Christmas Eve Eve";
	}else if (d==22){
		cout<<"Christmas Eve Eve Eve";
	}
	return 0;
}

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

int n,a[Maxn];
long long sig[Maxn];
map<long long,int>M;

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(n);
	for(int i=1;i<=n;++i)
	read(a[i]);
}

int main(){
	init();
	sig[0]=0;
	for(int i=1;i<=n;++i)
	sig[i]=sig[i-1]+a[i];
	long long ans=0;
	M[0]=1;
	for(int i=1;i<=n;++i){
		ans=ans+M[sig[i]];
		M[sig[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll INF=1e18L+5;
int main()
{
    string s,t;
    cin>>s>>t;
    ll n,m;
    n=s.size();
    m=t.size();
    ll dp[n+1][m+1];
    dp[n][m];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0||j==0)dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll ind=dp[n][m];

    string ans="";
    ll i=n,j=m;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
            ans=s[i-1]+ans;
            i--;j--;ind--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else j--;

    }
   cout<<ans<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i]; 
    vector<long long> dp(n, (long long)-2e18);
    dp[0] = 0;
    vector<queue<pair<int, long long>>> q(2);
    for (int i = 0; i < n; i++)
    {
        int rem = n / 2 - (n - i) / 2;
        for (int j = 3; j >= - 2; j--)
        {
            if (rem + j < 0) continue;
            if (rem + j + 1 >= n) continue;
            if (dp[rem + j + 1] < dp[rem + j] + a[i])
            {
                int y;
                long long z;
                y = rem + j + 1;
                z = dp[rem + j] + a[i];
                q[i % 2].push({y, z});
            }
        }
        while (q[!(i % 2)].size())
        {
            int y;
            long long z;
            y = q[!(i % 2)].front().first; z = q[!(i % 2)].front().second; q[!(i % 2)].pop();
            dp[y] = max(dp[y], z);
        }
    }
    while (q[0].size())
    {
        int y;
        long long z;
        y = q[0].front().first; z = q[0].front().second; q[0].pop();
        dp[y] = max(dp[y], z);
    }
    while (q[1].size())
    {
        int y;
        long long z;
        y = q[1].front().first; z = q[1].front().second; q[1].pop();
        dp[y] = max(dp[y], z);
    }
    cout << dp[n / 2] << endl;
}

Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(0<=b-a && b-a<=d && 0<=c-b && c-b<=d) cout<<"Yes";
  else if(0<=b-a && b-a<=d && 0<=c-b && c-b<=d) cout<<"Yes";
  else if(0<=a-b && a-b<=d && 0<=b-c && b-c<=d) cout<<"Yes";
  else if(0<=a-b && a-b<=d && 0<=c-b && c-b<=d) cout<<"Yes";
  else if(0<a-c && a-c<=d) cout <<"Yes";
  else if(0<c-a && c-a<=d) cout <<"Yes";
  else cout<<"No";
}

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

#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;

const int mod = 1000000007;
const int max_n = 2011;

int main() {
  int n, a[max_n], m, b[max_n];
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &b[i]);
  }
  int dp[max_n][max_n];
  for (int i = 0; i <= max(n, m); ++i) {
    dp[i][0] = 1;
    dp[0][i] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    for (int q = 1; q <= m; ++q) {
      dp[i][q] = 0;
      if (i) dp[i][q] += dp[i - 1][q];
      if (q) dp[i][q] += dp[i][q - 1];
      if (i && q && a[i - 1] != b[q - 1]) dp[i][q] -= dp[i - 1][q - 1];
      if (dp[i][q] < 0) dp[i][q] += mod;
      dp[i][q] %= mod;
      /*if (a[i - 1] == b[q - 1]) {
        dp[i][q] = dp[i - 1][q - 1] * 2 % mod;
      } else {
        dp[i][q] = 0;
        if (i) dp[i][q] += dp[i - 1][q];
        if (q) dp[i][q] += dp[i][q - 1];
        if (i && q) dp[i][q] -= dp[i - 1][q - 1];
        if (dp[i][q] < 0) dp[i][q] += mod;
        dp[i][q] %= mod;
      }*/
      // cout << i << " " << q << " " << dp[i][q] << endl;
    }
  }
  cout << dp[n][m] << endl;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

vector<bool> V(10);

bool check(int n){
	while(n>0){
		if(V[n%10])return false;
		n /= 10;
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	REP(i,k){
		int a;
		cin >> a;
		V[a] = true;
	}
	bool b = true;
	while(!check(n)){
		n++;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s,t;
    cin >> s >> t;
    // 部分文字列は後ろで合致している方が辞書順では先に来る
    // 全パターンだと、26 ^ 50だから無理
    string res = "UNRESTORABLE";
    string s_res = s;
    for(int64_t i=s.size()-1; i>=0; i--){
        // 部分一致している最初の文字のチェック
        if(s.at(i) != t.at(0) && s.at(i) != '?') continue;
        // 文字長のチェック
        if(t.size() > s.size()-i) continue;
        // ?のチェック
        for(int64_t j=0; j<t.size(); j++){
            if(t.at(j) == s.at(i+j) || s.at(i+j) == '?'){
                s_res.at(i+j) = t.at(j);
            }else{
                s_res = s;
                break;
            }
            if(j==t.size()-1) res = s_res;
        }
        if(res != "UNRESTORABLE") break;
    }
    if(res != "UNRESTORABLE"){
        rep(i,res.size()){
            if(res.at(i) == '?'){
                res.at(i) = 'a';
            }
        }
    }
    cout << res << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c.at(i) >> s.at(i) >> f.at(i);
    }
    
    vector<int> ans(n);
    int t;
    for (int from = 0; from <= n - 1; from++)
    {
        t = s.at(from) + c.at(from); 
    
        for (int to = from + 1; to < n - 1; to++)
        {
            if (t > s.at(to)) {
                t = s.at(to) + ceil(((double)t - s.at(to)) / f.at(to)) * f.at(to);
            }
            else if (t < s.at(to)) t = s.at(to);

            t += c.at(to);
        }
        
        ans.at(from) = t;
    }

    for (int i = 0; i < n; i++)
    {
        cout << ans.at(i) << endl;
    }
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    string n;
    cin>>n;
    if(n[0]=='1')n[0]='9';
    else if(n[0]=='9')n[0]='1';
  
    if(n[1]=='1')n[1]='9';
    else if(n[1]=='9')n[1]='1';
  
    if(n[2]=='1')n[2]='9';
    else if(n[2]=='9')n[2]='1';
  
    cout<<n;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll n, m;
	cin >> n >> m;
	if(2*n>m){
		cout << m/2 << endl;
	} else if(2*n==m){
		cout << n << endl;
	} else {
		ll x=m-2*n;
		cout << n+x/4 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    ll num_city, num_teleport;
    cin >> num_city >> num_teleport;
    vector<vector<int>> dest(num_city, vector<int>(100, 0));
    rep(i, 0, num_city) cin >> dest[i][0];
    rep(i, 0, num_city) --dest[i][0];
    

    rep(d, 0, 100)
    {
        rep(city, 0, num_city)
        {
            // cout << city << ' ' << d << ' ' << dest[city][d] << endl;
            dest[city][d+1] = dest[dest[city][d]][d];

        }
    }
    // cout << "***" << endl;

    int now = 0;
    int bit = 0;
    while (num_teleport>(1LL<<bit))
    {
        if ((num_teleport>>bit)&1)
            now = dest[now][bit];
        ++bit;
        // cout << now << ' ' << bit << endl;
    }
    cout << now+1 << endl;
    return 0;
}


Measured memory_bytes: 89320
S = input()
N = len(S)
sosu = 10 ** 9 + 7
dp = [[0 for i in range(13)] for j in range(N)]
j = 0
if S[j] == '?':
    flag = -1
else:
    flag = int(S[j])
if flag == -1:
    for i in range(10):
        dp[j][i] += 1
else:
    dp[j][flag] = 1
#print(dp)
for j in range(1, N):
    if S[j] == '?':
        flag = -1
    else:
        flag = int(S[j])
    for k in range(10):
        if flag == -1:
            for i in range(13):
                dp[j][(i * 10 + k) % 13] += dp[j - 1][i]
            for i in range(13):
                dp[j][i] = dp[j][i] % sosu
        else:
            for i in range(13):
                dp[j][(i * 10 + flag) % 13] = dp[j-1][i]
 
print(dp[N-1][5])

Measured memory_bytes: 66908
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        cnt[x]++;
    }
    vector<pair<int, int>> a;
    for (auto p : cnt) {
        if (p.second >= 2) {
            a.push_back(p);
        }
    }
    sort(a.rbegin(), a.rend());
    if (a.empty()) {
        cout << 0 << endl;
        return 0;
    }
    if (a[0].second >= 4) {
        cout << 1LL * a[0].first * a[0].first << endl;
        return 0;
    }
    if (a.size() == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << 1LL * a[0].first * a[1].first << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
int main(){
  string s; cin >> s;
  int cnt0=0,cnt1=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='0') cnt0++;
    else cnt1++;
  }
  cout << 2*min(cnt0,cnt1) << endl;
  return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	int N;
	bool ans = true;
	string W[100];
	cin >> N;
	for (int i = 0; i < N; ++i){
		cin >> W[i];
	}

	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j){
			if (i == j)
				break;
			if (W[i].compare(W[j]) == 0)
				ans = false;
		}
	}

	for (int i = 1; i < N; ++i){
		if (W[i - 1][W[i - 1].size() - 1] != W[i][0])
			ans = false;
	}

	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 2e5 + 55;

int n;
ll a[maxN];

bool chk(ll x){
	map<ll, ll> mp;
	for(int i = 2; i <= n; i++){
		if(a[i - 1] >= a[i]){
			if(x == 1){
				return false;
			}
			while(!mp.empty()){
				ll mx = mp.rbegin()->first;
				if(mx > a[i]){
					mp.erase(mx);
				} else {
					break;
				}
			}

			int j = a[i];
			while(j > 0 && mp[j] + 1 == x){
				mp.erase(j);
				j--;
			}
			if(j == 0){
				return false;
			}
			mp[j]++;
		}
	}

	return true;
}

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

	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	int lo = 1, hi = n, ans = n;
	while(lo <= hi){
		int mid = (lo + hi) / 2;
		if(chk(mid)){
			ans = mid;
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}

	cout << ans << '\n';

	return 0;
}

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

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    sl = r.readLine().split(" ");
    int n = Integer.parseInt(sl[0]);
    s = r.readLine();

    if(s.length() % 2 == 1)
    {
      System.out.println("No");
      System.exit(0);
    }

    for(int i = 0; i < s.length() / 2; i++)
    {
      if(s.charAt(i) != s.charAt(i + s.length() / 2))
      {
        System.out.println("No");
        System.exit(0);
      }
    }
    System.out.println("Yes");

  }

}


class RemRing
{
 long module;
 public RemRing(long module)
 {
   this.module = module;
 }

 public long sum(long a, long b)
 {
   return (a + b + module) % module;
 }

 public long sub(long a, long b)
 {
   return (a - b + module) % module;
 }

 public long prod(long a, long b)
 {
   return (a * b) % module;
 }

 public long div(long a, long b)
 {
   return (a * inv(b)) % module;
 }

 public long inv(long a)
 {
   long b = this.module;
   long u = 1;
   long v = 0;
   while(b > 0)
   {
     long t = a / b;
     a -= t * b;
     u -= t * v;
     long z = a;
     a = b;
     b = z;
     z = u;
     u = v;
     v = z;
   }
   u %= this.module;
   if(u < 0) u += this.module;
   return u;
 }
}


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

class res{
public:
  string str;
  int i;
};


void solve(){
  int n; cin >> n;
  vector<res> s(200);
  string s2[100];
  for(int i = 0; i < n; i++){
    string str; int p; cin >> str >> p;
    s[p].str = str;
    s[p].i = i + 1;
    s2[i] = str;
  }

  sort(s2, s2 + n);
  for(int i = 0; i < n; i++){
    for(int j = 100; j >= 0; j--){
      if(s2[i] == s[j].str){
        cout << /*s[j].str << " " <<*/ s[j].i << endl;
        s[j].str = "zzzzzzzzzzzzzzzzzzz";
        //for(int i = 0; i <= 100; i++) cout << s[i].str << " "; cout << endl;
      }
    }
  }


  return;
}

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


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

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

    int n;
    string s;
    cin >> n;
    cin >> s;
    for(int i=0;i<s.size();i++){
        s[i]+=n;
        if((int)s[i] > 90){
            s[i]%=91;
            s[i]+=65;
        }

    }
    cout << s << '\n';
    return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;

    int ans = A - B * 2;
    if (ans < 0) ans = 0;

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


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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x));
#define cou(x) cout << x << endl;
#define y() cout << "Yes" << endl;
#define n() cout << "No" << endl;
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	string s, t;
	int a, b;
	string u;
	cin >> s >> t >> a >> b >> u;
	if (u == s) {
		a--;
	}
	else b--;
	cou(a << " " << b)
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long


class DModSum {
public:
	void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    out << n * (n - 1) / 2 << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	DModSum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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

    int n;
    cin >> n;
    int total = 0, maxi = -1e9;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        total += a;
        maxi = max(maxi, a);
    }

    total -= maxi / 2;

    cout << total << endl;

    return 0;
}

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

int main(){
    int p = 0, m = 0;
    for(int i = 0; i < 4; i++){
        char c;
        cin >> c;
        if(c == '+'){
            p++;
        }else if(c == '-'){
            m++;
        }
    }
    cout << p - m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;using vci=vector<int>;using vcl=vector<ll>;template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
#define int ll

const int N=3018;
const ll M=1e9+7;
void add(ll&x,ll y){
    if((x+=y)>=M)x-=M;
}
ll sum(ll x, ll y){
    add(x,y);
    return x;
}
ll mult(ll x,ll y){
    return (x*y)%M;
}
#define sqr(x)((x)*(x))
ll bp(ll a,ll pw){ 
    ll res(1);
    for (;pw;a=sqr(a)%M,pw /= 2)
        if (pw & 1)
            res=(res*a)%M;
    return res;
}
ll inverse(ll a){return bp(a%M,M-2);} 
int a[N];
int p[N][N];
int rowx[N];
int rowy[N];
int colx[N];
int coly[N];
int32_t main() {
    int n,q;
    cin>>n>>q;
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            p[i][j]=(a[i]>a[j]);
    ll r=inverse(2);
    ll qq=bp(2,q);
    while(q--){
        int x,y;
        cin>>x>>y;
        for(int i=1;i<=n;++i){
            rowx[i]=p[x][i];
            rowy[i]=p[y][i];
            colx[i]=p[i][x];
            coly[i]=p[i][y];
        }
        for(int i=1;i<=n;++i){
            p[y][i]=p[x][i]=mult(sum(rowx[i],rowy[i]),r);
            p[i][y]=p[i][x]=mult(sum(colx[i],coly[i]),r);
        }
        p[x][x]=0;
        p[y][y]=0;
        p[x][y]=p[y][x]=mult(sum(rowx[y],rowy[x]),r);
    }
    ll ans=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            dbg(i,j,p[i][j],inverse(p[i][j]));
    for(int i=1;i<=n;++i)
        for(int j=i+1;j<=n;++j)
            add(ans,p[i][j]);
    cout<<mult(ans,qq)<<'\n';
    return 0;
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    int m; cin >> m;
    vector<ll> b(m);
    rep(i,m)cin >> b[i];
    cout << includes(all(a), all(b)) << endl;
    return 0;
}


Measured memory_bytes: 5908
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    cout << max(b + c - a, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
S = deque(input())
Q = int(input())
q = [list(input().split()) for _ in range(Q)]

ok = True #Falseで反転させる
for i in range(Q):
    l = q[i]
    if l[0] == "1":
        if ok: ok = False
        else: ok = True
    else:
        if ok:
            if l[1] == "1": S.appendleft(l[2])
            else: S.append(l[2])
        else:
            if l[1] == "1": S.append(l[2])
            else: S.appendleft(l[2])
if not ok:
    S = list(S)[::-1]
print("".join(list(S)))

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

int main() {



//write code hare

	int count = 0;
	int n = 5;
	int x ;

	while (n-- != 0) {
		cin >> x;
		if (x == 0) {
			count++;
			break;
		}
		count = count + 1;
	}

	cout << count;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 5100;
ll dp[maxn][maxn], n;
struct node {
    ll h, p;
};
node arr[maxn];

bool comp(node a, node b) {
    return a.h + a.p < b.p + b.h;
}

int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>arr[i].p>>arr[i].h;
    }

    sort(arr+1, arr+n+1, comp);

    for(int i=0;i<=n;i++) {
        for(int j=0;j<=n;j++) {
            dp[i][j] = LLONG_MAX;
        }
    }

    /*for(int i=1;i<=n;i++) {
        cout<<arr[i].h<<" "<<arr[i].p<<" -> "<<arr[i].h+arr[i].p<<"\n";
    }*/

    dp[0][0] = 0LL;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            dp[i][j] = dp[i-1][j];
            if(arr[i].p >= dp[i-1][j-1]) dp[i][j] = min(dp[i][j], dp[i-1][j-1] + arr[i].h);
        }
    }

    ll result = 0LL;
    for(int i=1;i<=n;i++) {
        if(dp[n][i] != LLONG_MAX) result = i;
    }
    cout<<result<<"\n";
    return 0;
}


Measured memory_bytes: 200960
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		List<String> s = new ArrayList<String>();
		for(int i=0;i<n;i++) {
			s.add(sc.next());
		}
		Collections.sort(s);
	//	System.out.println(s);
		String ans = "";
		for(int i=0;i<n;i++) {
			ans += s.get(i);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    string t = s;
    bool isok = true;
    int n = s.size();
    reverse(t.begin(), t.end());
    if(s!=t) isok = false;
    
    string s1 = s.substr(0, n/2);
    string t1 = s1;
    reverse(t1.begin(), t1.end());
    if(s1!=t1) isok = false;

    string s2 = s.substr(n/2+1, n/2);
    string t2 = s2;
    reverse(t2.begin(), t2.end());
    if(s2!=t2) isok=false;

    string ans = isok ? "Yes" : "No";
    cout <<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cctype>
#include<vector>
#include<queue>

using namespace std;

inline int read(void)
{
    register int x=0,c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}

int n,m;
int tag[200005];
vector <int> G[200005];

inline void addedge(int x,int y)
{
    G[x].push_back(y);
    G[y].push_back(x);
}

void bfs(void)
{
    queue <int> q;
    q.push(1);
    while(!q.empty())
    {
        int t=q.front();q.pop();
        for(register int i=0;i<G[t].size();++i)
        {
            if(tag[G[t][i]]==0)
            {
                tag[G[t][i]]=t;
                q.push(G[t][i]);
            }
        }
    }
}

int main(void)
{
    n=read(),m=read();
    while(m--)
    {
        int x=read(),y=read();
        addedge(x,y);
    }
    bfs();
    for(register int i=2;i<=n;++i)
        if(tag[i]==0)
        {
            puts("No");
            return 0;
        }
    puts("Yes");
    for(register int i=2;i<=n;++i)
        printf("%d\n",tag[i]);
    return 0;
}

Measured memory_bytes: 12812
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		ll int n,x,time;
      cin >> n >> x>>time;
		if(n%x==0){cout << (n/x)*time<<endl;}
      	else cout << (n/x + 1)*time<<endl;
    }
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

// https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main()
{
	int N, M;
	cin >> N >> M;
	UnionFind tree(N);
	for(int i = 0; i < M; i++){
		int X, Y, Z;
		cin >> X >> Y >> Z;
		tree.unite(X-1, Y-1);
	}
	
	set<int> roots;
	int ans = 0;
	for(int i = 0; i < N; i++){
		int root = tree.root(i);
		if(roots.find(root) == roots.end()){
			ans++;
			roots.insert(root);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5376
A, B = gets.split.map(&:to_i)

k = [A == 0 ? 0 : Math.log2(A).to_i, B == 0 ? 0 : Math.log2(B).to_i].max + 1
ans = 0
plus = 1
waru = 2
a = A - 1
k.times do |i|
  a_one = a / waru * plus + [(a % waru) - plus + 1, 0].max
  b_one = B / waru * plus + [(B % waru) - plus + 1, 0].max
  one = b_one - a_one
  if one.odd?
    ans += plus
  end
  # p [i, plus, waru, a_one, b_one, one]
  plus *= 2
  waru *= 2
end

puts ans


Measured memory_bytes: 3836
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int> VI;
 
int main(){
  int N;
  cin >> N;
  VI v;
  REP(i,N*2) {
    int L;
    cin >> L;
    v.push_back(L);
  }
  sort(v.begin(), v.end());
  
  int ret = 0;
  REP(i, N) {
    ret += v[i*2];
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef vector<pii> vp;
int OO = 2e9;
const double eps = 1e-9 ;
const int N = 200;
int mx = -1e9 , mn = 1e9 ;
int arr[N] , arr2[N];

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b/a,c)<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  string s;
  cin >> s;

  if(s[0]=='S') cout << "Cloudy" << "\n";
  else if(s[0]=='C') cout << "Rainy" << "\n";
  else cout << "Sunny" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
    int n;
    cin>>n;
    vector<P> va(n);
    ll a[2020];
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) va[i]=P(a[i], i);
    sort(va.begin(), va.end(), greater<P>());
    ll dp[2020][2020];
    for(int i=0; i<=n; i++) for(int j=0; j<=n-i; j++) dp[i][j]=-1e18;
    dp[0][0]=0;
    for(int i=0; i<=n; i++){
        for(int j=0; j<n-i; j++){
            ll a1=va[i+j].first, k=va[i+j].second;
            dp[i+1][j]=max(dp[i+1][j], abs(i-k)*a1+dp[i][j]);
            dp[i][j+1]=max(dp[i][j+1], abs(n-j-1-k)*a1+dp[i][j]);
        }
    }
    ll ans=-1e18;
    for(int i=0; i<=n; i++) ans=max(ans, dp[i][n-i]);
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 26372
import java.io.*;
class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		String[] cut = input.split(" ");
		int w =	Integer.parseInt(cut[0]);
		int h =	Integer.parseInt(cut[1]);
		int x =	Integer.parseInt(cut[2]);
		int y =	Integer.parseInt(cut[3]);
		int r =	Integer.parseInt(cut[4]);
		
		if((x-r)<0 || (x+r)>w || (y-r)<0 ||(y+r)>h){
			System.out.println("No");
		}
		else{
			System.out.println("Yes");
		}
		
		
		
	}
}

Measured memory_bytes: 24372
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a,b,c,d;
int main(){
  cin>>a;
  b=a/100;
  c=a%100;
  if(b>0&&b<13&&(c>12||c==0))return cout<<"MMYY",0;
  if(c>0&&c<13&&(b>12||b==0))return cout<<"YYMM",0;
  if(b>0&&b<13&&c>0&&c<13)return cout<<"AMBIGUOUS",0;
  cout<<"NA";
}

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

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

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = 0;
    if(a == 0){
        ll val1 = b/x;
        ans = val1 + 1;
    }else{
        ll val1 = b/x;
        ll val2 = (a-1)/x;
        ans = val1 - val2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
long F(long a){
  if(a==0)return 0;
  switch(a%4){
    case 0:
      return a;
    case 1:
      return 1;
    case 2:
      return a+1;
    case 3:
      return 0;
  }
}
int main(){
  long A,B,res;
  cin>>A>>B;
  if(A==B)res=A;
  else if(!A)res=F(B);
  else res=F(B)^F(A-1);
  cout<<res;
  return 0;
}

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

using namespace std;

int main()
{

    int a;
    cin>>a;
    double b=a;
    double c=((a%2)+(a/2))/b;
    cout<<fixed<<setprecision(10)<<c<<endl;

    return 0;
}


Measured memory_bytes: 256
/*---> 22 December 2019 <--- > 17:34:47 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#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 rge<c>{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 (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int a,b;
	cin>>a>>b;
	cout<<(a*b)/(__gcd(a,b))<<"\n";
return 0;
}

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

long long siz(long long A) {
  long long n2 = 1;
  long long rep = 0;
  while (A >= n2) {
    rep++;
    n2 *= 2;
  }
  return rep;
}

int main() {
  long long T,N;
  string S;
  cin >> T;
  
  long long now,Ac,Ac2;
  
  bool pppp;
  
  for (int p=0; p<T; p++) {
    pppp = true;
    cin >> N;
    vector<long long> A(N);
    for (int i=0; i<N; i++) {
      cin >> A[i];
    }
    cin >> S;
    vector<queue<long long>> Qs(70);
    for (int i=N-1; i>=0; i--) {
      if (S[i] == '0') {
        Ac = A[i];
        now = siz(Ac);
        while (now > 0) {
          Qs[now].push(Ac);
          Ac2 = Qs[now].front();
          Ac = (Ac) ^ (Ac2);
          now = siz(Ac);
        }
      }
      else {
        Ac = A[i];
        now = siz(Ac);
        while (now > 0) {
          if (Qs[now].empty()) {
            pppp = false;
            cout << 1 << endl;
            break;
          }
          Ac2 = Qs[now].front();
          Ac = (Ac) ^ (Ac2);
          now = siz(Ac);
        }
        if (!pppp) break;
        
      }
    }
    if (!pppp) continue;
    cout << 0 << endl;
  }
  
}

Measured memory_bytes: 3708
# B - String Palindrome
def main():
    S = input().rstrip()
    N = len(S)
    left, right = S[: (N - 1) // 2], S[(N + 3) // 2 - 1:]
    is_palindrome = S == S[::-1]
    check_left = left == left[::-1]
    check_right = right == right[::-1]
    print("Yes" if is_palindrome and check_left and check_right else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
X, N = map(int, input().split())
p = list(map(int, input().split()))
tip = 0
for i in range(3 * N):
    s = X - i
    t = X + i
    s_a = s not in p
    t_a = t not in p
    if tip == 0:
        if s_a:
            ans = s
            tip = 1
        elif t_a:
            ans = t
            tip = 1
if tip == 0:
    ans = X
print(ans)
            

Measured memory_bytes: 9196
# from collections import defaultdict
# dd = defaultdict(lambda: 0)

N = int(input())
T = [dict() for _ in range(N)]

for i in range(N-1):
    u, v, w = [int(x) for x in input().split()]
    u -= 1
    v -= 1
    T[u][v] = w
    T[v][u] = w

opened = {0}
g0 = {0}
used = {0}

while len(opened) != 0:
    n = opened.pop()
    for n2 in T[n]:
        if n2 in used:
            continue
        if n in g0:
            if T[n][n2] % 2 == 0:
                g0.add(n2)
        else:
            if T[n][n2] % 2 == 1:
                g0.add(n2)
        opened.add(n2)
        used.add(n2)

for i in range(N):
    print(0 if i in g0 else 1)






Measured memory_bytes: 97312
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;	
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
#define INF 1000000000
#define MOD 1000000007
#define itr ::iterator it
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remin(a,b) (a) = min((a),(b))
#define remax(a,b) (a) = max((a),(b))	
#define ll long long
#define db double
#define el "\n"
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,i;
	cin>>n;
	int a[n],b[n],c[n];
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	int c1[n],c2[n],c3[n];
	c1[0]=a[0];c2[0]=b[0];c3[0]=c[0];
	for(i=1;i<n;i++){
		c1[i]=a[i]+max(c2[i-1],c3[i-1]);
		c2[i]=b[i]+max(c1[i-1],c3[i-1]);
		c3[i]=c[i]+max(c1[i-1],c2[i-1]);
	}
	cout<<max(c1[n-1],max(c2[n-1],c3[n-1]));
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < n; ++i){
        cout << s[i] << t[i];
    }
    cout << endl;
}

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

using namespace std;

int main(void){

  int n,m,in,sumt,sumh;
  vector<int>taro,hanako;

  while(cin >> n >> m,n|m){
    taro.clear();
    hanako.clear();

    sumt=0;
    sumh=0;

    for(int i=0;i<n;i++){
      cin >> in;
      sumt+=in;
      taro.push_back(in);
    }
    
    for(int i=0;i<m;i++){
      cin >> in;
      sumh+=in;
      hanako.push_back(in);
    }

    int Min=10000000,anst,ansh;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(sumt-taro[i]+hanako[j]==sumh+taro[i]-hanako[j]){
	  if(Min>taro[i]+hanako[j]){
	    Min=taro[i]+hanako[j];
	    anst=taro[i];
	    ansh=hanako[j];
	  }
	}
      }
    }
    
    if(Min==10000000)cout << -1 << endl;
    else cout << anst << " " << ansh << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int a = getInt();
  const int b = getInt();

  if(a > 0) {
    puts("Positive");
  } else {
    if (b >= 0) {
      puts("Zero");
    } else {
      const int cnt = b - a + 1;
      puts(cnt % 2 == 0 ? "Positive" : "Negative");
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=1e6+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}



int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;
    string s;cin>>s;
    if(s[0]<='Z') cout<<"A"<<endl;
    else cout<<"a"<<endl;
    return 0;
}


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

int main(){
	int r,g,b,n;
	cin >> r >> g >> b >> n;
	int cnt = 0;
	for(int i = 0; i <= n / r; i++){
		for(int j = 0; i * r + j * g <= n; j++){
			if((n - i * r - j * g) % b == 0){
				cnt++;
			}
		}	
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "YES"; else return "NO"; }

int main() {

    string A,B,C;
    cin >> A >> B >> C;

    cout << YorN(A.back() == B.front() && B.back() == C.front()) << endl;

    return 0;

}

Measured memory_bytes: 256