akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;





fn main() {

    input! { 
       n: usize,
       z: i64,
       w: i64,
       a : [i64;n],
    }


    let mut a= a;
    
    let mut y = w;
    let mut ans = -1;
    if(a.len()>1){
        ans =  (a[a.len()-2] - a[a.len()-1]).abs(); //.... x y
    }
    ans =  cmp::max(ans , (a[a.len()-1] - y).abs()); //.....x

    
    
    
  
  
    
    
    
    
    println!("{}",ans);


}


Measured memory_bytes: 4352
N,M=map(int,input().split())
D=[]
for i in range(M):
  D.append(list(map(int,input().split())))
  D[-1]=D[-1][1:]
L=list(map(int,input().split()))
count=0
s=[]
for i in range(2**N):
  p = True
  for j in range(M):
    tmp = 0
    for k in range(N):
      if i>>k & 1:
        if k+1 in D[j]:
          tmp+=1
    if not L[j] == tmp%2:
      p = False
      break
  if p:
    s.append(bin(i))
    count+=1
print(count)

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

ll choose2(ll x){
    return x*(x-1)/2;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i]--;
    vector<int> cnt(n);
    rep(i,n) cnt[a[i]]++;
    ll tot = 0;
    rep(i,n){
        tot += choose2(cnt[i]);
    }

    rep(i,n){
        ll ans = tot;
        ans -= choose2(cnt[a[i]]);
        ans += choose2(cnt[a[i]]-1);
        cout << ans << endl;
    }


}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i=0;i<n;i++){
        cin >> s.at(i);
    }
    map<string,int> jisyo;
    for (int i=0;i<n;i++){
        jisyo[s.at(i)] +=1;
    }
    int nax =0;
    for (int i=0;i<n;i++){
        nax = max (jisyo[s.at(i)] , nax);
    }

    for (auto i:jisyo){
        if (i.second == nax)
        cout << i.first << endl;
    }
    return 0;
}



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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
  cout << "vowel" << endl;
 }
else {
cout << "consonant" << endl;
}
}

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

int main()
{
	int N,x,y,b,p;
	int total,wtotal;

	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d %d %d %d",&x,&y,&b,&p);
		total = x * b + y * p;

		if(b < 5)
			b = 5;
		if(p < 2)
			p = 2;

		wtotal = 0.8 * (x * b + y * p);
		if(total < wtotal)
			printf("%d\n",total);
		else
			printf("%d\n",wtotal);
	}

	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
typedef long long ll;
const ll mod=pow(10,9)+7;

//powを使うと変なことになるので掛け算する度にmodで割る処理をする関数を定義する
ll powmod(ll a, ll b){
    ll res=1;
    for(ll i=0; i<b; i++){
        res*=a;
        res%=mod; 
    }
    return res;
}
int main()
{
    ll n;
    cin >> n;
    
    ll ans = 0;

    ans = powmod(10,n) - powmod(9,n) - powmod(9,n) + powmod(8,n);

    ans%=mod;

    ans=(ans+mod)%mod;

    cout << ans << endl;

    return 0;
}

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

