akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
	long long a = rng();
    return a;
}
long long fact[100002];
int n, frq[28];
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> s;
    for(int i = 0; i < n; ++i)
        frq[s[i] - 'a']++;
    fact[0] = 1;
    long long ans = 1;
    for(int i = 0; i < 26; ++i)
        ans = (ans * (frq[i] + 1)) % mod;
    --ans;
    ans = (ans + mod) % mod;
    cout << ans;
    return 0;
}



Measured memory_bytes: 512
// ABC172-A
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int a;
    cin>>a;
    int ans=a+a*a+int(pow(a,3));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  ll x;
  cin >> N >> x;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  ll ans = 0;
  if(A[0]>x) {
    ans += A[0]-x;
    A[0] = x;
  }
  srep(i,1,N) {
    ll s = A[i-1]+A[i];
    if(s<=x) continue;
    ans += s-x;
    A[i] = x-A[i-1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>){
    val (a,b,x) = readLine()!!.split(" ").map{ it.toLong()}

    if(a != 0L){
        System.out.println(b/x - (a-1)/x)
    } else {
        System.out.println(b/x + 1)
    }

}

Measured memory_bytes: 36524
alphabet_list =['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']

if __name__=="__main__":
    # Problem C
    N = int(input())
    ans = ''
    while N > 0:
        N -= 1
        ans += alphabet_list[N % 26]
        N = N // 26

    print(ans[::-1])

Measured memory_bytes: 8912
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */
/* union_find.cpp {{{ */
class UnionFind {
public:
  UnionFind(int n = 0): cnt(n), data(n, -1){}
  int root(int x) const { return data[x] < 0 ? x : (data[x] = root(data[x])); }
  bool same(int x, int y) const { return root(x) == root(y); }
  bool unite(int x, int y){
    if ((x = root(x)) == (y = root(y))) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    cnt--;
    return true;
  }
  int count() const { return cnt; }
  int size(int x) const { return -data[root(x)]; }
private:
  int cnt;
  mutable vector<int> data;
};
/* }}} */

int main(){
  int n, m[2];
  cin >> n >> m[0] >> m[1];
  UnionFind tr[2]{{n}, {n}};
  rep(i, 2) rep(m[i]){
    int a, b;
    cin >> a >> b, a--, b--;
    tr[i].unite(a, b);
  }
  map<pair<int, int>, int> mp;
  rep(i, n) mp[{tr[0].root(i), tr[1].root(i)}]++;
  rep(i, n) cout << mp[{tr[0].root(i), tr[1].root(i)}] << "\n "[i + 1 < n];
}


Measured memory_bytes: 13568
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n,c = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (i != j && abs(a[i] - a[j]) > c){
        c = abs(a[i] - a[j]);
      }
    }
  }
  cout << c << '\n';
  return 0;
}

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

