akhauriyash/Code-Regression huggingface dataset:
/**
 * Created by hiramekun at 01:31 on 2019-10-03.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vector<vector<char>> s(n, vector<char>(n));
    auto get = [&](ll i, ll add) {
        ll ret = i + add;
        if (ret >= n) ret = ret - n;
        return ret;
    };
    rep(i, n) rep(j, n) {
            cin >> s[i][j];
        }
    ll ans = 0;
    ll a = 0;
    rep(b, n) {
        vector<vector<char>> tmp(n, vector<char>(n));
        rep(i, n) {
            rep(j, n) {
                ll ni = get(i, a), nj = get(j, b);
                tmp[ni][nj] = s[i][j];
            }
        }
        rep(i, n) {
            rep(j, n) {
                if (tmp[i][j] != tmp[j][i]) {
                    goto END;
                }
            }
            if (i == n - 1) ans++;
        }
        END:;
    }

    cout << ans * n << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 436
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define _ <<" "<<
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const int N = 1000 * 1000 ;
int main()
{
    Fast_IO();

int k , x ;
cin >> k >> x ;
for ( int i = x - k + 1 ;  i <= x+ k -1 ; ++i)
    cout<< i <<" " ;

    return 0 ;
}










Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    vector<int>towers(999);
    towers[0] = 1;
    for (int i=1; i<999; i++){
        towers[i] = i+1 + towers[i-1];
    }
    int a, b;
    cin >> a >> b;
    int diff = b-a;
    for (int i=0; i<998; i++){
        if(diff == towers[i+1] - towers[i]){
            cout << towers[i] - a << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

void solve(const double q)
{
  double a = q*0.5;
  while(fabs(a*a*a-q)>=1e-5*q) a -= (a*a*a-q)/(3*a*a);
  printf("%lf\n",a);
}

int main()
{
  double q;
  while(cin>>q,q>0) solve(q);
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,l=0;
  ll a[100005]={};
  
  cin >> n;
  for (i=1;i<=n;i++) cin >> a[i];
  
  sort(a+1,a+n+1);
  
  for (i=1;i<=n;i++){
    a[i]+=a[i-1];
    if (a[i]*2 < a[i+1]) l=i;
  }
  
  cout << n-l << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#pragma region Template

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <bitset>
#include<map>
#include<cmath>
#include <set>
#include<limits.h>
#include<fstream>

#define lli long long int
#define us unsigned short
#define mod 1000000007
#define INF 1e18+5

#define vi vector<int>
#define vus vector<unsigned short>
#define vlli vector<long long int>
#define vs vector<string>
#define mii map<int,int>
#define mlli map<long long int,long long int>

#define w(t) int t; cin>>t;while(t--)

using namespace std;

#pragma endregion

int main()
{
	lli H, W;
	cin >> H >> W;
	vector<vector<char>> m(H+1,vector<char>(W+1));
	vector<vlli> dp(H+1,vector<lli>(W+1));

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cin >> m[i][j];
		}
	}

	dp[1][0] = 1;

	for (lli i = 1; i <= H; i++)
	{
		for (lli j = 1; j <= W; j++)
		{
			if (m[i][j] == '.')
				dp[i][j] = dp[i - 1][j]%mod + dp[i][j - 1]%mod;
			else
				dp[i][j] = 0;
		}
	}

	cout << dp[H][W]%mod <<endl;

	return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()

using namespace std;

typedef vector<int> vi;
typedef long long  ll;

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

map<int,int> m;

int main()
{
    string x;
    cin >> x;
    if(x.find("YAKI") == 0){
        puts("Yes");
    }
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
def main():
    s = int(input())
    i = 1
    save_num = [s]
    while True:
        i += 1

        if s % 2 == 0:
            s = s // 2
        else:
            s = 3 * s + 1

        if s not in save_num:
            save_num.append(s)
        else:
            ans = i
            break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
using namespace std;
typedef long long LL;

int main(void) {
	LL a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - max(a, max(b, c)) << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
days = [list(map(int, input().split())) for i in range(N)]
scores = [[0,0,0] for i in range(N)]
scores[0] = days[0]

for i in range(N-1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            newscore = days[i+1][j] + scores[i][k]
            if newscore > scores[i+1][j]:
                scores[i+1][j] = newscore

print(max(scores[-1]))

Measured memory_bytes: 47332
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	string a, b, c;
	cin >> a >> b >> c;
	string ans = "";
	ans += a[0];
	ans += b[0];
	ans += c[0];
	transform(ALL(ans), ans.begin(), ::toupper);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r;
    cin >> r;
    cout << fixed << setprecision(15);
    cout << 2 * PI * r << endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;

int cDiv(int x, int y) { return (x+y-1)/y; }


int main() {
  ll n, m; cin >> n >> m;

  V ans(m+2);
  rep(i, n) {
    int l, r; cin >> l >> r;
    int d = 1;
    while (d <= l) {
      int a = cDiv(l, d);
      int x = cDiv(l, a);
      int y = r/a+1;
      if (a > 1) chmin(y, cDiv(l, a-1));
      ++ans[x];
      --ans[y];
      if (a == 1) break;
      d = cDiv(l, a-1);
    }
  }

  rep(i, m) ans[i+1] += ans[i];
  rep(i, m) cout << ans[i+1] << '\n';
  return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  
  int sum = 0;
  for(int i = A; i <= B; i++) {
    int s= i / 10000, t= i % 10;
    int u= i / 1000 % 10, v= i / 10 % 10;
    if (s == t && u == v ) sum++;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
# include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define in freopen( "input.txt" , "r" , stdin );
#define out freopen( "output.txt" , "w" , stdout );

using namespace std ;

int N2 = 2 * ( 1e5 + 7 ) ;

ll N1 = 1e7 + 7 ;

int main( ){

    // in

    // out

    double long n ;

    cin >> n ;

    double long u = n / 3.0 ;

    long double r = ( u * u ) * u ;

    cout<<fixed<<setprecision(11)<< r << endl ;


}


Measured memory_bytes: 3768
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
 
n,a,b,c,d = map(int,input().split())
a-=1;b-=1;c-=1;d-=1
s = input()
if (a < b and c<d):
        if  "##" in s[a:c+1]:
                print("No")
                exit()
        if   "##" in s[b:d+1]:
                print("No")
                exit()
        print("Yes")
else:
        if  "##" in s[a:c+1]:
                print("No")
                exit()
        if   "##" in s[b:d+1]:
                print("No")
                exit()
        if  "..." in s[b-1:d+2]:
                print("Yes")
                exit()
        print("No")

Measured memory_bytes: 40816
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef long long ll;

long long dp[1<<16];

int main() {
  int n;
  while(cin>>n, n) {
    ll l[n];
    int mask[n];
    REP(i, n) {
      int m;
      cin >> m >> l[i];
      mask[i] = 0;
      REP(j, m) {
        int s, e;
        cin >> s >> e;
        for (int k=s-6; k<e-6; ++k) {
          mask[i] |= 1<<k;
        }
      }
      //cout << bitset<32>(mask[i]) << endl;
    }
    memset(dp, 0, sizeof(dp));
    ll ans = 0;
    REP(i, n) {
      REP(j,1<<16) {
        if ((j & mask[i]) == 0) {
          dp[j|mask[i]] = max(dp[j|mask[i]], dp[j] + l[i]);
          ans = max(ans, dp[j|mask[i]]);
        }
      } 
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut a: Vec<usize> = sc.vec(n);
    a.sort();
    let mut bc: Vec<(usize, usize)> = (0..m)
        .map(|_| {
            let b = sc.read();
            let c = sc.read();
            (b, c)
        })
        .collect();
    bc.sort_by_key(|k| k.1);
    bc.reverse();
    let mut idx = 0;
    for &(b, c) in bc.iter() {
        let mut tmp_b = b;
        while tmp_b > 0 && idx < n && a[idx] < c {
            a[idx] = c;
            idx += 1;
            tmp_b -= 1;
        }
    }
    let sum = a.iter().fold(0, |sum, a| sum + a);
    println!("{}", sum);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12668
n, m = map(int, input().split())
flag = [True] * (n + 1)
cnt = [0] * (n + 1)
for i in range(m):
    a = int(input())
    flag[a] = False

for i in range(n, -1, -1):
    if flag[i]:
        if i == n or i == n - 1:
            cnt[i] = 1
        else:
            cnt[i] = (cnt[i + 1] + cnt[i + 2]) % (10 ** 9 + 7)
    else:
        cnt[i] = 0
print (cnt[0])

Measured memory_bytes: 7668
#include<stdio.h>

int main(void){
  int n,a,b,s=0,i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    s+=b-a+1;
  }

  printf("%d\n",s);

  return 0;
}




Measured memory_bytes: 128
x,y=map(int,input().split())
ans=0
if x==1:
  ans+=3*(10**5)
elif x==2:
  ans+=2*(10**5)
elif x==3:
  ans+=1*(10**5)

if y==1:
  ans+=3*(10**5)
elif y==2:
  ans+=2*(10**5)
elif y==3:
  ans+=1*(10**5)

if x==1 and y==1:
  ans+=4*(10**5)
print(ans)

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


int main() {
    vector<int> a(1100000);
    set<int> c;
    cin >> a[1];
    c.insert(a[1]);

    int ans;

    for(int i=2;i<1100000;i++){
        if(a[i-1]%2==0) a[i]=a[i-1]/2;
        else a[i]=3*a[i-1]+1;

        c.insert(a[i]);

        if(c.size()==i-1){
            ans=i;break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4608
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var li = 2L;
            var lj = 1L;
            var current = 0L;
            if (N == 1)
            {
                return 1;
            }
            for (var i = 1; i < N; i++)
            {
                current = li + lj;
                li = lj;
                lj = current;
            }
            return current;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27276
a,b,c = map(int, input().split())
k = int(input())
status = "No"
for i in range(k):
    if a >= b:
        b = 2 * b
    elif b >= c:
        c = 2 * c
    
    if a < b and b < c:
        status = "Yes"
        break
    else:
        status = "No"


print(status)

Measured memory_bytes: 61656
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(N-1,0,-1):
  for a in range(i-1,-1,-1):
    for b in range(a-1,-1,-1):
      if L[i]<L[a]+L[b] and L[i]!=L[a]!=L[b]:
        ans+=1
print(ans)

Measured memory_bytes: 9116
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a = 0, b = 0, d = 1000, e;
	string s;
	cin >> s;
	for (int h = 0; h < s.size() - 2; h++) {
		a = abs((s[h] - '0') * 100 + (s[h + 1] - '0') * 10 + (s[h + 2] - '0') - 753);
		if (a < d) {
			d = min(a, d);
		}
	}
	cout << d << endl;
	cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<endl
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int a; string s;
	cin>>a>>s;
	
	if(a<3200) cout<<"red"<<'\n';
	else cout<<s<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int A[15];
int x[15][15];
int y[15][15];

int bit_num(int bit_set){
    int ret = 0;
    for(int i = 0; i < 15; i++){
        if(((bit_set >> i) & 1) == 1){
            ret ++;
        }
    }
    return ret;
}

bool is_valid(int bit_set, int N){
    for(int i = 0; i < N; i++){
        if(((bit_set >> i) & 1) == 1){
            for(int j = 0; j < A[i]; j++){
                if(y[i][j] == 0 && ((bit_set >> (x[i][j] - 1)) & 1) == 1){
                    return false;
                }
                if(y[i][j] == 1 && ((bit_set >> (x[i][j] - 1)) & 1) == 0){
                    return false;
                }
            }
        }
    }
    return true;
}
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        for(int j = 0; j < A[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }

    int ans = 0;
    for(int bit_set = 0; bit_set < (1 << N); bit_set ++){
        if(is_valid(bit_set, N)){
            ans = max(ans, bit_num(bit_set));
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
  ll x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<ll>p(a),q(b);
  priority_queue<ll>r,color;
  for(int i=0; i<a; i++) cin >> p[i];
  for(int i=0; i<b; i++) cin >> q[i];
  for(int i=0; i<c; i++){
    ll z;
    cin >> z;
    r.push(z);
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  for(int i=0; i<x; i++) color.push(p[i]);
  for(int i=0; i<y; i++) color.push(q[i]);
  
  ll ans=0;
  for(int i=0; i<x+y; i++){
    if(r.size()==0){
      ll v;
      v=color.top();
      color.pop();
      ans+=v;
    }
    else{
      ll v,w;
      v=color.top();
      w=r.top();
      if(v>w){
        color.pop();
        ans+=v;
      }
      else{
        r.pop();
        ans+=w;
      }
    }
  }
  
  cout << ans << endl;
  
}
  


Measured memory_bytes: 7704
N,K = map(int,input().split())
S = list(map(int,input().split()))
divisor = 10**9 + 7

m = []
for i in range(N-1):
  cnt = sum([1 for j in range(i,N) if S[i] > S[j]])
  m.append(cnt)

f = sum(m) # within one copies

m = []
for i in range(N):
  cnt = sum([1 for j in range(0,N) if S[i] > S[j]])
  m.append(cnt)

g = sum(m) # between two copies
  
#print(m)
import decimal as d
f = d.Decimal(f)
g = d.Decimal(g)
ans = (f*K + g*K*(K-1)/2) % divisor
print(ans)
  

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    vec a(n);
    rep(i, n) cin >> a[i];
    set<int> s;
    rep(i, 1 << n){
        int tmp = 0;
        rep(j, n){
            if(i & (1 << j)) tmp += a[j];
        }
        s.insert(tmp);
    }
    int q; cin >> q;
    rep(i, q){
        int m; cin >> m;
        if(s.count(m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



Measured memory_bytes: 7272
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[][] S = new String[H][W];

		for(int i = 0; i < H; i++) {
			S[i] = sc.next().split("");
		}

		String result = "Yes";
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(S[i][j].equals(".")) continue;
				if(i -1 >= 0 && S[i-1][j  ].equals("#")) continue;
				if(i +1 <  H && S[i+1][j  ].equals("#")) continue;
				if(j -1 >= 0 && S[i  ][j-1].equals("#")) continue;
				if(j +1 <  W && S[i  ][j+1].equals("#")) continue;
				result = "No";
				break;
			}
		}
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int len = S.size();
    map<char, int>m;
    for (int i=0; i < len; i++) {
        if (m.count(S[i]) > 0) {
            m[S[i]] = m[S[i]] + 1;
        } else {
            m[S[i]] = 1;
        }
    }

    for (int i=1; i<N; i++) {
        string n;
        cin >> n;
        map<char, int> hikaku;
        int n_size = n.size();
        for (int j=0; j < n_size; j++) {
            if (m.count(n[j]) > 0) {
                if (hikaku.count(n[j]) > 0) {
                    hikaku[n[j]] = 1 + hikaku[n[j]];
                } else {
                    hikaku[n[j]] = 1;
                }
            }
        }

        for (const auto j: m){
            int count = hikaku[j.first];
            hikaku[j.first] = min(j.second, count);
        }

        m = hikaku;
    }

    vector<string>vec;
    for (const auto j:m) {
        int count = m[j.first];
        while (count > 0) {
            vec.emplace_back(string() + j.first);
            count -= 1;
        }
    }

    sort(vec.begin(), vec.end());
    int vec_size = vec.size();
    for (int i=0; i < vec_size; i++) {
        cout << vec[i];
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;
int main(void){
    char a , b ;
    cin >> a >> b ;
    if(a == 'H'){
        if(b == 'H'){
            cout << "H" << endl;
        }else{
            cout << "D" << endl;
        }
    }else{
        if(b=='H'){
            cout <<"D" << endl;
        }else{
            cout << "H" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  while(1){
    int n, x, sum = 0;
    scanf("%d%d", &n, &x);
    if(n == 0 && x == 0) break;
    for(int i = 1; i <= n - 2; i++){
      for(int j = i + 1; j <= n - 1; j++){
        for(int k = j + 1; k <= n; k++){
          if(i + j + k == x) sum++;
        }
      }
    }
    printf("%d\n", sum);
  }
}



Measured memory_bytes: 2752
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def string_to_number(a):
    return 1 << (ord(a) - ord("a"))

class SegmentTree:
    def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
    def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
    def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if a & 1 == 0:
                res |= self.seg[a]
            if b & 1 == 1:
                res |= self.seg[b]
                b -= 1
            a = a // 2
            b = (b - 1) // 2
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1")


def main():
    N = int(readline())
    s = readline().strip()
    seg = SegmentTree(list(s))
    #print(seg.seg)

    Q = int(readline())
    for _ in range(Q):
        q, a, b = map(str, readline().split())
        if q == "1":
            seg.update(int(a)-1, b)
        else:
            print(seg.query(int(a)-1, int(b)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 47400
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

C = [''] * N
ans = 0
for i, t in enumerate(T):
    if t == 'r':
        c = 'p'
        win = P

    if t == 's':
        c = 'r'
        win = R

    if t == 'p':
        c = 's'
        win = S

    if (i - K >= 0) and (C[i - K] == c):
        win = 0

    if win != 0:
        C[i] = c
    ans += win

print(ans)


Measured memory_bytes: 4084
import sys

def solve(N, mounts):
    count = 0
    for i in xrange(N):
        max_h = max(mounts[0:i+1])
        if mounts[i] >= max_h:
            count += 1
    return count

if __name__ == '__main__':

    N = sys.stdin.readline().strip()
    mounts = map(int, sys.stdin.readline().strip().split(" "))
    ans = solve(int(N), mounts)
    print ans

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int x;
 	cin >> x;
 	int a[x];
 	for (int i = 0; i < x; i++){
 		cin >> a[i];
 	}
 	sort(a,a+x);
 	int ann;
 	for (int i = 0; i < x-1; i++){
 		ann=ann+a[i];
 	}
 	int anm=a[x-1];
 	if(ann<=anm){
 		cout << "No" << endl;
 	}else{
 		cout << "Yes" << endl;
 	}
 }

Measured memory_bytes: 256
// Aizu 2833: Displayed tweets
// 2017.11.25 bal4u@uu

#include <stdio.h>
#include <string.h>

int a[100001], k[100001];
char f[100001];

char buf[20], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int N, K, i, re, v, ans;

	fgets(p=buf, 20, stdin), N = getint(), p++, K = getint();
	memset(k, 0x33, sizeof(int)*(N+1));
	for (i = 1; i <= N; i++) fgets(p=buf, 10, stdin), a[i] = getint();

	ans = 0;
	for (i = N; i > 0; i--) {
		re = a[i];
		if (!re) ans++;
		else {
			if (!f[i]) v = 0, ans++;
			else if ((v = k[i]) < K) ans++;
			v++;
			if (v < K && k[re] > v) k[re] = v;
			f[re] = 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2728
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	string ans = "NG";
	for (int i=A; i<=B; i++) {
		if (i % K == 0) ans = "OK";
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    
    vector<string> a(n);

    vector<int> b;
    vector<int> c;

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

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a[i][j] == '#'){
                b.push_back(j);
                c.push_back(i);
            }
        }
    }

    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    c.erase(unique(c.begin(), c.end()), c.end());
    
    for(int i = 0; i < c.size(); i++){
        for(int j = 0; j < b.size(); j++){
            cout << a[c[i]][b[j]];
        }
        cout << endl;
    }
    

    return 0;
}

Measured memory_bytes: 384
fun main() {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val AM = readLine()!!.split(" ").map(String::toInt)
    val sum = AM.sum()
    if (N < sum) {
        println("-1")
    } else {
        println(N - sum)
    }
}





Measured memory_bytes: 39320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H>> W;
 
  // N要素の配列
 
 
  // 入力処理
  for (int i = 0; i < W+2; i++) {
    cout << "#";
  }
  
  cout << "" <<endl;
  
  for (int i = 0; i < H; i++) {
    cout << "#";
  for (int j = 0; j < W; j++) {
    vector<char> A(W);
    cin >> A.at(j);
    cout << A.at(j);
  }
    cout << "#"<<endl;
  }
 
    for (int i = 0; i < W+2; i++) {
    cout << "#";
  }
  
  cout << "" <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  for (int i = 0; i < (1 << n); i++){
    cout << i << ':';
    for (int j = 0; j < n; j++){
      if (i & (1 << j)){
        cout << ' ' << j;
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3108
/// Author:- Lazy_Coder

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

long computeXOR(const int n)
{

    switch(n & 3)
    {
    case 0: return n;
    case 1: return 1;
    case 2: return n + 1;
    case 3: return 0;
    }
}

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

ll power(ll x, ll y)
{
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='1')
        {
            s[i] = '9';
        }
        else
            
        {
            s[i]='1';
        }
    }
    cout<<s<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  
  if (s == u) --a;
  else --b;
  
  cout << a << " " << b << endl;
}

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

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

    auto taka = (c + b - 1) / b;
    auto aoki = (a + d - 1) / d;

    cout << (taka <= aoki ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int n, k, r, s, p;

int get(char c) {
    if (c == 'r')
        return p;
    if (c == 'p')
        return s;
    if (c == 's')
        return r;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    forn (i, 0, k)
        t += '#';
    long long ans = 0;
    forn (i, 0, k) {
        int row = 1;
        for (int j = i + k; j < sz(t); j += k) {
            if (t[j] == t[j - k])
                row++;
            else {
                ans += 1LL * get(t[j - k]) * ((row + 1) / 2);
                row = 1;
            }
            //cout << ans << " ";
        }
        //cout << ans << " ";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 592
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        int[] count = new int[26];
        foreach (var c in s)
        {
            count[c - 'a']++;
        }
        Console.WriteLine(count.All(x => x % 2 == 0) ? "Yes" : "No");
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    string S, T; cin >> S >> T;
    
    int ans = 0;
    rep(i, S.length()) {
        if (S[i] != T[i]) ans++;
    }

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


Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long 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;
}

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

Measured memory_bytes: 3592
import sys
sys.setrecursionlimit(10000)
def resolve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    A = [0] + A + [0]
    Diff = [0]
    for i in range(1, N+2):
        Diff.append(abs(A[i] - A[i-1]))
    
    total = sum(Diff)
    for i in range(1, N+1):
        print(total + abs(A[i-1] - A[i+1]) - Diff[i] - Diff[i+1])

    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 57376
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
bool cross(int a, int b);

signed main()
{
    string input;
    while (cin >> input, input[0] != '#') {
        int lc = 0, rc = 0, ll, lr, rl, rr;
        rep(i, input.length()) {
            if (!i) {
                ll = input[0];
                continue;
            }
            if ((i+lc) % 2) {
                if (cross(ll - '0', input[i] - '0')) {
                    lc++;
                    ll = input[i];
                } else {
                    lr = input[i];
                }
            } else {
                if (cross(input[i] - '0', lr - '0')) {
                    lc++;
                    lr = input[i];
                } else {
                    ll = input[i];
                }
            }
        }
        rep(i, input.length()) {
            if (!i) {
                rr = input[0];
                continue;
            }
            if ((i+rc) % 2) {
                if (cross(input[i] - '0', rr - '0')) {
                    rc++;
                    rr = input[i];
                } else {
                    rl = input[i];
                }
            } else {
                if (cross(rl - '0', input[i] - '0')) {
                    rc++;
                    rl = input[i];
                } else {
                    rr = input[i];
                }
            }
        }
        cout << min(lc, rc) << endl;
    }
    return 0;
}

bool cross(int a, int b)
{
    if (!(a % 3)) {
        if (b % 3) {
            return true;
        } else {
            return false;
        }
    } else if ((a % 3) == 2) {
        if (b % 3 == 1) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T, typename S> T expo(T b, S e, const T &m){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b)%m, e>>1, m): (b*expo((b*b)%m, e>>1, m))%m;}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 410;
const int INF = 1e9;
int n;

int dp[41][MAXN][MAXN];
int ma, mb;
int a[MAXN], b[MAXN], c[MAXN];

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> ma >> mb;
  for(int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for(int i = 0; i < 41; i++) {
    for(int j = 0; j < MAXN; j++) {
      for(int k = 0; k < MAXN; k++) dp[i][j][k] = INF;
    }
  }
  dp[0][0][0] = 0;
  for(int i = 1; i <= n; i++) {
    for(int j = 0; j <= 400; j++) {
      for(int k = 0; k <= 400; k++) {
        dp[i][j][k] = dp[i-1][j][k];
        if(j >= a[i] and k >= b[i]) {
          dp[i][j][k] = min(dp[i][j][k], dp[i-1][j - a[i]][k - b[i]] + c[i]);
        }
      }
    }
  }
  int res = INF;
  for(int amt_a = 1; amt_a <= 400; amt_a++) {
    if((mb * amt_a) % ma == 0) {
      int amt_b = (mb * amt_a) / ma;
      if(amt_b < MAXN) {
        res = min(res, dp[n][amt_a][amt_b]);
      }
    }
  }
  if(res == INF) res = -1;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 27136
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

#define INF (1LL<<29)

ll dp[(1LL<<12)+5][1005];

ll A[1005];
ll B[1005];

ll n,m;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	for(ll i=0;i<m;i++)
	{
	    cin>>A[i];
	    ll tmp;
	    cin>>tmp;
	    while(tmp--)
	    {
	        ll lol;
	        cin>>lol;
	        lol--;
	        B[i]|=(1LL<<lol);
	    }
	}
	for(ll i=0;i<=(1LL<<n);i++)
	{
	    for(ll j=0;j<=m;j++)
	    {
	        dp[i][j]=INF;
	    }
	}
	dp[0][0]=0;
	for(ll mask=0;mask<(1LL<<n);mask++)
	{
	    for(ll j=0;j<m;j++)
	    {
	        if(dp[mask][j]==INF)
	            continue;
	        dp[mask][j+1]=min(dp[mask][j],dp[mask][j+1]);
	        dp[mask|B[j]][j+1]=min(dp[mask|B[j]][j],dp[mask|B[j]][j+1]);
	        dp[mask|B[j]][j+1]=min(dp[mask|B[j]][j+1],dp[mask][j]+A[j]);
	    }
	}
	if(dp[(1LL<<n)-1][m]==INF)
	{
	    cout<<-1;
	}
	else
	{
	    cout<<dp[(1LL<<n)-1][m];
	}
    return 0;
}


//252908XL

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

using namespace std;
typedef long long ll;

#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(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

// bool isOk(int index, int key)
// {
//     if (d[index] >= key)
//         return true;
//     else
//         return false;
// }

// int C(int key)
// {
//     int ng = -1;
//     int ok = N;

//     while (abs(ok - ng) > 1)
//     {
//         int mid = (ok + ng) / 2;
//         if (isOk(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<pair<int, int>> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(all(p));

    ll cnt = 0;
    rep(i, N)
    {
        if (cnt + p[i].second < K)
        {
            cnt += p[i].second;
        }
        else
        {
            cout << p[i].first << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024