akhauriyash/Code-Regression huggingface dataset:
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e11
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
map<ll,ll> ma;
map<ll,ll> :: iterator it;
ll bitDiff(ll A,ll B)
{
    ll cnt = 0;
    for (ll i = 0; i < 32; i++)
    {
        if (((A >> i) & 1LL) != ((B >> i) & 1LL))
            cnt++;

    }
    return cnt;
}
ll dp[1009][5009];
ll key[1009];
ll cost[1009];
ll n,m;
ll sol(ll keyno,ll mask)
{
    if(dp[keyno][mask]!=-1)
    {
        return dp[keyno][mask];
    }
    if(keyno==m)
    {
        if(mask==(1<<n)-1)
            return dp[keyno][mask] =0;
        return dp[keyno][mask] =inf;
    }
    ll res = inf;
    if(bitDiff(mask,key[keyno])!=0)
    {
        res = min(res,cost[keyno]+sol(keyno+1,mask | key[keyno]));
    }
    res = min(res,sol(keyno+1,mask));

    return dp[keyno][mask] = res;
}
int main()
{
    ll i,t,k,j,x=0,y=0;
    FAST
    cin>>n>>m;

    for(i=0;i<m;i++)
    {
        ll cnt;
        cin>>cost[i]>>cnt;
        k = 0;
        while(cnt--)
        {
            cin>>x;
            k  =k| (1<<(x-1));
        }
        key[i] = k;

    }
    memset(dp,-1,sizeof dp);
    x = sol(0,0);
    if(x>=inf)
        cout<<-1<<endl;
    else cout<<x<<endl;

    return 0;
}



Measured memory_bytes: 43212
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;

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

vector<int> x, y, h;


int is_ok(int Cx, int Cy, int X_base, int Y_base, int h_base, int X, int Y, int h) {

	if (h > 0 && abs(X_base - Cx) + abs(Y_base - Cy) + h_base == abs(X - Cx) + abs(Y - Cy) + h) {
		return 1;
	}

	else if (h == 0 && abs(X_base - Cx) + abs(Y_base - Cy) + h_base <= abs(X - Cx) + abs(Y - Cy) + h) {
		return 1;
	}

	else {

		return 0;
	}

}



int main() {
	int N;
	int s, t, u;
	int X, Y;
	int H;
	int ansx = 0, ansy = 0, ansh = 0;

	cin >> N;

	rep(i, N) {
		cin >> s >> t >> u;

		x.push_back(s);
		y.push_back(t);
		h.push_back(u);

	}

	rep(i, N) {
		if (h[i] > 0) {
			X = x[i];
			Y = y[i];
			H = h[i];
			break;
		}
	}

	bool ok = true;
	
	rep(i, 101) {
		rep(j, 101) {
			rep(k, N) {
				if (is_ok(i, j, X, Y, H, x[k], y[k], h[k]) != 1) {
					ok = false;
					break;
				}

				
			}

			if (ok == true) {
				ansx = i;
				ansy = j;
				ansh = abs(X - ansx) + abs(Y - ansy) + H;


				cout << ansx << " "<<  ansy << " "<< ansh << endl;

				

				return 0;
			}

			ok = true;

		}
	}
	



	
	return 0;
}

Measured memory_bytes: 256
D = {}
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    D[str(i + 1)] = a[i]

D2 = {k: v for v, k in D.items()}
S = []
for j in range(1, n+1):
    S.append(D2[j])
print(" ".join(S))

Measured memory_bytes: 31708
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [0]*n
rgcd = [0]*n
lgcd[0] = li[0]
rgcd[-1] = li[-1]

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

for i in range(n-1):
    lgcd[i+1] = gcd(lgcd[i],li[i+1])
    rgcd[-i-2] = gcd(rgcd[-i-1],li[-(i+2)])

gcd_list = [gcd(lgcd[i],rgcd[i+2]) for i in range(n-2)]

gcd_list.append(lgcd[-2])
gcd_list.append(rgcd[1])

print(max(gcd_list))


Measured memory_bytes: 14584
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int i = 0;
    int x;
    while(++i <= n){
        if(i % 3 == 0){
            printf(" %d",i);
            continue;
        }
        x = i;
        while(x){
            if(x % 10 == 3){
                printf(" %d",i);
                break;
            }
            x /= 10;
        }
    }
    printf("\n");
    return 0;
}

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

