akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool flag[ 114514 ] = {};

int main() {

  long long int n;
  cin >> n;

  vector< pair< long long int, long long int > > vl, vr;

  for ( long long int i = 0; i < n; i++ ) {

    long long int in_l, in_r;
    cin >> in_l >> in_r;

    vl.push_back( make_pair( -in_l, i ) );
    vr.push_back( make_pair( in_r, i ) );

  }

  sort( vl.begin(), vl.end() );
  sort( vr.begin(), vr.end() );

  long long int kl = 0;
  long long int kr = 0;

  long long int ans = 0;
  long long int cnt = 0;

  while( kl < n || kr < n ) {

    while( kl < n ) {
      long long int f = vl[ kl ].second;
      if ( flag[ f ] == true ) {
	kl++;
	continue;
      }
      if ( -vl[ kl ].first < cnt ) {
	kl = n;
	break;
      }
      flag[ f ] = true;
      ans += -vl[ kl ].first - cnt;
      cnt = -vl[ kl ].first;
      break;
    }

    while( kr < n ) {
      long long int f = vr[ kr ].second;
      if ( flag[ f ] == true ) {
	kr++;
	continue;
      }
      if ( vr[ kr ].first > cnt ) {
	kr = n;
	break;
      }
      flag[ f ] = true;
      ans += cnt - vr[ kr ].first;
      cnt = vr[ kr ].first;
      break;
    }

  }

  if ( cnt < 0 ) cnt = -cnt;
  ans += cnt;



  for ( long long int i = 0; i < n; i++ ) {
    flag[i] = false;
  }
  kl = 0;
  kr = 0;

  long long int ans2 = 0;
  cnt = 0;

  while( kl < n || kr < n ) {

    while( kr < n ) {
      long long int f = vr[ kr ].second;
      if ( flag[ f ] == true ) {
	kr++;
	continue;
      }
      if ( vr[ kr ].first > cnt ) {
	kr = n;
	break;
      }
      flag[ f ] = true;
      ans2 += cnt - vr[ kr ].first;
      cnt = vr[ kr ].first;
      break;
    }

    while( kl < n ) {
      long long int f = vl[ kl ].second;
      if ( flag[ f ] == true ) {
	kl++;
	continue;
      }
      if ( -vl[ kl ].first < cnt ) {
	kl = n;
	break;
      }
      flag[ f ] = true;
      ans2 += -vl[ kl ].first - cnt;
      cnt = -vl[ kl ].first;
      break;
    }

  }

  if ( cnt < 0 ) cnt = -cnt;
  ans2 += cnt;



  cout << max( ans, ans2 ) << endl;

  return 0;

}


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

int main() {
  int H , W;
  cin >> H >> W;
  for(int j = 0; j < W + 2; j++){
    cout << '#';
  }
  cout << endl;
  for(int i = 0; i < H; i++){
    cout << '#';
    for(int j = 0; j < W; j++){
      char s;
      cin >> s;
      cout << s;
    }
    cout << '#' << endl;
  }
   for(int j = 0; j < W + 2; j++){
    cout << '#';
   }
     cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    multiset<ll> s;

    rep(i, n) {
        ll now = a[i];
        auto itr = s.lower_bound(now);
        if (itr != s.begin()) s.erase(--itr);
        s.insert(now);
    }
    
    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;

  int mnt[10];
  for(ii=0;ii<10;ii++){
    cin >> mnt[ii];
  }
  int sw;
  for(ii=0;ii<9;ii++){
    for(jj=ii+1;jj<10;jj++){
      if(mnt[ii] < mnt[jj]){
        sw = mnt[ii];
        mnt[ii] = mnt[jj];
        mnt[jj] = sw;
      }
    }
  }
  
  for(ii=0;ii<3;ii++){
    cout << mnt[ii] << endl;
  }
  return 0;
  
}



Measured memory_bytes: 3072
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
int n,k;
int t[1111];
ll dp[55][55][2550];

ll dfs(int p,int sum,int x){
	if(dp[p][x][sum]>=0)return dp[p][x][sum];

	if(p>=n){
		if(x>0&&sum/x==k&&sum%x==0){return dp[p][x][sum]=1;}
		return dp[p][x][sum]=0;
	}

	ll ret=0;

	ret+=dfs(p+1,sum,x);
	ret+=dfs(p+1,sum+t[p],x+1);

	return dp[p][x][sum]=ret;
}
int main(){
	cin>>n>>k;
	rep(i,n)cin>>t[i];
	rep(i,55)rep(j,55)rep(k,2550)dp[i][j][k]=-1;
	cout<<dfs(0,0,0)<<endl;
	return 0;
}


Measured memory_bytes: 60544
#include <iostream>
#include <vector>


using namespace std;