int main()
{
	int N;

	cin >> N;

	int h[N];
	int hmax = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> h[i];

		if (h[i] > hmax)
		{
			hmax = h[i];
		}
	}

	int count = 0;

	for (int i = hmax; i > 0; i--)
	{
		bool flg = false;

		for (int j = 0; j < N; j++)
		{
			if (h[j] == i)
			{
				if (flg == false)
				{
					flg = true;
					count++;
				}

				h[j]--;
			}
			else
			{
				flg = false;
			}
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 700;
  string s;
  cin >> s;
  for(int i=0;i<3;i++){
    if(s.at(i) =='o'){
      ans += 100;
    }
  }
  cout << ans << endl;
}
      




Measured memory_bytes: 256
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
a.reverse()
f.sort()
maxproduct=0
for i in range(n):
  maxproduct=max(f[i]*a[i],maxproduct)
l1=0
r1=maxproduct
while True:
  l2=l1
  r2=(l1+r1)//2
  if l2==r2:
    break
  counter=0
  for i in range(n):
    c=r2//f[i]
    while (c+1)*f[i]<=r2:
      c+=1
    counter+=max(0,a[i]-c)
  if counter<=k:
    r1=r2
  else:
    l1=r2
if l1==r1:
  print(r2)
else:
  counter=0
  r2=l1
  for i in range(n):
    c=r2//f[i]
    while (c+1)*f[i]<=r2:
      c+=1
    counter+=max(0,a[i]-c)
  if counter<=k:
    print(l1)
  else:
    print(r1)

Measured memory_bytes: 80740
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  vector<vector<int>> C(H, vector<int>(W));
  REP(i, H) REP(j, W) cin >> C[i][j];
  int b;
  REP(i, H) REP(j, W){
    cin >> b;
    C[i][j] -= b;
    C[i][j] = abs(C[i][j]);
  }

  vector<vector<vector<bool>>> vec(H, vector<vector<bool>>(W, vector<bool>(12800, false)));
  vec[0][0][C[0][0]] = true;
  REP(i, H){
    REP(j, W){
      REP(k, 12800){
        if(vec[i][j][k] == false) continue;

        if(j+1 < W){
          vec[i][j+1][abs(C[i][j+1]-k)] = true;
          vec[i][j+1][C[i][j+1]+k] = true;
        }
        if(i+1 < H){
          vec[i+1][j][abs(C[i+1][j]-k)] = true;
          vec[i+1][j][C[i+1][j]+k] = true;
        }
      }
    }
  }

  REP(i, 12800){
    if(vec[H-1][W-1][i]){
      cout << i << endl;
      return 0;
    }
  }


  return 0;
}

Measured memory_bytes: 12544
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

ll n, x;

int main() {
	ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    cin >> n >> x;
    ll ans = n;
    ll cur1 = x, cur2 = n - x;
    while (1) {
        ans += cur2 / cur1 * cur1 * 2;
        //cerr << cur2 / cur1 * cur1 * 2 << "\n";
        if (cur2 % cur1 == 0) {ans -= cur1; break;}
        ll q = cur2;
        cur2 = cur1;
        cur1 = q % cur1;
    }
    
    cout << ans << "\n";
    
	return 0;
}


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

if 0 in A:
    ans = sum(map(abs, A))
    print(ans)
    exit()
else:
    negs = 0
    for a in A:
        if a < 0:
            negs += 1

    if negs % 2 == 1:
        A = list(map(abs, A))
        A.sort()
        # print(A, sum(A))
        ans = sum(A) - 2 *A[0]
        print(ans)
    else:
        ans = sum(map(abs, A))
        print(ans)


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

int main(){

  string s;
  cin>>s;
  
  int cnt=0;
  
  int N=s.length();
  
  if(N%2==0){
  
    rep(i,N/2){

      if(s[i]!=s[N-i-1])cnt++;
      
    }
  
  }
  else{
    
    rep(i,N/2){

      if(s[i]!=s[N-i-1])cnt++;
      
    }

  }
  
  cout<<cnt<<endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int N = scanner.nextInt();
        long lcm = 1;
        for (int i = 0; i < N; i++) {
            lcm = lcm(lcm, scanner.nextLong());
        }
        System.out.println(lcm);
    }

    long lcm(long a, long b) {
        long gcd = a > b ? gcd(a, b) : gcd(b, a);
        return a / gcd * b;
    }

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


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define INF 1e+18L
#define pb push_back
#define ll long long
#define vi vector<int>