long long n, a, b, c, d;
string s;

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

    for(long long i = a-1; i <= max(c-1, d-1); i++){
        if(s[i] == '#' and s[i+1] == '#'){
            printf("No\n");
            return 0;
        }
    }

    if(c < d){
        printf("Yes\n");
        return 0;
    }


    for(long long i = b-1; i <= d-1; i++){
        if(s[i-1]== '.' and s[i]== '.' and s[i+1]== '.' ){
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");

    return 0;
}
   

    
   

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

bool isSorted(int arr[],int n)
{
    for(int i = 0 ; i < n-1 ; i++)
    {
        if(arr[i] > arr[i+1])
        {
            return false;
        }
    }
    return true;
}

int getMin(int arr[],int s,int e)
{
    int tmp = s;
    while(s < e)
    {
        if(arr[tmp] > arr[s])
        {
            tmp = s;
        }
        s++;
    }
    return tmp;
}

int main()
{

    int n;
    cin >> n;
    int arr[n];

    for(int i = 0 ; i < n ; i++)
    {
        cin >> arr[i];
    }
    if(isSorted(arr,n))
    {
        cout << "YES" << endl;
        return 0;
    }

    for(int i = 0 ; i < n ; i++)
    {
        int minIndex = getMin(arr,i,n);
        if(minIndex != i)
        {
            swap(arr[i],arr[minIndex]);
            if(isSorted(arr,n))
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define int long long


signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int n; cin >> n;
        while (n) {
                if (n % 10 == 7) {
                        cout << "Yes";
                        return 0;
                }
                n /= 10;
        }
        
        cout << "No";
        return 0;
}

/*

*/

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
vec<vll> dp;
vec<vi> restore;

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    int n,weight; cin >> n >> weight;
    vi w(n) ,v(n); rep(i,n) cin  >> w[i] >> v[i];
    dp.resize(n+1, vll(100001, infll));
    restore.resize(n+1, vi(100000 + 1));
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= 100000; ++j) {
            if(j-v[i] >= 0) {
                if(chmin(dp[i+1][j], dp[i][j-v[i]] + w[i])) {
                    restore[i+1][j] = j-v[i];
                }
            }
            if(chmin(dp[i+1][j], dp[i][j])) restore[i+1][j] = j;
        }
    }
    int ans;
    for(int j = 1000*n; j >= 0; --j) {
        if(dp[n][j] <= weight) {
            ans = j;
            cout << ans << '\n';
            break;
        } 
    }

    // 復元
    // int j = ans;
    // for(int i = n-1; i >= 0; --i) {
    //     if(dp[i+1][j] == dp[i][j-v[i]] + w[i]) {
    //         cout << i+1 << '\n';
    //     }
    //     j = restore[i+1][j];
    // }
}

Measured memory_bytes: 121412
#include <bits/stdc++.h>
using namespace std;
const int N = 10050;
const long long mod = 1e9 + 7;
int d, n;
string num;
long long mem[N][105][2];
bool vis[N][105][2];

long long dp(int idx, int m, int last) {
	if (idx == n) {
		return (!m) ? 1 : 0;
	}
	if (vis[idx][m][last]) {
		return mem[idx][m][last];
	}
	vis[idx][m][last] = true;

	long long ans = 0;
	for (int i = 0; i < 10; i++) {
		if (last && i == num[idx] - '0') {
			ans = (ans + dp(idx + 1, (m + i) % d, 1)) % mod;
			break;
		}
		ans = (ans + dp(idx + 1, (m + i) % d, 0)) % mod;
	}

	return mem[idx][m][last] = ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> num >> d;
	n = num.size();

	cout << (mod + dp(0, 0, 1) - 1) % mod << '\n';

	return 0;
}


Measured memory_bytes: 19712
(let* ((free 0)
       (entry (loop repeat (read)
                    with hash = (make-hash-table)
                    for i = (read) then (read)
                    do (cond ((<= 1 i 399) (setf (gethash 1 hash) t))
                             ((<= 400 i 799) (setf (gethash 2 hash) t))
                             ((<= 800 i 1199) (setf (gethash 3 hash) t))
                             ((<= 1200 i 1599) (setf (gethash 4 hash) t))
                             ((<= 1600 i 1999) (setf (gethash 5 hash) t))
                             ((<= 2000 i 2399) (setf (gethash 6 hash) t))
                             ((<= 2400 i 2799) (setf (gethash 7 hash) t))
                             ((<= 2800 i 3199) (setf (gethash 8 hash) t))
                             (t (incf free)))
                    finally (return (hash-table-count hash)))))
  (format t "~A ~A~%" (max 1 entry) (+ entry free)))

Measured memory_bytes: 21220
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
void solve() {
    int m, n;
    cin >> m >> n;
    if (m == 2) {
        int ans = 0;
        REP(i, n) {
            int t;
            cin >> t;
            t--;
            if (i%2 == 0){
                if (t % 2 == 0) {
                    ans++;

                }
            }
            else {
                if (t % 2 == 1) {
                    ans++;
                }
            }
        }
        cout << min(ans,n-ans) << endl;
    }
    else {
        int ans = 0;
        int back = 0;
        cin >> back;
        REP(i, n-1) {
            int t;
            cin >> t;
            if (back == t) {
                ans++;
                back = -1;
            }
            else {
                back = t;
            }
        }
        cout << ans << endl;
    }
}
int main() {
    init();
    solve();
}


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

