akhauriyash/Code-Regression huggingface dataset:
import collections
n = int(input())
a = list(map(int, input().split()))

counter = collections.Counter(a)
count = 0
for k, v in counter.items():
    if v >= 2:
        count += v-1
if count % 2 == 0:
    print(n-count)
else:
    print(n-count - 1)


Measured memory_bytes: 18656
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main() {
	long long n, k, tmp;
	cin >> n >> k;

	n = n % k;
	tmp = abs(n - k);
	if (n > tmp) n = tmp;

	cout << n << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

int main() {
  ll L,R; cin >>L >>R;
  ll ans=pow(10,9);
  for (ll i=L;i<R;i++) {
    for (ll j=i+1;j<=R;j++) {
      ll a=(i*j)%2019;
      if (a==0) {
        cout <<0 <<endl;
        return 0;
      }
      ans=min(ans,a);
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3632
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll A,B;
	cin >> A>>B;
	
	// 解法
	ll ans = A+B;
	ans = max(ans, A-B);
	ans = max(ans, A*B);
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	t := make([]byte, 0)
	for _, c := range []byte(s) {
		switch c {
		case '0', '1':
			t = append(t, c)
		default:
			if len(t) > 0 {
				t = t[:len(t)-1]
			}
		}
	}
	fmt.Println(string(t))
}


Measured memory_bytes: 1768
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
char a[10005];
int d,len;
ll dp[10005][105][3];

ll solve(int idx,int sum,int pre){

    if(idx == len){
        if(sum == 0) return dp[idx][sum][pre] = 1;
        return dp[idx][sum][pre] = 0;
    }
    if(dp[idx][sum][pre] != -1) return dp[idx][sum][pre];

    ll ret = 0;
    if(idx == 0 || pre == 1){
    for(int i = 0;i <= (a[idx]-'0'); i++){
        if(i == a[idx]-'0')
        ret += solve(idx+1,(sum + i)%d, 1);
        else
        ret += solve(idx+1,(sum+i)%d,0);
        if(ret >= mod) ret -= mod;
        }
    }
    else{
        for(int i=0;i < 10; i++){
        ret += solve(idx+1,(sum + i)%d, pre);
        if(ret >= mod) ret -= mod;
        }
    }
    return dp[idx][sum][pre] = ret;
}

int main()
{
    cin>>a>>d;
    len = strlen(a);
    memset(dp,-1,sizeof(dp));
    cout<<(((solve(0,0,0)-1) + mod)%mod)%mod;

    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
 int a ; 
 cin >> a ;
  
 cout << a + a*a + a*a*a ;


}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool prime(ll n){
	if(n == 1) return 0;
	else if(n == 2) return 1;
	for(ll i = 2; i <= (ll)sqrt(n) + 1; ++i){
		if(!(n % i)) return 0;
	}
	return 1;
}
int main(){
	ll pri[114514] = {};
	ll dp[114514] = {};
	for(ll i = 1; i < 114514; ++i) pri[i] = prime(i); 
	for(ll i = 0; i < 114514 - 1; ++i) dp[i + 1] = dp[i] + (pri[i + 1] && pri[(i + 2) / 2]);
	ll q; cin >> q;
	for(ll i = 0; i < q; ++i){
		ll l, r; cin >> l >> r;
		cout << dp[r] - dp[l - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <cstdlib>


using namespace std;

int main() {
    

    int a,b;
    a = 1;
    b = 1;
    while (true){
        cin >> a >> b;
        if (a == 0 and b == 0){
            break;
        }
        if (a > b){
            cout << b << " " << a << endl;
        }else{
            cout << a << " " << b << endl;
        }
    }


}



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

#define f first
#define s second

typedef long long ll;

int n;
ll ans;

pair<int,int> x[200010];
multiset<int> b,r;

void work()
{
	sort(x+1,x+n+1);
    for(int i=1;i<=n;i++)
    {
        b.erase(b.find(x[i].f)),r.insert(x[i].f);
        r.erase(r.find(x[i].s)),b.insert(x[i].s);
        ans=min(ans,1ll*(*b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin()));
    }
    printf("%lld",ans);
}

void init()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i].f,&x[i].s);
		if(x[i].f>x[i].s) swap(x[i].f,x[i].s);
		b.insert(x[i].f),r.insert(x[i].s);
	}
	ans=1ll*(*b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin());
}

int main()
{
    init();
    work();
    return 0;
}

Measured memory_bytes: 20608
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  string s;
  int t;
  cin>>s>>t;
  int n=s.size();
  for(char &c:s){
    if(c=='a') continue;
    if('z'+1-c>t) continue;
    t-='z'+1-c;
    c='a';
  }
  rep(i,t%26){
    if(++s[s.size()-1]>'z') s[s.size()-1]='a';
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define INF 10000000000
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;

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

    while(cin >> a >> b >> n){
        cout << b / n - (a + n - 1) / n + 1 << endl;
    }
}



Measured memory_bytes: 256
//
// Created by yamunaku on 2019/10/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll ans=0;
    rep(i,n){
        rep(j,i){
            ans += max(0, (int)(lower_bound(all(a),a[i]+a[j]) - a.begin()-1-i));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $a[] = 0;
  $total = abs($a[0]);
  for($i=0; $i<$n; $i++){
      $dis = abs($a[$i+1]-$a[$i]);
      $total += $dis;
  }
//   echo $total;
  
  for($i=0; $i<$n; $i++){
      if($i==0){
          $ans = $total+abs(0-$a[$i+1])-(abs(0-$a[$i])+abs($a[$i]-$a[$i+1]));
      }else{
          $ans = $total+abs($a[$i-1]-$a[$i+1])-(abs($a[$i-1]-$a[$i])+abs($a[$i]-$a[$i+1]));
      }
      echo $ans."\n";
  }
  
  

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

int main(){
    int N; cin >> N;
    vector<int> A(N+2);
    A[0] = 0, A[N+1] = 0;
    int sum = 0;
    for(int i = 1; i <= N; i++) cin >> A[i]; 
    for(int i = 1; i <= N + 1; i++){
        sum += abs(A[i] - A[i-1]);
    }

    for(int i = 1; i <= N; i++){
        //cout << abs(A[i] - A[i-1]) << " " <<  abs(A[i] - A[i+1]) << " " <<  abs(A[i-1] - A[i+1]) << endl;
        cout << sum - abs(A[i] - A[i-1]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1]) << endl; 
    }
    
}

Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
using ll = long long;

ll n, m;

// c を 2s 個使って，S に変換した後，n + s 個の Scc が作れるか判定
bool check(ll s) {
    return 2 * (n + s) <= m - 2 * s;
}

ll binary_search(ll ok, ll ng) {
    assert(check(ok) == true);
    assert(check(ng) == false);
    while (abs(ng - ok) > 1) {
        ll mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    return ok;
}

int main() {
    cin >> n >> m;
    ll ok = 0;
    ll ng = m / 2;
    if (!check(0)) {
        cout << m / 2 << endl;
    } else {
        cout << n + binary_search(ok, ng) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
taro = 0
hana = 0
for i in range(n):
    list1 = list(map(str, input().split()))
    if list1[0] == list1[1]:
        taro += 1
        hana += 1
    elif list1 == sorted(list1):
        hana += 3
    else:
        taro += 3
print(str(taro) + " " + str (hana))


Measured memory_bytes: 5592
#include <iostream>

using namespace std;

int main(void)
{
  int N;
  int n[250], d[250];
  int x[250], y[250];

  while(1){
  cin >> N;
  if(N == 0) break;
  for(int i = 1; i < N; i++){
    cin >> n[i];
    cin >> d[i];
  }

  x[0] = y[0] = 0;
  for(int i = 1; i < N; i++){
    switch(d[i]){
    case 0:
      x[i] = x[n[i]] - 1;
      y[i] = y[n[i]];
      break;
    case 1:
      x[i] = x[n[i]];
      y[i] = y[n[i]] - 1;
      break;
    case 2:
      x[i] = x[n[i]] + 1;
      y[i] = y[n[i]];
      break;
    case 3:
      x[i] = x[n[i]];
      y[i] = y[n[i]] + 1;
      break;
    }
  }

    int minX = 100000, minY = 100000;
    int maxX = -100000, maxY = -100000;
    for(int i = 0; i < N; i++){
      if(minX > x[i]) minX = x[i];
      if(minY > y[i]) minY = y[i];
      if(maxX < x[i]) maxX = x[i];
      if(maxY < y[i]) maxY = y[i];
    }
    cout << maxX - minX +1 << " " << maxY - minY +1<< endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int a[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    rep(i,1,n)cin>>a[i];
    int q;cin>>q;while(q--){
        int k;cin>>k;
        int l=1,r=n;
        while(l<=r){
            int mid=l+r>>1;
            if(a[mid]>=k)r=mid-1;
            else l=mid+1;
        }
        cout<<(a[l]==k)<<endl;
    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;

	const int n = s.size();
	bool ok = false;
	rep(i,n-1) if(s.substr(i,2)=="AC") ok = true;

	if(ok)
		puts("Yes");
	else
		puts("No");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int a[3];
    for(int i = 0 ; i < 3 ; i++)
        cin >> a[i];
    
    sort(a , a+3);

    if(a[1] == a[2])
    {
        if(a[0] != a[1] && a[0] != a[2])cout << "Yes\n";
        else cout << "No\n";
    }
    else if(a[0] == a[1])
    {
        if(a[0] != a[2] && a[2] != a[1])cout << "Yes\n";
        else cout << "No\n";
    }
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>
#include <string>

int main()
{
    int32_t a,b;
    std::cin >> a >> b;

    if ( a < b ) {
        std::string c(b, (char)(a + 0x30));
        std::cout << c << std::endl;
    } else {
        std::string c(a, (char)(b + 0x30));
        std::cout << c << std::endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = (1'000'000'000 + 7);

bool is_ok(string s)
{
    int n = s.size();
    rep(i, n / 2)
    {
        if (s[i] != s[n - 1 - i])
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    cerr << s << endl;
    cerr << s.substr(0, (n - 1) / 2) << endl;
    cerr << s.substr((n + 1) / 2, n - (n + 1) / 2 + 1) << endl;
    if (is_ok(s) && is_ok(s.substr(0, (n - 1) / 2))

        && is_ok(s.substr((n + 1) / 2, n - (n + 1) / 2 + 1)))

    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e5+10;
uli a[mx];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",a+i);
  }
  sort(a,a+n,greater<uli>());
  uli x=0,y=0;
  for(int i=0;i<n && y==0;){
    uli v=a[i];
    int c=0;
    while(i<n && a[i]==v)i++,c++;
    if(c>=2){
      if(x==0){
        x=v;
        c-=2;
        if(c>=2)y=v;        
      }
      else y=v;
    }
  }
  printf("%lld\n",x*y);
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
s = [list(input()) for i in range(N)]
for i in range(N):
    s[i].sort()
s = [''.join(s[i]) for i in range(N)]

import collections
cnt = collections.Counter(s)

ans = 0
for n in cnt.values():
    if n != 1:
        k = n * (n-1) // 2
        ans += k 

print(ans)

Measured memory_bytes: 31440
from sys import stdin
import itertools
import numpy as np

#Aの行列作って平坦化
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = list(itertools.chain.from_iterable([A1,A2,A3]))

N = int(stdin.readline().rstrip())
b = [int(stdin.readline().rstrip()) for _ in range(N)]

#bに含まれている要素を0に
for i in range(len(A)):
  if A[i] in b:
    A[i] = 0

#3x3に戻す
A = np.reshape(A, (3,3))

#行でビンゴ
for raw in range(3):
  if A[raw][0] == 0 and A[raw][1] == 0 and A[raw][2] == 0:
    print("Yes")
    exit()
#列でビンゴ
for col in range(3):
  if A[0][col] == 0 and A[1][col] == 0 and A[2][col] == 0:
    print("Yes")
    exit()
#↘︎のびんご
if A[0][0] == 0 and A[1][1]==0 and A[2][2] ==0:
  print("Yes")
  exit()
#↙︎のビンゴ
if A[0][2]==0 and A[1][1]==0 and A[2][0] ==0:
  print("Yes")
  exit()

print("No")

Measured memory_bytes: 14460
#15dpro
n=int(input())
s=''
#print(n)
for i in range(1,n+1):
 #   print(i)
    if i%3==0:
        s+=' '+str(i)
    else:
        x=i
  #      print(x)
        while x>0 and x%10!=3:
      #      print(x)
            x//=10
        if x%10==3:
            s+=' '+str(i)
print(s)

Measured memory_bytes: 7672
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=1000;
const int MOD=1000000007;

int n;
bool isp[MAXN+1];

int calc(int n,int p) {
	int ret=0;
	while(n>=p) ret+=n/p,n/=p;
	return ret;
}

void run() {
	scanf("%d",&n);
	REPE(i,n) isp[i]=true; isp[0]=isp[1]=false; REPE(i,n) if(isp[i]) for(int j=2*i;j<=n;j+=i) isp[j]=false;
	int ret=1;
	REPE(i,n) if(isp[i]) ret=(ll)ret*(calc(n,i)+1)%MOD;
	printf("%d\n",ret);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

using vd=vector<double>;
using data=tuple<double,int,int>;

double hypot3(double x,double y,double z){
	return sqrt(x*x+y*y+z*z);
}
double dist(vd a, vd b){
	auto d=hypot3(a[0]-b[0],a[1]-b[1],a[2]-b[2]);
	return max(d-a[3]-b[3],0.0);
}

struct UnionFind{
	int n; vi par;
	UnionFind(int N){n=N; par.resize(n); iota(all(par),0);}
	int root(int a){return par[a]=par[a]==a?a:root(par[a]);}
	bool same(int a, int b){return root(a)==root(b);}
	void unite(int a, int b){a=root(a),b=root(b);if(a!=b) par[a]=b;}
};

int main(){
	int n;
	while(cin>>n,n){
		vector<vd> cell(n,vd(4));
		vector<data> edge;
		rep(i,n) {
			rep(j,4) cin>>cell[i][j];
			rep(j,i) edge.emplace_back(dist(cell[i],cell[j]),i,j);
		}
		sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});

		UnionFind uf(n);
		double ans=0;
		for(auto e:edge){
			double d; int a,b;
			tie(d,a,b)=e;
			if(!uf.same(a,b)){
				ans+=d;
				uf.unite(a,b);
			}
		}
		cout.precision(3);
		cout<<fixed<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3376
def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)


main()


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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector <string> s(n);
  for(int i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector <int> x = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  vector <int> y = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
  vector <int> z = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

  map <char, int> mp;
  for(int i = 0; i < n; i++) {
    mp[s[i][0]]++;
  }

  vector <char> march = {'M', 'A', 'R', 'C', 'H'};
  long long ans = 0;

  for(int i = 0; i < 10; i++) {
    int tmp1, tmp2, tmp3;
    tmp1 = mp[march[x[i]]];
    tmp2 = mp[march[y[i]]];
    tmp3 = mp[march[z[i]]];
    ans += (long long)tmp1 * tmp2 * tmp3;
  }

  cout << ans << endl;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;
struct PH{
  template<class T, class U>
  size_t operator()(const pair<T,U>& x) const{
	return hash<T>()(x.first) ^ hash<U>()(x.second);
  }
};

const int MAX = 1e6;
int N, M;
struct Edge{
  int to;
  int cost;

  Edge(int t, int c): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
using Graph = vector<vector<Edge>>;

int sz = 0;
void add_edge(Graph& graph, map<PII,int>& idx, int u, int v, int t){
  if(!idx.count(MP(u,t)))
	idx[MP(u,t)] = sz++;
  if(!idx.count(MP(v,t)))
	idx[MP(v,t)] = sz++;
  int i = idx[MP(u,t)], j = idx[MP(v,t)];
  graph[i].emplace_back(j, 0);
  graph[j].emplace_back(i, 0);
}


void Dijkstra(Graph& edges, VI& d, int s){
  using Type = PII;
  priority_queue<Type, vector<Type>, greater<Type> > pq;
  fill(begin(d), end(d), INF);
  d[s] = 0;
  pq.push(MP(0,s));

  while(!pq.empty()){
	Type pii = pq.top(); pq.pop();
	int v = pii.SS;
	if(d[v] < pii.first) continue;
	for(uint i=0;i<edges[v].size();++i){
	  const Edge& e = edges[v][i];
	  int nc = pii.first + e.cost;
	  if(d[e.to] > nc){
		d[e.to] = nc;
		pq.push(MP(nc,e.to));
	  }
	}
  }
}

int main(){
  scanf("%d%d", &N, &M);
  unordered_set<PII,PH> s;
  Graph G(MAX);
  map<PII,int> idx;
  REP(i,M){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	--a; --b;
	add_edge(G, idx, a, b, c);
  }
  REP(i,N)
	idx[MP(i,-1)] = sz++;
  for(auto&& p: idx){
	if(p.FF.SS == -1) continue;
	int j = idx[MP(p.FF.FF,-1)];
	G[p.SS].emplace_back(j, 0);
	G[j].emplace_back(p.SS, 1);
  }

  VI dist(MAX);
  Dijkstra(G, dist, idx[MP(0,-1)]);
  int ans = INF;
  for(auto&& p: idx)
	if(p.FF.FF == N-1 && p.FF.SS != -1)
	  ans = min(ans, dist[p.SS]);
  printf("%d\n", ans==INF?-1:ans);

  return 0;
}


Measured memory_bytes: 78072
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long a, b, c;
	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << "0\n";
	} else {
		long long ab = a * b * (c - c / 2) - a * b * (c / 2);
		long long bc = b * c * (a - a / 2) - b * c * (a / 2);
		long long ac = a * c * (b - b / 2) - a * c * (b / 2);
		cout << min(min(ab, bc), ac) << "\n";
	}

	return 0;

}

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

int main(){
   string s;    cin >> s;
   int n = 3, op=0;
   
   for(int i=0; i<(1<<n); i++){
       ll tmp = s.at(0)-'0';
       for(int j=0; j<n; j++){
           if(i&(1<<j)) tmp += s.at(j+1)-'0';
           else tmp -= s.at(j+1)-'0';
       }
       if(tmp==7){
           op = i; break;
       }
   }
    for(int k=0; k<=n; k++){
        cout << s.at(k);
        if(k==n)    cout << "=7" << endl; 
        else if(op&1<<k) cout << '+';
        else cout << '-';
    }

}

Measured memory_bytes: 256
//半分全列挙
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == 5 && b == 7 && c == 5) printf("YES\n");
	else if(a == 5 && b == 5 && c == 7) printf("YES\n");
	else if(a == 7 && b == 5 && c == 5) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int x[] = new int[n];
		int y[] = new int[n];
		int h[] = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = scanner.nextInt();
			y[i] = scanner.nextInt();
			h[i] = scanner.nextInt();

		}

		List<Integer> cx = new ArrayList<>();
		List<Integer> cy = new ArrayList<>();
		List<Integer> H = new ArrayList<>();
		int ind = -1;
		for (int d = 0; d < n; d++) {
			if (h[d] != 0) {
				ind = d;
				break;
			}
		}
		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100; j++) {
				int k = h[ind] + Math.abs(x[ind] - i) + Math.abs(y[ind] - j);
				cx.add(i);
				cy.add(j);
				H.add(k);
			}
		}

		for (int j = 0; j < cx.size(); j++) {
			boolean b = true;
			int Cx = cx.get(j);
			int Cy = cy.get(j);
			int Ha = H.get(j);
			for (int i = 0; i < n; i++) {
				/*if (h[i] == 0) {
					continue;
				}*/
				if (h[i] == Math.max(Ha - Math.abs(x[i] - Cx) - Math.abs(y[i] - Cy),0)) {
					continue;
				} else {
					b = false;
					break;
				}
			}
			if (b) {
				System.out.println(Cx + " " + Cy + " " + Ha);
				return;
			}
		}

	}
}


Measured memory_bytes: 23892
#include<stdio.h>


#include<string.h>
int main()
{
    long long int ch[1000];
    char arr[1000];
    long long  int a,b,c,d,e=0,i=0,tep=0,temp=0,j=0,k=0,l=0,m=0,n=0;
    arr[0]=0;
    ch[0]=0;
    scanf("%lld",&a);
    if(a%10==2 || a%10==4 || a%10==5 || a%10==7 || a%10==9)
        printf("hon\n");
    if(a%10==0 || a%10==1 || a%10==6 || a%10==8)
        printf("pon\n");
    if(a%10==3)
        printf("bon\n");


    return 0;
}

Measured memory_bytes: 1620
/*
 * @Author: Kaizyn
 * @Date: 2020-08-29 20:45:48
 * @LastEditTime: 2020-08-29 20:52:04
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 1e6+7;

int n;
int a[N], cnt[N];

inline void solve() {
  cin >> n;
  int g = 0, f = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    g = __gcd(a[i], g);
    ++cnt[a[i]];
  }
  for (int i = 2; i < 1000000; ++i) {
    int sum = 0;
    for (int j = i; j <= 1000000; j += i) sum += cnt[j];
    if (sum > 1) f = 0;
  }
  if (f && g == 1) cout << "pairwise coprime" << endl;
  else if (!f && g == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

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

#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second

using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;

template <typename A, typename B>
inline void chmin(A& a, B b) {
    if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A& a, B b) {
    if (a < b) a = b;
}

template <class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>& p) {
    ost << "{" << p.first << "," << p.second << "}";
    return ost;
}

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

inline int topbit(unsigned long long x) {
    return x ? 63 - __builtin_clzll(x) : -1;
}

inline int popcount(unsigned long long x) {
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x) {
    return __builtin_parity(x);
}

const int INF = 1001001001;

signed main() {
    int H, W;
    cin >> H >> W;

    vint dp(W, 0);
    set<int> idx;
    multiset<int> val;
    rep(i, W) {
        idx.insert(i);
        val.insert(0);
    }

    rep(i, H) {
        int a, b;
        cin >> a >> b;
        a--;
        int mi = INF;
        while (true) {
            auto it = idx.lower_bound(a);
            if (it == idx.end() || *it >= b) break;
            int k = *it;
            idx.erase(it);
            chmin(mi, b - k + dp[k]);
            val.erase(val.find(dp[k]));
            dp[k] = INF;
        }
        if (b < W && mi != INF) {
            if (idx.find(b) != idx.end()) {
                val.erase(val.find(dp[b]));
            }
            chmin(dp[b], mi);
            val.insert(dp[b]);
            idx.insert(b);
        }
        if (val.size() == 0)
            puts("-1");
        else
            printf("%lld\n", *val.begin() + i + 1);
    }
    return 0;
}

Measured memory_bytes: 23516
#include<bits/stdc++.h>
using namespace std;
int N;
int M[100],D[100],V[100],S[100];
int fi[100],se[100];



int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>M[i]>>D[i]>>V[i]>>S[i];
    fi[i]=(M[i]-1)*30+(D[i]-1);
    se[i]=(fi[i]+V[i])%360;
  }
  int ans=1e9;
  for(int x=0;x<360;x++){
    int val=0;
    for(int j=0;j<N;j++){
      int tmp = -1;
      if( (fi[j]<=x&&x<se[j]) || (fi[j]>=se[j]&&(fi[j]<=x || x<se[j])) ){
        tmp=S[j];
      }else{
        int a=(x-se[j]+1+360)%360;
        int b=(fi[j]-x+360)%360;
        tmp=S[j]-min(a,b);
      }

      val=max(val,tmp);
    }
    ans=min(ans,val);
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main() {
    int n, i, min_num, current=0;
    string s;
    bool d[500000]; // E: true, W: false
    cin >> n >> s;
    for(i=0; i<n; i++) {
        d[i] = (s[i] == 'E');
        if(i!=0 && d[i]) current++;
    }
    min_num = current;
    for(i=1; i<n; i++) {
       if(d[i] == d[i-1]) {
           if(d[i]) current--;
           else current++;
       }
       min_num = min(min_num, current);
    }
    cout << min_num << endl;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int n,v,c[110],w[110];
long long dp[100010];
int main(){
	cin>>n>>v;
	for(int i=1;i<=n;i++)
		cin>>c[i]>>w[i];
	for(int i=1;i<=n;i++)
		for(int j=v;j>=c[i];j--)
			dp[j]=max(dp[j],dp[j-c[i]]+w[i]);
	cout<<dp[v];
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p.at(i);
    }
    sort(p.begin(), p.end(), greater<int>());
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        if (i == 0) {
            sum += p.at(i)/2;
        }
        else
        {
            sum += p.at(i);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys
if __name__ == '__main__':
    line = sys.stdin.readline()
    N = int(line)
    count = 0
    for i in range(N):
    	line = sys.stdin.readline().split(" ")
    	count += int(line[1]) - int(line[0]) + 1
    print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
const double PI = 3.14159265358979323846264338327950288;

ll A[100010];
ll sum[100010];
int main()
{
	int N;
	ll M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = 0;
	map<ll, ll> mp;
	for (int i = 0; i < N; i++) {
		sum[i + 1] = (sum[i] + A[i]) % M;
	}
	sort(sum, sum + N + 1);
	ll cnt = 1;
	for (int i = 0; i < N; i++) {
		if (sum[i] == sum[i + 1]) {
			cnt++;
		}
		else {			
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt * (cnt - 1) / 2;
	cout << ans << endl;
}


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

ll RepeatSquare(ll x,ll y,ll mod){
    if(y==0) return 1;
    if(y%2==0){
        ll a= RepeatSquare(x,y/2,mod);
        return a*a%mod;
    }
    if(y%2==1) {
        return x*RepeatSquare(x,y-1,mod)%mod;
    }
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rp(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    ll com;
    ll ans=0;
    for(ll i=k; i<=n;i++){
        if(i==k) com=1;
        else{
            com*=(i-1);
            com%=1000000007;
            com*=RepeatSquare(i-k,1000000005,1000000007);
            com%=1000000007;
        }
        ans+=(a.at(i-1)-a.at(n-i))*com;
        ans%=1000000007;

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){
  int x,a; cin >> x >> a;
  if(x < a) puts("0");
  else puts("10");
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(2e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int tree[MAXSIZE];
int lazy[MAXSIZE];
int a[MAXSIZE];

void build(int node, int left, int right){
	if(left==right){
		tree[node] = a[left];
		return ;
	}
	int mid = (left+right)/2;
	build(2*node, left,mid);
	build(2*node+1,mid+1,right);
	tree[node] = max(tree[2*node],tree[2*node+1]);
}

void propogate(int node, int left, int right){
	if(lazy[node]!=0){
		tree[node]= max(tree[node],lazy[node]);
		if(left!=right){
			lazy[2*node]+=lazy[node];
			lazy[2*node+1]+=lazy[node];
		}
		lazy[node] = 0;	
	}
	
}

void update(int node, int left, int right, int l, int r, int val){
	//propogate(node,left,right);
	if(left>r || right<l || right<left) return ;
	if(left>=l and right<=r){
		tree[node] = max(tree[node], val);
		//propogate(node,left,right);
		return ;
	}
	int mid = (left+right)/2;
	update(2*node,left,mid,l,r,val);
	update(2*node+1,mid+1,right,l,r,val);
	tree[node] = max(tree[2*node],tree[2*node+1]);
}

int query(int node, int left, int right, int l, int r){
	//propogate(node,left,right);
	if(left>r || right<l || right<left) return 0;
	if(left>=l and right<=r) return tree[node];
	int mid = (left+right)/2;
	int p = query(2*node,left,mid,l,r);
	int q = query(2*node+1,mid+1,right,l,r);
	return max(p,q);
}

int dp[2][3 * maxn];

int32_t main(){
	fastio();
	int n,k;
	cin >> n >> k;
	int ans = 0;
	build(1,1,3 * maxn);
	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		int l = query(1,0,3 * maxn, max(0ll,x - k), min(3ll * maxn,x + k));
		ans = max(ans, 1 + l);
		update(1,0,3 * maxn,x,x,1 + l);
	}
	cout << ans;

}


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

int main() {
  long long h,w; cin >> h >> w;
  if(h==1 || w==1) cout << 1 << endl;
  else if((h*w)%2==0) cout << (h*w)/2 << endl;
  else if((h*w)%2!=0) cout << (h*w)/2+1 << endl;
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m;
	cin>>n>>m;
	vector<ll>ch;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ch.push_back(x);
	}
	sort(ch.begin(),ch.end());
    ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right =200005; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;
        ll cnt=0;
        for(ll i=0;i<n;i++){
        	ll now=ch[i];
        	now=mid-now;
        	auto itr=lower_bound(ch.begin(),ch.end(),now);
        	cnt+=n-(itr-ch.begin());
        }
        if (cnt<=m) right = mid;
        else left = mid;
    }
    right--;
    ll ch2[100010]={};
    for(ll i=0;i<n;i++){
    	ch2[i+1]=ch[i]+ch2[i];
    }
    //cout << ch2[n]<<endl;
    ll cnt=0;
    ll sum=0;
    for(ll i=0;i<n;i++){
    	ll now=right-ch[i];
    	auto itr=lower_bound(ch.begin(),ch.end(),now);
    	cnt+=n-(itr-ch.begin());
    	sum+=ch[i]*(n-(itr-ch.begin()));
    	sum+=ch2[n]-ch2[itr-ch.begin()];
    }
    //cout <<sum<<endl;
    cout << sum-(cnt-m)*right;
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    //cout << right;	
	// your code goes here
	return 0;
}

Measured memory_bytes: 4848
import numpy as np
n,m,x = list(map(int, input().split()))
masu = [list(map(int, input().split())) for _ in range(n)]
price = [masu[i][0] for i in range(n)]
skills = [masu[i][1:] for i in range(n)]



ans = 100000000000000
for idx_n in range(2**n):
    skill_sets = np.array([0 for _ in range(m)])
    total = 0
    #print(skill_sets.shape)
    for i_row, row in enumerate(skills):
        if idx_n & (2**i_row) >0:
            total += price[i_row]
            #print(np.array(row).shape)
            skill_sets += np.array(row)
    #print(skill_sets)
    if skill_sets.min() >= x:
        if ans >= total:
            ans = total
if ans == 100000000000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 26972
void main(){
	string a, b, c;
	readf("%s %s %s\n", &a, &b, &c);
	writeln( (a[$-1]==b[0] && b[$-1]==c[0])?"YES":"NO" );
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2832
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
const long double INF=1e18;


int main(){
	int N;
  	cin>>N;
	vector<long double> x[3], y[3];
	
	rep(_,N){
		long double X, Y;
		char d;
		cin>>X>>Y>>d;
		if(d == 'R'){
			x[2].push_back(X);
			y[1].push_back(Y);
		}
		if(d == 'L'){
			x[0].push_back(X);
			y[1].push_back(Y);
		}
		if(d == 'U'){
			x[1].push_back(X);
			y[2].push_back(Y);
		}
		if(d == 'D'){
			x[1].push_back(X);
			y[0].push_back(Y);
		}
	}
	int xln[3], yln[3];
	rep(k,3){
		xln[k]=sz(x[k]);
		yln[k]=sz(y[k]);
	}
	rep(k,3){
		if(!x[k].empty())sort(x[k].begin(), x[k].end());
		if(!y[k].empty())sort(y[k].begin(), y[k].end());
	}
	vector<long double> t;
	t.push_back(0);	
	rep(k,3)rep(l,3)if(k>l){
		if(xln[k]>0 && xln[l]>0){
			long double time1=(x[k][0]-x[l][0])/(-k+l);
			if(time1>0)t.push_back(time1);
			long double time2=(x[k][xln[k]-1]-x[l][xln[l]-1])/(-k+l);
			if(time2>0)t.push_back(time2);			
		}
		if(yln[k]>0 && yln[l]>0){
			long double time1=(y[k][0]-y[l][0])/(-k+l);
			if(time1>0)t.push_back(time1);
			long double time2=(y[k][yln[k]-1]-y[l][yln[l]-1])/(-k+l);
			if(time2>0)t.push_back(time2);			
		}
	}
	long double ans=INF;
	int p=sz(t);
	rep(i,p){
		long double time=t[i];
		long double xmin=INF;
		long double xmax=-INF;
		long double ymin=INF;
		long double ymax=-INF;
		rep(k,3){
			if(xln[k]>0){
				xmin=min(xmin, x[k][0]+time*(k-1));
				xmax=max(xmax, x[k][xln[k]-1]+time*(k-1));
			}
			if(yln[k]>0){
				ymin=min(ymin, y[k][0]+time*(k-1));
				ymax=max(ymax, y[k][yln[k]-1]+time*(k-1));
			}
		}
		ans=min(ans, (xmax-xmin)*(ymax-ymin));
	}

	cout<<fixed;
	cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 4196
s=input()
mod=10**9+7
a=0
ab=0
abc=0
q=1
for i in s:
    if i=="?":
        abc*=3
        abc+=ab
        ab*=3
        ab+=a
        a*=3
        a+=q
        q*=3
        q%=mod
    elif i=="A":
        a+=q
    elif i=="B":
        ab+=a
    else:
        abc+=ab
    abc%=mod
    ab%=mod
    a%=mod
print(abc)

Measured memory_bytes: 42092
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a, b;
    cin >> a >> b;
    if(a == b){
        cout << "Draw" << endl;
    }else if(a == 1){
        cout << "Alice" << endl;
    }else if(b == 1){
        cout << "Bob" << endl;
    }else if(a > b){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n,m,i,j,k,ans=0;
	scanf("%d",&n);
	char sn[100][15]={'a'}; 
	for(i=0;i<n;i++)
	{
		scanf("%s",&(sn[i]));
	}
	scanf("%d",&m);
	char sm[100][15]={'a'}; 
	for(i=0;i<m;i++)
	{
		scanf("%s",&(sm[i]));
	}
	
	for(i=0;i<n;i++)
	{
		int sum=0,flag=0;
		for(j=0;j<(n+m);j++)
		{
			flag=0;
			if(j<n)
			{
				for(k=0;k<10;k++)
				{
					if(sn[i][k]==sn[j][k])flag=1;
					else 
					{
						flag=0;
						break;
					}
				}
				if(flag)sum++;
			}
			else
			{
				for(k=0;k<10;k++)
				{
					if(sn[i][k]==sm[j-n][k])flag=1;
					else
					{
						flag=0;
						break;
					}
				}
				if(flag)sum--;
			}
		}
		//printf("%d\n",sum);
		if(sum>ans)ans=sum;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
mod = 10**9+7

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

mf = factorize(m)
from collections import Counter

c = Counter(mf)
ans = 1
from scipy.misc import comb
for i in list(c.values()):
  ans*= comb((i+(n-1)),i,exact=True)

print(int(round(ans))%mod)

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

int getS(int x_n) {
    int ret = 0;

    while (x_n > 0) {
        ret += x_n % 10;
        x_n /= 10;
    }
    
    return ret;
}

int main(void) {
    int n;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout << (n % getS(n) == 0? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

char buf[100000+10];
int n;

bool solve(void) {
  if(buf[0] != '1') return false;
  if(buf[n-1] != '0') return false;
  REP(i, n-1) {
    if(buf[i] != buf[n-2-i]) {
      return false;
    }
  }
  vector<pair<int,int>> es;
  es.push_back(make_pair(1, 2));
  int rest = n-2;
  int last = 2;
  for(int i = 1; rest > 0; ++i) {
    es.push_back(make_pair(last, i+2));
    if(buf[i] == '1') {
      last = i+2;
    }
    --rest;
  }
  REP(i, es.size()) {
    printf("%d %d\n", es[i].first, es[i].second);
  }
  return true;
}

int main(void) {
  scanf("%s", buf);
  n = strlen(buf);
  bool res = solve();
  if(!res) {
    puts("-1");
  }
  
  return 0;
}


Measured memory_bytes: 2420