akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

constexpr int inf = 1e9;

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> g(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b, a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  V<> l(n, -inf), r(n, inf);
  int k, rt; cin >> k;
  for (int i = 0; i < k; i++) {
    int v, p; cin >> v >> p, v--;
    l[v] = r[v] = p;
    if (!i) rt = v;
  }
  V<> par(n, -1);
  queue<int> que;
  par[rt] = n; que.push(rt);
  while (!que.empty()) {
    int v = que.front(); que.pop();
    for (int w : g[v]) if (par[w] == -1) {
      par[w] = v; que.push(w);
    }
  }
  VV<> ch(n);
  for (int i = 0; i < n; i++) if (par[i] != n) ch[par[i]].push_back(i);
  function<void(int)> dfs = [&](int v) {
    for (int w : ch[v]) {
      dfs(w);
      l[v] = max(l[v], l[w] - 1);
      r[v] = min(r[v], r[w] + 1);
    }
  };
  dfs(rt);
  V<> res(n);
  if (l[rt] > r[rt]) return cout << "No" << '\n', 0;
  res[rt] = l[rt];
  for (int w : ch[rt]) que.push(w);
  while (!que.empty()) {
    int v = que.front(); que.pop();
    if (l[v] <= res[par[v]] + 1 and res[par[v]] + 1 <= r[v]) res[v] = res[par[v]] + 1;
    else if (l[v] <= res[par[v]] - 1 and res[par[v]] - 1 <= r[v]) res[v] = res[par[v]] - 1;
    else return cout << "No" << '\n', 0;
    for (int w : ch[v]) que.push(w);
  }
  cout << "Yes" << '\n';
  for (int i = 0; i < n; i++) cout << res[i] << '\n';
}

Measured memory_bytes: 19712
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a,b,c;
	while(cin>>a>>b>>c,a+b+c){
		vector<int>in(a+b+c+1,2);
		int n;
		cin>>n;
		vector<vector<int> >tmp(n,vector<int>(4));
		rep(i,n)rep(j,4)cin>>tmp[i][j];
		rep(i,n)if(tmp[i][3]==1){
			in[tmp[i][0]]=1;
			in[tmp[i][1]]=1;
			in[tmp[i][2]]=1;
		}
		rep(i,n){
			int co=0;
			rep(j,3)if(in[tmp[i][j]]!=1)co++;
			if(co==1){
				rep(j,3)if(in[tmp[i][j]]==2)in[tmp[i][j]]=0;
			}
		}
		loop(i,1,a+b+c+1)cout<<in[i]<<endl;
	}
}

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

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

  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if (a+b < c+d) {
    cout << "Right" << endl;
  }
  else cout << "Balanced" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    map<ll, queue<ll>> a;
    repf(i, n) rep(j, n-1){
        ll num; cin >> num;
        a[i].push(num);
    }

    ll cnt = 0;
    queue<ll> pos;
    while(1){
        ll chk_f = 0;
        vector<bool> chk(n+1, false);
        if(cnt == 0){
            // 初回
            for(ll i=1; i<=n; i++){
                ll cur = i, f = 1001;
                bool hit = false;
                // すでにチェック済みの場合
                if(chk[cur] == true) continue;
                // キューが空の場合
                if(!a[cur].size()){
                    chk[cur] = true;
                    continue;
                }

                while(1){
                    // 先頭要素を読み出す
                    f = a[cur].front();

                    // チェック
                    chk[cur] = true;

                    // 読みだした要素がチェック済みの場合
                    if(chk[f] == true) break;

                    // 読みだした要素のキューが空の場合
                    if(!a[f].size()) break;

                    if(a[f].front() == cur){
                        hit = true;
                        chk[f] = true;
                        break;
                    }
                    else cur = f;
                }
                if(hit){
                    pos.push(cur);
                    pos.push(f);
                    a[f].pop();
                    a[cur].pop();
                    chk_f++;
                }
            }
        }
        else{
            // 2回目以降は1回目の変更箇所だけ見ていけば良い
            ll pos_size = pos.size();
            while(pos_size > 0){
                pos_size--;
                auto f = pos.front();
                pos.pop();
                if(chk[f] == true) continue;
                if(!a[f].size()) continue;

                ll p = a[f].front();
                if(chk[p] == true) continue;
                if(!a[p].size()) continue;

                if(a[p].front() == f){
                    chk_f++;
                    chk[f] = true;
                    chk[p] = true;
                    pos.push(p);
                    pos.push(f);
                    a[f].pop();
                    a[p].pop();
                }
            }
        }
        if(chk_f == 0) break;
        cnt++;
    }

    for(auto &p: a) if(p.second.size() != 0) cnt = -1;
    cout << cnt << endl;
}