int s[200005];
int main(void) {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--, B--, C--, D--;
    int orgB = B;
    string S;
    int As = A, Bs = B;
    cin >> S;
    vector<int> impa;
    int Slen = S.size();
    for(int i = B; i < Slen; i++) {
        if(S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
            s[i + 1]++;
        }
    }
    bool aok = true;
    while(A != C) {
        if(S[A + 1] == '.')
            A++;
        else if(S[A + 2] == '.')
            A += 2;
        else {
            aok = false;
            break;
        }
    }
    bool bok = true;
    while(B != D) {
        if(S[B + 1] == '.')
            B++;
        else if(S[B + 2] == '.')
            B += 2;
        else {
            bok = false;
            break;
        }
    }
    if(aok * bok == 0) {
        cout << "No" << endl;
    } else if(C < D) {
        cout << "Yes" << endl;
    } else if(C > D) {
        bool swap = 0;
        for(int i = orgB; i <= D; i++) {
            if(S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                swap = 1;
                break;
            }
        }
        if(swap) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 640
import qualified Data.IntMap.Strict as M
import Control.Monad.State.Strict

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  bs <- sequence . replicate m $ unsafeListToTuple . map read . words <$> getLine
  sequence_ . map print . scanl1 (+) . evalState (foldr (flip (>>=) . f) (return []) bs) $ newUF
    where
      f (x, y) ls = do
        x' <- root x
        y' <- root y
        if x' == y'
          then
            return $ 0 : ls
          else
            do
              nx <- size' x'
              ny <- size' y'
              unite' x' y'
              return $ (nx * ny) : ls

unsafeListToTuple :: [a] -> (a, a)
unsafeListToTuple (x : y : _) = (x, y)
unsafeListToTuple _ = undefined

type SizedUF = (M.IntMap Int, M.IntMap Integer)

newUF :: SizedUF
newUF = (M.empty, M.empty)

unite :: Int -> Int -> State SizedUF ()
unite x y = do
  x' <- root x
  y' <- root y
  if x' == y'
    then
      return ()
    else
      do
        nx <- size x'
        ny <- size y'
        (ps, cs) <- get
        put (M.insert y' x' ps, M.insert x' (nx + ny) cs)

unite' :: Int -> Int -> State SizedUF ()
unite' x' y' = do
  nx <- size' x'
  ny <- size' y'
  (ps, cs) <- get
  put (M.insert y' x' ps, M.insert x' (nx + ny) cs)

find :: Int -> Int -> State SizedUF Bool
find x y = (==) <$> root x <*> root y

root :: Int -> State SizedUF Int
root = \x -> maybe x id <$> root' x
  where
    root' :: Int -> State SizedUF (Maybe Int)
    root' x = do
      px <- M.lookup x . fst <$> get
      case px of
        Nothing -> return Nothing
        Just y -> do
          ry <- root' y
          case ry of
            Nothing -> return px
            Just z -> do
              (ps, cs) <- get
              put (M.insert x z ps, cs)
              return ry

size :: Int -> State SizedUF Integer
size x = do
  x' <- root x
  (M.findWithDefault 1 x') . snd <$> get

size' :: Int -> State SizedUF Integer
size' x' = do
  (M.findWithDefault 1 x') . snd <$> get


Measured memory_bytes: 122236
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	arr := make([]bool, 26)
	for _, char := range s {
		arr[char-97] = true
	}
	result := "None"
	for i, b := range arr {
		if !b {
			result = string(i + 97)
			break
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 1280
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int n,a,b,c,d,jun[101],x;
typedef pair<int,int> P;
P t[101];

bool cmp(const P& a,const P& b){
	return a.first == b.first ? a.second < b.second : a.first > b.first;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) t[i].second=i;
	for(int i=1;i<=n*(n-1)/2;i++){
		cin>>a>>b>>c>>d;
		if(c>d) t[a].first+=3;
		else if(c<d) t[b].first+=3;
		else {t[a].first++; t[b].first++;}
	}
	sort(t+1,t+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(i>1&&t[i].first==t[i-1].first){
			jun[t[i].second]=x;
		}
		else{
			jun[t[i].second]=i;
			x=i;
		}
	}
	for(int i=1;i<=n;i++){
		cout<<jun[i]<<endl;	
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

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


    ll ans = 0;
    rep(i,6){
        if(s[i]=='1')ans++;
    }
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

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

	int N;
	cin >> N;
	int kazu[5] = {};
	rep(i, N) {
		string S;
		cin >> S;
		if (S[0] == 'M') kazu[0]++;
		if (S[0] == 'A') kazu[1]++;
		if (S[0] == 'R') kazu[2]++;
		if (S[0] == 'C') kazu[3]++;
		if (S[0] == 'H') kazu[4]++;
	}
	ll kotae = 0;
	for (int i = 0; i < 5; i++) {
		for (int ii = i + 1; ii < 5; ii++) {
			for (int iii = ii + 1; iii < 5; iii++) {
				kotae += 1ll * kazu[i] * kazu[ii] * kazu[iii];
			}
		}
	}

	co(kotae);
	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,c;
  cin>>s;
  int n=s.size();
  bool ok =0;
  for(int i=0;i<n;i=i+1){
   if(s[i]=='h' and s[i+1]=='i'){
       i++;
       continue;
       }
        ok =1;
  }
  cout<<(ok?"No":"Yes")<<endl;
  return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
	H, W = map(int, input().split())

	ans = 0
	
	if H ==1 or W == 1:
		ans = 1
	elif H % 2 == 0 or W % 2 == 0:
		ans = H * W / 2
	else:
		ans = H * (W - 1) / 2 + (H+1) / 2

	print(int(ans))

Measured memory_bytes: 3060
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    loop {
        let mut deck: Vec<u8> = sc.next::<String>().into();
        if deck[0] == b'-' {
            break;
        }
        let m: i32 = sc.next();
        for _ in 0..m {
            let at: usize = sc.next();
            let mut new_deck = vec![];
            {
                let (start, end) = deck.split_at(at);
                new_deck.extend_from_slice(end);
                new_deck.extend_from_slice(start);
            }
            deck = new_deck;
        }
        let s = std::str::from_utf8(&deck).unwrap();
        println!("{}", s);
    }
}



Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
	int a,b,c;
	int d,e,f;
	int t;
int main()
{
	
	cin>>a>>b>>c;
	
	d=a+b;
	e=a+c;
	f=b+c;
	if(d<e)  t=d;
	else 	t=e;
	if(f<t) t=f;
	
	cout<<t;
	return 0;
}

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

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    int V[N], C[N];
    for (int i=0; i<N; i++) cin >> V[i];
    for (int i=0; i<N; i++) cin >> C[i];
    int ans = 0;
    for (int i=0; i<N; i++){
        if (V[i] - C[i] > 0) ans += V[i] - C[i];
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int mat[5][200];
int res[5][200];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= N; ++j) {
      cin >> mat[i][j];
    }
  }
	
  for (int i = N; i >= 1; --i) {
    res[2][i] = res[2][i + 1] + mat[2][i];
  }
	
  for (int i = N; i >= 1; --i) {
    res[1][i] = max(res[2][i] , res[1][i + 1]) + mat[1][i];
  }

  printf("%d", res[1][1]);
  return 0;
}




Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	long long int ans = 0;
	for (int i = 1; i <= N; i++) {
		long long int box = N / i;
		ans += box * (box + 1) / 2 * i;
	}
	cout << ans << endl;
}

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

struct Restrict{
    int v;
    int idx;
    int t;
    bool isLess;
};

bool l_to_r(Restrict lhs,Restrict rhs){
    return lhs.idx==rhs.idx &&
            lhs.isLess && !rhs.isLess  &&
            lhs.t<rhs.t;
}

using Graph=vector<vector<int>>;

bool isDAG(Graph &g){
    int n=g.size();
    vector<int> d(n);
    for(int i=0;i<n;i++)for(int j=0;j<g[i].size();j++) d[g[i][j]]++;
    queue<int> que;
    for(int i=0;i<n;i++) if(d[i]==0) que.push(i);
    int cnt=0;
    while(!que.empty()){
        int v=que.front(); que.pop();
        cnt++;
        for(int i=0;i<g[v].size();i++){
            d[g[v][i]]--;
            if(d[g[v][i]]==0){
                que.push(g[v][i]);
            }
        }
    }
    return cnt==n;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<Restrict> rvec;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int s,t;
            string cond;
            cin>>s>>cond>>t;
            s--;
            bool isLess=(cond=="<=");
            rvec.push_back(Restrict{i,s,t,isLess});
        }
    }
    Graph g(n);
    for(int i=0;i<rvec.size();i++){
        for(int j=0;j<rvec.size();j++){
            if(l_to_r(rvec[i],rvec[j])){
                g[rvec[i].v].push_back(rvec[j].v);
            }
        }
    }
    cout<<(isDAG(g) ? "Yes" : "No")<<endl;
    return 0;
}


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

int main(){
	int a,b,c,k;
	//int ans;
	
	cin  >> a >> b >> c >> k;
	
	int count = 0;
	while ( a >= b ){
		b = b * 2;
		count = count + 1;
	}
	while ( b >= c ){
		c = c * 2;
		count = count+1;
	}
	
	
	if (count <= k) {cout << "Yes" << endl;} 
	else  {cout << "No" << endl;}
//	cout << y << endl;
return 0;
}


Measured memory_bytes: 3600
#include <iostream>

typedef long long ll;
using namespace std;

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

    for (int i = 0; i < Q; i++) {
        ll A, B;
        cin >> A >> B;

        if (A == B) {
            cout << 2 * A - 2 << endl;
            continue;
        }

        if (A > B) swap(A, B);

        ll low = A, high = 2 * B;
        ll AB = A * B;
        while (high - low > 1) {
            ll x = (high + low) / 2;

            ll score = (x + 1) / 2 * (x / 2 + 1);

            if (score < AB) {
                low = x;
            } else {
                high = x;
            }
        }

        cout << low - 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned h,n;
    cin>>h>>n;
    uvec a(n),b(n);
    for(unsigned i=0;i<n;++i) cin>>a[i]>>b[i];
    uvec mpoints(h+1,numeric_limits<unsigned>::max());
    mpoints[0]=0;
    for(unsigned i=1;i<=h;++i)
    {
        for(unsigned j=0;j<n;++j)
        {
            if(i>=a[j]) mpoints[i]=min(b[j]+mpoints[i-a[j]],mpoints[i]);
            else mpoints[i]=min(b[j],mpoints[i]);
        }
    }
    cout<<mpoints[h];
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // input
            int X, Y, Z, K;
            X = in.nextInt();
            Y = in.nextInt();
            Z = in.nextInt();
            K = in.nextInt();

            long[] A = new long[X];
            long[] B = new long[Y];
            long[] C = new long[Z];

            for (int i1 = 0; i1 < X; i1++) {
                A[i1] = in.nextLong();
            }

            for (int i1 = 0; i1 < Y; i1++) {
                B[i1] = in.nextLong();
            }

            for (int i1 = 0; i1 < Z; i1++) {
                C[i1] = in.nextLong();
            }

            long[] D = new long[X * Y];
            for (int i = 0; i < X; i++) {
                for (int j = 0; j < Y; j++) {
                    D[i * Y + j] = A[i] + B[j];
                }
            }
            Arrays.sort(D);

            long[] result = new long[Math.min(K, D.length) * Z];
            for (int i = 0; i < Math.min(K, D.length); i++) {
                for (int j = 0; j < Z; j++) {
                    result[i * Z + j] = D[D.length - 1 - i] + C[j];
                }
            }
            Arrays.sort(result);


            for (int i = 0; i < K; i++) {
                out.println(result[result.length - 1 - i]);
            }
        }

    }
}



Measured memory_bytes: 62692
fun main(args: Array<String>) {
    // Your code here!
    val list = readLine()!!.toList().groupBy{it}.map{it.value.size}
    var msg = "No"
    
    if(list.size == 2){
        if(list[0] == 2 && list[1] == 2){
            msg = "Yes"
        }
    }
    print(msg)
}


Measured memory_bytes: 31792
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int a[3] = {1,0,0};
  string str;
  while(cin>>str){
    int p1 = str[0] - 'A';
    int p2 = str[2] - 'A';
    swap(a[p1], a[p2]);
  }
  REP(i,3) if(a[i]==1) printf("%c\n",i+'A');
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] weather = new char[h][w + 1];
		int[][] result = new int[h][w + 1];
		for (int i = 0; i < h; i++) {
			weather[i] = sc.next().toCharArray();
		}
		int cnt;
		for(int i = 0; i < h; i++) {
			cnt = -1;
			for(int k = 0; k < w; k++) {
				if(weather[i][k] == 'c') {
					cnt = 0;
					result[i][k] = cnt;
					cnt = cnt + 1;
				} else if(cnt >= 0) {
					result[i][k] = cnt;
					cnt = cnt + 1;
				} else {
					result[i][k] = cnt;
				}
				
			}
		}
		for(int i = 0; i < h; i++) {
			for(int k = 0; k < w; k++) {
				if(k == w - 1) {
					System.out.println(result[i][k]);
				} else {
					System.out.print(result[i][k] + " ");
				}
			}
		}
	}

}

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