using ll = long long;


template <typename T>
class disjoint_set {
    vector<T> parent, rank;

    public:
        disjoint_set();
        disjoint_set(long long size);

        void make_set(T x);
        long long find_set(T x);
        void unite(T x, T y);
        void resize(long long size);
};


template <typename T>
disjoint_set<T>::disjoint_set(long long size)
{
    resize(size);
}


template <typename T>
disjoint_set<T>::disjoint_set()
    : disjoint_set(0)
{
}


template <typename T>
void disjoint_set<T>::resize(long long size)
{
    parent.resize(size);
    rank.resize(size);

    for (long long i = 0; i < size; i++) {
        make_set(i);
    }
}


template <typename T>
void disjoint_set<T>::make_set(T x)
{
    parent[x] = x;
    rank[x] = 0;
}


template <typename T>
long long disjoint_set<T>::find_set(T x)
{
    if (x != parent[x]) {
        parent[x] = find_set(parent[x]);
    }
    return parent[x];
}


template <typename T>
void disjoint_set<T>::unite(T x, T y)
{
    long long rx, ry;
    rx = find_set(x);
    ry = find_set(y);
    if (rank[rx] == rank[ry]) {
        parent[rx] = ry;
        // when the rank (height) of the trees are the same
        // uniting trees wilong long increase the rank.
        rank[ry]++;
    } else if (rank[rx] < rank[ry]) {
        // uniting a shorter tree under a higher tree
        // won't change the rank (height) of the united tree.
        parent[rx] = ry;
    } else {
        parent[ry] = rx;
    }
}


int main()
{
    disjoint_set<ll> ds;

    ll n, q;
    cin >> n >> q;

    ds.resize(n + 1);

    for (ll i = 0; i < q; i++) {
        ll com, x, y;
        cin >> com >> x >> y;

        switch(com) {
            case 0:
                ds.unite(x, y);
                break;
            case 1:
                if (ds.find_set(x) == ds.find_set(y)) {
                    cout << 1 << endl;
                } else {
                    cout << 0 << endl;
                }
                break;
        }
    }
}



Measured memory_bytes: 3240
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

area_x = 0
for k in range(n):
    area_x += k * x[k] - (n - k-1) * x[k]

area_y = 0
for l in range(m):
    area_y += l * y[l] - (m - l-1) * y[l]

print((area_x * area_y) % (10**9 + 7))


Measured memory_bytes: 18556
import sys

class Card:
	def __init__(self, card):
		self.card = card
		self.mark = card[0]
		self.value = card[1]
	
	def equals(self, other):
		if self.mark != other.mark: return False
		if self.value != other.value: return False
		return True

	def __str__(self):
		return self.card

def print_cards(cards, cards_):
	n = len(cards)
	same = True
	for i in range(n):
		if cards_ != None and cards[i].equals(cards_[i]) == False:
			same = False
		sys.stdout.write(str(cards[i])) 
		if i != n - 1:
			sys.stdout.write(' ')
	print()
	return same	

def swap(cards, i, j):
	temp = cards[i]
	cards[i] = cards[j]
	cards[j] = temp

def bubble_sort(cards):
	n = len(cards)
	for i in range(n):
		for j in range(n - 1, i, -1):
			if cards[j].value < cards[j - 1].value:
				swap(cards, j, j - 1)

def selection_sort(cards):
	n = len(cards)
	for i in range(n):
		mini = i
		for j  in range(i, n):
			if cards[j].value < cards[mini].value:
				mini = j
		if mini != i:
			swap(cards, i, mini)
		
n = int(input())
input_list = list(map(str, input().split()))
cards1 = [None] * n
cards2 = [None] * n
for i in range(n):
	cards1[i] = Card(input_list[i])
	cards2[i] = Card(input_list[i])
	
bubble_sort(cards1)
selection_sort(cards2)

print_cards(cards1, None)
print('Stable')

stable = print_cards(cards2, cards1)
if stable == True:
	print('Stable')