Measured memory_bytes: 12308
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(1<=a && a<=9 && 1<=b && b<=9){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  ll l = sz(s);
  ll count = 0;
  rep(i, l / 2){
    if(s[i]!=s[l-i-1]){
      count++;
    }
  }
  print(count);
}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

int main()
{
    string s; cin>>s;
    int m=0;
    for0(i,s.sz){
        m+=s[i]-'0';
    }
    if(m%9==0) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3696
#include<iostream>
using namespace std;
#define N 10000000
bool P[N + 1];
void eratos(){
for ( int i = 0; i <= N; i++ ) P[i] = true;
P[0] = P[1] = false;
for ( int i = 2; i*i <= N; i++ )
if ( P[i] )
for ( int j = 2; i*j <= N; j++ ) P[i*j] = false;
}
int getQuads(int n){
for ( int i = n; i >= 13; i--)
if ( P[i] && P[i-2] && P[i-6] && P[i-8] ) return i;
}
int main(){
eratos();
int n;
while( cin >> n && n ) cout << getQuads(n) << endl;
return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 998244353;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  bitset<200000> s; cin >> s;

  vl power(n);
  power[0] = 1;
  rep(i,n-1) power[i+1] = power[i] * 2 % MOD;
  ll num = 1;
  rep(i,n) if (s.test(i)) (num += power[i]) %= MOD;
  ll ans = n*2 * num % MOD;

  map<int, ll> decrease;
  ll tmp = 0;

  for (int i=1; i<=n/3; ++i) {
    ((tmp *= 2) += s[n-i]) %= MOD;

    if (n%i == 0 && n/i%2 == 1) {
      decrease[i] = tmp;

      bool x = true;
      bool exit = false;

      for (int j=1; j<n/i; ++j) {
        for (int k=1; k<=i; ++k) {
          int bit = s[n-k];
          if (j%2) bit = 1 - bit;

          if (s[n-j*i-k] == bit) continue;

          if (s[n-j*i-k] < bit) x = false;
          exit = true;
          break;
        }
        if (exit) break;
      }

      if (x) ++decrease[i];
    }
  }

  vi length;

  for (auto p : decrease) {
    int key = p.first;
    
    for (auto d : length) {
      if (key%d == 0 && key/d%2 == 1) {
        decrease[key] -= decrease[d];
        if (decrease[key] < 0) decrease[key] += MOD;
      }
    }

    ans -= (n*2 - key*2) * decrease[key] % MOD;
    if (ans < 0) ans += MOD;
    length.push_back(key);
  }

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


Measured memory_bytes: 1852
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

EPS = 1e-9

#http://www.deqnotes.net/acmicpc/2d_geometry/lines
def dot(a, b):
    return a.real * b.real + a.imag * b.imag

def cross(a, b):
    return a.real * b.imag - a.imag * b.real

def distance(a, b, c):
    if dot(b-a, c-a) <= EPS:
        return abs(c-a)
    if dot(a-b, c-b) <= EPS:
        return abs(c-b)
    return abs(cross(b-a, c-a)/(b-a))

N, T = ln()
A = ln()

count = 0
max_diff = -1
minimum = 10**10
for a in A:
    if a < minimum:
        minimum = a
    diff = a - minimum
    if diff > max_diff:
        max_diff = diff
        count = 1
    elif diff == max_diff:
        count += 1

print count


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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  bool first = true;
  while(N--){
    if(first) first = false;
    else cout << endl;
    int f[9][9];
    for(int i = 0; i < 9; i++){
      for(int j = 0; j < 9; j++){
        cin >> f[i][j];
        f[i][j]--;
      }
    }
    vector< vector<bool> > wrong(9, vector<bool>(9, false));
    vector<bool> used(9, false);
    //columm
    for(int i = 0; i < 9; i++){
      used = vector<bool>(9, false);
      list<int> t;
      for(int j = 0; j < 9; j++){
        if(used[ f[i][j] ] == true){
          t.push_back(f[i][j]);
        }else{
          used[ f[i][j] ] = true;
        }
      }
      for(int j = 0; j < 9; j++){
        for(list<int>::iterator it = t.begin(); it != t.end(); it++){
          if(f[i][j] == *it){
            wrong[i][j] = true;
          }
        }
      }
    }

    //row
    for(int j = 0; j < 9; j++){
      used = vector<bool>(9, false);
      list<int> t;
      for(int i = 0; i < 9; i++){
        if(used[ f[i][j] ] == true){
          t.push_back(f[i][j]);
        }else{
          used[ f[i][j] ] = true;
        }
      }
      for(int i = 0; i < 9; i++){
        for(list<int>::iterator it = t.begin(); it != t.end(); it++){
          if(f[i][j] == *it){
            wrong[i][j] = true;
          }
        }
      }
    }

    //sp area
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){

        used = vector<bool>(9, false);
        list<int> t;
        for(int k = 0; k < 3; k++){
          for(int l = 0; l < 3; l++){
            if(used[ f[i*3+k][j*3+l] ] == true){
              t.push_back(f[i*3+k][j*3+l]);
            }else{
              used[ f[i*3+k][j*3+l] ] = true;
            }
          }
        }
        for(int k = 0; k < 3; k++){
          for(int l = 0; l < 3; l++){
            for(list<int>::iterator it = t.begin(); it != t.end(); it++){
              if(f[i*3+k][j*3+l] == *it){
                wrong[i*3+k][j*3+l] = true;
              }
            }
          }
        }
      }
    }

    for(int i = 0; i < 9; i++){
      for(int j = 0; j < 9; j++){
        if(wrong[i][j]) cout << "*";
        else cout << " ";
        cout << f[i][j]+1;
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1204
using System;
using System.Linq;

class Program
{
    public static void Main(string[] args)
    {
        int N = int.Parse(System.Console.ReadLine());

        int total = 0, oddMin = int.MaxValue;
        for (int i = 0; i < N; i++)
        {
            int score = int.Parse(System.Console.ReadLine());

            total += score;
            if (score<oddMin & score % 10 != 0)
            {
                oddMin = score;
            }
        }

        if (total % 10 == 0)
        {
            if (oddMin == int.MaxValue)
            {
                total = 0;
            }
            else
            {
                total -= oddMin;
            }
        }

        System.Console.WriteLine(total);
    }
}



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

const int MAX = 510000;
const int MOD = 1000000007;

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() {
    // 前処理
    long long res= 0;
    int h,w,a,b; cin >> h >> w >> a >> b;

    COMinit();
    for(int i=0; i<h-a; ++i){
        res +=  COM(b+i-1,i)%MOD * COM(w-b+h-i-2,h-i-1)%MOD;
    }
    cout << res%MOD << endl;
}

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

int main(){
    string s;
    cin >> s;
    bool Counter[3] = {};
    int tmp = -1;
    int count = 0;
    int n = s.size();

    if(s[0] == 'A') Counter[0] = 1;

    for(int i = 2; i < n-1; i++){
        if(s[i] == 'C'){
            count += 1;
            tmp = i;
        }
    }
    if(count == 1) Counter[1] = 1;

//個々の動作がおかしい
    for(int i = 1; i < n; i++){
        if(i != tmp && islower(s[i])){
            Counter[2] = 1;
        }else if(i == tmp){}
        else{
            Counter[2] = 0;
            break;
        }
    }

    //cout << Counter[0] << Counter[1] << Counter[2] << endl;
    if(Counter[0] == 1 && Counter[1] == 1 && Counter[2] == 1){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  let today = parseInput(input)[0][0];
  const weathers = ['Sunny', 'Cloudy', 'Rainy'];
  console.log(weathers[(weathers.indexOf(today)+1)%3]);
}

function parseInput(input) {
  const lines = input.trim().split('\n');
  return lines.map(line => line.split(' '));
}

Main(require('fs').readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n);
  vector<ll> cnt(60);
  rep(i, n) {
    cin >> A[i];
    rep(j, 60) if((A[i]>>j)&1) cnt[j]++;
  }
  ll ans = 0;
  rep(j, 60) {
    (ans += (1LL<<j)%mod*(cnt[j]*(n-cnt[j])%mod)%mod) %= mod;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 5540
import numpy as np
N,X,Y=map(int, input().split())
ans = [0]*(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
    root1 = j-i
    root2 = abs(X-i) + 1 + abs(Y-j)
    min_k = min(root1, root2)
    ans[min_k-1] = ans[min_k-1] + 1

for a in ans:
  print(int(a))

Measured memory_bytes: 12712
#include <stdio.h>
#include <algorithm>
using namespace std;

pair<int, int> q[22][22];
int cmd[22], A[22], n, ans;

void check(void)
{
	int i, j, cnt = 0;

	for (i = 1; i <= n; i++)
		if (cmd[i] == 2)
		{
			++cnt;

			for (j = 1; j <= A[i]; j++)
				if (cmd[q[i][j].first] != q[i][j].second + 1)
					return;
		}

	ans = max(ans, cnt);
}

void recursion(int lev)
{
    if (lev > n)
		check();
	else
	{
        cmd[lev] = 1; // 1 is false
        recursion(lev + 1);

        cmd[lev] = 2; // 2 is true
        recursion(lev + 1);
	}
}

int main(void)
{
	int i, j;

    scanf("%d" ,&n);
    for (i = 1; i <= n; i++)
	{
		scanf("%d" ,&A[i]);
        for (j = 1; j <= A[i]; j++)
            scanf("%d %d" ,&q[i][j].first, &q[i][j].second);
	}

	recursion(1);

	printf("%d" ,ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long 
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	int mi = (n - 1) / 2;
	for (int i = 0; i < n; i++) {
		ans += abs(a[i] - a[mi]);
	}
	cout << ans << endl;
}

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

const int N=100010;
int n,m;
char s1[N],s2[N];

int main() {
    scanf("%d%d",&n,&m);
    scanf("%s%s",s1,s2);
    ll tmp=0;
    for(int i=0;i<n;i++) {
        if(tmp%n==0&&s1[i]!=s2[tmp/n]) return puts("-1"),0;
        tmp+=m;
    }
    printf("%lld\n",1ll*n*m/__gcd(n,m));
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"YES\n"; else cout<<"NO\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


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

    ll n;
    cin>>n;
    vi x(n),y;
    rep(i,n) cin>>x[i];
    y=x;
    sort(all(y));
    ll q=n/2-n%2,a=y[q],b=y[q-1],c=y[q+1];
    if(n%2){rep(i,n){
        if(x[i]<=a)cout<<c<<"\n";
        else cout<<a<<"\n";
    }}
    else rep(i,n){
        if(x[i]<a) cout<<a<<"\n";
        else cout<<b<<"\n";
    }
    


    return 0;
}


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

// Union Find Tree
#define MAX_N 100010
struct UnionFind
{
	int par[MAX_N];
	int _rank[MAX_N];
	void init(int n)
	{
		for (int i = 0; i < n; ++i)
		{
			par[i] = i;
			_rank[i] = 0;
		}
	}
	int root(int x)
	{
		return par[x] == x ? x : par[x] = root(par[x]);
	}
	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
	void unite(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y)
			return;
		if (_rank[x] < _rank[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (_rank[x] == _rank[y])
				++_rank[x];
		}
	}
};

int a[55];
int b[55];

void Main()
{
	int N, M; cin >> N >> M;
	rep(i,M) {
		int _a, _b; cin >> _a >> _b;
		--_a, --_b;
		a[i] = _a; b[i] = _b;
	}
	int total_cnt = 0;
	rep(i, M) {
		UnionFind uf;
		uf.init(N);
		rep(j,M) {
			if (i == j) continue;
			uf.unite(a[j], b[j]);
		}
		int cnt = 0;
		rep(j,N) {
			if (j == uf.root(j)) ++cnt;
		}
		if (cnt > 1) ++total_cnt;
	}
	cout << total_cnt << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef online_judge
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll k;
    cin >> k;
    ll n = 7;
    map<int, int> done;
    if(k % 2 == 0)
        cout << -1;
    else {
        int cnt = 1;
        while (true) {
            if(n % k == 0) {
                cout << cnt;
                return 0;
            }
            n *= 10;
            n += 7;
            n %= k;
            if(done[n]) {
                cout << -1;
                return 0;
            }
            cnt++;
            done[n] = true;
        }
    }
    return 0;
}

Measured memory_bytes: 50496
s = list(input())
K = int(input())

for i in range(len(s)):
    if s[i] == "a":
        continue
    d = ord("z")-ord(s[i]) + 1
    if d <= K:
        s[i] = "a"
        K -= d

x = (ord(s[-1])-ord("a")+K)%26
s[-1] = chr(ord("a")+x)
print("".join(s))

Measured memory_bytes: 4152
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		long N = sc.nextLong();
		long ret = 0;
		for (long i = 1; i < N; i++) {
			ret += i;
		}
		System.out.println(ret);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

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

  vector<int> P(N);
  int min_p = N, count = 0;
  for (int i = 0; i < N; ++i)
  {
    cin >> P[i];
  
    if (min_p >= P[i])
    {
      ++count;
      min_p = P[i];
    }

  }
  cout << count << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
using namespace std;

typedef pair<int,int> P;

typedef long long ll;
ll ans;
vector<P> tmp;
vector<P> rtmp;
int main() {
  int n;
  cin >> n;
  vector<P> LR(n);
  for(int i = 0; i < n; i++) {
    int l,r;
    cin >> l >> r;
    LR[i] = P(l,r);
  }
  sort(LR.begin(),LR.end());

  
  int l = 0;
  int r = 1e9+7;
 
  for(int i = 0; i < n; i++) {
    l = max(l,LR[i].first);
    r = min(r,LR[i].second);
    tmp.push_back(P(l,r));
  }
  l = 0;
  r = 1e9 + 7;
  for(int i = n - 1; i >= 0; i--) {
    l = max(l,LR[i].first);
    r = min(r,LR[i].second);
    rtmp.push_back(P(l,r));
  }
  
  for(int i = 0; i < n - 1; i++) {
    int S = max(tmp[i].second - tmp[i].first + 1,0);
    int T = max(rtmp[n-i-2].second - rtmp[n-i-2].first + 1,0);
    ans = max(ans,ll(S + T));
    //   cout << ans << endl;
  }
  for(int i = 1; i < n - 1; i++) {
    int S = max(tmp[i-1].first,rtmp[n-i-2].first);
    int T = min(rtmp[n-i-2].second,tmp[i-1].second);
    ans = max(ans,max(ll(T-S+1),0ll) + LR[i].second-LR[i].first+1);
  }
  cout << ans << endl;
}	
    
  


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



int main() {
  double PI = 3.14159265358979;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double degree = abs((h*30.0+m/2.0)-m*6.0);
  
  double dist = sqrt(a*a + b*b - 2.0*a*b*cos((degree/180)*PI));
  cout << fixed << setprecision(15);
  cout << dist << endl;
  return 0;
}


Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x)
    {
        return -par[root(x)];
    }
};

const int MAX = 100010;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    UnionFind uf(2 * MAX);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        uf.merge(x[i], y[i] + MAX);
    }
    map<int, int> mx, my;
    for (int i = 0; i < MAX; i++)
    {
        mx[uf.root(i)]++;
    }
    for (int i = MAX; i < 2 * MAX; i++)
    {
        my[uf.root(i)]++;
    }
    ll ans = 0;
    for (int i = 0; i < 2 * MAX; i++)
    {
        ans += (ll)mx[i] * my[i];
    }
    cout << ans - n << endl;
}

Measured memory_bytes: 20608
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		String str1=s.next();
		String str2=s.next();
		
		int p=0;
		
		for(int i=0;i<str1.length();i++)
		{
			if(str1.charAt(i)!=str2.charAt(i))
			{
				p=1;
				break;
			}
		}
		
		if(p==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
		
	}
	
}

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


int main(){
    string s;cin>>s;
    ll N=s.size()-1;
    ll cn=0,ans=0;
    for(int i=0;i<(1<<N);i++){
        ans+=s.at(N)-'0';
        cn=0;
        for(int j=0;j<N;j++){
            if(i&(1<<j)){
                cn=0;
                ans+=s.at(N-1-j)-'0';
            }
            else{
                cn++;
                ans+=(ll)pow(10,cn)*(s.at(N-1-j)-'0');
            }
        }
    }
    cout<<ans<<endl;
}







Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

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

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    ll N, K;
    cin >> N >> K;

    vector<ll> s(N,0);

    REP(i, K){
        ll d;
        cin >> d;
        REP(j, d){
            ll A;
            cin >> A;
            s[A-1]++;
        }
    }

    ll count = 0;
    REP(i, N){
       if( s[i] == 0 ) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int n; ll L, ans; scanf("%lld%d", &L, &n);
	vector<ll> a(n), pref(n + 1, 0);
	rep(i,0,n)scanf("%lld", &a[i]);
	rep(i,0,n)pref[i + 1] = pref[i] + a[i];
	ans = 0;
	rep(i,0,n){
		int k = min(i, n - 1 - i);
		ll sub = a[i];
		sub += 2 * (pref[i] - pref[i - k]);
		if (i + k + 1 < n) k++;
		sub += 2 * (k * L - pref[i + k + 1] + pref[i + 1]);
		ans = max(ans, sub);
	}
	rep(i,0,n){
		int k = min(i, n - 1 - i);
		ll sub = L - a[i];
		sub += 2 * (k * L - pref[i + k + 1] + pref[i + 1]);
		if (i > k) k++;
		sub += 2 * (pref[i] - pref[i - k]);
		ans = max(ans, sub);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
using namespace std;
int N,K,d[100],cnt,t1,t2;
int main() {
    cin>>N>>K;
    for (int i=0; i<K; i++) {
        cin>>t1;
        for (int j=0; j<t1; j++) {
            cin>>t2; d[t2-1]++;
        }
    }
    for (int i=0; i<N; i++) if (d[i]==0) cnt++;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void) {
	int k, a ,b, i, flag=0;
	scanf("%d %d %d", &k, &a, &b);
	for(i=a; i<=b; i++){
		if(i%k==0){
			printf("OK");
			flag=1;
			break;
		}
	}
	if(flag==0)
		printf("NG");
	return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(s, e) for(int i=s; i<e; ++i)
#define pb push_back
#define all(v) v.begin(), v.end()
#define MOD 1000000007

int main(){
    IO
    int N, M, u;
    string v;
    cin >> N >> M;
    map<int, string> ref;
    int arr[N+1] = {0};
    int ac = 0, p = 0;
    for(int i=0; i<M;++i){
        cin >> u >> v;
        auto it = ref.find(u);

        if(it==ref.end()){
            if(v=="AC"){
                ++ac;
                ref.insert({u, "AC"});
            }
            else{
                ++arr[u];
                ref.insert({u, "WA"});
            }
        }
        else if(it->second=="AC")
            continue;
        else if(it->second == "WA" && v=="AC"){
            ++ac;
            it->second = "AC";
            p+=arr[u];
        }
        else if(it->second=="WA" && v=="WA")
            ++arr[u];

    }

    cout << ac << " " << p;
    return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod =1e9+7;

int main(){
    ll n;
    cin>>n;
    ll sum=0;
    ll a[n+5];
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum=sum+a[i];
        sum%=mod;
    }
    ll pre=0;
    for(int i=0; i<n; i++){
        pre=(pre+(a[i]*a[i]));
        pre%=mod;
    }
    ll ans=((sum*sum-pre)+mod)%mod;
    ans*=500000004;
    cout<<ans%mod<<endl;

    return 0;
}


Measured memory_bytes: 5152
x = int(input())


def prime(n):
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

# returnの位置
# 割り切れない時はTrueを返して、割り切れるときはFalseを返す

while not prime(x):
    x += 1
print(x)
# prime(n)は素数判定機となっているので、while文を素数じゃないときまで回す

Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

int pow(int n, int t) {
    int result = 1;
    for (int i = 0; i < t; i++) {
        result *= n;
    }
    return result;
}

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

    int count = pow(3, n);
    int evens = 1;

    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        if ((t & 1) == 0) {
            evens *= 2;
        }
    }

    cout << count - evens << "\n";

    int a;
    cin >> a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int A,B,C,D,N,K;
    int ans=0;
    
    cin>>N>>K;
    int d[N];
    rep(i,N){
        cin>>d[i];
        if(d[i]>=K){
            ans++;
        }
    }
    Out(ans);
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main {
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        String[] inputs = br.readLine().split(" ");
        int n = Integer.parseInt(inputs[0]);
        int m = Integer.parseInt(inputs[1]);

        int sum = 0;

        inputs = br.readLine().split(" ");
        int[] nums = new int[n];
        for(int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(inputs[i]);
            sum += nums[i];
        }

        String ans = "Yes";
        Arrays.sort(nums);
        if(nums[n-m] * (4 * m) < sum) {
            ans = "No";
        }

        pw.println(ans);
        pw.flush();
    }
}


Measured memory_bytes: 22484
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


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

int main(){
  int A, B, C, D, E;
  cin>>A>>B>>C>>D>>E;

  if(A < 0) cout<<-A * C + D + E * B<<endl;
  if(A > 0) cout<<E * (B - A)<<endl;

  return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli x;
    cin>>x;
    if(x==0)
    cout<<1<<"\n";
    if(x==1)
    cout<<0<<"\n";
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long l,r;
	cin>>l>>r;
	if(r-l>=2018)
	{
		cout<<0<<endl;
		return 0;
	}
	long long ans=2018;
	for(long long i=l;i<=r;i++)
		for(long long j=i+1;j<=r;j++)
			ans=min(ans,i*j%2019);
	cout<<ans<<endl;
	return 0;
}


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

struct Problem {

    UL N, M;
    vector<UL> E[10000];
    vector<UL> rE[10000];
    UL I[10000];
    bool F[10000];
    UL G[10000];

    bool ans = false;

    void DFS(UL p, UL& i) {
        if (F[p]) return;
        F[p] = true;
        for (UL e : E[p]) DFS(e, i);
        I[p] = i; i++;
    }

    void Solve() {
        scanf("%d%d", &N, &M);
        rep(i, M) {
            UL u, v; scanf("%d%d", &u, &v);
            E[u].push_back(v);
            rE[v].push_back(u);
        }
        UL j = 0;
        rep(i, N) if (!F[i]) DFS(i, j);
        rep(i, N) {
            for (UL e : rE[i]) if (I[e] < I[i]) ans = true;
        }

        printf(ans ? "1\n" : "0\n");
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    //cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}




Measured memory_bytes: 3312
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  tmp = input[0]
  ans = tmp.replace(/hi/g,'')
  if(ans.length == 0){
    console.log('Yes')
  }else{
    console.log('No')
  }

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
# -*- coding: utf_8 -*-

def maxHeapify(A, i):
    l = 2 * i - 1
    r = 2 * i
    largest = i - 1

    if l < len(A):
        largest = largest if A[largest] > A[l] else l

    if r < len(A):
        largest = largest if A[largest] > A[r] else r

    if largest != i - 1:
        A[largest], A[i - 1] = A[i - 1], A[largest]
        maxHeapify(A, largest + 1)

if __name__ == "__main__":
    H = int(input())
    a = [int(x) for x in input().split()]

    for i in range(int(H / 2), 0, -1):
        maxHeapify(a, i)

    print(" " + " ".join(str(x) for x in a)),

Measured memory_bytes: 65720
#include <iostream>
#include <string>

using namespace std;

void resolve()
{
    string S;
    cin >> S;

    if (S == "AAA" || S == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

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


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int n,f[100010],g[100010];
int min(int a,int b)
{
	return (a<b?a:b);
}
int abs(int x)
{
	return (x>0?x:(-x));
}
int main()
{
	memset(g,0x3f,sizeof(g));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&f[i]);
	}
	g[1]=0;
	for(int i=1;i<=n;i++)
	{
		g[i+1]=min(g[i+1],g[i]+abs(f[i]-f[i+1]));
		g[i+2]=min(g[i+2],g[i]+abs(f[i]-f[i+2]));
	}
	printf("%d",g[n]);
} 

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,k; cin >> n >> k;
  string s; cin >> s;

  vector<int> nums;
  int cnt = 0;
  int now = 1;
  REP(i, n) {
    if (s[i]-'0' == now) cnt++;
    else {
      nums.push_back(cnt);
      now ^= 1; // 0と1を切り替える
      cnt = 1;
    }
  }
  if (cnt != 0) nums.push_back(cnt);

  // 1-0-1-0-1 の配列がほしい. 1-0-1-0のように0で終わっていたら1つ足す
  if (nums.size() % 2 == 0) nums.push_back(0);

  int add = 2*k+1; // 1-0-1-0-1 の配列になっているため
  int ans = 0;

  // 累積和
  /*
  vector<int> sum(nums.size()+1, 0);
  REP(i,sum.size()) sum[i+1] = sum[i]+nums[i];

  for(int i = 0; i < nums.size(); i+=2) {
    int left = i;
    int right = min(i+add, (int)nums.size());
    int tmp = sum[right] - sum[left];

    chmax(ans,tmp);
  }
  */

  // しゃくとり法
  int left=0, right=0;
  int tmp = 0; // [left, right) の sum
  // 1-0-1... の偶数番目だけみる
  for (int i = 0; i < nums.size(); i+=2) {
    int nextL = i;
    int nextR = min(i+add, (int)nums.size());
    while(nextL > left) {
      tmp -= nums[left];
      left++;
    }
    while(nextR > right) {
      tmp += nums[right];
      right++;
    }
    chmax(ans,tmp);
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 1020
n=int(input())
a=list(input())
b=list(input())
ans=1
i=0
f=0
mod=1000000007
while i!=n:
    if i==0:
        if a[i]==b[i]:
            i+=1
            ans*=3
            ans%=mod
            f=1
        else:
            i+=2
            ans*=6
            ans%=mod
            f=2
    else:
        if a[i]==b[i] and f==1:
            i+=1
            ans*=2
            ans%=mod
            f=1
        elif a[i]==b[i] and f==2:
            i+=1
            f=1
        elif a[i]!=b[i] and f==1:
            i+=2
            ans*=2
            ans%=mod
            f=2
        else:
            i+=2
            ans*=3
            ans%=mod
            f=2
print(ans%mod)
            
        


Measured memory_bytes: 3064
package main

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

const (
	WHITE int = iota
	GRAY
	BLACK
)

type graph struct {
	G [][]int
	C []int
	D []int
	P []int
}

var INFTY = 1 << 32

func constructGraph() *graph {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	g := make([][]int, n)
	c := make([]int, n)
	d := make([]int, n)
	p := make([]int, n)

	for i := 0; i < n; i++ {
		sc.Scan()
		fields := strings.Fields(sc.Text())
		g[i] = toIntSlice(fields)
	}

	return &graph{g, c, d, p}
}

func (g *graph) initMst() {
	for i := 0; i < len(g.G); i++ {
		g.C[i] = WHITE
		g.D[i] = INFTY
	}
	g.D[0] = 0
	g.P[0] = -1
}

func (g *graph) primMst() int {
	g.initMst()

	var u int
	for {
		mincost := INFTY
		for i := 0; i < len(g.G); i++ {
			if g.C[i] != BLACK && g.D[i] < mincost {
				mincost = g.D[i]
				u = i
			}
		}

		if mincost == INFTY {
			break
		}

		g.C[u] = BLACK

		for i := 0; i < len(g.G); i++ {
			if g.C[i] != BLACK && g.existEdge(u, i) {
				if g.G[u][i] < g.D[i] {
					g.D[i] = g.G[u][i]
					g.P[i] = u
				}
			}
		}
	}

	totalCost := 0
	for _, cost := range g.D {
		totalCost += cost
	}
	return totalCost
}

func (g *graph) existEdge(u, v int) bool {
	return g.G[u][v] != INFTY && g.G[v][u] != INFTY
}

func toIntSlice(s []string) []int {
	a := make([]int, len(s))
	for i, v := range s {
		num, _ := strconv.Atoi(v)
		if num == -1 {
			num = INFTY
		}
		a[i] = num
	}
	return a
}

func main() {
	g := constructGraph()
	fmt.Println(g.primMst())
}



Measured memory_bytes: 1464