akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

void print_ans(bool flag){
    if(flag){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }   
}

int main(){
    int a;
    int go = 0;
    int nana = 0;
    for(int i = 0; i < 3; i++){
        cin >> a;
        if(a == 5){
            go++;
        } else if(a == 7){
            nana++;
        }
    }
    print_ans(go == 2 && nana == 1);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, T[101], M, P[100], X[100];
    cin >> N;
    int sum = 0;
    FOR(i, 1, N + 1, 1) {
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;
    REP(i, M) {
        cin >> P[i] >> X[i];
    }
    REP(i, M) {
        cout << sum + X[i] - T[P[i]] << endl;
    }
    return 0;
}


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

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


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

    string s; cin >> s;
    cout << s << (s.back() == 's' ? "es" : "s");
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size()<=k) {
        cout << s << endl;
        return 0;
    }
    rep(i,0,k) cout << s[i];
    cout << "..." << endl; 
}

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

string s;
int ans = 0;
int counts = 0;

int main() {
    cin >> s;

    for (int i = 0; i < s.size(); ++i)
    {
        if (s.at(i) == 'A' || s.at(i) == 'T' || s.at(i) == 'G' || s.at(i) == 'C')
        {
            counts = 0;
            for (int j = i; j < s.size(); ++j)
            {
                if (s.at(j) == 'A' || s.at(j) == 'T' || s.at(j) == 'G' || s.at(j) == 'C')
                {
                    counts++;
                    if (ans < counts)
                    {
                        ans = counts;
                    }
                    continue;
                }else {
                    break;
                }

                
            }

        }
        
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split())) + [0]

count = 0
before = 0
for i in range(n+1):
    if As[i] >= before:
        count += before
        As[i] -= before
    else:
        count += As[i]
        As[i] = 0


    if As[i] > 0:
        if As[i] < Bs[i]:
            count += As[i]
            before = Bs[i] - As[i]
        else:
            before = 0
            count += Bs[i]
    else:
        before = Bs[i]

print(count)

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

int main()
{
  int n,d;
  cin >> n >> d;
  int ans=0;
  for (int i=0; i < n; i++)
  {
    long long x, y;
    cin >> x >> y;
     double dis=(sqrt(x*x+y*y));
    if (ceil(dis)<=d)
    {
      ans+=1;
    }
  }
  cout << ans << endl;
}


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

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

    def union(self, x, y):
        x = self.find(x) ; y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
N,M=map(int,input().split())
uf=UnionFind(N)
for i in range(M):
    a,b=map(int,input().split(' '))
    uf.union(a-1,b-1)

ans=sum([1 for i in uf.parents if i<0])-1
print(ans)

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

template<typename F, typename G, typename H>
struct Mo {
  int width;
  vector< int > left, right, order;
  vector< bool > v;
  const F fadd;
  const G fdel;
  const H frem;

  Mo(int N, int Q, const F fadd, const G fdel, const H frem) : width((int) sqrt(N)), order(Q), v(N), fadd(fadd), fdel(fdel), frem(frem) {
    iota(begin(order), end(order), 0);
  }

  void add(int l, int r) { /* [l, r) */
    left.emplace_back(l);
    right.emplace_back(r);
  }

  void run() {
    assert(left.size() == order.size());
    sort(begin(order), end(order), [&](int a, int b) {
      int ablock = left[a] / width, bblock = left[b] / width;
      if(ablock != bblock) return ablock < bblock;
      if(ablock & 1) return right[a] < right[b];
      return right[a] > right[b];
    });
    int nl = 0, nr = 0;
    auto push = [&](int idx) {
      v[idx].flip();
      if(v[idx]) fadd(idx);
      else fdel(idx);
    };
    for(auto idx : order) {
      while(nl > left[idx]) push(--nl);
      while(nr < right[idx]) push(nr++);
      while(nl < left[idx]) push(nl++);
      while(nr > right[idx]) push(--nr);
      frem(idx);
    }
  }
};
int A[1000001];
int f[1000001];
int main() {
    int N, Q;
    cin >> N >> Q;
    for (int i = 0; i < N; i++) scanf("%d", A + i);
    int ret = 0;
    vector<int> ans(Q);
    auto fadd = [&](int idx) -> void { if(f[A[idx]]++ == 0) ret++; };
    auto fdel = [&](int idx) -> void { if(f[A[idx]]-- == 1) --ret; };
    auto frem = [&](int idx) -> void { ans[idx] = ret; };
   	auto mo = Mo(N, Q, fadd, fdel, frem);
    int l, r;
    for (int i = 0; i < Q; i++) {
        scanf("%d%d", &l, &r);
        mo.add(--l, r);
    }
    mo.run();
    for (int i = 0; i < Q; i++) printf("%d\n", ans[i]);
}