else:
	print('Not stable')



Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  vector<Int> cnt(50);
  for(Int i=0;i<n;i++)
    for(Int j=0;j<50;j++)
      cnt[j]+=(a[i]>>j)&1;

  Int ans=0;
  function<void(Int, Int, Int)> dfs=
    [&](Int x,Int v,Int f){
      if(x<0){
        chmax(ans,v);
        return;
      }
      if(f){
        dfs(x-1,v+max(cnt[x],n-cnt[x])*(1LL<<x),1);
        return;
      }
      if((k>>x)&1){        
        dfs(x-1,v+(cnt[x])*(1LL<<x),1);   // 0 
        dfs(x-1,v+(n-cnt[x])*(1LL<<x),0); // 1
      }else{
        dfs(x-1,v+(cnt[x])*(1LL<<x),0);   // 0
      }
    }; 
  dfs(49,0,0);
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
  ll n, k;
  cin >> n >> k;
  ll ans = 1e9;
  while (1)
  {
    ll buf = min(abs(n - k), n % k);
    n = buf;
    if (ans == n)
    {
      break;
    }
    ans = n;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3616
buf[20000];char*p=buf;
i,w;
main(){
	read(0,buf,20000);
	for(;*p>10;p++)w=*p==32?0:w*10+*p-48;
	for(;i++<w+1;)putchar_unlocked('#');
	for(;*p>0;p++){
		*p==10&&putchar_unlocked('#');
		putchar_unlocked(*p);
		*p==10&&putchar_unlocked('#');
	}
	for(i=0;i++<w+1;)putchar_unlocked('#');
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

vector<int> G[MAX_N];
int dp[MAX_N][2];

void dfs(int u, int p)
{
    int cri0 = 1, cri1 = 1;
    each(v,G[u]){
        if(v != p){
            dfs(v,u);
            cri0 = mul(cri0, dp[v][1]);
            cri1 = mul(cri1, add(dp[v][0], dp[v][1]));
        }
    }
    dp[u][0] = cri0, dp[u][1] = cri1;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        G[u-1].pb(v-1), G[v-1].pb(u-1);
    }
    dfs(0, -1);
    cout << add(dp[0][0], dp[0][1]) << "\n";
    return 0;
}

Measured memory_bytes: 13440
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define Min(a,b) ((a)<(b)?(a):(b))

#define Max(a,b) ((a)>(b)?(a):(b))

#define ABS(a) ((a)>(0)?(a):-(a))

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

#define Rep2(i,bottom,ceiling) for(int (i)=(bottom);(i)<=(ceiling);(i)++)

int Str_cmpfunc (const void * a, const void * b) {
   return strcmp(*(const char**)a,*(const char**)b );
}

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

int Arrcmp(int *arr1,int *arr2,int len){
	Rep(i,len){
		if(arr1[i]>arr2[i]) return 1;
		if(arr1[i]<arr2[i]) return -1;
	}	
	return 0;
}

void SwapInt(int* v1,int* v2){
	int sw = *v1;
    *v1=*v2;
    *v2=sw;
}

void SwapChar(char* v1,char* v2){
    char sw = *v1;
    *v1=*v2;
    *v2=sw;
}

void SwapStr(char** str1,char** str2){
    char* sw = *str1;
    *str1=*str2;
    *str2=sw;
}

int main(){ 
	long long a,b,c,k;;	
	scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
	if(k%2) printf("%lld\n",b-a);
	else printf("%lld\n",a-b);
	return 0;
}


Measured memory_bytes: 128
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
arrABC = np.array(input().split(),dtype=np.int64)
cnt = Counter(arrABC % 2)
arrABC.sort()
if cnt[0] > 0:
    print(0)
else:
    ans = arrABC[0]*arrABC[1]
    print(ans)

# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 12496
use proconio::input;
use std::cmp::min;
fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n:isize,
        k:isize
    }

    let mut ans = n % k;
    ans = min(ans,(ans - k).abs());
    

    println!("{}",ans);


}    


Measured memory_bytes: 2168
e=input
a=[]
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=[len(z)]
print(*a,sep='\n')


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

int main() {
	long long h, w, n;
	cin >> h >> w >> n;

	set<pair<int, int>> st;
	set<pair<int, int>> check;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		st.emplace(a, b);
		for (int i = -2; i <= 0; i++) {
			for (int j = -2; j <= 0; j++) {
				if (a + i >= 0 && b + j >= 0 && a + i + 3 <= h && b + j + 3 <= w) {
					check.emplace(a + i, b + j);
				}
			}
		}
	}

	vector<long long> num(10);
	num[0] = (h - 2) * (w - 2);

	for (auto p : check) {
		int c = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				c += st.count(make_pair(p.first + i, p.second + j));
			}
		}
		num[c]++;
		num[0]--;
	}

	for (int i = 0; i < 10; i++) {
		cout << num[i] << endl;
	}
}

Measured memory_bytes: 47104
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