int main()
{
    FASTIO
    int n;
    cin >> n;
    vector<char> s(n);
    ll r = 0, g = 0, b = 0;
    rep(i,0,n)
    {
        cin >> s[i];
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }
    ll ans = r*g*b;
    rep(i,0,n-2)
    {
        rep(k,i,n)
        {
            if(s[i] != s[k])
            {
                if((i+k)%2 == 0)
                {
                    if(s[i] != s[(i+k)/2] && s[(i+k)/2] != s[k]) ans--;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;   
}

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

int main() {
    int n; cin >> n;
    vector<ll> x(n), y(n);
    vector<ll> h(n);
    ll xt, yt, ht;
    rep(i,n) {
        cin >> x.at(i) >> y.at(i) >> h.at(i);
        if(h.at(i)>=1){
            xt = x.at(i); yt = y.at(i); ht = h.at(i);
        }
    }

    rep(X, 101){
        rep(Y, 101){
            bool ok = true;
            ll H = ht + (ll)abs(xt-X) + (ll)abs(yt-Y);
            H = max(H, 0LL);
            for(int k=0; k<n; k++){
                ll w = H - (ll)abs(x.at(k)-X) - (ll)abs(y.at(k)-Y); w = max(w, 0LL);
                if(h.at(k)!=w) ok = false;
            }

            if(ok){
                cout << X << " " << Y << " "<< H << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    string s, t;
    cin >> s >> t;

    int n = s.size(), m = t.size();
    int ans = m;
    for (int i = 0; i <= n - m; i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            cnt += s[i + j] != t[j];
        }
        ans = min(ans, cnt);
    }
    cout << ans << newl;

    return 0;
}

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

int main(){
	int a,b,c; cin>>a>>b>>c;
	if(b-a==c-b) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;

// セグメント木をソラで書きたいあなたに
// http://tsutaj.hatenablog.com/entry/2017/03/29/204841

struct SegmentTree {
  private:
    int n;
    vector<ll> node;

  public:
    SegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while(n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, INF);
        //最下段に値をいれる
        for(int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        // 下の段から順番に値を入れる
        for(int i = n - 2; i >= 0; i--) {
            //最小値を管理する
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    //もとの配列で場所xの値をvalにupdateする
    void update(int x, ll val) {
        {
            //最下段のノードにアクセスする
            x += (n - 1);
            node[x] = val;
            while(x > 0) {
                x = (x - 1) / 2;
                node[x] = min(node[2 * x + 1], node[2 * x + 2]);
            }
        }
    }

    // 対象区間 : 各ノードがカバーしている区間
    // 要求区間 [a, b) 中の要素の最小値を答える
    // k := 自分がいるノードのインデックス
    // 対象区間は [l, r) にあたる
    ll getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
        //最初に呼び出された時の対象区間は[0, n)
        if(r < 0) {
            r = n;
        }
        if(r <= a || b <= l) {
            //[l.r) \cap [a, b)_= \emptyset
            //要求区間が対象区間と交わらない->適当に返す
            return INF;
        }
        if(a <= l and r <= b) {
            //要求区間が対象区間を完全にconver
            //[l, r) \subset [a, b)
            return node[k];
        }
        //
        //左側の子がvl
        //右側の子がvr
        //新しい対象区間は，現在の対象
        ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    SegmentTree seg(vector<ll>(N, pow(2, 31) - 1));
    string ans;
    for(int i = 0; i < Q; i++) {
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0)
            seg.update(x, (ll)y);
        else {
            ans += to_string(seg.getmin(x, y + 1)) + "\n";
        }
    }
    cout << ans.substr(0, ans.size() - 1) << endl;
    return 0;
}


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

ll comb(ll n)
{
    return n * (n - 1) / 2;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;

    vector<int> cnt(n);
    rep(i, n) cnt[a[i]]++;
    ll tot = 0;
    rep(i, n) tot += comb(cnt[i]);

    rep(i, n)
    {
        ll ans = tot;
        ans -= comb(cnt[a[i]]);
        ans += comb(cnt[a[i]] - 1);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,d,x,t;cin>>n>>d>>x;
    cout << (n+d<x?"No":"Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll H, W;
  cin >> H >> W;
  vvl C = VVL(10, 10, 0);
  vl A(10, 0);
  REP(i, 10) REP(j, 10) cin >> C[i][j];

  REP(k, 10) REP(i, 10) REP(j, 10) {
    C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
  }

  REP(i, H) REP(j, W) {
    ll a;
    cin >> a;
    if (a != -1)
      A[a]++;
  }

  ll ans = 0;
  REP(i, 10) { ans += A[i] * C[i][1]; }
  cout << ans << endl;

  return 0;
}


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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, M, Q;
    std::cin >> N >> M >> Q;

    vector<vector<int>> table(N + 1, vector<int>(N + 1, 0));
    REP(i, M) {
        int l, r;
        std::cin >> l >> r;
        table[l][r]++;
    }

    REP(flag, 2) {
        for(int i = 1; i <= N; i++) {
            for(int j = 1; j <= N; j++) {
                table[i][j] += flag ? table[i - 1][j] : table[i][j - 1];
            }
        }
    }

    REP(i, Q) {
        int p, q;
        std::cin >> p >> q;
        std::cout << table[q][q] + table[p - 1][p - 1] -
                     table[p - 1][q] - table[q][p - 1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 1920
word = input()
n = len(word)
hanbun = int((n-1)/2)
notk = 0
for i in range(hanbun):
    if word[i] != word[n-i-1]:
        notk = 1
        break
        
if hanbun % 2 == 0:
    hanbun2 = int(hanbun/2)
else:
    hanbun2 = int((hanbun-1)/2)
    
for j in range(hanbun2):
    if word[j] != word[hanbun-j-1]:
        notk = 1
        break

if notk == 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 61828
d = int(input())
a,b = "Christmas","Eve"

if d == 25:
    print("{}".format(a))
elif d == 24:
    print("{} {}".format(a,b))
elif d == 23:
    print("{} {} {}".format(a,b,b))
elif d == 22:
    print("{} {} {} {}".format(a,b,b,b))


Measured memory_bytes: 2940
# coding: utf-8
import os
from sys import stdin, stdout

__LOCAL__ = False
if(__LOCAL__):
    __dirname = os.path.dirname(__file__)
    __basename = os.path.splitext(os.path.basename(__file__))[0]
    __inputname = './input/' + __basename + '.txt'
    __outputname = './output/' + __basename + '.txt'
    input_path = os.path.join(__dirname, __inputname)
    output_path = os.path.join(__dirname, __outputname)
    stdin = open(input_path)
    stdout = open(output_path, "w")

def TLEmain():
    A, B = map(int,stdin.readline().rstrip().split(' '))
    ans = 0
    for x in range(A,B+1):
        ans ^= x
    print(ans)

def xorsum(A):
    if(A&1):
        return (A+1)//2 & 1
    else:
        return ((A+1)//2 & 1) ^ A

def main():
    A, B = map(int,stdin.readline().rstrip().split(' '))
    if(A==B):
        ans = A
        stdout.write("{}\n".format(ans))
    else:
        ans = xorsum(A-1)^xorsum(B)
        stdout.write("{}\n".format(ans))     

if __name__ == "__main__":
    main()
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
// typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

typedef complex<double> P;
const double EPS = 1e-10;
const double INF = 1e12;

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

    int T;
    cin >> T;

    while (T--) {
        V N(9);
        rep(i, 9) cin >> hex >> N[i];

        int K = 0;
        rep(j, 32) {
            int sm = 0;
            rep(i, 8) {
                sm += N[i] ^ K;
            }
            if (((sm >> j) & 1) != ((N.back() >> j) & 1)) {
                K |= (1LL << j);
            }
        }

        cout << hex << K << endl;
    }

}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    string s;
    cin>>s;
    int ans = 1;
    if(s == "RRR") ans = 3;
    if(s == "RRS") ans = 2;
    if(s == "SRR") ans = 2;
    if(s == "SSS") ans = 0;
    show(ans);
    return 0;
}

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

int ans[31];

int main(){
  int w, n;
  scanf("%d", &w);
  for(int i=1; i<=30; i++){
    ans[i]=i;
  }
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(ans[a], ans[b]);
  }
  for(int i=1; i<=w; i++){
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 1188
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    for i in range(50000):
        t = i * 1.08 // 1
        if t == N:
            print(i)
            break
    else:
        print(':(')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=2000004;
const int mod=1000000007,inf=1000000007;

std::string s;
inline ll powmod(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1) (res*=a)%=mod;
		(a*=a)%=mod,b>>=1;
	}
	return res;
}
ll fact[maxn],invfact[maxn];
inline void init()
{
	fact[0]=invfact[0]=1;
	for(rgi i=1;i<maxn;++i)
		fact[i]=fact[i-1]*i%mod,invfact[i]=powmod(fact[i],mod-2);
}
inline ll C(ll n,ll m) {return fact[n]*invfact[m]%mod*invfact[n-m]%mod;}
signed main()
{
	int n;
	fin>>n;
	std::cin>>s;
	init();
	int len=s.length()-1;
	ll ans=0;
	for(rgi i=0;i<=n;++i)
		(ans+=powmod(26,i)*powmod(25,n-i)%mod*C(n-i+len,len))%=mod;
	fout<<ans;
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 35636
#include <iostream>
#include <string>
#include <complex>

using namespace std;

// typedef complex<int> comp;

class comp : public complex<int> {
public:
    comp() : complex<int>() {}
    comp(complex<int> const& c) {
        real(c.real()), imag(c.imag());
    }
    bool overflow;
};

int const lim = 10000;

comp operate(const comp &a, const comp &b, char o) {
    comp c;
    if (o == '+') {
        c=a+b;
    } else if (o == '-') {
        c=a-b;
    } else /* if (0 == '*') */ {
        c=a*b;
    }

    bool t = c.real() > lim || c.real() < -lim || c.imag() > lim || c.imag() < -lim;
    c.overflow = a.overflow || b.overflow ? true : t;
    return c;
}

comp expr(string &);
comp term(string &);
comp fctr(string &);

comp expr(string &s) {
    comp a = term(s);
    while (s[0] == '+' || s[0] == '-') {
        char o = s[0];
        s.erase(0, 1);
        comp b = term(s);
        a = operate(a, b, o);
    }
    return a;
}

comp term(string &s) {
    comp a = fctr(s);
    while (s[0] == '*') {
        s.erase(0, 1);
        comp b = fctr(s);
        a = operate(a, b, '*');
    }
    return a;
}

comp fctr(string &s) {
    comp z;
    z.overflow = false;
    if (s[0] == '(') {
        s.erase(0, 1);
        z = expr(s);
        s.erase(0, 1);
        return z;
    }

    int sign = 1;
    if (s[0] == '+')
        s.erase(0, 1);
    else if (s[0] == '-') {
        s.erase(0, 1);
        sign = -1;
    }

    if (s[0] == 'i') {
        s.erase(0, 1);
        z.imag(sign);
        return z;
    }

    int i = 0;
    while (s[i] >= '0' && s[i] <= '9') {
        z.real(z.real() * 10 + s[i] - '0');
        i++;
        if (z.real() > lim) z.overflow = true;
    }
    z.real(z.real()*sign);
    s.erase(0, i);
    return z;
}

 void print(const comp &z) {
     if (z.imag() == 0){
         cout << z.real() << endl;
     } else if (z.real() == 0) {
         cout << z.imag() << "i" << endl;
     } else {
         cout << z.real();
         if (z.imag() > 0)
             cout << "+";
         cout << z.imag() << "i" << endl;
     }
 }

int main() {
    string s;
    while (cin >> s) {
        comp z = expr(s);
        if (z.overflow) puts("overflow");
        else print(z);
    }
}

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

int main(){
    int N;
    cin >> N;
    if (N == 2) cout << -1 << endl;
    else if (N == 3) {
        cout << "aab" << endl;
        cout << "c.b" << endl;
        cout << "cdd" << endl;
    }
    else if (N == 4) {
        cout << "aabc" << endl;
        cout << "ddbc" << endl;
        cout << "efgg" << endl;
        cout << "efhh" << endl;
    }
    else if (N == 6) {
        cout << "aab..." << endl;
        cout << "c.b..." << endl;
        cout << "cdd..." << endl;
        cout << "...hii" << endl;
        cout << "...h.k" << endl;
        cout << "...jjk" << endl;
    }
    else if (N == 7) {
        cout << "aabbcc." << endl;
        cout << "d.e...f" << endl;
        cout << "d.e...f" << endl;
        cout << ".g.hhii" << endl;
        cout << ".gjj..k" << endl;
        cout << "lm....k" << endl;
        cout << "lm..nn." << endl;
    }
    else if (N == 11) {
        string f = "....", s = ".......";
        cout << "aabbcc." << f << endl;
        cout << "d.e...f" << f << endl;
        cout << "d.e...f" << f << endl;
        cout << ".g.hhii" << f << endl;
        cout << ".gjj..k" << f << endl;
        cout << "lm....k" << f << endl;
        cout << "lm..nn." << f << endl;
        cout << s << "aabc" << endl;
        cout << s << "ddbc" << endl;
        cout << s << "efgg" << endl;
        cout << s << "efhh" << endl;
    }else {
        string nt = "";
        for (int i = 0; i < N; i++) nt += ".";
        vector<string> ans(N, nt);
        int y = N%4;
        int x = (N-y*5)/4;
        for (int i = 0; i < x; i++) {
            ans[4*i].replace(4*i, 4, "aabc");
            ans[4*i+1].replace(4*i, 4, "ddbc");
            ans[4*i+2].replace(4*i, 4, "efgg");
            ans[4*i+3].replace(4*i, 4, "efhh");
        }
        for (int i = 0; i < y; i++) {
            int t = 4*x+5*i;
            ans[t].replace(t, 5, "aabcc");
            ans[t+1].replace(t, 5, "d.b.e");
            ans[t+2].replace(t, 5, "df..e");
            ans[t+3].replace(t, 5, ".fhhi");
            ans[t+4].replace(t, 5, "jjkki");
        }
        for (string s : ans) cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define VEC(kata, num) (kata*)malloc(num * sizeof(kata))
#define DB puts("ok")
#define SENTINEL 1000000007
typedef long long lli;
typedef struct {
    lli a;
    lli b;
} drink;
// 昇順
int cmp(const void *x, const void *y) {
    return ((drink*)x)->a - ((drink*)y)->a;
}

int main()
{
    int n, m, count=0, i, j;
    lli ans=0;
    drink A[100000];
    scanf("%d%d",&n,&m);
    for(i=0; i<n; i++) {
        scanf("%lld%lld",&A[i].a, &A[i].b);
    }
    qsort(A, n, sizeof(drink), cmp);
    for(i=0; count<m; i++) {
        if(count+A[i].b <= m) {
            count += A[i].b;
            ans += A[i].a * A[i].b;
        } else {
            lli temp = m - count;
            count += temp;
            ans += A[i].a * temp;
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3324
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll inf=1e17;

int main(){
  int n; cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1) cin >> a[i];
  vector<ll> mx(n+1);
  mx[0]=1;
  for(int i=1;i<n+1;i++){
    mx[i]=(mx[i-1]-a[i-1])*2;
    if(mx[i]>=inf) mx[i]=inf;
  }
  rep(i,n+1){
    if(mx[i]<a[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(all(mx));
  reverse(all(a));
  ll now=0;
  ll ans=0;
  rep(i,n+1){
    now=now+a[i];
    chmin(now,mx[i]);
    ans+=now;
    //cout << now << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4796
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		int valores[] = new int[3];
		Scanner scanner = new Scanner(System.in);
		
		for(int i = 0; i < 3; i++) {
			valores[i] = scanner.nextInt();	
		}
		Arrays.sort(valores);
		System.out.println(valores[0] + valores[1]);
	}
}

Measured memory_bytes: 21972
/**
 *  author: mahfuzz
 *  created: 27.06.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define trace(x) cout << #x << ':' << x << "\n"
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    
    int a; cin >> a;
    cout << a + a * a + a * a * a << "\n";
        
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int a,b,c,d; cin >> a >> b >> c >> d;
	if(a != c) puts("1");
	else puts("0");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
using namespace std;
vector<int> l;
int N,A,B,C;
int dfs(int cur,int a,int b,int c){
    if (cur==N){
        if (min({a,b,c})>0) return abs(A - a) + abs(B - b) + abs(C - c) - 30;
        else return INF;
    }
    int ret0 = dfs(cur+1,a,b,c);
    int ret1 = dfs(cur+1,a+l[cur],b,c)+10;
    int ret2 = dfs(cur+1,a,b+l[cur],c)+10;
    int ret3 = dfs(cur+1,a,b,c+l[cur])+10;
    return min({ret0,ret1,ret2,ret3});
    
}
int main(){
    cin >> N >> A >> B >> C;
    rep(i,N) {
        int t;
        cin >> t;
        l.push_back(t);
    }
    int ans = dfs(0,0,0,0);
    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int a[3], m[3], sum;
int x[3];

ll gcd(ll a, ll b){
  if(a < b)swap(a, b);
  if(a % b == 0)return b;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    sum = 0;
    rep(i, 3){
      scanf("%d %d", &a[i], &m[i]);
      sum += a[i] + m[i];
    }
    if(!sum)break;

    rep(i, 3){
      x[i] = 1;
      int now = 1;
      for(;;++x[i]){
        now = (now * a[i]) % m[i];
        if(now == 1)break;
      }
    }

    ll a = lcm(lcm(x[0], x[1]), x[2]);
    pri(a);

//*/

//*/ break;
  }
  return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    ll A[N]; 
    ll sum_a = 0;
    REP(i, N) {
        cin >> A[i];
        sum_a += A[i];
    }
    ll ans = 0;
    REP(i, N - 1) {
        sum_a -= A[i];
        ans += (sum_a % MOD) * (A[i] % MOD);
        ans = ans % MOD;
    }
    cout << ans << "\n";
}

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

using namespace std;
typedef long long ll;

int mod=1e9+7;
const int N=4e6+5;
int k[10];
int main()
{
  int kk,n,x;
  cin>>kk>>n;
  for(int i=1;i<=n;i++) {
    cin>>x;k[x]++;
  }
  for(int i=1;i<100000;i++){
        int f=0;
    if(i>=kk){
        int z=i;
        while(z){
            int p=z%10;
            z/=10;
            if(k[p]){f=1;break;}
        }
       if(!f){cout<<i;break;}
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		BigInteger nextBigIntger() {
			BigInteger bb = new BigInteger(next());
			return bb;
		}
	}

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		HashMap<Character, Integer> map = new HashMap<>();
		char[] aa = sc.nextLine().toCharArray();
		boolean flag = true;
		for (int i = 0; i < aa.length; i++) {
			if (aa[i] == '9') {
				flag = true;
				break;
			} else
				flag = false;
		}
		if(flag)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 21204
#include <iostream>

using namespace std;

int main(){

 char op;
 int a,b;

 while(1){
 if(op != '?'){
  cin >> a >> op >> b ;
  if( op == '+'){
   cout << a+b << endl;
  }else if(op == '-'){
   cout << a-b << endl;
  }else if(op == '*'){
   cout << a*b << endl;
  }else if(op == '/'){
   cout << a/b << endl;
  }
 }else
 break;

 }

 return 0;

}

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

int main(){
  string n;
  cin >> n;
  if((n[0]==n[1]||n[2]==n[3])&&n[1]==n[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

const int N=200000;

int l;
char ts[300],tt[300];
char s[N+5],t[N+5];

int main()
{
	scanf("%s %s",s+1,t+1);
	l=strlen(s+1);
	for(int i=1;i<=l;i++)
	{
		if(!ts[ s[i] ] && !tt[ t[i] ])
		{
			ts[ s[i] ] = t[i];
			tt[ t[i] ] = s[i];
		}
		if(ts[ s[i] ] != t[i] || tt[ t[i] ] != s[i])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

char S[4];

void solve(){
  int A=0,B=0,C=0;
  for(int i=0; i<3; i++){
    if(S[i]=='a') A++;
    if(S[i]=='b') B++;
    if(S[i]=='c') C++;
  }
  if(A==1 && B==1 && C==1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(){
  cin >> S;
  solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
bool chmin(long long &a, long long b) { if (a > b) {a = b; return true;} return false;}
const long long INF = 1LL<<60;

using Edge = pair<int, long long>;
int N, M;
vector<vector<Edge> > G;
                                 
int main() {
    cin >> N >> M;
    G.clear(); G.resize(N);
    for (int i = 0; i < M; ++i) {
        int a, b; long long w;
        cin >> a >> b >> w; --a, --b;
        G[a].push_back(Edge(b, -w));
    }

    vector<long long> dist(N, INF);
    bool negative = false;
    dist[0] = 0;
    for (int iter = 0; iter <= N*2; ++iter) {
        for (int v = 0; v < N; ++v) {
            if (dist[v] >= INF/2) continue;
            for (auto e : G[v]) {
                if (chmin(dist[e.first], dist[v] + e.second)) {
                    if (e.first == N-1 && iter == N*2) negative = true;
                }
            }
        }
    }
    if (!negative) cout << -dist[N-1] << endl;
    else cout << "inf" << endl;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    if(s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2) ||
      s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3)) {
      System.out.println("Yes");
    }
    else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vii;
typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, h;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> h;
    vector<pair<int, char> > ab;
    rep(i, 0, n) {
      int a, b;
      cin >> a >> b;
      ab.pb(mp(a, 'a'));
      ab.pb(mp(b, 'b'));
    }
    ll ans = 0;
    sort(ALL(ab), greater<pair<int, char>>());
    rep(i, 0, 2*n) {
      if (h <= 0) break;
      pair<int, char> p = ab[i];
      if (p.second == 'b') {
        h -= p.first;
        ans++;
      } else {
        ans += (h % p.first == 0 ? h / p.first : h /p.first + 1);
        h = 0;
      }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
using namespace std;
int n;
inline int calc(int t)
{
    int s=0;
    while(t>0)
    {
        s+=(t%10);
        t/=10;
    }
    return s;
}
int main()
{
    scanf("%d",&n);
    int ans=(1<<30);
    for(int i=1;i<=n/2;i++)
        ans=min(ans,calc(n-i)+calc(i));
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256