int main() {

  string S, T;
  cin >> S >> T;

  int cnt = 0;
  for(int i = 0; i < S.length(); i++){
    if(S[i] != T[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3852
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Min__Max_and_Sum
{
    class Program
    {
        static void Main( string[ ] args ) {


            int num = int.Parse( Console.ReadLine( ) );
            var ary = new int[ num ];
            int min = 1000000;
            int max = -1000000;
            long sum = 0;
            string st1 = Console.ReadLine( );
            string [] st2 = st1.Trim( ).Split( ' ' );


            for( int i = 0 ; i < num ; i++ ) {

                ary[ i ] = int.Parse( st2[ i ] );

                if( ary[ i ] > max ) {
                    max = ary[ i ];


                }
                if(ary[ i ] < min ) {
                    min = ary[ i ];


                }
                sum += ary[ i ];
            }

            Console.WriteLine( min + " " + max + " " + sum );

            
           
        }
    }
}



Measured memory_bytes: 18000
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

bool compare(const pair<pair<int,string>,int>  &a, const pair<pair<int,string>,int>  &b){
  if(a.first.second!=b.first.second) return a.first.second < b.first.second;
  else return a.first.first > b.first.first;
}

#if 1
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif


int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    
    vector<pair<int,int>> work(n);

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

    sort( work.begin(), work.end() );

    bool fail = false;
    long long sum = 0;
    for(int i=0; i<n; ++i){
        sum += work[i].second; // 単位時間++
        if( work[i].first < sum ){ // 締め切り過ぎとる
            fail = true;
        }
        else{

        }
    }

    cout << ( fail ? "No" : "Yes" ) << endl;

	return 0;
}


Measured memory_bytes: 3328
import java.io.*;

class Main{
    public static void main(String[] a){
        StringBuffer sb = new StringBuffer();
        for(int i=1; i<=9; i++)
            for(int j=1; j<=9; j++)
                sb.append(i).append("x").append(j).append("=").append(i*j).append("\n");
        System.out.print(sb);
    }
}

Measured memory_bytes: 23932
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
ll n,k;
ll a[200005];
ll f[200005];
bool isOK(ll num){
    ll kk=k;
    for(ll i=0;i<n;i++){
        ll x=num/f[i];
        kk-=max(0ll,a[i]-x);
    }
    return kk>=0;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    cin>>n>>k;
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cin>>f[i];
    sort(a,a+n,greater<ll>());
    sort(f,f+n);
    ll l=-1,r=1e18;
    while(r-l>1){
        ll mid=(r+l)/2;
        if(isOK(mid))
        r=mid;
        else
        l=mid;
    }
    cout<<r;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>

using namespace std;

template<typename T, class Fn>
void split(vector<T>& v, Fn f,  string input, char delimiter=' '){
    stringstream stream(input);
    string field;

    while(getline(stream, field, delimiter)){
        v.push_back(f(field));
    }

    return;
}

int Stoi(string s){
    return stoi(s);
}


int main(int, char**) {
    string line;
    getline(cin, line);

    vector<int> v;
    split<int>(v, Stoi, line);
    sort(v.begin(), v.end());

    vector<int> v_correct = {5, 5, 7};
    cout << ((v == v_correct) ? "YES" : "NO");
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SUN")cout<<7<<endl;
  if(s=="MON")cout<<6<<endl;
  if(s=="TUE")cout<<5<<endl;
  if(s=="WED")cout<<4<<endl;
  if(s=="THU")cout<<3<<endl;
  if(s=="FRI")cout<<2<<endl;
  if(s=="SAT")cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b; string s;
int main()
{
    cin >>a>>b>>s;
    int cnt = 0;
    for(auto x:s) if(x=='-') ++cnt;
    if(s[a] == '-' && cnt==1) puts("Yes");
    else puts("No");
}

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

using vi=vector<int>;
using vvi=vector<vector<int>>;

int main(){
  int n;cin>>n;
  bool x=true;
  vector<pair<int,int>>v(n);
  rep(i,n){
    int a,b;cin>>a>>b;
    v.at(i)=make_pair(b,a);
  }
  sort(v.begin(),v.end());
  int ans=0;
  rep(i,n){
    ans+=v.at(i).second;
    if(ans>v.at(i).first){
      x=false;
      continue;
    }
  }
  if(x)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 1792
### constant

MAX_F = 1.0e20

### subroutines

def catch(fb, dg)
  ## pt = t * fbv + fbp = (t * fbvx + fbpx, t * fbvy + fbpy)
  ## |pt - dgp| = t * dgv
  ## (t * fbvx + fbpx - dgpx) ^ 2 + (t * fbvy + fbpy - dgpy) ^ 2 = t^2 * dgv^2
  ## (fbvx^2 + fbvy^2 - dgv^2) * t^2 +
  ## 2 * (fbvx * (fbpx - dgpx) + fbvy * (fbpy - dgpy)) * t +
  ## (fbpx - dgpx)^2 + (fbpy - dgpy)^2 = 0

  a = fb[2] ** 2 + fb[3] ** 2 - dg[2] ** 2
  b = 2 * (fb[2] * (fb[0] - dg[0]) + fb[3] * (fb[1] - dg[1]))
  c = (fb[0] - dg[0]) ** 2 + (fb[1] - dg[1]) ** 2

  d = b ** 2 - 4 * a * c
  return [nil, nil, nil] if d < 0.0

  sd = Math.sqrt(d)
  t0 = (-b + sd) / (2 * a)
  t1 = (-b - sd) / (2 * a)

  return [nil, nil, nil] if t0 < 0.0 && t1 < 0.0

  t = nil
  if t0 < 0.0
    t = t1
  elsif t1 < 0.0
    t = t0
  else
    t = (t0 < t1) ? t0 : t1
  end

  dgvx = (t == 0.0 ? 0.0 : (fb[2] * t + fb[0] - dg[0]) / t)
  dgvy = (t == 0.0 ? 0.0 : (fb[3] * t + fb[1] - dg[1]) / t)

  [t, dgvx, dgvy]
end

### main

loop do
  n, m = gets.split.map(&:to_i)
  break if n == 0 && m == 0

  dogs = []
  n.times do
    dogs << gets.split.map(&:to_f)
  end
  #p dogs

  frbs = []
  m.times do
    frbs << gets.split.map(&:to_f)
  end
  #p frbs

  catches = n.times.map{0}

  for frb in frbs
    min_t = MAX_F
    min_i = -1
    ts = []

    for i in (0...n)
      ti = catch(frb, dogs[i])
      ts << ti
      if ! ti[0].nil? && min_t > ti[0]
        min_t = ti[0]
        min_i = i
      end
    end
    #p [min_t, min_i]

    catches[min_i] += 1

    for i in (0...n)
      ti = ts[i]
      if ! ti[0].nil?
        dogs[i][0] += ti[1] * min_t
        dogs[i][1] += ti[2] * min_t
      end
    end    
  end

  puts catches.join(' ')
end

Measured memory_bytes: 6200
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
  SS(string,s)
  ll ans=0;
  rep(i,s.size()){
      if(s[i]=='2')ans++;
  }
  p(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define foreach(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<int64, int64> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(a);
    cill(b);
    cill(c);
    cill(x);
    cill(y);
    LL ans = 0;
    LL minxy = min(x, y);
    if (a + b < c * 2){
        ans += minxy * (a + b);
    }else{
        ans += minxy * c * 2;
    }
    x -= minxy;
    y -= minxy;
    if (x > 0){
        ans += x * min(a, c*2);
    }
    if (y > 0){
        ans += y * min(b, c*2);
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s=list(map(int,input()))
lis_one=[]
lis_zero=[]
if s[0]!=1:
    lis_one.append(0)
i=0
if n==1:
    print(1)
    exit()
while i<n-1:
    cnt=1
    while s[i]==s[i+1]:
        cnt+=1
        i+=1
        if i==n-1:
            break
    if s[i]==0:
        lis_zero.append(cnt)
    else:
        lis_one.append(cnt)
    i+=1
ans=0
lis_one.append(0)
lis_zero.append(0)
oone=[]
zzero=[]
oone.append(sum(lis_one[0:k+1]))
zzero.append(sum(lis_zero[0:k]))
for i in range(len(lis_one)-k-1):
    oone.append(oone[i]-lis_one[i]+lis_one[i+k+1])
    zzero.append(zzero[i]-lis_zero[i]+lis_zero[i+k])
for i in range(len(oone)):
    ans=max(ans,oone[i]+zzero[i])
print(ans)

Measured memory_bytes: 48604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int MOD = 1e9+7;
const int INF = 1e17;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

    int N,M; cin >> N >> M;
    int dp[N+1]; rep(i,N+1) dp[i] = 0;
    int m[N+1];
    rep(i,N+1) m[i] = false; 
    rep(i,M){
        int a; cin >> a;
        m[a] = true;
    }
    dp[0] = 1;
    dp[1] = 1;
    if(m[1]) dp[1]=0;
    rng(i,2,N+1){
        if(m[i]) continue;
        dp[i] = (dp[i-1]%MOD+dp[i-2]%MOD)%MOD;
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;




int main() {
    char s[100005],t[100005];
    int q;
    scanf("%s %s",s,t);
    scanf("%d",&q);
    int ss[100005],tt[100005];
    ss[0]=0;
    tt[0]=0;
    for(int i=0;i<=100005-1;i++){
        if(s[i]=='A')ss[i+1]=ss[i]+1;
        else ss[i+1]=ss[i]+2;
    }
    for(int i=0;i<=100005-1;i++){
        if(t[i]=='A')tt[i+1]=tt[i]+1;
        else tt[i+1]=tt[i]+2;
    }
    
    for(int i=1;i<=q;i++){
        int a,b,c,d;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        if((399999+(ss[b]-ss[a-1])-(tt[d]-tt[c-1]))%3==0)printf("YES\n");
        else printf("NO\n");
    }
    
    return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> t(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      t[i] = 1;
    }
  }
  vector<int> tt(N + 1, 0);
  for (int i = 0; i < N; i++) {
    tt[i + 1] = tt[i] + t[i];
  }
  int l, r;
  for (int i = 0; i < Q; i++) {
    scanf("%d %d", &l, &r);
    printf("%d\n", tt[r - 1] - tt[l - 1]);
  }
  return 0;
}


Measured memory_bytes: 1856
#include<iostream>
#include<algorithm>
using namespace std;
int n,c;
int a[30],b[30];
int memo[30][1<<16];
int f(int i,int A)
{
	if(i==n)return 0;
	A|=a[i];
	if(memo[i][A]>=0)return memo[i][A];
	int ans=0;
	for(int j=0;j<c;j++)
	{
		int now=__builtin_popcount(A&b[j]);
		now+=f(i+1,A&~b[j]);
		ans=max(ans,now);
	}
	return memo[i][A]=ans;
}
main()
{
	while(cin>>n>>c,n)
	{
		for(int i=0;i<n;i++)for(int j=0;j<1<<16;j++)memo[i][j]=-1;
		for(int i=0;i<n;i++)
		{
			a[i]=0;
			for(int j=0;j<16;j++)
			{
				int A;cin>>A;a[i]=a[i]*2+A;
			}
		}
		for(int i=0;i<c;i++)
		{
			b[i]=0;
			for(int j=0;j<16;j++)
			{
				int B;cin>>B;b[i]=b[i]*2+B;
			}
		}
		cout<<f(0,0)<<endl;
	}
}



Measured memory_bytes: 10776
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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
















int main(){
    string s;
    cin >> s;
    bool f = true;
    ll n = s.size();
    REP(i, n / 2){
        if(s[i] != s[n - 1 - i]){
            f = false;
        }
    }
    for(ll i = (n + 3) / 2 - 1; i < n; i++){
        if(s[i] != s[n - 1 - (i - ((n + 3) / 2 - 1))]){
            f = false;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define ll long long

int main (){

    int a,b,c;
    
    cin>>a>>b>>c;
    
    if(a+b+c >= 22) cout<<"bust"<<endl;
    
    else cout<<"win"<<endl;
    
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  repr(i,n,0){
    if(s.substr(n-i,i)==t.substr(0,i)){cout<< 2*n-i<<endl;return 0;}
  }
  cout << 2*n<< endl;
  return 0;
}


Measured memory_bytes: 256
object Main {
  def d(a: Seq[Double], b: Seq[Double], p: Int): Double =
    math.pow((a zip b).foldLeft(0.0d){ case (s, t) => s + math.pow(math.abs(t._1 - t._2), p) }, 1.0d / p)

  def di(a: Seq[Double], b: Seq[Double]): Double =
    (a zip b).map(t => math.abs(t._1 - t._2)).max
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val n = scanner.nextInt
    val a = Seq.fill(n)(scanner.nextDouble)
    val b = Seq.fill(n)(scanner.nextDouble)

    println(d(a, b, 1))
    println(d(a, b, 2))
    println(d(a, b, 3))
    println(di(a, b))
  }
}



Measured memory_bytes: 46856
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

struct Edge {
    int to;
    int cost;
    Edge(int t, int c) : to(t), cost(c) {}
};

constexpr int INF = numeric_limits<int>::max();

int V;
int E;
int r;
vector<vector<Edge>> G;

bool bellmanford(int start, vector<int>& d)
{
    d.resize(V);
    fill(begin(d), end(d), INF);
    d[start] = 0;

    REP(i, V) {
        REP(from, V) {
            if(d[from] == INF) continue;
            for(Edge e : G[from]) {
                int d_new = d[from] + e.cost;
                if(d_new < d[e.to]) {
                    d[e.to] = d_new;
                    if(i == V-1) return false;
                }
            }
        }
    }

    return true;
}

void solve()
{
    vector<int> d(V);
    bool ok = bellmanford(r, d);

    if(!ok) {
        cout << "NEGATIVE CYCLE" << "\n";
    }
    else {
        REP(i, V) {
            if(d[i] == INF) {
                cout << "INF" << "\n";
            }
            else {
                cout << d[i] << "\n";
            }
        }
    }
}

int main()
{
    cin >> V >> E >> r;
    G.resize(V);

    REP(_, E) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].emplace_back(t, d);
    }

    solve();

    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int n,m,p,d[100001];

int get_dis(int a,int b){return (n+b-a)%n;}

int main(){
  cin>>n>>m>>p;
  d[m]=p;
  for(int i=0;i<m;i++)cin>>d[i];
  sort(d,++m+d);
  int st=0;
  for(int i=0;i<m;i++) if(d[i]==p) st=i;
  
  int ans=min(get_dis(p,d[(m+st-1)%m]),get_dis(d[(st+1)%m],p));
  for(int i=1;i<m;i++){
    int j=(st+i)%m;
    int dis1=get_dis(p,d[j]);
    int dis2=get_dis(d[(j+1)%m],p);
    ans=min(ans,dis1*2+dis2);
  }

  for(int i=1;i<m;i++){
    int j=(m+st-i)%m;
    int dis1=get_dis(d[j],p);
    int dis2=get_dis(p,d[(m+j-1)%m]);
    ans=min(ans,dis1*2+dis2);
  }
  cout <<ans*100<<endl;
  return 0;
}

Measured memory_bytes: 1220
using System;

class Prog{
  static void Main(){
    int[] ls = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int a = ls[0];
    int b = ls[1];
    int i = 0;
    while(a +(a-1)*i - b < 0){
      i++;
    }
    if(b != 1){
      Console.WriteLine(i+1);
    }else{
      Console.WriteLine(0);
    }
  }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int n, k;
    cin >> n >> k;
    k--;
    string s;
    cin >> s;
    if (s[k] == 'A'){
        s[k] = 'a';
    }else if (s[k] == 'B'){
        s[k] = 'b';
    }else{
        s[k] = 'c';
    }
    cout << s << endl;
    

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll N,K;
	cin >> N>>K;
	vector<ll> a(N + 1);
	repn(i, N) cin >> a[i];

	ll m = 0;
	ll g = a[1];

	repn(i, N) {
		m = max(m, a[i]);
		g = gcd(g, a[i]);
	}

	if (K <= m && K%g == 0) { cout << "POSSIBLE"; }
	else { cout << "IMPOSSIBLE"; }

	
	system("PAUSE");

}





Measured memory_bytes: 1272
h, w = map(int, input().split())
list_prob = []
for i in range(0,h):
    list_prob.append(list((map(str, input().split()))))
#print(list_prob)

for row in list_prob:
    for col in row:
        #print(col)
        if col == "snuke":
            num_row = list_prob.index(row)
            num_col = row.index(col)
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

print(alphabet[num_col] + str(num_row+1))


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a,b,c,d,i,j,f[250000];
    scanf("%d",&a);
    for(i=1;i<=a;i++)
    {
        scanf("%d",&b);
        f[b]=i;
    }
    for(i=1;i<=a;i++)
    {
        printf("%d",f[i]);
        if(i!=a)printf(" ");
        else printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1152
//https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_B
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

typedef struct segtree{
	int n;
	vector<int> a;
	segtree(){};
	segtree(int n){init(n);};

	void init(int n_){
		n = 1;
		while(n<n_)n*=2;
		a.resize(2*n-1,0);
	}

	void update(int pos,int x){
		pos += n-1;
		a[pos]+=x;
		while(pos>0){
			pos = (pos-1)/2;
			a[pos] += x;
		}
	}

	int getSum(int ll,int rr){
		int vl=0,vr=0;
		for (int l=ll+n, r=rr+n ; l<r ; l=(l>>1),r=(r>>1)){
			if(l&1) vl=vl+a[l-1],l++;
			if(r&1) r--,vr=vr+a[r-1];
		}
		return vl+vr;
	}

}segtree;

int main()
{
	int n,q;
	cin>>n>>q;
	segtree seg(n);
	rep(qq,q){
		int query,x,y;
		cin>>query>>x>>y;
		if(query==0)seg.update(x,y);
		else cout<<seg.getSum(x,y+1)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
signed main() {
  int n,k,s;
  cin >> n >> k >> s;
  int a = 1e9;
  if(s==1e9) a = 1;

  rep(i,n) {
    if(i<k) cout << s <<" "<< flush;
    else cout << a << " "<< flush;
  }
  cout << "" << endl;


  return 0;
}


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

int main(){
  int N;cin>>N;
  bool ans=(N%4==0);
  if ((N%4==1&&N>20)||(N%4==2&&N>13)||(N%4==3&&N>6)){
    ans=1;
  }
  cout<<(ans?"Yes":"No")<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
int main() {
    int N, W;
    cin >> N >> W;

    vector<vector<Int>> dp = vector<vector<Int>>(N+10,vector<Int>(W+10,0));
    vector<Int> weights = vector<Int>(N);
    vector<Int> values = vector<Int>(N);

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

    for(int i =0;i<W; i++){
        dp[0][W] = 0;
    }

    for(int i = 0; i<N; ++i){
        for(int w=0; w<=W; ++w){
            if(w >= weights[i]){
                dp[i+1][w] =  max(
                        dp[i][w-weights[i]]+values[i],
                        dp[i][w]
                );
            }else{
                dp[i+1][w] = dp[i][w];

            }

        }
    }


    cout <<  dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 87296
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
        int k;
        cin >> k;
        ll ans,count=0;
        priority_queue<ll ,vector<ll>,greater<ll>>pq;
//        if(k<=12)
//        {
//            cout<< k << endl;
//            return 0;
//        }
        for(int i=1;i<=9;i++)
        {
            pq.push(i);
        }
        while(true)
        {
            ll num=pq.top();
            pq.pop();
            count++;

            if(count==k)
            {
                ans=num;
                break;
            }
            ll ld=num%10;
            ll num1=num*10+ld;
            pq.push(num1);

            if(ld!=0)
            {
                num1=num*10+ld-1;
                pq.push(num1);
            }
            if(ld!=9)
            {
                num1=num*10+ld+1;
                pq.push(num1);
            }
        }
        cout<<ans;




    }
    return 0;
}


Measured memory_bytes: 5296
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	h, _ := strconv.Atoi(Scanner())
	w, _ := strconv.Atoi(Scanner())
	k, _ := strconv.Atoi(Scanner())
	s := make([][]int, h)
	for i := 0; i < h; i++ {
		t := Scanner()
		x := make([]int, w)
		for j := 0; j < w; j++ {
			if string(t[j]) == "1" {
				x[j] = 1
			}
		}
		s[i] = x
	}
	ps := make([][]int, 0)
	p := make([]bool, 0)
	ps = perm(h, p, ps)
	ans := h * w
	for _, list := range ps {
		ln := len(list) - 1
		num := make([][]int, ln)
		for i := 0; i < len(list)-1; i++ {
			l, r := list[i], list[i+1]
			x := make([]int, w)
			for j := 0; j < w; j++ {
				for k := l; k < r; k++ {
					x[j] += s[k][j]
				}
			}
			num[i] = x
		}
		t := make([]int, ln)
		g := true
		a := 0
		for i := 0; i < w; i++ {
			f := true
			for j := 0; j < ln; j++ {
				t[j] += num[j][i]
				if num[j][i] > k {
					g = false
					break
				}
				if t[j] > k {
					f = false
					break
				}
			}
			if !g {
				break
			}
			if !f {
				a++
				for j := 0; j < ln; j++ {
					t[j] = num[j][i]
				}
			}
		}
		a += ln - 1
		if g && a < ans {
			ans = a
		}
	}
	fmt.Println(ans)
}
func perm(n int, p []bool, ret [][]int) [][]int {
	if len(p) == n-1 {
		x := make([]int, 1)
		for i, v := range p {
			if v {
				x = append(x, i+1)
			}
		}
		x = append(x, n)
		ret = append(ret, x)
		return ret
	} else {
		ret = perm(n, append(p, true), ret)
		ret = perm(n, append(p, false), ret)
	}
	return ret
}


Measured memory_bytes: 5504
n, a, b = [int(item) for item in input().split()]
s = input().rstrip()

domestic = 0; foreign = 0
for item in s:
    if item == "a":
        if domestic + foreign < a + b:
            print("Yes")
            domestic += 1
        else:
            print("No")
    elif item == "b":
        if domestic + foreign < a + b and foreign < b:
            print("Yes")
            foreign += 1
        else:
            print("No")
    elif item == "c":
        print("No")
    
    

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

int f(int n, int k, vector<int> &v)
{
    vector<int> dp(n+1);
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(v[2]-v[1]);
    
    for(int i=3; i<=n; i++){
      	int mi=INT_MAX;
      	for(int j=1; j<=k; j++){
          if((i-j) < 1)
            break;
          mi = min(mi, dp[i-j]+ abs(v[i]-v[i-j]));
        }
        dp[i] = mi;
    }
    return dp[n];
}

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n+1);
  v[0]=0;
  for(int i=1; i<=n; i++)
      cin >> v[i];
  cout << f(n, k, v) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<lli,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int inf = 1e9;
const int maxn = 305;
Double dp[maxn][maxn][maxn];
int cnt[4];
int main(){__
	int n;
	cin >> n;
	for(int i=1; i <=n; i++){
		int x;
		cin >> x;
		cnt[x]++;
	}

	dp[cnt[3]][cnt[2]][cnt[1]] = 1.0;
	Double ans = 0.0;
	cout << fixed << setprecision(10);
	for(int i= maxn-1; i >=0; i--){
		for(int j=maxn-1; j>=0; j--){
			for(int k=maxn-1; k>=0; k--){
				if(!j && !i && !k) continue;
				Double todas = i+j+k;
				//Pongo mi valor
				ans+= dp[i][j][k] * (1.0 / (todas/Double(n)));
				//cout << "ans suma " << ans << endl;
				//paso proba a las demas
				if(i-1 >=0)
					dp[i-1][j+1][k]+= (dp[i][j][k] * (Double(i)/todas));
				if(j-1 >=0)
					dp[i][j-1][k+1]+= (dp[i][j][k] * (Double(j)/todas));
				if(k-1 >=0)
					dp[i][j][k-1]+= (dp[i][j][k] * (Double(k)/todas));
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 447040
K=int(input())
S=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(S[K-1])


Measured memory_bytes: 2940
n, m = gets.chomp.split(' ').map(&:to_i)
sc = []

m.times do
  sc << gets.chomp.split(' ').map(&:to_i)
end

for i in 0...1000
  i_s = i.to_s
  ok = true
  next if (i_s.length != n)
  sc.each do |pair|
    ok = false if (i_s[pair[0]-1] != pair[1].to_s)
  end
  if (ok)
    puts i_s
    exit
  end
end

puts '-1'


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define se second
#define pb push_back
using namespace std;
ll ans , n , cnt ,a  , b;

string s , s1;
int type = 0;
int main(){
    ios_base::sync_with_stdio( false );
        ll T;
        cin >> a >> b;
        for( int i = 0;i < a;i ++ )
            s1+=to_string(b);
        for( int i = 0;i < b;i ++ )
            s+=to_string(a);
            cout << min( s1 , s );
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n,m,t[100001],p[101],x[100001],i,sum=0;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d\n",&t[i]);
		sum=sum+t[i];
	}
	scanf("%d\n",&m);
	for(i=0; i<m; i++){
		scanf("%d%d",&p[i],&x[i]);
	}
	for(i=0; i<m; i++){
		printf("%d\n",sum-t[p[i]-1]+x[i]);
	}
	return 0;
}

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

int main(){

int s;
cin >> s;
int cnt = 1;
vector<int>sum(1000000);
sum.at(0) = s;

      while(1){
            
            if(s % 2 == 0){
                  s = s / 2;
                  sum.at(cnt) = s;
                  cnt++;
            }else if(s % 2 != 0){
                  s = 3 * s + 1;
                  sum.at(cnt) = s;
                  cnt++;
            }

            for(int i = 0; i < cnt - 1; i++){ 
                  if(sum.at(i) == sum.at(cnt -1)){
                        cout << cnt << endl;
                        return 0;
                  }
            }

      }


}

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

using namespace std;
const string EOT = "END_OF_TEXT";

void to_lower_string(string& str);

int main(){
    string w;
    cin >> w;
    to_lower_string(w);
    string t;
    int counter = 0;
    while(cin >> t){
        to_lower_string(t);
        if(t == w){
            ++counter;
        }
    }
    cout << counter <<endl;
}

void to_lower_string(string& sTr){
    for(auto &c : sTr){
        c = tolower(c);
    }
}

Measured memory_bytes: 1196
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	k := getNextInt(scanner)
	n := getNextInt(scanner)
	aa := make([]int, n+1)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	aa[n] = k + aa[0]
	var ans int
	ans = k
	for i := 0; i < n; i++ {
		if ans > k-(aa[i+1]-aa[i]) {
			ans = k - (aa[i+1] - aa[i])
		}
	}
	fmt.Fprintln(writer, ans)
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  vector<int> x(5);
  
  for (int i = 0; i < 5; i++) cin >> x.at(i);
  
  for (int i = 0; i < 5; i++) {
    if (x.at(i) == 0) {
      cout << i + 1 << '\n';
      return 0;
    }
  }
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

from collections import OrderedDict

n = int(input())
dic = OrderedDict()

for i in range(n):
    l,d = list(map(str,input().split()))
    dic[l] = d

a = str(input())

flag = False
time = 0

for key,value in dic.items():
    if flag == False:
        if key == a:
            flag = True
    else:
        time += int(value)

print(time)

Measured memory_bytes: 3572
#include <iostream>
#include <vector>

using u32 = uint32_t;
using i32 = int32_t;

int main()
{
	u32 n;
	i32 k, q;
	
	std::cin >> n >> k >> q;

	std::vector<i32> a;
	a.resize(n, 0);

	for(i32 i = 0; i < q; i++)
	{
		u32 x;
		std::cin >> x;
		a[x-1]+=1;
	}

	for(u32 i = 0; i < n; i++)
	{
		//std::cout << k-q << " " << a[i] << "\n";
		if((k-q + a[i]) < 1)
		{
			std::cout << "No\n";
		}
		else
		{
			std::cout << "Yes\n";
		}
	}
	
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int p=0,m=0;
    for(int i=0;i<4;++i){
        if(s[i]=='+')p++;
        else m--;
    }
    int ans=p+m;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[200005];
int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	ll ans = 2*inf;
	ll sum2 = 0;
	for (int i = n - 1; i > 0; i--) {
		sum2 += a[i];
		sum -= a[i];
		
		ans = min(ans, abs(sum-sum2));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int n;

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

	int max = 0;
	for (int i = 0;i < n;i++)
	{
		for (int j = i;j < n;j++){
			int t = abs(a[i] - a[j] );
			if (t > max)
			{
				max = t;
			}
		}
	}
	cout << max << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 1000001
  #define INF 1000000000000
  #define eps 1e-6



int32_t main()
{



    set<int> s;
    int x,y,z;
    cin >> x >> y >> z;
    s.insert(x);
    s.insert(y);
    s.insert(z);

    if(s.size() == 2)
    {
      cout <<"Yes";
    }
    else
    {
      cout <<"No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,k,x[101],y[101];
double ans,d[205],P=acos(-1);
main(){
	cin>>n;++m=i=n;
	while(m--)cin>>x[m]>>y[m];
	while(i--){
		k=ans=j=0;
		for(;j<n;j++)if(i-j)d[k++]=atan2(y[j]-y[i],x[j]-x[i]);
		sort(d,d+k);
		for(j=0;j<k;j++)d[j+k]=d[j]+2*P;
		for(j=0;j<k;j++)ans=max(ans,P-d[j+k-1]+d[j]);
		cout<<ans/2./P<<'\n';
	}
}

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

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int cnt = 0;
  int mn = 1e9;
  rep(i, N) {
    if (A[i] < 0)
      ++cnt;
    mn = min(mn, abs(A[i]));
  }

  ll ans = 0;
  rep(i, N) ans += abs(A[i]);
  if (cnt % 2 != 0)
    ans -= 2 * mn;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

ll a[100100];

int main(void){
	int n,i,c=0;
	ll ans=0ll,x=INFLL;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		if(a[i]<0){
			++c;
		}
	}
	for(i=0; i<n; ++i){
		ans += abs(a[i]);
		x = min(x,abs(a[i]));
	}
	cout << (ans-x*2*(c%2)) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,W;
  cin>>N>>W;
  int w[N];
  lint v[N];
  REP(i,N)cin>>w[i]>>v[i];
  map<int,lint> dp;
  dp[0]=0;
  lint ans=0;
  REP(i,N){
    auto itr=dp.rbegin();
    for(itr;itr!=dp.rend();itr++){
      int p=itr->first+w[i];
      if(p>W)continue;
      dp[p]=max(dp[p],itr->second+v[i]);
      ans=max(ans,dp[p]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8448
while True:
   x,y = map(int, input().split())
   if x==0 and y==0:
      break
   elif x<y:
      X=y
      Y=x
   else:
      X=x
      Y=y
   i = 0
   while True:
      a = X%Y
      X = a
      Z = Y
      Y = X
      X = Z
      i += 1
      if a==0:
         break
   print(X, i)


Measured memory_bytes: 5600