if m < n * 2:
    print(m // 2)
elif m == n * 2:
    print(n)
else:
    t, m = n, m - n * 2
    t += m // 4
    print(t)


Measured memory_bytes: 2940
#include <stdio.h>

int tanri_calc(int saisyo,double riritu,int tesuu_ryo,int nensu) {
	int i;
	int risi=0;
	int now=saisyo;
	for(i=0;i<nensu;i++) {
		risi+=(int)(now*riritu);
		now-=tesuu_ryo;
	}
	return now+risi;
}

int fukuri_calc(int saisyo,double riritu,int tesuu_ryo,int nensu) {
	int i;
	int now=saisyo;
	for(i=0;i<nensu;i++) {
		now+=(int)(now*riritu);
		now-=tesuu_ryo;
	}
	return now;
}

int main(void) {
	int dataset_num,c_dataset;
	int saisyo;
	int nensu;
	int choice_num;
	int type;
	double riritu;
	int tesuu_ryo;
	int i;
	int now,result;
	scanf("%d",&dataset_num);
	for(c_dataset=0;c_dataset<dataset_num;c_dataset++) {
		scanf("%d",&saisyo);
		scanf("%d",&nensu);
		scanf("%d",&choice_num);
		result=0;
		for(i=0;i<choice_num;i++) {
			scanf("%d%lf%d",&type,&riritu,&tesuu_ryo);
			if(type) {
				now=fukuri_calc(saisyo,riritu,tesuu_ryo,nensu);
			} else {
				now=tanri_calc(saisyo,riritu,tesuu_ryo,nensu);
			}
			if(result<now)result=now;
		}
		printf("%d\n",result);
	}
	return 0;
}

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

using namespace std;

int main() {
    int n; cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    long long res = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int x = lower_bound(arr, arr + n, arr[i] + arr[j]) - upper_bound(arr, arr + n, arr[j] - arr[i]);
            if (2 * arr[i] > arr[j]) x--;
            if (2 * arr[j] > arr[i]) x--;
            res += x;
        }
    }
    cout << res / 3;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
  ll n,y;
  cin >>n>>y;
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=n-i;j++){
        if(i*10000+j*5000+(n-i-j)*1000==y){
          cout <<i<<" "<<j<<" "<<n-i-j<<endl;
          return 0;
        }
      }
    }
  cout <<-1<<" "<<-1<<" "<<-1<<endl;
}


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