Measured memory_bytes: 15696
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long ll;

int main()
{
    string s;
    cin>>s;
    int n=s.size();

    int v0=0,v1=0;
    REP(i,n){
        if(s[i]=='0') v0++;
        else v1++;
    }

    cout<<2*min(v0,v1)<<endl;

	return 0; 
}


Measured memory_bytes: 512
def main():
    n, m, *ab = map(int, open(0).read().split())
    e = [[] for _ in range(n)]
    for u, v in zip(*[iter(ab)] * 2):
        e[u - 1].append(v - 1)
        e[v - 1].append(u - 1)

    ans = 0
    for _ in range(m):
        count = 0
        for i, x in enumerate(e):
            if len(x) == 1:
                e[i] = []
                e[x[0]].remove(i)
                count += 1
        if count:
            ans += count
        else:
            print(ans)
            exit()




if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	int ans = 0;
	int c = 0;
	rep(_, n) {
		int a, b;
		cin >> a >> b;
		if (chmax(c, a)) ans = a + b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s_list = list(input())
seizon_t = 0
s_amari = 0
for char in s_list:
  if char == "T":
    if s_amari == 0:
      seizon_t += 1
    else:
      s_amari -= 1
  else:
    s_amari += 1
print(2*seizon_t)


Measured memory_bytes: 61552
// Problem : D - RGB Triplets
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

const int maxn=4000+10;
char s[maxn];

int id(char ch){
	if(ch=='R') return 1;
	if(ch=='G') return 2;
	return 3;
}

int sum[maxn][4];

int main()
{
	int n;
	cin>>n;
	scanf("%s",s+1);
	rep(i,1,n){
		rep(j,1,3) sum[i][j]=sum[i-1][j];
		++sum[i][id(s[i])];
	}

	ll ans=0;	
	rep(i,1,n){
		rep(j,i+2,n) if(s[i]!=s[j]){
			int v=1;
			for(;v<=3;++v){
				if(v!=id(s[i]) && v!=id(s[j])) break;
			}
			ans+=sum[j][v]-sum[i-1][v];
			if(((i+j)&1) == 0 && id(s[(i+j)/2]) == v) --ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3768
count = Array.new(4) {0}
for i in 1..3 do
  a,b = gets.split(" ").map { |e| e.to_i }
  count[a-1] += 1
  count[b-1] += 1
end

if count.max >= 3
  puts "NO"
elsif count.min == 0
  puts "NO"
else
  puts "YES"
end


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int n;
  cin >> n;
  ll mn = 1e18;
  ll ans = 0;
  rep(i,0,n) {
    ll k;
    cin >> k;
    if (k <= mn) ++ans;
    mn = min(mn, k);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    string S;
    cin >> S;
    int ans=0;
    int N=S.size();
    for(int i=0;i<N;i++){
        if(S.at(i)=='0') ans++;
    }
    ans=min(ans,N-ans);
    cout << ans*2 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000

int main(){
  int N;
  cin>>N;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin>>s.at(i);
  }
  int ans=0;
  int A=0;
  int B=0;
  int same=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<s.at(i).size()-1;j++){
      if(s.at(i).at(j)=='A'&&s.at(i).at(j+1)=='B'){
        ans++;
      }
    }
    if(s.at(i).at(0)=='B'){
      B++;
    }
    if(s.at(i).at(s.at(i).size()-1)=='A'){
      A++;
    }
    if(s.at(i).at(0)=='B'&&s.at(i).at(s.at(i).size()-1)=='A'){
      same++;
    }
  }
  if(A==same&B==same){
    cout<<ans+max(same-1,0)<<endl;
  }else{
    cout<<ans+min(A,B)<<endl;
  }
}


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

int main(){

    int a,left=0,right=0;
    for(int i=0;i<2;i++){
        cin >> a;
        left += a;
    }
    for(int i=0;i<2;i++){
        cin >> a;
        right += a;
    }
    if(left == right) cout << "Balanced" << endl;
    else if(left > right) cout << "Left" << endl;
    else cout << "Right" << endl;

    return 0;
}

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

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

    for(int i=0;i<s.size();++i){
        char c = s[i];
        c = 'A' + (c-'A'+n)%26;
        s[i] = c;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

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

template<class T>
bool chmax(T &a,const T &b) {
    if(a<b) {
        a=b;
        return true;
    }
    return false;
}

int N,W;
struct Goods {
    int w,v;
};
Goods gs[102];
int dp[102][10004];
int main() {
    cin>>N>>W;
    rep(i,N) cin>>gs[i].v>>gs[i].w;

    rep(i,N) rep(w,W+1) {
        chmax(dp[i+1][w],dp[i][w]);
        if(w-gs[i].w<0) continue;
        chmax(dp[i+1][w],dp[i][w-gs[i].w]+gs[i].v);
    }
    /*
    rep(i,N+1) {
        cout<<i<<" : ";
        rep(w,W+1) cout<<dp[i][w]<<" ";
        cout<<endl;
    }
    */
    cout<<dp[N][W]<<endl;
    return 0;
}

Measured memory_bytes: 5076
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ld n, m, d;
	cin >> n >> m >> d;
	ld ans = 0;
	if(!d) ans = (m - 1) * (n / sq(n));
	else ans = (m - 1) * (2 * (n - d) / (sq(n)));
	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
// A - Connection and Disconnection
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll f(string &S){//文字列の操作回数を求める
	ll c = 0;
	for(int i=1; i < S.size(); ++i){
		if(S[i-1] == S[i]){
			c++;
			i++;
		}
	}
	return c;
}

int main(){
	string S; cin>>S;
	ll K; cin>>K;

	string S2 = S + S;
	string S3 = S2 + S;

	ll s1 = f(S);//K=1 のときの操作回数
	ll s2 = f(S2);//K=2 のときの操作回数
	ll s3 = f(S3);//K=3 のときの操作回数

	ll d1 = s2 - s1;//K=2 と K=1 の操作回数の差分
	ll d2 = s3 - s2;//K=3 と K=3 の操作回数の差分

	ll ans = 0;
	//繰り返し K <= 3 までは計算済み
	if(K == 1) ans = s1;
	else if(K == 2) ans = s2;
	else if(K == 3) ans = s3;
	if(K <= 3){
		cout<< ans <<endl;
		return 0;
	}
	//ここからは等差数列の問題
	if(d1 == d2) ans = s1 + d1 * (K-1);
	else
		if(K % 2) ans = s1 + (d1+d2) * ((K+2-1)/2-1);
		else ans = s2 + (d1+d2) * (K/2-1);
	cout<< ans <<endl;
}

Measured memory_bytes: 256
// Try Hitachi Hokudai Labo & Hokkaido University Contest 2019-1
// author: Leonardone @ NEETSDKASU

fn main() {
    use std::io::{stdin, stdout, BufRead, Write};
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let stdout = stdout();
    let mut stdout = stdout.lock();

    let mut get_line = || {
        let mut line = String::new();
        stdin.read_line(&mut line).unwrap();
        line
    };

    let (_, e) = {
        let line = get_line();
        let mut tokens = line.split_whitespace();
        let v = tokens.next().unwrap().parse::<usize>().unwrap();
        let e = tokens.next().unwrap().parse::<usize>().unwrap();
        (v, e)
    };

    for _ in 0 .. e {
        get_line();
    }

    let freqs: Vec<_> = get_line()
        .split_whitespace()
        .map(|v| v.parse::<usize>().unwrap())
        .collect();

    let t_max = if freqs[0] != 0 { freqs[0] } else {
        get_line().trim().parse().unwrap()
    };

    if freqs[0] != 0 {
        for _ in 0 .. t_max {
            let n_new = get_line().trim().parse::<usize>().unwrap();
            for _ in 0 .. n_new {
                get_line();
            }
        }
        for _ in 0 .. t_max {
            println!("-1");
        }
        stdout.flush().unwrap();

    } else {

        for _ in 0 .. t_max {

            let n_new = get_line().trim().parse::<usize>().unwrap();
            for _ in 0 .. n_new {
                get_line();
            }

            let n_put = get_line().trim().parse::<usize>().unwrap();
            for _ in 0 .. n_put {
                get_line();
            }

            println!("-1");
            stdout.flush().unwrap();

            if get_line().trim() != "OK" {
                break;
            }

            let n_ach = get_line().trim().parse::<usize>().unwrap();
            for _ in 0 .. n_ach {
                get_line();
            }
        }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	ll n;
	cin >> n;
	vll A;
	ll i, j;
	for (i = 0; i < n; i++){
		ll a;
		cin >> a;
		A.push_back(a);
	}
	vll B(n, 0);
	if (n % 2 == 0){
		ll num = n - 1;
		for (i = 0; i < n / 2; i++){
			B[i] = A[num];
			num--;
			B[n - i - 1] = A[num];
			num--;
		}
	}
	else{
		ll num = n - 1;
		for (i = 0; i < (n - 1) / 2; i++){
			B[i] = A[num];
			num--;
			B[n - i - 1] = A[num];
			num--;
		}
		B[(n - 1) / 2] = A[num];
	}
	for (i = 0; i < n; i++){
		cout << B[i] << " ";
	}
	cout << endl;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
int main() {
    std::cin >> N;
    int multi4 = 0, multi2 = 0, other = 0;

    REP(i, N) {
        int a;
        std::cin >> a;
        if(a % 4 == 0) {
            multi4++;
        } else if(a % 2 == 0) {
            multi2++;
        } else {
            other++;
        }
    }

    bool a = multi2 > 0;
    bool b = multi4 >= other;
    bool c = multi4 + 1 >= other;

    if( (a && b) || (!a && c) ) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int n;
	int ans=LLONG_MAX;
	cin>>n;
	for (int i = 1; i*i <= n; ++i)
	{
		if(!(n%i))
			ans=min(ans,i-1+(n/i)-1);
	}
	cout<<ans;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <map>
#include <utility>
#include <vector>

using namespace std;

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

  int N, K;
  cin >> N >> K;

  vector<int> x_plots;
  vector<int> y_plots;
  vector<pair<int, int> > plots;
  for (int i = 0; i < N; ++i) {
    int x, y;
    cin >> x >> y;
    x_plots.push_back(x);
    y_plots.push_back(y);
    plots.push_back(make_pair(x, y));
  }

  sort(x_plots.begin(), x_plots.end());
  sort(y_plots.begin(), y_plots.end());

  long long ans =
      1LL * (x_plots[N - 1] - x_plots[0]) * (y_plots[N - 1] - y_plots[0]);
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (i == j) continue;
      for (int k = 0; k < N; ++k) {
        for (int l = k + 1; l < N; ++l) {
          if (k == l) continue;

          long long left_x = 1LL * x_plots[i];
          long long right_x = 1LL * x_plots[j];
          long long down_y = 1LL * y_plots[k];
          long long up_y = 1LL * y_plots[l];

          int res = 0;
          for (int p = 0; p < N; ++p) {
            if (left_x <= plots[p].first && plots[p].first <= right_x &&
                down_y <= plots[p].second && plots[p].second <= up_y) {
              res++;
            }
          }
          if (res >= K)
            ans = min(ans, (long long)(right_x - left_x) * (up_y - down_y));
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int d0[200000],d1[200000];
int main(){
  int N,i,x,y;scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d%d",&x,&y);
    d0[i] = x-y;
    d1[i] = x+y;
  }
  printf("%d\n",max(*max_element(d0,d0+N)-*min_element(d0,d0+N),*max_element(d1,d1+N)-*min_element(d1,d1+N)));
}

Measured memory_bytes: 5380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=110;
const double eps=-1e8;
int n,m;
double a[N];
int main(){
	double sum=0;
	scanf("%d%d",&n,&m);
	rep(i,1,n+1){
		scanf("%lf",&a[i]);
		sum+=a[i];
	}
	int ans=0;
	rep(i,1,n+1){
		if(a[i]*4*m>=sum)
		{
			ans++;
		}
	}
	if(ans>=m)puts("Yes");
	else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[500][500];
vector<ll> x(250000);
vector<ll> y(250000);
vector<ll> x2(250000);
vector<ll> y2(250000);

int main() {
	ll h, w, v;
	scanf("%d %d", &h, &w);
	rep(i, 0, h)rep(j, 0, w) {
		scanf("%d", &v);
		a[i][j] = v % 2;
	}

	ll cnt = 0;
	rep(i, 0, h) {
		rep(j, 0, w - 1) {
			if (a[i][j] & 1) {
				a[i][j + 1]++;

				y[cnt] = i + 1;
				x[cnt] = j + 1;
				y2[cnt] = i + 1;
				x2[cnt] = j + 2;
				cnt++;
			}
		}

		if (i != h - 1) {
			if (a[i][w - 1] & 1) {
				a[i + 1][w - 1]++;

				y[cnt] = i + 1;
				x[cnt] = w;
				y2[cnt] = i + 2;
				x2[cnt] = w;
				cnt++;
			}
		}
	}

	printf("%d\n", cnt);
	rep(i, 0, cnt)	printf("%d %d %d %d\n", y[i], x[i], y2[i], x2[i]);

	return 0;
}

Measured memory_bytes: 11904
#include<iostream>
using namespace std;
int main(){
    int n,m,a;
    cin>>n>>m;
    int c[n+1]={1};
    for(int i=0;i<m;i++){cin>>a;c[a]=-1;}
    if(c[1]!=-1)c[1]=1;
    for(int i=2;i<=n;i++){
        if(c[i]==-1)continue;
        if(c[i-2]!=-1)c[i]+=c[i-2];
        if(c[i-1]!=-1)c[i]+=c[i-1];
        c[i]%=1000000007;
    }
    cout<<c[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
import sys
#import collections as col
input=sys.stdin.readline

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().rstrip().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def facto(x, y, mod):
	re = 1
	for i in range(y, x+1):
		re *= i
		re %= mod
	#print(re, file=sys.stderr)
	return re

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    #return facto(n, n-r+1, mod) * g2[r] % mod
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
NN = 10**5+10
g1 = [1, 1] # factorial
g2 = [1, 1] # factorial^(-1)
inverse = [0, 1] # tmp

def init_comb():
    for i in range( 2, NN + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )


def main():
	A,B = linput()
	M = mod
	
	res = cmb(B+1, A+1, M)
	print(res)

def solve():
	S, = linput(str)
	res = 0
	mod = 9
	
	t = 0
	for s in S:
		t = 10*t + int(s)
		t %= mod
	
	sT = "No Yes".split()
	res = sT[t < 1]
	print(res)
	
	
solve()

#init_comb()
#main()


Measured memory_bytes: 9352
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, n - 1):

    if p[i - 1] < p[i] and p[i] < p[i + 1]:
        count += 1
    elif p[i - 1] > p[i] and p[i] > p[i + 1]:
        count += 1

print(count)    



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  double N;
  cin >> N;

  for(double h = 1; h <= 3500; h++){
    for(double n = 1; n <= 3500; n++){
      double w = (N*n*h) / (4*h*n-N*n-N*h);
      if(w > 0 && w <= 3500 && isInteger(w)){
        cout << (int)h << " " << (int)n << " " << (int)w << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

using namespace std;

int main() {
    string str;
    cin >> str;
    
    for(int i=0; i<str.size(); i++) {
        if(i%2) {
            if(str[i]=='R') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(str[i]=='L') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;

    return 0;
    
}

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

string S;

int main() {
    cin >> S;

    ll ans = 0;
    int w_cnt = 0;
    for (int i = S.length() - 1; i >= 0; i--) {
        if (S[i] == 'W') {
            w_cnt++;
        }
        else {
            ans += w_cnt;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define crossNum 110




int main(void){
  long a,b,odd;
  long cross[crossNum];
  for(int i=0;i<crossNum;i++){
    cross[i]=0;
  }
  while(cin>>a>>b){
    if(a>0 or b>0){
      cross[a]++;
      cross[b]++;
    }
    else{
      odd=0;
      for(int i=0;i<crossNum;i++){
        if(cross[i]%2==1){
          odd++;
        }
      }
      if(odd==2 and cross[1]%2==1 and cross[2]%2==1){
        cout<<"OK"<<endl;
      }
      else{
        cout<<"NG"<<endl;
      }

      for(int i=0;i<crossNum;i++){
        cross[i]=0;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>

int main() {

	int h1, m1, h2, m2, k;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	
	h1*=60;
	h2*=60;
	
	int waktu=h2+m2-h1-m1-k;
//	int output= waktu/k-1;
//	output*=k;
	
	printf("%d\n", waktu);
	


    return 0;
}


Measured memory_bytes: 2144
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
use std::collections::VecDeque;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        mut k:usize
    }
    let mut q: VecDeque<usize> = VecDeque::new();
    for i in 1..10 {
        q.push_back(i);
    }
    for i in (0..k).rev() {
        if let Some(x) = q.pop_front() {
            //            println!("{}", x);
            if i == 0 {
                println!("{}", x);
                return;
            }
            let y = x % 10;
            if y != 0 {
                q.push_back(x * 10 + y - 1);
            }
            q.push_back(x * 10 + y);
            if y != 9 {
                q.push_back(x * 10 + y + 1);
            }
        }
    }

    return;
}


Measured memory_bytes: 3972
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;
std::string SS;
bool updated[500] = {};
bool startmemo[500] = {};
int32_t K;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> S>>K;
	if (S.size() == 1) {
		out << K / 2 << endl;
		return 0;
	}

	SS = S;
	SS += S;
	SS += S;
	SS += S;

	int roop = 0;
	int i = 1;
	while (!startmemo[i % S.size()]) {
		startmemo[i % S.size()] = true;
		++roop;
		assert(roop-1 == i / S.size());
		for (int start_roop = i/ S.size(); i / S.size() == start_roop; i++)
		{
			if (SS[i - 1] == SS[i]) {
				updated[i] = true;
				++i;
			}
		}

		if (roop >= K) {
			break;
		}
	}
	assert(1 <= roop);
	assert(roop <= 2);

	int64_t count = 0;
	if (i % S.size() == 1)
	{
		int base = K / roop;
		for (int r = 0; r < roop; r++)
		{
			for (int j = 0; j < S.size(); j++)
			{
				int kk = j + S.size() * r;
				if (updated[kk]) {
					count += base;
					if (r < K % roop) {
						++count;
					}
				}

			}
		}
	}
	else {

		for (int j = 0; j < S.size(); j++)
		{
			int kk = j;
			if (updated[kk]) {
				count += 1;
			}

		}
		for (int j = 0; j < S.size(); j++)
		{
			int kk = j + S.size();
			if (updated[kk]) {
				count += (K-1);
			}

		}
	}
	out << count << endl;


	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7;
const double PI = acos(-1);


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

    vector<int> v(n+2, 0), a(n, 0);

    for (auto&x : a) cin >> x;

    for (int i=n-1; i>=0; i--){
        v[a[i]] = max(v[a[i]], v[a[i] + 1] + 1);
    }

    if (v[1]) cout << n - v[1] << endl;
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int n, int p) {
    VI a(n);
    int owan = p;
    int id = 0;
    while (true) {
        bool f = (owan == 1);
        if (owan) {
            a[id]++;
            owan--;
        } else {
            owan = a[id];
            a[id] = 0;
        }
        if (f) {
            if (count(ALL(a), 0) == n - 1) {
                cout << id << endl;
                return ;
            }
        }
        id = (id + 1) % n;
    }
}

int main(void) {
    int n, p;
    while (cin >> n >> p) {
        if (n == 0 && p == 0) return 0;
        solve(n, p);
    }
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int>H(N);
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    int ans = 0;
    int hantei = 0;
    for(int i = N-1; i >= 1; i--){
        if(H[i] <= H[i-1]){
            hantei++;
        }else{
            hantei = 0;
        }
        ans = max(ans , hantei);
    }

    cout << ans << endl;
}

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

const int INF=-1;

//状態を表すクラスpairの場合、typedefしておくと便利
typedef pair<int, int> P;

//入力
char maze[60][60];//迷路
int N, M;
int sx=0, sy=0;         //スタート地点
         //ゴール地点

int d[100][100];    //各点までの最短距離の配列

//移動４方向のベクトル
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

//(sx, sy)から(gx, gy)への最短距離を求める
//たどり着けないとINF
int bfs(int gy, int gx){
	queue <P> que;

	//すべての点をINFで初期化
	for(int i=0; i<N; i++)for(int j=0; j<M; j++)d[i][j]=INF;
	  //スタート地点をキューに入れ、その点の距離を０にする
	  que.push(P(sy, sx));
		d[sy][sx]=0;

		//キューが空になるまでループ
		while(que.size()){
			//queの先頭を取り出す
		  P p = que.front();que.pop();
			//取り出して来た状態がゴールなら探索をやめる
		  if(p.first == gy && p.second == gx)break;

			//移動４方向をループ
			for(int i=0; i<4; i++){
			  //移動した後の点を(nx, ny)とする
				int ny=p.first+dy[i], nx=p.second+dx[i];

				//移動が可能かの判定とすでに訪れたことがあるかの判定
				//(d[nx][ny] != INFなら訪れたことがある)
				if(0<=nx && nx<M && 0<=ny && ny<N && maze[ny][nx]!='#' && d[ny][nx] == INF){
					//移動できるならキューに入れ、その点の距離をpからの距離+1で確定する
					que.push(P(ny, nx));
					d[ny][nx]=d[p.first][p.second]+1;
				}
			}
		}
	return d[gy][gx];
}

int main(void){
	int cnt=0;
	cin >> N >> M;
	int gx=M-1;
	int gy=N-1;
	for(int i=0; i<N; i++){
		for(int j=0; j<M; j++){
			cin >> maze[i][j];
			if(maze[i][j]=='#'){cnt++;}
		}
	}
	int res=bfs(gy, gx);
	if(res==-1){cout << "-1" << endl;return 0;}
	cout << N*M-res-cnt-1 << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X = get_int

if X <= 599
  puts 8
elsif X <= 799
  puts 7
elsif X <= 999
  puts 6
elsif X <= 1199
  puts 5
elsif X <= 1399
  puts 4
elsif X <= 1599
  puts 3
elsif X <= 1799
  puts 2
elsif X <= 1999
  puts 1
end


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

int main() {
  int a,b;
  cin>>a>>b;
  int d[b];
  int sum=0;
  vector<int> N(0);
  for(int i=0;i<b;i++) {
    cin>>d[i];
    sum+=d[i];
    for(int j=0;j<d[i];j++) {
      int c;
      cin>>c;
      N.push_back(c);
    }
    
  }
  int ans=1;
  sort(N.begin(),N.end());
  for(int i=0;i<sum-1;i++) {
    if(N.at(i)!=N.at(i+1)){
      ans++;
    }
  }
  cout<<a-ans<<endl;
  return 0;
  
}


Measured memory_bytes: 3700
#include<stdio.h>
#include<math.h>

int main(void){
    int n, s[1000];
    while(1){
        double ave=0.0, tmp=0.0;
        scanf("%d", &n);
        if(!n) break;
        for(int i=0; i<n; i++) scanf("%d", &s[i]);
        for(int i=0; i<n; i++) ave += s[i];
        ave=ave/n;
        for(int i=0; i<n; i++) tmp += (s[i]-ave)*(s[i]-ave);
        printf("%lf\n", sqrt(tmp/n));
    }
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int A,B,a[100100],b[100100],M;
int main()
{
	cin>>A>>B>>M;
	int mna=10000000,mnb=10000000;
	for(int i=1;i<=A;i++) scanf("%d",a+i),mna=min(mna,a[i]);
	for(int i=1;i<=B;i++) scanf("%d",b+i),mnb=min(mnb,b[i]);
	int ans=mna+mnb;
	for(int i=1;i<=M;i++)
	{
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		ans=min(ans,a[x]+b[y]-z);
	}
	cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int A, B; cin >> A;
  cin >> B;

  int res = 6 - A - B;
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  vector<int> x(n);
  vector<int> y(n);
  for(int i = 0;i < n;i++){
    cin >> x[i] >> y[i] >> h[i];
  }
  bool judge;
  for(int i = 0;i <= 100;i++){
    for(int j = 0;j <= 100;j++){
      int cx,cy,H;
      cx = i;
      cy = j;
      for(int k = 0;;k++){
        if(h[k] != 0){
          H = abs(cx-x[k]) +abs(cy-y[k]) + h[k];
          break;
        }
      }
      for(int k = 0;k < n;k++){
        if(h[k] == max(H-abs(cx-x[k])-abs(cy-y[k]),0)) judge = true;
        else{
          judge = false;
          break;
        }
      }
      if(judge == true){
        cout << cx << " " << cy << " " << H << endl;
        break;
      }
    }
    if(judge == true) break;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E
 
int LevenshteinDistance(string s1,string s2) {
  int n = (int)s1.size(), m = (int)s2.size();
  vector<vector<int> > dp(n+1,vector<int>(m+1));
  for(int i=0;i<=n;++i) dp[i][0] = i;
  for(int i=0;i<=m;++i) dp[0][i] = i;
  for(int i=1;i<=n;++i) {
    for(int j=1;j<=m;++j) {
      dp[i][j] = min(dp[i-1][j]+1,
                     min(dp[i][j-1]+1,dp[i-1][j-1]+(s1[i-1]!=s2[j-1])));
    }
  }
  return dp[n][m];
}
 
int main() {
  string s1,s2;
  getline(cin,s1);
  getline(cin,s2);
  cout << LevenshteinDistance(s1,s2) << endl;
  return 0;
}

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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int h, a; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	h = read(), a = read(); 
	printf("%d\n", (h + a - 1) / a); 
	
	return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(a[i][j] == '#') {
        break;
      } else if(j == w - 1) {
        for(int k = 0; k < w; k++) {
          a[i][k] = '!';
        }
      }
    }
  }
  for(int i = 0; i < w; i++) {
    for(int j = 0; j < h; j++) {
      if(a[j][i] == '#') {
        break;
      } else if(j == h - 1) {
        for(int k = 0; k < h; k++) {
          a[k][i] = '!';
        }
      }
    }
  }
  int count = 0;
  for(int i = 0; i < h; i++) {
    count = 0;
    for(int j = 0; j < w; j++) {
      if(a[i][j] != '!') {
        cout << a[i][j];
      } else {
        count++;
      }
    }
    if(count != w && i != h - 1) {
      cout << "\n";
    }
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_printf(x...) cerr << "line " << __LINE__ << " : "; debug_printf_in(x);

template <typename First>
void debug_printf_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_printf_in(First first, Rest... rest){
  cerr << first << " ";
  debug_printf_in(rest...);
  return;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  string S;
  IN(S);

  map<string, ll> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;

  OUT(mp[S]);

  return 0;
}

Measured memory_bytes: 256
def main():
    ranks = [-1, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    a, b = [int(x) for x in input().split()]
    if ranks[a] > ranks[b]:
        print("Alice")
    elif ranks[b] > ranks[a]:
        print("Bob")
    else:
        print("Draw")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060