//Compiler version g++ 6.3.0

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a==b || b==c || c==a)
    {
      if(a==b && b==c )
      {
        cout<<"No";
        return 0;
      }
      
      
      cout<<"Yes";
    }
    
    else
    {
      cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

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

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a.begin(), a.end());
    ll mid = a[n/2], ans = 0;
    rep(i,n){
        ans += abs(a[i] - mid);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int i, j;
	int num1, num2;

	while (1) {
		scanf("%d %d", &num1, &num2);
		if (num1 == 0 && num2 == 0) {
			break;
		}

		for (i = 1; i <= num1; i++) {
			for (j = 1; j <= num2; j++) {
				if (i % 2 != 0) {
					if (j % 2 != 0) {
						printf("#");
					}
					else {
						printf(".");
					}
				}
				else {
					if (j % 2 == 0) {
						printf("#");
					}
					else {
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


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

int main() {
	int q;cin>>q;
	map<string,int> mp;
	
	while(q--){
		int query;string key;cin>>query>>key;
		if(query==0){
			int x;cin>>x;
			mp[key]=x;
		}else if(query==1){
			cout<<mp[key]<<endl;
		}else{
			mp[key] = 0;
		}
	}
  return 0;
}



Measured memory_bytes: 27784
package main

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

func main() {
	H, W, K := getStdinInt3()
	C := make([][]string, H)

	for i := 0; i < H; i++ {
		C[i] = make([]string, W)
		c := getStdin()
		for j := 0; j < len(c); j++ {
			C[i][j] = string(c[j])
		}
	}

	ans := 0
	for y := 0; y < (1<<(H))-1; y++ {
		for x := 0; x < (1<<(W))-1; x++ {
			sum := 0
			for n := 0; n < H; n++ {
				if ((1 << (n)) & y) != 0 {
					continue
				}
				for m := 0; m < W; m++ {
					if ((1 << (m)) & x) != 0 {
						continue
					}
					if C[n][m] == "#" {
						sum++
					}
				}
			}
			if sum == K {
				ans++
			}
		}
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2164
# -*- coding: utf-8 -*-
"""
E - 1 or 2
https://atcoder.jp/contests/abc126/tasks/abc126_e

"""
import sys


class DisjointSet(object):
    def __init__(self, n):
        self.rank = [0] * n
        self.p = list(range(n))
        self.size = [1] * n

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

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.size[self.p[x]] += self.size[self.p[y]]
            self.p[y] = self.findSet(x)
        else:
            self.size[self.p[y]] += self.size[self.p[x]]
            self.p[x] = self.findSet(y)
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

def solve(N, M, hints):
    d = DisjointSet(N+1)
    for x, y, z in hints:
        d.unite(x, y)
    for i in range(1, N+1):
        d.findSet(i)

    ans = set(d.p[1:])
    return len(ans)


def main(args):
    N, M = map(int, input().split())
    hints = [[int(i) for i in input().split()] for _ in range(M)]
    ans = solve(N, M, hints)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

inline void draw(char c, int n){
    for(int i = 0; i < n; i++) cout << c;
    cout << endl;
}

int main()
{
    int H, W, i;
    while(1){
        cin >> H >> W;
        if(H + W < 1) break;
        for(i = 0; i < H; i++) draw('#', W);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
import numpy as np
N, M = map(int, input().split())

#create 0/1 matrix for all lamps and switches 
s=np.zeros((M,N))
for i in range(M):
    ks = list(map(int, input().split()))  
    for j in range(ks[0]):
        s[i, ks[j+1]-1]=1
P = list(map(int, input().split()))      
    
counter=0
# 2^N possible combinations of switches
for k in range(2**N):
    k_bit = list(map(int, list(np.binary_repr(k, N))))
    #calculate how many switches are on for each lamp
    b_status = np.dot(s, k_bit)%2
    #print(k_bit, b_status)
    if all(b_status==P)==True:
        counter +=1

print(counter)

Measured memory_bytes: 14628
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

struct L {
  int a,b,c;
  L(int a,int b,int c) : a(a),b(b),c(c) {}
};


int main() {
  int n,m;
  cin >> n >> m;
  // convert x,y -> X,Y
  map<int,int> X;
  map<int,int> Y;
  X[0]=0;
  Y[0]=0;


  // length 用
  vector<L> lx;
  vector<L> ly;
  rep(i,n) {
    int a,b,c;
    cin >> a >> b >> c;
    X[a]=0;
    X[b]=0;
    Y[c]=0;
    lx.eb(L(a,b,c));
  }

  rep(i,m) {
    int d,e,f;
    cin >> d >> e >> f;
    X[d]=0;
    Y[e]=0;
    Y[f]=0;
    ly.eb(L(e,f,d));
  }
  // sort x,y
  vi xs;
  vi ys;
  for(auto &v : X) {
    v.se=xs.size();
    xs.eb(v.fi);
  }
  for(auto &v : Y) {
    v.se=ys.size();
    ys.eb(v.fi);
  }
  int h=xs.size()*2;int w=ys.size()*2;
  vvi d(h,vi(w,0));


  // wall
  for(auto l : lx) {
    srep(i,X[l.a]*2,X[l.b]*2) {
      d[i][Y[l.c]*2]=-1;
    }
  }
  for(auto l : ly) {
    srep(i,Y[l.a]*2,Y[l.b]*2) {
      d[X[l.c]*2][i]=-1;
    }
  }

  vi dx = {-1,0,1,0};vi dy={0,1,0,-1};
  // bfs
  queue<P> que;
  que.push(P(X[0]*2,Y[0]*2));
  d[X[0]*2][Y[0]*2]=1;
  while(que.size()) {
    P now=que.front();que.pop();
    rep(i,4) {
      int nx=now.fi+dx[i];int ny=now.se+dy[i];
      if(isin(nx,0,h) and isin(ny,0,w) and d[nx][ny]==0){
        d[nx][ny]=1;
        que.push(P(nx,ny));
      }
    }
  }

  ll ans=0;
  // S calc
  rep(i,h) rep(j,w) {
    if(d[i][j]!=1) continue;
    if(i==h-1 or i == 0 or j == 0 or j == w-1) {
      cout << "INF" << endl;
      return 0;
    }
    if(i % 2 == 0 or j % 2 == 0) continue;
    ll ex=xs[i/2+1]-xs[i/2];
    ll ey=ys[j/2+1]-ys[j/2];
    ans+=ex*ey;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 144516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    string s;
    cin >> s;
    int n;
    n = s.size();
    bool a = (n % 2 == 1);
    bool b = (s[0] == s[n-1]);
    if(a ^ b){
        printf("First\n");
    }
    else{
        printf("Second\n");
    }

}


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

int main(){
  string s;
  cin >> s;
  if(s=="SUN") cout << 7 << endl;
  else if(s=="MON") cout << 6 << endl;
  else if(s=="TUE") cout << 5 << endl;
  else if(s=="WED") cout << 4 << endl;
  else if(s=="THU") cout << 3 << endl;
  else if(s=="FRI") cout << 2 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String...args) {

		String result = "No";
		int[] list = {1, 2, 3, 4, 5, 6, 7, 8, 9};

		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();

			for (int i : list) {
				if (n % i == 0 && n / i < 10) {
					result = "Yes";
					break;
				}
			}

			System.out.println(result);
		}
	}

}


Measured memory_bytes: 23764
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
X = []

ans = min(A) + min(B)
for i in range(m):
    x, y, c = map(int, input().split())
    if A[x-1] + B[y-1] - c < ans:
        ans = A[x-1] + B[y-1] - c
print(ans)


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

int main(){
    int n;
    cin>>n;
    if(n%10==2 ||n%10==4 || n%10==5 || n%10==7 || n%10==9 )
        cout<<"hon"<<endl;
    if(n%10==0 ||n%10==1 || n%10==6 || n%10==8)
        cout<<"pon"<<endl;
    if(n%10 == 3)
        cout<<"bon"<<endl;
    return 0;
}

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


int main()
{
    int a,b,x;;
    cin>>a>>b>>x;
    if(a<=x&&x<=a+b) yn;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(bu.readLine());
        String s[]=bu.readLine().split(" ");
        int i,a=Integer.parseInt(s[0]),b=Integer.parseInt(s[1]);
        int l=a%n,r=b%n;
        if(l==0 || r==0) System.out.print("OK");
        else
        {
            a=a-l;
            a+=n;
            if(a<b) System.out.print("OK");
            else System.out.print("NG");
        }
    }
}


Measured memory_bytes: 32520
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;


main(){
    ll n=in();
    ll k=in();
    string s;cin>>s;
    char c='{';
    rep(i,s.size()){
        c=min(c,s[i]);
    }
    ll t=1;
    rep(i,k-1){
        t*=2;
        if(t>=n){
            rep(j,n)cout<<c;
            return 0;
        }
    }
    string ss=s;
    reverse(s.begin(),s.end());
    string u=ss+s;
    string MIN="{";
    //cout<<u<<endl;
    if(k!=1)
    reverse(u.begin(),u.end());
    rep(j,n+1){
        string tmp=u.substr(j,n);
        MIN=min(MIN,tmp);
    }
    if(k==1){
        cout<<MIN;return 0;
    }
    ll z=0;
    for(auto e:MIN){
        if(e==c)z++;
        else break;
    }
    int zz=z;
    //cout<<MIN<<endl<<z<<endl;
    rep(i,k-1){
        z*=2;
    }
    rep(i,(ll)min(z,n))cout<<c;
    rep2(i,zz,n-z+zz-1)cout<<MIN[i];

}


Measured memory_bytes: 256