int main()
{
    string s, s1;
    cin >> s >> s1;
    vector<vector<int>> cache(s.size() + 1, vector<int>(s1.size() + 1));
    for (int i = 0; i < cache.size(); i++)
    {
        for (int j = 0; j < cache[i].size(); j++)
        {
            if (i == 0 || j == 0) cache[i][j] = 0;
            else if (s[i - 1] == s1[j - 1])
                cache[i][j] = cache[i - 1][j - 1] + 1;
            else
                cache[i][j] = max(cache[i - 1][j], cache[i][j - 1]);
        }
    }
    //cout<<"maxLength: "<<cache[s.size()][s1.size()]<<endl;
    int i = s.size(), j = s1.size();
    string ans;
    while (i >= 1 && j >= 1)
    {
        if (s[i - 1] == s1[j - 1]) {
                ans.push_back(s[i-1]);
                i--;
                j--;
            }
        else if (cache[i - 1][j] > cache[i][j - 1]) i--;
        else j--;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <boost/math/common_factor.hpp>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

ll lcm(vint &a)
{
    ll res = 1;

    for (ll b : a)
    {
        res = boost::math::lcm(res, b);
    }
    return res;
}

int countPow2(int x)
{
    int res = 0;
    while (x % 2 == 0)
    {
        res++;
        x /= 2;
    }

    return res;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vint a(n);
    rep(i, n)
    {
        cin >> a[i];
        a[i] /= 2;
    }

    int count = countPow2(a[0]);
    rep(i, n)
    {
        if (countPow2(a[i]) != count)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    ll k = lcm(a);
    if (k > m)
    {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for (int i = 1; k * i <= m; i += 2)
        ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int flg=0;
        
        char n = a.charAt(0);
        
        for(int i=0; i<300; i++){
            
            
            
            
            if(n=='a'){
                if(a.length()==0){
                    System.out.println("A");
                    return;
                }
                n = a.charAt(0);
                a = a.substring(1,a.length());
            }else if(n=='b'){
                if(b.length()==0){
                    System.out.println("B");
                    return;
                }
                n = b.charAt(0);
                b = b.substring(1,b.length());
            }else if(n=='c'){
                if(c.length()==0){
                    System.out.println("C");
                    return;
                }
                n = c.charAt(0);
                c = c.substring(1,c.length());
            }
        }
        
   }
}


Measured memory_bytes: 35540
import numpy as np

A, B = map(int, input().split())

K = 50
grid = np.ones((100, 100), dtype='int')

# 白1黒0
grid[:K, :] = 0

A -= 1
col = 0
row = 0
while A:
    if A >= K:
        grid[col, ::2] = 1
        A -= K
        col += 2
        continue

    grid[col, row] = 1
    row += 2
    A -= 1

B -= 1
col = K + 1
row = 0
while B:
    if B >= K:
        grid[col, ::2] = 0
        B -= K
        col += 2
        continue

    grid[col, row] = 0
    row += 2
    B -= 1

grid = np.where(grid, '.', '#')
print(100, 100)
print('\n'.join(map(''.join, grid)))

Measured memory_bytes: 12632
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
#include <limits.h>
#include <bits/stdc++.h>
#define fw(x) freopen("x.txt","w",stdout)
#define For(i,a,b,c) for(int i = a;i < b;i+=c)
#define REP(i,n) for(int i = 0;i < n;++i)
#define REP1(i,n) for(int i = 1; i<=n;i++)
#define mem(a,s) memset(a,s,sizeof a)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define pf printf
#define sc scanf
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define vii vector<int>
#define vll vector<ll>
#define vss vector<string>
#define debug(x)  cout<<#x"="<<(x)<<endl
#define pb push_back


using namespace std;


// moves

//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/


//big_mod

//ll bigmod(ll a,ll b,ll m)
//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}
//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}
//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}

const int mod = 1000000007;

int main()
{
    fast;
    int n;
    cin>>n;
    int arr[n];
    REP(i, n) cin>>arr[i];
    int cost[n] = {0};
    cost[1] = abs(arr[1]-arr[0]);
    for(int i=2; i<n; i++){
      cost[i] = min(cost[i-1]+abs(arr[i-1]-arr[i]), cost[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout<<cost[n-1]<<'\n';
    return 0;
}


Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int count = 0;
    for(int i = 0;i<a;i++){
        int c;
        cin >> c;
        if(b <= c){
            count++;
        }
    }
    cout << count << endl;
} 
    


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int num,line[105],line1[105],i;
  
double d(int p)
{
    int i;
    double D;
    for(D=0.0,i=0;i<num;i++)
    {
        if(p==4)D=D>abs(line[i]-line1[i])?D:abs(line[i]-line1[i]);
        else D+=pow(abs(line[i]-line1[i]),p);
    }
    return p==4?D:pow((double)D,1.0/p);
}
  
int main(void)
{
    scanf("%d",&num);
    for(i=0;i<num;i++)
        scanf("%d",&line[i]);
    for(i=0;i<num;i++)
        scanf("%d",&line1[i]);
    for(i=1;i<5;i++)
        printf("%lf\n",d(i));
    return 0;
}

Measured memory_bytes: 696
x = 10**9
n = int(input())
w = list(map(int,input().split()))
for i in range(n):
    g,t = 0,0
    for j in range(i):
        g+=w[j]
    for k in range(n-i):
        t+=w[n-k-1]
    x = min(x,abs(g-t))
print(x)

Measured memory_bytes: 3060
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    println!("{}", (n - 1) / 2);
}


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

using namespace std;

string s;

bool is(int n) {
  int m = n / 2;
  if (n % 2 == 0) {
    for (int i = 0, j = m; i < m; i++, j++) {
      if (s[i] != s[j]) {
        return false;
      }
    }
  } else {
    return 0;
  }
  return 1;
}

int main() {
  cin >> s;
  for (int i = (int)s.length() - 1; i >= 0; i--) {
    if (is(i)) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	String X;
	List<Pair> playList;
	int result = 0;

	static class Pair {
		Pair(String s, int t) {
			this.s = s;
			this.t = t;
		}

		String s;
		int t;
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		this.playList = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			this.playList.add(new Pair(tokens[0], Integer.parseInt(tokens[1])));
		}
		X = in.readLine();
	}

	void calc() {
		boolean isSleep = false;
		for (int i = 0; i < N; ++i) {
			if (isSleep) {
				result += this.playList.get(i).t;
			} else {
				if (this.playList.get(i).s.equals(X)) {
					isSleep = true;
				}
			}
		}
	}

	void showResult() {
		System.out.println(result);
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(3*max(max(a,b),c)+3*min(min(a,b),c)==2*a+2*b+2*c){
    cout<<"YES";
    return 0;
    }
    cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;

    vector<string> wer;
    wer = {"Sunny","Cloudy","Rainy","Sunny"};
    for(int i = 0; i < 3; i++){
        if(S == wer.at(i)){
            cout << wer.at(i+1) << endl;
        }
        else {
        }
    }
    return 0;
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Permutation - Permutation Enumeration
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_5_D&lang=jp

"""
from itertools import permutations

for p in permutations(range(1, int(input())+1)):
    print(*p)



Measured memory_bytes: 6348
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	for (int n; cin >> n;) {
		int M, m, R;
		cin >> R; m = R;
		cin >> R; M = R - m; m = min(R, m);
		for (int j = 2; j < n; j++) {
			cin >> R;
			M = max(R - m, M);
			m = min(R, m);
		}
		cout << M << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  int a,b,c, tmp;

  cin >> a >> b >> c;


  tmp = a;
  a = b;
  b = tmp;

  tmp = a;
  a = c;
  c = tmp;

  cout << a << " " << b << " " << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1000001;
ll n;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll dp[maxn][4];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];
    for (int i = 2; i <= n; i++)
    {
        dp[i][1] += max(dp[i - 1][2], dp[i - 1][3]) + a[i];
        dp[i][2] += max(dp[i - 1][1], dp[i - 1][3]) + b[i];
        dp[i][3] += max(dp[i - 1][1], dp[i - 1][2]) + c[i];
    }
    cout << max(dp[n][3], max(dp[n][1], dp[n][2]));
    return 0;
}

Measured memory_bytes: 12544
#include <algorithm>
#include <cstdio>

using namespace std;

int N, L[220];

int solve() {
    sort(L, L+2*N);
    int ret = 0;
    for (int i = 0; i < 2*N; i++) {
        if (i % 2 == 0) ret += min(L[i], L[i+1]);
    }
    return ret;
}

int main() {
    scanf("%d", &N);
    for (int i = 0; i < 2*N; i++) scanf("%d", L+i);
    int ans = solve();
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

//#define scanf scanf_s

string isl[15];
int cnt;
int di[4] = { -1, 0, 0, 1 }; int dj[4] = { 0, -1, 1, 0 };

void dfs(int i, int j)
{
	if (i >= 0 && j >= 0 && i < 12 && j < 12)
	{
		if (isl[i][j] == '1')
		{
			isl[i][j] = '0';
			REP(k, 4) dfs(i + di[k], j + dj[k]);
		}
	}
}

int main()
{
	while (cin >>isl[0])
	{
		FOR(i, 1, 12) cin >> isl[i];
		cnt = 0;
		REP(i, 12)REP(j, 12)
		{
			if (isl[i][j] == '1')
			{
				cnt++;
				dfs(i, j);
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
s = []
for i in range(a):
  s.append([p[i],1])
for i in range(b):
  s.append([q[i],2])
for i in range(c):
  s.append([r[i],0])
s.sort(reverse=True)
cnt = 0
cnt1 = 0
cnt2 = 0
ans = 0
for z in s:
  v,j = z
  if j == 1:
    if cnt1 == x:
      continue
    else:
      cnt1 += 1
      cnt += 1
      ans += v
  elif j == 2:
    if cnt2 == y:
      continue
    else:
      cnt2 += 1
      cnt += 1
      ans += v
  else:
    cnt += 1
    ans += v
  if cnt == x+y:
    print(ans)
    exit()

Measured memory_bytes: 128748
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 2000+5;

int n;
bool vis[N][N];

int main(){
	ri(n);
	for(int i=1; i<=n; i++) vis[i][i] = true;
	if(n & 1){
		for(int i=1; i<=n-i; i++){
			vis[i][n-i] = true;
		}
	}
	else{
		for(int i=1; i<=n+1-i; i++){
			vis[i][n+1-i] = true;
		}
	}
	vii edges;
	for(int i=1; i<=n; i++){
		for(int j=i; j<=n; j++){
			if(vis[i][j]) continue;
			edges.emplace_back(mp(i,j));
		}
	}
	cout << edges.size() << endl;
	for(auto x : edges){
		printf("%d %d\n",x.first,x.second);
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

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

int main(){
    int K;
    int ans=0;
    cin >> K;

    for(int i=1; i<=K; i++){
      for(int j=1; j<=K; j++){
        for(int k=1; k<=K; k++)
          ans += gcd3(i, j, k);
      }
    }

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

Measured memory_bytes: 3616
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if s == u:
        print(a-1,b)
        return
    print(a,b-1)

    
main()

Measured memory_bytes: 5076
#include <iostream>
#include <queue>
#include <tuple>

using namespace std;

struct Node {
  // ダイクストラ法のためのデータ
  bool done;  // 確定ノードか否か
  int cost;   // このノードへの現時点で判明している最小コスト
};

const int S[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
Node m[502][502];
int N;
int P[502][502] = {0};
int Q[502 * 502] = {0};

int diff_solve(int num, int sx, int sy)
{
  // 周辺を差分更新
  priority_queue<tuple<int, int, int>> que;
  que.push(make_tuple(-m[sx][sy].cost, sx, sy));
  while (!que.empty())
  {
    auto next = que.top();
    que.pop();
    int c(-get<0>(next)), cx(get<1>(next)), cy(get<2>(next));

    for (int d = 0; d < 4; d++)
    {
      int x = cx + S[d][0];
      int y = cy + S[d][1];
      int cost = c + (num < P[cx][cy] ? 1 : 0);

      if (cost < m[x][y].cost)
      {
        m[x][y].cost = cost;
        auto t = make_tuple(-cost, x, y);
        que.push(t);
      }
    }
  }

  return m[sx][sy].cost;
}

int main() {
  cin >> N;
  for (int i = 1; i <= N * N; i++)
  {
    int pos;
    cin >> pos;
    P[(pos - 1) / N + 1][(pos - 1) % N + 1] = i;
    Q[i] = pos;
  }

  /*cerr << "player" << endl;
  for (int i = 0; i <= N + 1; i++)
  {
    for (int j = 0; j <= N + 1; j++) cerr << " " << P[i][j];
    cerr << endl;
  }*/

  // 初期化
  for (int i = 0; i <= N + 1; i++) for (int j = 0; j <= N + 1; j++)
  {
    m[i][j].cost = max(0, min(min(i - 1, N - i), min(j - 1, N - j)));
    m[i][j].done = false;
  }

  int sum = 0;
  for (int i = 1; i <= N * N; i++)
  {
    int pos = Q[i];
    //int cost = solve(i, (pos - 1) / N + 1, (pos - 1) % N + 1);
    int cost = diff_solve(i, (pos - 1) / N + 1, (pos - 1) % N + 1);

    /*cerr << "cost" << endl;
    for (int i = 1; i <= N; i++)
    {
      for (int j = 1; j <= N; j++) cerr << " " << m[i][j].cost;
      cerr << endl;
    }*/

    sum += cost;
  }

  cout << sum << endl;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;
    cin >> s;
    string ans;
    //std::string str = 文字列;
    //str.substr(開始位置, 取り出す長さ);
    string y = s.substr(0, 4);
    string m = s.substr(5, 2);
    string d = s.substr(8, 2);
    //cout << y<<m<<d<<"\n";

    int yy, mm, dd;
    yy = stoi(y);
    mm = stoi(m);
    dd = stoi(d);
    //cout << yy << mm << dd;
    if(yy==2019){
        if(mm>4){
            ans = "TBD";
        }else{
            ans = "Heisei";
        }
    }else if (yy > 2019)
    {
        ans = "TBD";
    }
    else
    {
        ans = "Heisei";
    }
    

    cout << ans << "\n";

    return 0;
}

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

#define ONE 0x1
#define NINE 0x2
#define SEVEN 0x4
#define FOUR 0x8
#define ALL 0xF

int main(){
  int N;
  int chk = 0;
  for(int i = 0; i < 4; i++){
	cin >> N;
    if(N == 1) chk |= ONE;
    if(N == 9) chk |= NINE;
    if(N == 7) chk |= SEVEN;
    if(N == 4) chk |= FOUR;
  }
//  cout << chk << endl;
  if(chk == ALL){
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;    
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Equation
public class Main{

	boolean[] assign;
	char[] s;
	int idx;
	char get(){
		return s[idx++];
	}
	
	String s1, s2;
	
	boolean f(int k){
		if(k==11){
			s = s1.toCharArray();
			idx = 0;
			boolean f1 = formula();
			s = s2.toCharArray();
			idx = 0;
			return f1==formula();
		}
		assign[k] = false;
		if(!f(k+1))return false;
		assign[k] = true;
		return f(k+1);
	}
	
	boolean formula(){
		char ch = get();
		if(ch=='('){
			boolean f1 = formula();
			ch = get();
			if(ch=='*'){
				boolean f2 = formula();
				get();
				return f1&&f2;
			}
			else if(ch=='+'){
				boolean f2 = formula();
				get();
				return f1||f2;
			}
			else{
				get();
				boolean f2 = formula();
				get();
				return !f1||f2;
			}
		}
		else if(ch=='-'){
			return !formula();
		}
		else if(ch=='T'){
			return true;
		}
		else if(ch=='F'){
			return false;
		}
		else return assign[ch-'a'];
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		assign = new boolean[11];
		for(;;){
			String t = sc.next();
			if("#".equals(t))break;
			String[] tt = t.split("=");
			s1 = tt[0]+"$"; s2 = tt[1]+"$";
			System.out.println(f(0)?"YES":"NO");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	ll a[n],b[n][n];
	rep(i,0,n)rep(j,0,n)b[i][j]=-1;
	rep(i,0,n){
		cin>>a[i];
		rep(j,0,a[i]){
			ll x,y;cin>>x>>y;x--;
			b[i][x]=y;
		}
	}
	ll mx=-1;
	rep(i,0,(1<<n)){
		ll c[n];
		rep(j,0,n)c[j] = bool(i&(1<<j));
		ll ans=0;
		rep(j,0,n)if(c[j])ans++;
		bool ok=1;
		rep(j,0,n){
			if(c[j]){
				rep(k,0,n)if(b[j][k]!=-1)if(b[j][k]!=c[k])ok=0;
			}
		}
		if(ok) mx=max(mx,ans);
	}
	cout<<mx;
	
	return 0;
}



Measured memory_bytes: 256
N=int(input())
cnt=0
ans=0
H=[int(x) for x in input().rstrip().split()]
for i in range(N-1):
  if H[i]>=H[i+1]:
    cnt+=1
  else:
    ans=max(cnt,ans)
    cnt=0
ans=max(cnt,ans)
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fprintf(stderr, "\n"), fflush(stderr)

typedef long long ll;

using namespace std;

const ll inf = static_cast<const ll>(1e18);
const int infi = static_cast<const int>(1e9);

vector<set<int> > G, I;

void solve() {
    int n, m;
    cin >> n >> m;
    G.resize(n);
    I.resize(n);
    vector<int> in_deg(n);
    for (int i = 0; i < n + m - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].insert(b);
        I[b].insert(a);
        in_deg[b]++;
    }
    int root = -1;
    set<pair<int, int> > F;
    for (int i = 0; i < n; i++) {
        F.insert({G[i].size(), i});
        if (in_deg[i] == 0) {
            root = i;
        }
    }
    vector<int> time(n);
    for (int i = 0; i < n; i++) {
        auto f = F.begin()->second;
        F.erase(F.begin());
        time[f] = i;
        for (auto v : I[f]) {
            F.erase({G[v].size(), v});
            G[v].erase(f);
            F.insert({G[v].size(), v});
        }
    }
    for (int i = 0; i < n; i++) {
        int best = -1;
        for (auto v : I[i]) {
            if (best == -1 || time[best] > time[v]) {
                best = v;
            }
        }
        cout << best + 1 << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef SIR
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
};

Measured memory_bytes: 25088
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N;
  while(cin>>N,N!=0){
    vector<int> a(N);
    for (int i=0;i<N;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int ans=INF;
    for (int i=0;i<N-1;i++) {
      ans=min(ans,a[i+1]-a[i]);
    }
    cout<<ans<<endl;
  }
}




Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
	int h, w;

	cin >> h >> w;

	char s[52][52];

	for (int i = 0; i < 52; i++){
		for (int j = 0; j < 52; j++)
			s[i][j] = '.';
	}

	for (int i = 1; i < h+1; i++){
		for (int j = 1; j < w+1; j++)
			cin >> s[i][j];
	}


	for (int i = 1; i < h+1; i++){
		for (int j = 1; j < w+1; j++){
			if (s[i][j] == '#')
				cout << '#';
			else {
				int num = 0;
				for (int a = -1; a < 2; a++){
					for (int b = -1; b < 2; b++){
						if (s[i+a][j+b] == '#')
							num++;
					}
				}
				cout << num;
			}
		}

		cout << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

int main (void)
{
	char a[3];
	int go,na;
	go = 0;
	na = 0;

	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}

	for (int i = 0; i < 3; i++)
	{
		if (a[i] == '5')
		{
			go += 1;
		}
		else if (a[i] == '7')
		{
			na += 1;
		}
	}
	if (go == 2 && na == 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S = input()

alphabets = set(chr(ord('a')+x) for x in range(26))

def F(S,alphabets):
    if len(S) == 0:
        return -1
    T = F(S[1:],alphabets-set([S[0]]))
    if T == -1:
        larger = [x for x in alphabets if x > S[0]]
        if not larger:
            return -1
        return min(larger)
    return S[0] + T

answer = F(S,alphabets)
print(answer)


Measured memory_bytes: 62044
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())

uf = UnionFind(N)
Fr = [set() for _ in range(N)]

for _ in range(M):
  A, B = map(lambda x: int(x)-1, input().split())
  uf.union(A, B)
  Fr[A].add(B)
  Fr[B].add(A)

ans = []

for i in range(N):
  ans.append(uf.size(i) - len(Fr[i]) - 1)

for _ in range(K):
  C, D = map(lambda x: int(x)-1, input().split())
  if uf.same(C, D):
    ans[C] -= 1
    ans[D] -= 1

print(*ans)

Measured memory_bytes: 56004
#include <iostream>
using namespace std;
typedef long long int64;

int main()
{
    int64 x, y, z;
    cin >> x >> y;
    if (y - 2 * x > 0)
        cout << x + (y - 2 * x) / 4 << endl;
    else
        cout << y / 2 << endl;
}


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

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

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

  int n; cin >> n;
  int bucket[101010] = {};
  rep(i, n) {
    int a;
    cin >> a;
    bucket[a-1]++;
  }

  int ans = 0, even = 0;
  rep(i, 101010) {
    if(bucket[i]&1) ans++;
    else if(bucket[i] != 0)even++;
  }
  if(even&1) ans--;
  cout << ans+even << '\n';
  return 0;
}


Measured memory_bytes: 640