akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);

  int N,K;
  cin >> N >> K;
  vector<int> d(K);
  vector<int> person(N,0);
  for(int i=0; i<K; i++){
    cin >> d[i];
    for(int j=0; j<d[i]; j++){
      int p;
      cin >> p;
      p--;
      person[p]++;
    }
  }
  int result=0;
  for(int p : person){
    if(p==0) result++;
  }
  cout << result << endl;

  return 0;
}

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

#define F(I,J,N) for(int I=J;I<N;I++)
int main(){
  int a,b,c,n;
  cin >>n;
  F(i,0,n){
    priority_queue<int> q;
    cin>>a>>b>>c;
    q.push(a);
    q.push(b);
    q.push(c);
    a=q.top();q.pop();
    b=q.top();q.pop();
    c=q.top();q.pop();
    bool f=false;
    if(a*a==(b*b+c*c))f=true;
    if(f) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1208
#include<iostream>

using namespace std;

int main(){
    int a[10][10];
    int n,flg = 0;
    int i,j;
    cin >> n;
    for(i=0;i<9;i++){
        for(j=0;j<9;j++){
            a[i][j] = (i+1)*(j+1);
            if(a[i][j]==n){
                flg = 1;
            }
        }
    }
    if(flg==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {


int a,b,c,d;
cin>>a>>b>>c>>d;
  if((a+b)>(c+d))
  {
    cout<<"Left";
  } 
  
  else if((a+b)==(c+d))
    { 
        cout<<"Balanced";
   }
  
  else {cout<<"Right";}

return 0;}


Measured memory_bytes: 256
#include <stdio.h>

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

        scanf("%d",&n);

        p=0;
        for(i=1;i<=n;i++){
                c=0;
                for(j=1;j<=i;j++){
                        if(i%2==0) break;
                        if(i%j==0) c++;
                }
                if(c==8) p++;
        }

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


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
//#include<bits/stdc++.h>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+10;
void FAST(){ios::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr);}
const ll mod =  998244353;

int n, m, k;
vector<pii > v;
bool cmp(pii a, pii b)
{
    return min(a.se,a.fi+b.se)>min(b.se, b.fi+a.se);
}

string s;
void solve()
{
    cin>>n;
    int ans = 0, sum = 0;
    for(int i = 0; i < n; ++i) {
        cin>>s;
        int cnt = 0, mn = 0;
        for(char c:s) (c=='(')?cnt++:cnt--, mn = min(mn, cnt);
        v.emplace_back(cnt, mn);
        sum += cnt;
    }
    if(sum){
        puts("No"); return ;
    }
    sort(v.begin(), v.end(), cmp);
    for(auto p:v)
    {
        if(ans < -p.se) {
            puts("No");
            return ;
        }
        ans += p.fi;
    }
    puts("Yes");

}

int main()
{
//    init();
//    int _;scanf("%d", &_); while(_--)
    solve();
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b, c;cin >> a >> b >> c;
    cout << max({a+b, a-b, a*b}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

string solve() {
    int n, m;
    cin >> n >> m;
    string ans = string(n, '*');
    bool ok = true;
    for (int i = 0; i < m; ++i) {
        int s;
        char c;
        cin >> s >> c;
        --s;
        if (ans[s] == '*') ans[s] = c;
        if (ans[s] != c) ok = false; // return "-1";
    }
    if (ans[0] == '*') ans[0] = n == 1 ? '0' : '1';
    for (int i = 1; i < n; ++i) {
        if (ans[i] == '*') ans[i] = '0';
    }
    if (!ok || (n >= 2 && ans[0] == '0')) return "-1";
    return ans;
}

int main() {
    int t = 1;
    // cin >> t;
    while (t--) cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <map>
#include <iostream>
using namespace std;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    ll res = 0;
    for(ll i = 1; i <= n; i ++) {
        if(i % 3 != 0 && i % 5 != 0) res += i;
    }
    cout << res << endl;
    return 0;
} 

Measured memory_bytes: 3592
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.Char
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> String -> Int
solve n s = (VU.foldl' mMul 1 cnts) `mSub` 1
  where
  cnts = VU.create $ do
    vec <- VUM.replicate 26 1
    forM_ s $ \c -> do
      let i = ord c - ord 'a'
      VUM.modify vec (+ 1) i
    return vec

mPrime = 10^9 + 7

mAdd :: Int -> Int -> Int
mAdd x y = let w = x + y in if w < mPrime then w else w - mPrime

-- mSub x y = (x - y) `mod` mPrime    -- ok even if x < y
mSub :: Int -> Int -> Int
mSub x y = let w = x - y in if w >= 0 then w else w + mPrime

mMul :: Int -> Int -> Int
mMul x y = (x * y) `mod` mPrime



readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      [bs_s]:remLines2 = remLines1
      s = B.unpack bs_s
  in solve n s

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "4\nabcd\n"
inp2 = "3\nbaa\n"
inp3 = "5\nabcab\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == 15
test2 = tv2 == 5
test3 = tv3 == 17
alltest = test1 && test2 && test3



Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>

using namespace std;
int main(){
	int n;
	int a,b,c,d,where=1;
	int points[105]={0};
	int rank[105];
	vector<int> conti;
	cin>>n;
	for(int i=0;i<n*(n-1)/2;i++){
		cin>>a>>b>>c>>d;
		a--,b--;
		if(c==d){
			points[a]++;
			points[b]++;
		}else if(c>d){
			points[a]+=3;
		}else{
			points[b]+=3;
		}
	}
	for(int i=0;i<n;i++){
		conti.push_back(points[i]);
		//cout<<points[i]<<endl;
	}
	sort(conti.begin(),conti.end());
	reverse(conti.begin(),conti.end());
	int checker=1,cnt;
  for(int i=0;i<n;){
		cnt=0;
		
		for(int j=0;j<n;j++){
			if(points[j]==conti[i]){
				cnt++;
				rank[j]=checker;
			}
		}
		i+=cnt;
		checker+=cnt;
	}
	for(int i=0;i<n;i++){
		cout<<rank[i]<<endl;
	}	
	
}

Measured memory_bytes: 1220
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int n;string s;int r=0,b=0;cin>>n>>s;for(char c:s){if(c=='R')r++;if(c=='B')b++;}cout<<(r>b?"Yes":"No")<<endl;}


Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/abc125/tasks/abc125_b

#include <bits/stdc++.h>

typedef long long ll;

#define MAX 20

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

using namespace std;

int N;
int V[MAX];
int C[MAX];
int ans;

int main() {
    
    cin >> N;

    REP(i, N) {
        cin >> V[i];
    }

    REP(i, N) {
        cin >> C[i];
    }

    REP(i, N) {
        int diff = V[i] - C[i];
        if (diff > 0) {
            ans += diff; 
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bitset>
using namespace std;
int c[999999]={0,1};
int main() {
	bitset<499999> b;
	int i,j,n=3;
	for(i=0;n*n<=999999;i++,n+=2) {
		if(b[i])continue;
		for(j=i+n;j<499999;j+=n)b[j]=1;
	}
	for(i=0,n=3;i<=499998;i++,n+=2) {
		if(!b[i])c[n-1]=c[n]=c[n-2]+1;
		else c[n-1]=c[n]=c[n-2];
	}
	while(scanf("%d",&n)!=EOF) {
		printf("%d\n",c[n-1]);
	}
}

Measured memory_bytes: 4988
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<map>
#include<vector>

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

using namespace std;

typedef long long ll;
int X;

int main(){
  int ans=0;
  int p;
  cin >> X;
  /*i is basis*/
  for(int i=2;i*i<=X;i++){
    for(int k=2;pow(i,k)<=X;k++){
      p=k;
    }
    if(ans<=pow(i,p))ans=pow(i,p);
  }
  if(ans==0){
    cout << 1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    map<int, int> m;
    REP(i, N) {
        cin >> a.at(i);
        m[a[i]]++;
    }

    int ans = 0;
    for (auto a : m) {
        if (a.first <= a.second) {
            ans += a.second - a.first;
        } else {
            ans += a.second;
        }
    }

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


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

long long  mod = 1000000007;
int p[40002],p2[502];
int r[40002],r2[502];

void init(int n){
    for (int i = 0; i < n; ++i) {
        p[i]=i;
        r[i]=0;
    }
}


int find(int x){
	if(x != p[x]){
		p[x] = find(p[x]);
    }
   	return p[x];
}
     
void union_set(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y) return;
	if(r[x] < r[y]){
		p[x] = y;	
	}else{
		p[y] = x;
		if(r[x] == r[y])r[x]++;
	}
	return ;
}

void init2(int n){
    for (int i = 0; i < n; ++i) {
        p2[i]=i;
        r2[i]=0;
    }
}


int find2(int x){
	if(x != p2[x]){
		p2[x] = find2(p2[x]);
    }
   	return p2[x];
}
     
void union_set2(int x,int y){
	x = find2(x);
	y = find2(y);
	if(x==y) return;
	if(r2[x] < r2[y]){
		p2[x] = y;	
	}else{
		p2[y] = x;
		if(r2[x] == r2[y])r2[x]++;
	}
	return ;
}

int main(){
	int n,k;
	cin >> n >> k;
	VI a(k),b(k),c(k);
	rep(i,k){
		cin >> a[i] >> b[i] >> c[i];
		if(b[i]>c[i])swap(b[i],c[i]);
	}
	for(int i=0;i<=k/200;i++){
		init(n+3);
		init2(421);
		set<int> num;
		set<pair<int,int> > st,st2;
		map<int,int>mp;
		for(int j=min(k-1,200*(i+1)-1);j>=200*i;j--){
			num.insert(b[j]);
			num.insert(c[j]);
			if(a[j]==2){
				st2.insert(MP(b[j],c[j]));
			}
			if(a[j]==1){
				if(st2.count(MP(b[j],c[j]))!=0){
					st2.erase(MP(b[j],c[j]));
				}
			}
		}
		for(int j=0;j<min(200*i,k);j++){
			if(a[j]==1){
				if(st2.count(MP(b[j],c[j]))==0){
					st.insert(MP(b[j],c[j]));
				}
			}
			if(a[j]==2){
				if(st2.count(MP(b[j],c[j]))==0){
					st.erase(MP(b[j],c[j]));
				}
			}
		}
		for(auto zz:st){
			union_set(zz.first,zz.second);
		}
		int cnt = 1;	
		for(int j=0;j<n+1;j++){
			if(num.count(j)!=0&&mp.find(find(j))==mp.end()){
				mp[find(j)] = cnt;
				cnt++;
			}
		}
		for(int x=200*i;x<min(200*(i+1),k);x++){
			if(a[x]==3){
				init2(501);
				for(auto zz:st2){
					int xx = mp[find(zz.first)];
					int yy = mp[find(zz.second)];
					union_set2(xx,yy);
				}
				int xx = mp[find(b[x])];
				int yy = mp[find(c[x])];
				if(find2(xx)==find2(yy)){
					cout << "YES" << endl;	
				}else{
					cout << "NO" << endl;
				}	
			}
			if(a[x]==1){
				st2.insert(MP(b[x],c[x]));
			}
			if(a[x]==2){
				st2.erase(MP(b[x],c[x]));
			}
		}		
	}
	return 0;
}

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

int main() {
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    // 円を収める正方形の左上と右下の頂点が矩形に入っているかで判定する
    // アルジェブラすれば、
    // x >= r && x <= W-r && y >= r && y <= H-r
    // になるのか… 内接円の軌跡に(x,y)が含まれていればいいんだね。
    if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 1160
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;

const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6+1);
 
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    read(n);
    int a[10][10] = {}, ans = 0;

    fori(k, 1, n)
    {
        int j = k%10;
        int i = k%10;
        for(int x = k; x > 0; x = x/10) i = x%10;
        a[i][j]++;
    }

    fori(i, 1, 9)
    {
        fori(j, i, 9)
        {
            if(i == j) ans += a[i][j]*a[i][j];
            else ans += 2*a[i][j]*a[j][i];
        }
    }

    cout << ans;

    return 0;
}

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

using namespace std;

const int N = 100005;

int n, r[2];
int a[2][N];
int nxt[2][N];
int res[N];
vector<int> G[2][N];
vector<int> vec[2][N];

void dfs(int t, int u) {
	for (auto v : G[t][u]) {
		dfs(t, v);
		assert(vec[t][v].size() == 1);
		vec[t][u].push_back(vec[t][v][0]);
	}
	while (vec[t][u].size() > 1) {
		int x = vec[t][u].back(); vec[t][u].pop_back();
		int y = vec[t][u].back(); vec[t][u].pop_back();
		nxt[t][x] = y, nxt[t][y] = x;		
	}
	if (!vec[t][u].size()) a[t][u] = 1, vec[t][u].push_back(u);

}

void dfs2(int u) {
	for (int i = 0; i < 2; ++i) {
		int v = nxt[i][u];
		if (v && !res[v]) {
			res[v] = -res[u], dfs2(v);
		} 
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < 2; ++i) {
		for (int j = 1; j <= n; ++j) {
			int x; cin >> x;
			if (x != -1) G[i][x].push_back(j);
			else r[i] = j;
		}
		dfs(i, r[i]);
	}
	for (int i = 1; i <= n; ++i) {
		if (a[0][i] != a[1][i]) {
			cout << "IMPOSSIBLE\n"; return 0;
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (a[0][i] == 0 || a[0][i] == 1 && res[i]) continue; res[i] = 1, dfs2(i);
	}
	cout << "POSSIBLE\n";
	for (int i = 1; i <= n; ++i) cout << res[i] << ' ';
	cout << '\n';
}

Measured memory_bytes: 29824
N = int(input())
A = list(map(int, input().split()))

m = 1000000007

result = 0
for i in range(60):
    j = 1 << i
    c = sum((a & j) >> i for a in A)
    result += (c * (N - c)) << i
    result %= m
print(result)


Measured memory_bytes: 50900
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> pii;
typedef pair<double,double> dop;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;



signed main()
{
int n,m;
std::cin >> n >> m;
//1 -> 2,3->7
std::vector<int> check(10,0);
int cost[10] = {INF,2,5,5,4,5,6,3,7,6};
rep(i,m){
    int temp;
    std::cin >> temp;
    check[temp]++;
}
std::vector<std::vector<int>> dp(n + 1,std::vector<int>(9,-1));
dp[0][0] = 0;
for(int i = 0; i <= n; i++){
    if(cost[1] + i <= n){
        if(check[1] == 1 && dp[i][0] >= 0 && dp[i + cost[1]][0] < dp[i][0] + 1){
            dp[i + cost[1]][0] = dp[i][0] + 1;
        }
    } 
}
for(int j = 1; j < 9; j++){
    for(int i = 0; i <= n; i++){
        if(dp[i][j] < dp[i][j - 1]){
            dp[i][j] = dp[i][j - 1];
        }
        if(check[j + 1] == 1 && cost[j + 1] + i <= n){
           if(dp[i][j] >= 0 && dp[i + cost[j + 1] ][j] < dp[i][j] + 1){
            dp[i + cost[j + 1]][j] = dp[i][j] + 1;
           } 
        }
    }
}
std::vector<int> count(8,0);
std::string out;
int index = n;
int num = 8;
while(index > 0 && num >= 0){
    if(index - cost[num + 1] >= 0){        
        if((check[num + 1] == 1) && (dp[index][num] - 1 == dp[index - cost[num + 1]][num])){
            count[cost[num + 1]]++;
            index -= cost[num + 1];
        } else {
            num--;
        }
    } else {
        num--;
    }
}
for(int i = 9; i > 0; i--){
    if(check[i] != 1){
        continue;
    }
    for(int j = 0; j < count[cost[i]]; j++){
        out += (char)('0' + i);
    }
    count[cost[i]] = 0;
}
std::cout << out << std::endl;
return 0;
}

Measured memory_bytes: 1280
S = input().split()

#冷蔵庫
A = int(S[0])
#電子レンジ
B = int(S[1])
#割引券
M = int(S[2])



a = list(map(int,input().split()))
b = list(map(int,input().split()))
total_mini = min(a) + min(b)


for i in range(M):
    m = list(map(int,input().split()))
    amount = a[m[0]-1] + b[m[1]-1] - m[2]

    if total_mini > amount:
        total_mini = amount


print(total_mini)


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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    cout << ((n == m) ? "Yes\n" : "No\n");
    return 0;
}



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

int main()
{
  i64 n;
  cin >> n;
  vector<i64> v(n);
  for (i64 i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  double ans = (double)(v[0] + v[1]) / 2;
  for (i64 i = 2; i < n; i++)
    ans = (ans + v[i]) / 2;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s=str(input())
n=len(s)
ans=0
x=1
list=[int(s[n-1])]
for i in range(2**(n-1)):
    for j in range(n-1):
        if (i>>j)&1==True:
            x*=10
        else:
            x=1
        list.append((int(s[n-2-j])*x))
    ans+=sum(list)
    x=1
    list=[int(s[n-1])]
print(ans)
            

Measured memory_bytes: 9204
L,R=gets.chomp.split(" ").map(&:to_i)

 if R-L >= 2019
    puts 0
    exit
 end

 ret = 2018
 (L..(R-1)).each do |i|
    ((i+1)..R).each do |j|
        ret = [ret,(i*j)%2019].min
    end 
 end
 puts ret
 

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,vis[500010],depth[500010],low[500010],fa[500010],ans;
vector<int> v[500010];
void dfs(int p,int f){
	fa[p]=f;
	vis[p]=1;
	depth[p]=depth[f]+1;
	low[p]=depth[p];
	for(int i=0;i<v[p].size();i++){
		if(v[p][i]!=f&&!vis[v[p][i]])
			dfs(v[p][i],p);
		if(v[p][i]!=f)
			low[p]=min(low[p],low[v[p][i]]);
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,0);
	for(int i=2;i<=n;i++)
		if(low[i]>=depth[i])
			ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 15284
#include<stdio.h>

int main(void){
	long long H,W,J;
	scanf("%lld",&H);
	scanf("%lld",&W);
	J=H*W;
	if(W==1||H==1)printf("1");
	else if(W%2==0||H%2==0){
		printf("%lld",J/2);
	}else{
		printf("%lld",(J+1)/2);
	}
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> a(n + 1);
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long b; cin >> b;
        ans += min (a[i], b);
        b -= min (b , a[i]);
        ans += min (a[i + 1], b);
        a[i + 1] = max (0ll, a[i + 1] - b);
    }
    cout << ans;
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;
ll f(ll a) {
    ll res[] = {a, 1, a + 1, 0};
    return res[a % 4];
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (a == 0) {
        if (b == 0) {
            cout << 0 << endl;
        } else {
            cout << f(b) << endl;
        }
    } else {
        cout << (f(b) ^ f(a - 1)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll P[10];

int main(){
  char A;
  cin   >> A;
  if(A>96){
    cout << 'a' << endl;
  }
  else{
    cout << 'A' << endl;
  }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+5;
ll tree[N];
void update(int i,ll up)
{
  while(i<N)
  {
    tree[i]=max(tree[i],up);
    i+=(i&-i);
  }
}
ll query(int i)
{
  ll ans=0;
  while(i>0)
  {
    ans=max(tree[i],ans);
    i-=(i&-i);
  }
  return ans;
}
int main()
{
  int n;
  cin>>n;
  ll a[n],b[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++)
    cin>>b[i];
  ll ans=0;
  for(int i=0;i<n;i++)
  {
    ans=max(ans,b[i]+query(a[i]));
    update(a[i],b[i]+query(a[i]));
  }
  cout<<ans<<endl;
 }


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println(mod_sum(Integer.parseInt(scanner.nextLine())));
		scanner.close();
	}
	
	public static long mod_sum(long n) {
		return (long) (n * (n + 1l)) / 2l - n;
	}

}

Measured memory_bytes: 23764
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A)
H = N//2
if N%2==0:
    ans = -2*sum(B[:H-1]) -B[H-1] +B[H] +2*sum(B[H+1:])
    print(ans)
else:
    ans1 = -2*sum(B[:H-1]) -B[H-1] -B[H] +2*sum(B[H+1:])
    ans2 = -2*sum(B[:H]) +B[H] + B[H+1] +2*sum(B[H+2:])
    print(max(ans1, ans2))

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

int main(){
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    
    int t = a / k;
    if (t * k == a || (t + 1) * k <= b) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n;
    cin>>n;
    set<int> a;
    for(int i=0;i<n;i++){
	int k;
	cin>>k;
	a.insert(k);
    }
    if( a.size() == n )cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <stdio.h>
using namespace std;
typedef unsigned long long ull;

int n,p,a[55],cnt[2];

inline ull combo(int x,int y){
    static ull arr[55][55];
    if(y==0||x==y)return 1;
    if(x<y)return 0;
    if(arr[x][y]==0)arr[x][y]=combo(x-1,y)+combo(x-1,y-1);
    return arr[x][y];
}

ull f(int x,int least){
    ull res=0;
    for(int i=least;i<=x;i+=2)res+=combo(x,i);
    return res;
}

int main(){
    scanf("%d %d",&n,&p);
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        cnt[a[i]%2]++;
    }
    if(p==0){
        printf("%llu\n",(1ull<<cnt[0])*f(cnt[1],0));
        return 0;
    }
    if(cnt[1]==0){
        printf("%llu\n",0ull);
        return 0;
    }
    printf("%llu\n",(1ull<<cnt[0])*f(cnt[1],1));
    return 0;
}


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

using namespace std;

int main() {
  int N,D; cin>>N>>D;
  vector<vector<int> > X(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
  //X[i]とX[j]で調べる
    int sum = 0;
    for (int a = 0; a < D; a++) {
      sum += (X[i][a] - X[j][a]) * (X[i][a] - X[j][a]);
    }
    double rt = sqrt(sum);
    int fl = (int)floor(rt);
    int cl = (int)ceil(rt);
    if (fl*fl == sum || cl*cl == sum) cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

int main(){
   int W,n,i,z,*num;
   int a[30],b[30];
   char s;
   cin>>W>>n;
   
   num = new int[W];
   for(i=0;i<W;i++) num[i] = i+1;
   
   for(i=0;i<n;i++){
      cin>>a[i]>>s>>b[i];
   }
   for(i=0;i<n;i++){
      z = num[a[i]-1];
      num[a[i]-1] = num[b[i]-1];
      num[b[i]-1] = z;
   }
   for(i=0;i<W;i++){
      printf("%d\n",num[i]);
   }
   delete[] num;
   return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int s[M], c[M];
    for (int i = 0; i < M; i++) {
        cin >> s[i] >> c[i];
    }

    if (N == 1) {
        bool ok = true;
        for (int i = 1; i < M; i++) {
            if (c[i] != c[i-1]) ok = false; 
        }
        if (ok) cout << c[0] << endl;
        else cout << -1 << endl;
    }

    else if (N == 2) {
        for (int i = 10; i < 100; i++) {
            bool ok = true;
            for (int j = 0; j < M; j++) {
                if (s[j] == 1) {
                    if (i / 10 != c[j]) ok = false;
                }
                else if (s[j] == 2) {
                    if (i % 10 != c[j]) ok = false;
                }
            }
            if (ok) {
                cout << i << endl;
                break;
            }
            if (i == 99) cout << -1 << endl;
        }
    }

    else if (N == 3) {
        for (int i = 100; i < 1000; i++) {
            bool ok = true;
            for (int j = 0; j < M; j++) {
                if (s[j] == 1) {
                    if (i / 100 != c[j]) ok = false;
                }
                else if (s[j] == 3) {
                    if (i % 10 != c[j]) ok = false;
                }

                else if (s[j] == 2) {
                    if ((i / 10) % 10 != c[j]) ok = false;
                }
            }
            if (ok) {
                cout << i << endl;
                break;
            }
            if (i == 999) cout << -1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Bs = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    Bs[a].append(b)
    Bs[b].append(a)
import heapq
import copy

st = []
ap = [{1: True}]
heapq.heappush(st, (1, 0))
c = 0
while len(st) > 0:
    (node, log) = heapq.heappop(st)
    for b in Bs[node]:
        if b in ap[log]:
            continue
        elif len(ap[log]) == N - 1:
            c += 1
        else:
            heapq.heappush(st, (b, len(ap)))
            newlog = copy.copy(ap[log])
            newlog[b] = True
            ap.append(newlog)
print(c)

Measured memory_bytes: 63960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000005,p=1000000007,inv3=(p+1)/3;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,ans,inv[N];
int main(){
	n=read();ans=0;
	int t=1;inv[1]=1;
	for (int i=2;i<=n;i++) inv[i]=(ll)inv[p%i]*(p-p/i)%p;
	for (int i=1;i<=n;i++){
		t=(ll)t*inv3%p;
		ans=(ans+(ll)t*inv[n-i+1])%p;
	}
	ans=(ll)ans*qpow(n,p-2)%p;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice,Bob = 0,0
for i in range(N):
  if i%2 == 0:
    Alice += a[i]
  else:
    Bob +=a[i]
print(Alice - Bob)

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


void solve(){
  long long int r, d, x[11]; cin >> r >> d >> x[0];
  for(int i = 1; i <= 10; i++){
    x[i] = r * x[i - 1] - d;
    cout << x[i] << endl;
  }
  return;
}

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


Measured memory_bytes: 256
DBG = !true
n,k = gets.split.map{|x| x.to_i}
a = gets.split.map{|x| x.to_i}
s = []
for i in 0...n
  sum = 0
  for j in i...n
    sum += a[j]
    s << sum
  end
end

if DBG
  printf("n:%d k:%d\n", n, k)
  puts "s ---"
  print s
  puts ""
end

prod = 0
while true
  puts "in while loop" if DBG

  40.downto(0) { |i|
    c = []
    for x in s
      c << x if (1 << i) & x != 0
    end
    if c.size >= k
      prod |= (1 << i)
      s = c
      if DBG
        printf("bit on, i:%d post s:\n", i)
        print s
        puts ""
      end
    end
  }
  print prod
  exit
end


Measured memory_bytes: 12216
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <map>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	int vsum=0, csum=0;
	int v, c, cnt;
	for(cnt=0; scanf("%d,%d", &v, &c) != EOF; ++cnt){
		vsum += v*c;
		csum += c;
	}

	printf("%d\n%d\n", vsum, (int)((double)csum/cnt+0.5));

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int[][] a = new int[3][3];
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                a[i][j] = Integer.parseInt(sc.next());
            }
        }
        boolean[][] ok = new boolean[3][3];
        int n = Integer.parseInt(sc.next());
        for(int i = 0; i < n; i++){
            int b = Integer.parseInt(sc.next());
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 3; k++){
                    if(a[j][k] == b){
                        ok[j][k] = true;
                    }
                }
            }
        }
        boolean yes = false;
        for(int i = 0; i < 3; i++){
            if(ok[i][0] && ok[i][1] && ok[i][2]){
                yes = true;
            }
            if(ok[0][i] && ok[1][i] && ok[2][i]){
                yes = true;
            }
        }
        if(ok[0][0] && ok[1][1] && ok[2][2]){
            yes = true;
        }
        if(ok[0][2] && ok[1][1] && ok[2][0]){
            yes = true;
        }
        if(yes){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

template <typename T>
int partition(vector<T> &a, int left, int right){// right基準で　[left, right)を分割してrightの入れるindexを返す
  T x = a[right];
  int part = left;//partitionの位置
  for(int i=left; i<right; i++){//基準x以外の数字をpartitionの左か右かを検討する
    if(a[i] <= x){// 基準x以下の数字なら，
      swap(a[part], a[i]);//partitionの位置の数字と交換して
      part++;//partitionを1つ右にずらす
    }
  }
  swap(a[part], a[right]);//最後に基準xをpartitionの位置に入れるためにpartitionの位置の数字と交換
  return part;

}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];

  int part = partition(a, 0, n-1);
  for(int i=0; i<n; i++){
    if(i == part)cout << "[" << a[part] << "] ";
    else if(i==n-1) cout << a[i] << endl;
    else cout << a[i] << " ";
  }

  return 0;  
}





Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a;
  string s[a];
  int c[a]={};
  cin>>s[0];
  c[0]++;
  for(int i=1;i<a;i++){
    cin>>s[i];
    for(int j=0;j<i;j++){
      if(s[i]==s[j]){
        c[j]++;
        break;
      }else if(j==i-1&&s[i]!=s[j]){
        c[i]++;
      }
    }
  }
  cin>>b;
  string d;
  for(int i=0;i<b;i++){
    cin>>d;
    for(int j=0;j<a;j++){
      if(d==s[j]){
        c[j]--;
        break;
      }
    }
  }
  int m=0;
  for(int i=0;i<a;i++){
    m=max(m,c[i]);
  }
  cout<<m;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li x;
    cin >> x;
    li res = (x / 500) * 1000;
    x = x % 500;
    res += (x / 5) * 5;
    cout << res << endl;

    return 0;
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

vector<char> boin = {'a','i','u','e','o'};
vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

ll gcd(ll a,ll b){
  if(a < b){
    ll temp = a+b;
    a = temp - a;
    b = temp - b;
  }
  ll c = 1ll;
  if(b == 0)return a;
  while(c != 0){
    c = a%b;
    if(c == 0)return b;
    a = b;
    b = c;
  }
}

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> a(N);
    vector<ll> b;
    bool judge = true;
    Rep(i,N){
        cin >> a[i];
    }
    sort(All(a));
    a.erase(unique(All(a)),a.end());
    Rep(i,a.size()){
        b.push_back(a[i]/2ll);
        //cout << b[i] << endl;
    }
    ll l = b[0];
    ll min_ans = b[0];
    Rep(i,a.size()-1){
        if(b[i+1]/gcd(b[i+1],l) % 2 == 0){
            judge = false;
            break;
        }
        else if(l/gcd(b[i+1],l) % 2 == 0){
            judge = false;
            break;
        }
        l *= b[i+1]/gcd(b[i+1],l);
    }
    Rep(i,b.size()){
        if(l%b[i] != 0 || (l/b[i])%2 == 0){
            judge = false;
            break;
        }
    }
    if(judge){
        ll ans = (M+l)/(2ll*l);
        cout << ans;
    }else{
        cout << 0;
    }
    //cin >> N;
}

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

int main(){
    string S;
    cin >> S;
    int N = S.size() + 1;
    vector<ll> a(N, -1);
    if(S[0] == '<') a[0] = 0;
    rep(i, 1, N - 1){
        if(S[i-1] == '>' && S[i] == '<'){
            a[i] = 0;
        }
    }
    if(S[N-2] == '>') a[N-1] = 0;

    ll ans = 0;
    rep(i, 0, N-1){
        if(S[i] == '<'){
            a[i+1] = a[i] + 1;
        }
    }
    rrep(i, 0, N - 1){
        if(S[i] == '>') a[i] = max(a[i+1] + 1, a[i]);
    }
    rep(i, 0, N) ans += a[i];
    cout << ans << endl;

    /* rep(i, 0, N) cout << a[i] << " ";
    cout << endl; */
}

Measured memory_bytes: 4740
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n,k,r,s,p;
    scanf("%d%d",&n,&k);
    scanf("%d%d%d",&r,&s,&p);
    char c;
    vector<char> ch(n);
    c=getchar();
    forn(i,n)
    {
        ch[i]=getchar();
    }
    int res=0;
    forn(i,n)
    {
        if(i<k||ch[i]!=ch[i-k])
        {
            if(ch[i]=='r')res+=p;
            else if(ch[i]=='s')res+=r;
            else res+=s;
        }
        else
        {
            ch[i]='n';
        }
    }
    printf("%d\n",res);
    return 0;
}

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

int main() {
  string S; cin >>S;
  int A=S.size();
  int sa;
  for(int i=0;i+2<A;i++)
  {
    string str2 = S.substr(i,3);
    int B=stoi(str2);
    int sa2;
    if(753>=B)sa2=753-B;
    else sa2=B-753;
    
    if(i==0)sa=sa2;
    else 
    {
      sa=min(sa,sa2);
    }
  }
  cout <<sa;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗, int 2*10^9

int main() {
  ll A, B;
  ci(A, B);
  co(A * B / __gcd(A, B));
}

Measured memory_bytes: 256
/*input
chokudai
chokudaiz
*/
#include <bits/stdc++.h>
#define int long long
#define len(x) x.size()
#define rep(i,a) for(int i=0;i<a;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

signed main(){
	string a, b;
	cin >> a >> b;
	for(int i = 0; i < len(a); i++){
		if(a[i] != b[i]) {
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


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

int main(){
    int n,a;
    cin >> n >> a;
    int q = n/500;
    int tmp = n-500*q;
    if(a>=n){
        cout << "Yes\n";
    }else{
        if(tmp<=a){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
}

Measured memory_bytes: 256