akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 998'244'353;

int main() {
    std::ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> has(N);
    while(K--) {
        int D;
        cin >> D;
        while(D--) {
            int a;
            cin >> a;
            has[a - 1] = 1;
        }
    }
    cout << N - accumulate(has.begin(), has.end(), 0);
}




Measured memory_bytes: 3652
S = input()
T = [letter for letter in S]
que = [T]
a = 0
while que:
	T1 = que[0]
	if len(T1) > 1:
		a += int(T1[0])*2**(len(T1) - 2)
		t2 = T1[:]
		t2[1] = t2[0] + t2[1]
		t2 = t2[1:]
		que.append(t2)
		t1 = T1[1:]
		que.append(t1)
	else:
		a += int(T1[0])
	que = que[1:]
print(a)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
     
int main(){
  string a, b, c; cin >> a >> b >> c;
  cout << (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] ? "YES\n" : "NO\n");
  return 0;
}
 

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define equals(a,b) (fabs((a)-(b)) < EPS)


using namespace std;

const int IINF = INT_MAX;

// Library

class Point{
public:
  double x,y;

  Point(double x = -IINF,double y = -IINF): x(x),y(y){}

  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}
  Point operator * (Point a){ return Point(x * a.x - y * a.y, x * a.y + y * a.x); }

  bool operator < (const Point& p) const{ return !equals(x,p.x)?x<p.x:y<p.y; }

  bool operator == (const Point& p)const{ return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; }

};


double norm(Point a){ return a.x*a.x+a.y*a.y; }

double abs(Point a){ return sqrt(norm(a)); }



struct Circle{
  Point p;
  double r;
  Circle(Point p=Point(),double r=IINF):p(p),r(r){}
};

pair<Point, Point> intersectCC( Point C1, double r1, Point C2, double r2) {
  complex<double> c1(C1.x,C1.y);
  complex<double> c2(C2.x,C2.y);
  complex<double> A = conj(c2-c1), B = (r2*r2-r1*r1-(c2-c1)*conj(c2-c1)), C = r1*r1*(c2-c1);
  complex<double> D = B*B-4.0*A*C;
  complex<double> z1 = (-B+sqrt(D))/(2.0*A)+c1, z2 = (-B-sqrt(D))/(2.0*A)+c1;
  return pair<Point, Point>(Point(z1.real(),z1.imag()),Point(z2.real(),z2.imag()));
}



// Library

bool insideCC(Circle a,Circle b){
  double d = sqrt(norm(a.p-b.p));
  double r1 = max(a.r,b.r);
  double r2 = min(a.r,b.r);
 
  if(!equals(d,r1-r2) && d < r1-r2) return a.r < b.r; 
  return false;
}

bool insideCP(Circle c,Point p){
  double dist = abs(c.p-p);
  return equals(dist,c.r) || dist < c.r;
}

int n;
Point ps[11];
double ls[11];

bool check(double h){
  vector<Circle> cs;
  bool out[n];
  rep(i,n) out[i] = false;

  rep(i,n) {
    if( equals(h,ls[i]) || h >= ls[i] ) return false;
    rep(j,n){
      if( i == j ) continue;
      double r1 = sqrt( pow(ls[i],2) - pow(h,2) ), r2 = sqrt( pow(ls[j],2) - pow(h,2) );
      if(insideCC((Circle){ps[i],r1},(Circle){ps[j],r2})) out[j] = true;
    }
  }

  rep(i,n) if( !out[i] ) {
    double r = sqrt( pow(ls[i],2) - pow(h,2) );
    cs.push_back(Circle(ps[i],r));
  }

  assert(cs.size());
  if( cs.size() == 1 ) return true;

  vector<Point> cps;

  rep(i,cs.size()) REP(j,i+1,cs.size()){
    pair<Point,Point> pp = intersectCC(cs[i].p,cs[i].r,cs[j].p,cs[j].r);
    cps.push_back(pp.first);    
    cps.push_back(pp.second);
  }

  rep(i,cps.size()){
    rep(j,cs.size()) if( !insideCP(cs[j],cps[i]) ) goto Skip;
    return true;
  Skip:;
  }
  return false;
}

int main(){
  while( cin >> n, n ){
    rep(i,n) cin >> ps[i].x >> ps[i].y >> ls[i];

    double L = 0, R = 1e10;
    rep(_,120){
      double M = ( L + R ) * 0.5;
      if( check(M) ) L = M;
      else           R = M;
    }
    printf("%.7f\n",R);
  }
  return 0;
}

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

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

#define REPR(i, n) for (int i = n; i >= 0; --i)

#define REP_(i, m, n) for (int i = m; i < n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

using hint = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    vector<vector<hint>> evi;
    evi.resize(N);

    REP(i, N)
    {
        int a;
        cin >> a;
        evi[i].resize(a);
        REP(j, a)
        {
            cin >> evi[i][j].first >> evi[i][j].second; // first:target sec: true or false
            evi[i][j].first--;
        }
    }

    ll ans = 0;
    bool judge;
    for (int bit = 0; bit < (1 << N); ++bit)
    {
//        cout << bitset<2>(bit)<< endl; ;
        judge = true;
        for (int i = 0; i < N; i++)
        {
            //cout << "2:" <<(( bit >> i)&1)<< endl; ;
            if (!((bit >> i) & 1)^0)
            {
                //cout << bitset<4>(bit) << endl;
                continue;
            }
            for (auto x : evi[i])
            {
              //  cout << bitset<2>(bit) ;
              //  cout << "bit" << (!((bit >> x.first) & 1) ^ x.second) << endl;
                //cout << "judge: " << ((bit >> x.first)&1)   << " bit"<<( ((bit >> x.first)&1)^x.second) << " x "<< x.second  << endl;
                if (((bit >> x.first) & 1) ^ x.second){
                //    cout << "judge: " << ((bit >> x.first)&1)   << " bit"<<( ((bit >> x.first)&1)^x.second) << " x "<< x.second  << endl;
                    judge = false;
                }
//                else{
//                    cout << "judge: " << ((bit >> x.first)&1)   << " bit"<<( ((bit >> x.first)&1)^x.second) << " x "<< x.second  << endl;
//
//                }
            }
        }
        if (judge)
        {
 //           cout << "aaa" << bitset<2>(bit) << endl;
            ll mid_ans = 0;
            if(bit == 0)mid_ans = 0;
            else{
                for (int i = 0; i < N; i++)
                {
                    if ((bit >> i) & 1)
                        mid_ans++;
                }
                ans = max(ans, mid_ans);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
K = gets.chomp.to_i
str = gets.split
X,Y = str[0].to_i, str[1].to_i
W = X.abs+Y.abs
x = 0
y = 0
q,r = 0,0
if X<0
    q = -1
else
    q = 1
end
if Y<0
    r = -1
else
    r = 1
end
if W%2 == 1 && K%2 == 0
    puts -1
elsif W%K == 0
    puts W/K
    while (x + q*K).abs < X.abs
        x += q*K
        print x," ",y
        puts
    end
    y = r*(K-(X-x).abs)
    x = X
    print X," ",y
    puts
    while (y + r*K).abs <= Y.abs
        y += r*K
        print X," ",y
        puts
    end
elsif K%2 == 0
    a = W/K+1
    if a == 1
        a += 1
    end
    puts a
    for i in 1..a-2 do
        if (x + q*K).abs < X.abs
            x += q*K
            print x," ",y
            puts
        elsif x != X
            y = r*(K-(X-x).abs)
            x = X
            print X," ",y
            puts
        else
            y += r*K
            print X," ",y
            puts
        end
    end
    b = (2*K - (X-x).abs - (Y-y).abs)/2
    if K > (X-x).abs+b
        x -= q*b
        y += r*(K-b)
        print x," ",y
    else
        x += q*(K-b)
        y -= r*b
        print x," ",y
    end
    puts
    print X," ",Y
    puts
else
    a = W/K+1
    if a%2 != W%2
        a += 1
    end
    if a == 1 && W%2 == 1
        puts 3
        x = X
        b = K-W
        y = Y + r*b
        print  x," ",y
        puts
        b = (2*K - (X-x).abs - (Y-y).abs)/2
        y -= r*(K-b)
        print X-q*b," ",y
        puts
        print X," ",Y
        puts
    else
        puts a
        for i in 1..a-2 do
            if (x + q*K).abs < X.abs
                x += q*K
                print x," ",y
                puts
            elsif x != X
                y = r*(K-(X-x).abs)
                x = X
                print X," ",y
                puts
            else
                y += r*K
                print X," ",y
                puts
            end
        end
        b = (2*K - (X-x).abs - (Y-y).abs)/2
        if K > (X-x).abs+b
            x -= q*b
            y += r*(K-b)
            print x," ",y
        else
            x += q*(K-b)
            y -= r*b
            print x," ",y
        end
        puts
        print X," ",Y
        puts
    end
end

Measured memory_bytes: 3836
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=ja
# 二分探索を用いた解法
from bisect import bisect_left as bil

N = int(input())
*S, = map(int, input().split())
q = int(input())
*T, = map(int, input().split())

ans = 0
for t in T:
    l = bil(S, t)
    if S[l] == t:
        ans += 1
print(ans)



Measured memory_bytes: 16736
#include <bits/stdc++.h>
using namespace std;
#define REP(i,f,n) for(int i=f;i<(n);i++)
int n,t,ans=-1000000001,f[101],p[101][11];
int main() {
    int n;
    cin>>n;
    REP(i,0,n)
        REP(j,0,10) {
            cin>>t;
            f[i]|=t<<j;
        }
    REP(i,0,n) REP(j,0,11) cin>>p[i][j];
    REP(i,1,1<<10) {
        t=0;
        REP(j,0,n) t+=p[j][__builtin_popcount(f[j]&i)];
        if(ans<t) ans=t;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }




// ***************************************

ll pw(ll x, ll y, ll z){
    return pow(x, 2) + pow(y, 2) + pow(z, 2);
}

ll f(ll x, ll y, ll z){
    return pw(x,y,z) + x * y + y * z + z * x;
}

int main(){

    ll N;
    cin >> N;

    FOR(n, 1, N + 1){
        ll x, y, z;
        ll cnt = 0;
        for(x = 1; f(x, x, x) <= n; x++) {
            for (y = x; f(x, y, y) <= n; y++){
                for (z = y; f(x,y,z) <= n; z++){
                    if (pw(x,y,z) >= n) break;
                    if (f(x,y,z) == n) {
                        set<ll> s{x,y,z};
                        if(s.size() == 3) cnt += 6;
                        else if(s.size() == 2) cnt += 3;
                        else cnt++;
                    }
                }
                if (z == 1) break;
            }
            if(y == 1 && z == 1) break; 
        }

        cout << cnt << endl;
    }

    return 0;
}


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

int main()
{
  int x,a,b;
  cin >> x >> a >> b;
  if(a >= b){
    cout <<"delicious\n";
  }else if(b-a <= x){
    cout <<"safe\n";
  }else{
    cout << "dangerous\n";
  }
  return 0;
}

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

using namespace std;

using LL = long long;

LL fexp(LL b, LL e) {
	if (b == 0 || e == 1) return b;
	if (b == 1 || e == 0) return 1LL;

	LL r = fexp(b, e / 2);
	r = r * r;
	if (e & 1LL) r *= b;
	return r;
}

int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);

	LL X; cin >> X;	

	for(LL i = 0; i < 1001; ++i) {
		for(LL j = 0; j < 1001; ++j) {

			LL a = fexp(i, 5LL);
			LL b = fexp(j, 5LL);
	
			if (a - b == X) {
				cout << i <<  ' ' << j << '\n';
				return 0;
			}
			
			if (a + b == X) {
				cout << i << ' ' << (-1LL) * j << '\n';
				return 0;
			}

		}
	}

	assert(0 == 1);

	return 0;	
}

Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstring>
#include<functional>
#include<cmath>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)

using namespace std;

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(B / A > C) cout << C << endl; else cout << B / A << endl;
}

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

int main(){
    int N;
    cin>>N;
    long long ans = 0;
    int zero = 99;
    int lst = -99;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(a==0){
            zero = i;
            lst = a;
            continue;
        }
        if(lst+1==a){
            lst = a;
            ans++;
            continue;
        }
        if(lst+1<a){
            cout<<-1<<endl;
            return 0;
        }

        ans += a;
        lst = a;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    int n; cin>>n;
    vector<int>vvataarne(n); rep(i,n)cin>>vvataarne[i];
    vector<int>kitikuyarou(n); rep(i,n)cin>>kitikuyarou[i];
    set<int>vvhaAORIkaiwanotourist;
    rep(i,n)vvhaAORIkaiwanotourist.insert(kitikuyarou[i]);
    if(vvhaAORIkaiwanotourist.size()==n)return puts("Yes")*0;
    map<int,int>vvhasinntyokukaiwainotourist;
    rep(i,n)vvhasinntyokukaiwainotourist[kitikuyarou[i]]++;
    int safe=INF;
    puts("No");
    rep(i,n){
        if(i)cout<<" ";
        cout<<kitikuyarou[i];
    }
    cout<<endl;
    rep(i,n){
        if(i)cout<<" ";
        if(vvhasinntyokukaiwainotourist[vvataarne[i]])cout<<kitikuyarou[i];
        else cout<<vvataarne[i];
    }
    cout<<endl;
}



Measured memory_bytes: 13848
h, w = map(int, input().split())
S = ["."*(w+2)] + [ "."+input()+"." for _ in range(h) ] + ["."*(w+2)]
for i in range(h+2):
  for j in range(w+2):
    if S[i][j] == "#":
      if S[i+1][j] != "#" and S[i][j+1] != "#" and S[i-1][j] != "#" and S[i][j-1] != "#":
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3064
# coding: utf-8
import math
K = int(input())
rep = 0
gcds = [[0 for i in range(201)] for _ in range(201)]
for a in range(1,K+1):
    for b in range(1,K+1):
        gcds[a][b] = math.gcd(a,b)
for a in range(1,K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            rep += gcds[gcds[a][b]][c]
print(rep)

Measured memory_bytes: 9480
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000

int main (void)
{
    long long n, sum=0;
    char c;

    // scanf("%lld", &n);

    while ((c = getchar()) != '\n') {
        sum += c - '0';
    }

    if (sum % 9 == 0) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 1492
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    a *= 1000;
    t *= 1000;
    int k = INF<int>, x = 0;
    for (int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        if(abs(a-t+6*h) <= k) {
            k = abs(a-t+6*h);
            x = i;
        }
    }
    cout << x+1 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x;
  int y;
  for(int i=1;;i++){
    cin >> x >> y;
    if(x==0 && y==0)break;
    if(x<=y){
      cout << x << " " << y << endl;
    }else{
      cout << y << " " << x << endl;
    }
  }
}

Measured memory_bytes: 1160
S=input()
K=int(input())

import itertools
if len(set(S))==1:
  print((len(S)*K)//2)
elif S[0]!=S[-1]:
  ans=0
  for key,g in itertools.groupby(S):
    ans+=len(list(g))//2
  print(ans*K)
else:
  first=0
  last=0
  ans=0
  isfirst=True
  for key,g in itertools.groupby(S):
    num=len(list(g))
    if isfirst:
      first=num
      isfirst=False
    else:
      last=num
      ans+=num//2
  ans-=num//2
  print(ans*K+((first+last)//2)*(K-1)+first//2+last//2)


Measured memory_bytes: 3064
#include <iostream>
#define MAXN 2005
using namespace std;

int n;
int Z, W, a[MAXN];

int main() {
    ios::sync_with_stdio(0);

    cin >> n >> Z >> W;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    if (n == 1) {
        cout << abs(W - a[1]) << "\n";
        return 0;
    }

    cout << max(abs(W - a[n]), abs(a[n] - a[n - 1])) << "\n";

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;
	int same = 0;
	bool ok = false;
	for (int i = 0; i < N; i++) {
		int d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2) same++;
		else same = 0;
		if (same == 3) ok = true;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
# coding: utf-8
# ?????????????????¨????????????
class Dice(object):
	def __init__(self):
		# ???????????????????????°
		# ????????¶???
		self.dice = (2, 5), (3, 4), (1, 6) # x, y, z
		self.ax = [[0, False], [1, False], [2, False]]
		self.axmap = [0, 1, 2]
		self.mm = {"N": (0, 2), "S": (2, 0), "E": (1, 2), "W": (2, 1), "R": (0, 1), "L": (1, 0)}

	def rotate(self, dir):
		def rot(k, r):
			# k?????????????????????????????????????????§?§????
			# r?????????????????¢???????§????
			t = self.axmap[r]
			self.axmap[k], self.axmap[r] = t, self.axmap[k]
			self.ax[t][1] = not self.ax[t][1]

		rot(*self.mm[dir])

	def top(self):
		z = self.ax[self.axmap[2]]
		return self.dice[z[0]][z[1]]
	
	def right(self):
		y = self.ax[self.axmap[1]]
		return self.dice[y[0]][y[1]]

	def front(self):
		x = self.ax[self.axmap[0]]
		return self.dice[x[0]][x[1]]

if __name__=="__main__":
	dice = Dice()
	labels = input().split()
	q = int(input())
	def tf(p, f, d):
		for _ in range(4):
			if p==f():
				break
			dice.rotate(d)

	for _ in range(q):
		a, b = input().split()
		p = labels.index(a) + 1
		f = dice.top
		tf(p, f, "N")
		tf(p, f, "E")
		
		p = labels.index(b) + 1
		f = dice.front
		tf(p, f, "R")

		print(labels[dice.right()-1])

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

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

Measured memory_bytes: 768
H,W = map(int, input().split())

table = []

for i in range(H):
	table.append(list(input()))

counter = 0
	
def check(x,y):
	counter = 0
			
	if x > 0:
		if table[y][x-1] == '#':
			counter += 1
			
	if x < W-1:
		if table[y][x+1] == '#':
			counter += 1
	
	if y > 0:
		if table[y-1][x] == '#':
			counter += 1
	
	if y < H-1:
		if table[y+1][x] == '#':
			counter += 1
	
	if counter == 0:
		print('No')
		quit()
			
	

for y in range(H):
	for x in range(W):
		if table[y][x] == '#':
			check(x,y)

print ('Yes')	

Measured memory_bytes: 3064
(let* ((k (read))
       (str (concatenate 'list (read-line))))
  (defun f (a b)
    (loop :for n :in (remove-duplicates a) :count(find n b :test #'char=)))
  (princ (loop :for s :from 1 :upto (- (length str) 2) :maximize(f (subseq str 0 s) (subseq str s)))))

Measured memory_bytes: 15076
#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(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

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

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;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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





int main() {
	ll N;
	cin >> N;
	double x[2000], y[2000];
	repn(i, N) cin >> x[i] >> y[i];

	double ans = 1000000000;

	
	repn(i, N) {
		repn(j, N) {
			if (i == j) { continue; }
			double xx = (x[i] + x[j]) / 2.0;
			double yy = (y[i] + y[j]) / 2.0;
			double v = 0;

			repn(l, N) {
				v = max(v, sqrt((x[l] - xx)*(x[l] - xx) + (y[l] - yy)*(y[l] - yy)));
			}


			ans = min(v, ans);
		}
	}
	


	repn(i, N) {
		repn(j,N) {
			repn(k,N) {
				if (i == j || j == k || k == i) { continue; }

				double a = x[j]-x[i];//円の方程式の導出
				double b = y[j]-y[i];
				double c = x[k]-x[i];
				double d = y[k]-y[i];

				double Odeno = 2 * (a * d - b * c);
				double Ox = (a * a + b * b) * d - (c * c + d * d) * b + Odeno * x[i];
				double Oy = (c * c + d * d) * a - (a * a + b * b) * c + Odeno * y[i];

				double xx, yy;

				if (Odeno == 0) { continue; }

				
				xx = Ox / Odeno;
				yy = Oy / Odeno;
				

				double v = 0;

				repn(l,N){
					v = max(v, sqrt((x[l] - xx)*(x[l] - xx) + (y[l] - yy)*(y[l] - yy)));
				}

				
				ans = min(v, ans);
			}
		}
	}

	
	cout << fixed << setprecision(10);

	cout << ans;

	system("PAUSE");


}


Measured memory_bytes: 504
m, d = gets.chomp.split(' ').map(&:to_i)
def check(m, d)
  d1, d2 = sprintf('%02d', d).split('').map(&:to_i)
  d1 >= 2 && d2 >= 2 && d1 * d2 == m
end
count = 0
1.upto(m) do |i|
  1.upto(d) do |j|
    count += 1 if check(i, j)
  end
end
puts count

Measured memory_bytes: 2044
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}

int n, k, p;
string s;

int main()
{
	n = read();
	k = read();
	cin >> s;
	if (k > n << 1)
		k = (n << 1) + ((k - (n << 1)) & 1);

	char ch = 'A';
	for (int i = 1; i <= k; i++) {
		if (s[p] == ch) {
			s[p] = 'A' + 'B' - ch;
		} else {
			ch = 'A' + 'B' - ch;
			p = (p + 1) % n;
		}
	}

	for (int i = p; i < n; i++) {
		if (s[i] == ch)
			printf("A");
		else
			printf("B");
	}
	for (int i = 0; i < p; i++) {
		if (s[i] == ch)
			printf("A");
		else
			printf("B");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  while(cin>>n,n){
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=0;
    
    vector<int> p[555];
    for(int i=0;i<n;i++){
      int x=a[i];
      while(x%2==0) x/=2;
      p[x].push_back(a[i]/x);
    }
    auto calc=[](vector<int> &a){
      int sum=accumulate(a.begin(),a.end(),0);
      vector<vector<int> > dp(2,vector<int>(sum+1,-1));
      dp[0][0]=0;
      int idx=0;
      for(int x:a){
	fill(dp[!idx].begin(),dp[!idx].end(),-1);
	for(int i=0;i<=sum;i++){
	  dp[!idx][i]=max(dp[!idx][i],dp[idx][i]);
	  if(~dp[idx][i]&&i%x==0&&i+x<=sum) 
	    dp[!idx][i+x]=max(dp[!idx][i+x],dp[idx][i]+1);
	}
	idx=!idx;
      }
      int res=0;
      for(int i=1;i<=sum;i<<=1) res=max(res,dp[idx][i]);
      return res;
    };
    for(int i=0;i<555;i++)
      if(!p[i].empty()) ans=max(ans,calc(p[i]));
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1<<29;
int main() {
    string N; cin >> N;
    for (int i=0;i<3;i++){
        if (N[i]=='7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>

void swap(int *x,int *y);
  
int main(){
  int x,y,r;

  scanf("%d%d",&x,&y);
  if(x<y) swap(&x,&y);

  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  printf("%d\n",x);
  return 0;
}

void swap(int *x,int *y)
{
  int a;
  a=*x;
  *x=*y;
  *y=a;
}

Measured memory_bytes: 592
var R = mutableListOf<String>()
fun main(args: Array<String>) {
    val (N, M) = listOfLong()
    val A = listOfLong().map { a -> a / 2 }
    val s = A.reduce { acc, a -> lcm(acc, a) }
    if (A.any { a -> (s / a) % 2 == 0L }) {
        println(0)
        return
    }
    var ans = 0L
    var S = s
    while (S <= M) {
        ans += 1
        S += s * 2
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun gcd(a: Long, b: Long): Long = if (b > 0) gcd(b, a % b) else a
fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b


Measured memory_bytes: 70188
#include<stdio.h>

int main(void) {
	int a[3], i, j;
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	for (i = 0; i < 3; i++) {
		for (j = 2; j > i; j--) {
			if (a[j] > a[j - 1]) {
				int tmp;
				tmp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = tmp;
			}
		}
	}
	printf("%d\n", a[2] + a[1]);
	return 0;
}


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

using namespace std;

#define int long long
#define nl '\n'

#define st first
#define nd second
#define ins insert

#define pb push_back
#define mp make_pair

#define hashmap unordered_map
#define hashset unordered_set

signed main(){
	int x, y; cin >> x >> y;
	bool flag = false;
	for (int i = 0; i <= x; i++){
		if (2*i + 4*(x - i) == y){
			flag = true;
		}
	}
	if (flag) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 3580
#include <iostream>

int main(void){
    int a, b;
    std::string ans="Positive";
    std::cin >> a >> b;
    if (a <= 0 && b >= 0){
        ans = "Zero";
    } else if (b < 0) {
        int d = b - a;
        if (d % 2 == 0){
            ans = "Negative";
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main(){
  int a,b,c,t;
  scanf("%d%d%d",&a,&b,&c);
  if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(b>c){t=b;b=c;c=t;}
  printf("%d",c-b+(b-a)/2+(b-a)%2*2);
}


Measured memory_bytes: 1704
#include <iostream>

const int N = 600 + 7;

int n;
int f[N][N], g[4], h;

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n), n <<= 1;
	for (int t = 1, k, d; t <= 2; ++t) {
		scanf("%d", &d),
		k = 1 << __builtin_ctz(d) / 2;
		d = d / k / k % 4 == 1;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				f[i][j] |= (i / k + j / k * d) & 1 ? t : 0;
	}
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			++g[f[i][j]];
	for (int i = 1; i <= 3; ++i)
		h = g[i] > g[h] ? i : h;
	for (int i = 0, k = n * n / 4; i < n; ++i)
		for (int j = 0; j < n; ++j)
			if (f[i][j] == h && k) --k, printf("%d %d\n", i, j);

	return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        boolean ans = false;

        //        for (int i = 0; i < n; i++) {
        //
        //        }

        if (a == b && b == c)
            ans = true;

        sc.close();

        System.out.println(ans ? "Yes" : "No");

    }
}

Measured memory_bytes: 22228
from sys import stdin, stdout
def IL():return list(map(int, stdin.readline().split()))

def main():
    N,M = IL()
    t = 2**M
    n = 100* (N-M)* t
    m = 1900*M * t
    
    print(n+m)
    
if __name__ == "__main__": main()

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

int main() {
  int A,B,M;
  cin>>A>>B>>M;
  int a[A],b[B];
  int min_a=1e9,min_b=1e9;
  for(int i=0;i<A;i++) {
    cin>>a[i];
    min_a=min(min_a,a[i]);
  }
  for(int i=0;i<B;i++){
    cin>>b[i];
    min_b=min(min_b,b[i]);
  }
  int min_cost=min_a+min_b;
  for(int i=0;i<M;i++){
    int x,y,c;
    cin>>x>>y>>c;
    min_cost=min(min_cost,a[x-1]+b[y-1]-c);
  }
  cout<<min_cost<<endl;
  return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
K = m//n
ans = 0
i = 1
while i <= K:
  if m % i == 0:
    if m//i <= K:
      ans = m//i
      break
    ans = i
    K = min(m//n, m//i)
  i += 1
print(ans)

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

int main(void){
	string s;
	cin >> s;
	string t = "CODEFESTIVAL2016";
	int cnt = 0;
	for(int i=0;i<s.size();i++)
		if(s[i] != t[i])cnt++;
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
#define pcii pair<char, pair<int, int>>
using namespace std;

const ll N = 1e5, mod = 1e9 + 7;
const ll inf = 1e18 + 5;

void solve(){
    ll n, c;
    cin >> n >> c;
    vl w(n), v(n);
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    bool a[N + 1];
    memset(a, 0, sizeof(a));
    vl maxw(N + 1, inf);
    for(int i = 0; i < n; i++){
        if(w[i] > c) continue;

        for(int j = N; j > 0; j--){
            if(a[j]){
                a[j + v[i]] = 1;
                maxw[j + v[i]] = min(maxw[j + v[i]], maxw[j] + w[i]);
            }
        }
        a[v[i]] = 1;
        maxw[v[i]] = min(maxw[v[i]], w[i]);
    }
    int i;
    for(i = N; i > 0; --i){
        if(a[i] && maxw[i] <= c) break;
    }
    cout << i << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3992
//Name: Live Schedule
//Level: 3
//Category: 動的計画法,DP
//Note:

/**
 * ある区間でライブが開催できるかと、その区間における利益、負担は累積和を使うとO(1)で計算できる。
 * 状態としては、(現在の日付,連続公演を行った回数,負担合計)を使い、各状態ごとに最大の利益を管理する。
 * 状態数はO(CDW)、ライブを行う候補の区間数はO(C^2)であるから、全体のオーダーは O(C^3DW)。
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// sum of [l, r]
int get(const vector<int> &v, int l, int r) {
    if(l <= 0) return v[r];
    return v[r] - v[l-1];
}

bool solve() {
    int C, D, W, X;
    if(!(cin >> C >> D >> W >> X)) return false;
    if(!C && !D && !W && !X) return false;

    vector<vector<int>> es(D, vector<int>(C));
    vector<vector<int>> ps(D, vector<int>(C)); // prohibition
    vector<vector<int>> fs(D, vector<int>(C));
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < D; ++j) {
            cin >> es[j][i];
            ps[j][i] = es[j][i] == 0;
            if(i > 0) es[j][i] += es[j][i-1];
            if(i > 0) ps[j][i] += ps[j][i-1];
        }
    }
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < D; ++j) {
            cin >> fs[j][i];
            if(i > 0) fs[j][i] += fs[j][i-1];
        }
    }

    vector<vector<vector<int>>> dp(D, vector<vector<int>>(X+1, vector<int>(W+1, 0)));
    for(int d = 0; d < D; ++d) {
        for(int x = 0; x <= X; ++x) {
            for(int w = 0; w <= W; ++w) {
                if(d > 0) dp[d][x][w] = dp[d-1][x][w]; // ライブをしない場合
                for(int l = 0; l < C; ++l) {
                    for(int r = l; r < C; ++r) {
                        if(get(ps[d], l, r) != 0) break;
                        const int px = x - (l != r);
                        const int pw = w - get(fs[d], l, r);
                        if(px < 0 || pw < 0) continue;
                        int nv = get(es[d], l, r);
                        if(d > 0) nv += dp[d-1][px][pw];
                        dp[d][x][w] = max(dp[d][x][w], nv);
                    }
                }
            }
        }
    }
    int ans = -1;
    for(int x = 0; x <= X; ++x) {
        for(int w = 0; w <= W; ++w) {
            ans = max(ans, dp[D-1][x][w]);
        }
    }
    cout << ans << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string a, b; cin >> a >> b;
  a += b;
  int N = std::stoi(a);
  int res = false;
  for (int i = 0; i*i <= N; ++i) {
    if (i*i == N) {
      res = true;
      break;
    }
  }
  auto ans = res ? "Yes" : "No";
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    cout<<48-x<<'\n';
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
//     int a, b, c, d, e;
//     std::cin >> a >> b >> c >> d >> e;
    int a[5];
    std::cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    int min = 1000, minIdx;
    for (int i = 0; (i < 5); ++i) {
        int lower = a[i] % 10;
        if (lower != 0 && lower < min) {
            min = lower;
            minIdx = i;
        }
    }

    int sum = 0;
    for (int i = 0; (i < 5); ++i) {
        if (i == minIdx) continue;
        int time;
        if (a[i] % 10 == 0)
            time = a[i];
        else
            time = a[i] / 10 * 10 + 10;
        sum += time;
    }
    sum += a[minIdx];
    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0){break;}
		int a,b;
		a = b = 0;
		int ac,bc;
		for(int i=0;i<n;i++){
			scanf("%d %d",&ac,&bc);
			if(ac == bc){
				a += ac;
				b += bc;
			}else{
				(ac > bc ? a : b) += ac + bc;
			}
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e6+5;
void solve(){
	int n; 
	cin>>n; 
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	int ans = 0;
	for(int i=0;i<n;i++){
		if(i%2==0)ans+=a[i];
		else ans-=a[i];
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


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

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

    vector<int> heights(n, 0);
    for(int i=0; i<n; ++i) cin >> heights[i];

    vector<int> dp(n, 0);
    for(int i=1; i<n; ++i)
    {
        dp[i] = dp[i-1] + abs(heights[i]-heights[i-1]);
        for(int j=1; j<=k && i-j>=0; ++j)
            dp[i] = min(dp[i], dp[i-j] + abs(heights[i]-heights[i-j]));
    }
    
    cout << dp[n-1] << '\n';

    return 0;
}

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


int main(){
	long long N;
	cin>>N;
	vector<long long> V(0);
	for(long long i = 1;i*i<=N;i++){
		if(N%i==0){
			V.push_back(i);
			if(i*i!=N){
				V.push_back(N/i);
			}
		}
	}
	
	long long ans = 0;
	
	for(int i=0;i<V.size();i++){
		long long x = V[i]-1;//(N/V[i]);
		if(x<=0)continue;
		if(N/x==N/V[i]){
			ans+=x;
		}
	}
	
	cout<<ans<<endl;
	
		
	
	
	
	return 0;
}


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

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int n = scan.nextInt();
	int m = scan.nextInt();
	int X = scan.nextInt();
	int Y = scan.nextInt();
	int[] x = new int[n];
	int[] y = new int[m];
	for(int i = 0; i < n; i++){
	    x[i] = scan.nextInt();
	}
	for(int i = 0; i < m; i++){
	    y[i] = scan.nextInt();
	}

	Arrays.sort(x);
	Arrays.sort(y);

	if(x[n-1] > y[0]){
	    System.out.println("War");
	}else{
	    String z = "NO";
	    for(int i = x[n-1]+1; i <= y[0]; i++){
		if(X < i && i <= Y){
		    z = "YES";
		}
	    }
	    if(z.equals("YES")){
		System.out.println("No War");
	    }else{
		System.out.println("War");
	    }
	}
    }
}


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

int main() {
    int k;
    cin >> k;
    int ctr = 0;
    ll ans = 0;
    priority_queue<ll, vector<ll>, greater<ll>> q;
    q.push(1);
    while(!q.empty()){
      ctr ++;
      ll u = q.top(); q.pop();
      if(ctr == k){ans = u; break;}
      if( u < 9 )  q.push(u+1);
      if( u % 10 != 0) q.push(u*10+u%10-1);
      q.push(u*10 + u%10);
      if( u % 10 != 9) q.push(u*10+u%10+1);
    }
   cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int sumAlice = 0;
  int sumBob = 0;
  int i = 0;
  while (i < N) {
    sumAlice += a.at(i);
    i++;
    if (i == N) {
      break;
    }
    sumBob += a.at(i);
    i++;
  }
  cout << sumAlice - sumBob << endl;
}


Measured memory_bytes: 256
function main(lines) {
    const input = lines.split('\n')
    for(let i=0; i<input.length; i+=2){
        if(input[i] == '0'){
            break;
        }

        let output = ''
        let tmpCalc = 0

        for(let k=0; k<input[i]-0; k++){
            const tmpArray = input[i+1].split(' ')
            const average = tmpArray.reduce(function(a,b){return (a-0)+(b-0)})/input[i]

            tmpCalc += Math.pow( tmpArray[k] - average, 2 ) / input[i]
        }
            output += (Math.sqrt(tmpCalc)).toFixed(4)
            console.log(output)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 19136
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
bool Grid[51][51];
int w, h;
void dfs(int x, int y) {
    //cout << x << ':' << y << "HaHaHaHa" << endl;
    rep(i, 8) {
        int nx = x + dx8[i];
        int ny = y + dy8[i];
        //cout << x << ':' << dx8[i] << ' ' << y << ':' << dy8[i] << ' ' << nx << ':' << ny << endl;
        if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if(Grid[nx][ny]) {
            Grid[nx][ny] = false;
            dfs(nx, ny);
        }
    }
}
signed main(void) {
    while(true) {
        cin >> w >> h;
        if(w == 0 && h == 0) return 0;
        rep(i, 51) rep(j, 51) Grid[i][j] = false;
        rep(i, h) rep(j, w) {
            int x;
            cin >> x;
            if(x == 1) Grid[i][j] = true;
        }
        int ans = 0;
        rep(i, h) rep(j, w) {
            if(Grid[i][j]) {
                ans++;
                Grid[i][j] = false;
                dfs(i, j);
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+500;
int A[maxn],B[maxn];
int n;
map<string,int> mp;
int T[maxn],C[2019]; 
string str;
int main()
{   
    cin>>str;
    n=str.length();
    T[n]=0;
    int mod=1;
    C[0]=1;
    for(int i=n-1;i>=0;i--)
    {
        T[i]=((str[i]-'0')*mod+T[i+1])%2019;
        C[T[i]]++;
        mod=(mod*10)%2019;
    }
    int res=0;
    for(int i=0;i<2019;i++)
            res+=C[i]*(C[i]-1)/2;
    cout<<res<<endl;
}

Measured memory_bytes: 4488
fun main(args: Array<String>) {
    val bingo = (1..3).map {
        readLine()!!.split(" ").map(String::toInt)
    }
    val N = readLine()!!.toInt()
    val lottery = (1..N).map {
        readLine()!!.toInt()
    }
    val isHitted = bingo.map { row ->
        row.map { b ->
            b in lottery
        }
    }
    val rowHitted = isHitted.map { row ->
        row.all {b -> b}
    }.any { it }
    val colHitted = (0..2).map { i -> 
        (0..2).map { j -> 
            isHitted[j][i]
        }.all { it }
    }.any { it }
    val leftNanameHitted = listOf(Pair(0,0), Pair(1,1), Pair(2,2)).map { 
        val (i, j) = it
        isHitted[i][j]
    }.all { it }
    val rightNanameHitted = listOf(Pair(0,2), Pair(1,1), Pair(2,0)).map { 
        val (i, j) = it
        isHitted[i][j]
    }.all { it }
    if(rowHitted || colHitted || leftNanameHitted || rightNanameHitted) { "Yes" }  else  { "No" }.run(::println)
}


Measured memory_bytes: 37860
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int a,b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') {
        cout << a+b << "\n";
    } else {
        cout << a-b << "\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
int k,s,ans;
int main(){
	scanf("%d%d",&k,&s);
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k;j++)
			if(s-i-j>=0&&s-i-j<=k) 
				ans++;
	printf("%d\n",ans);
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL q, h, s, d; cin >> q >> h >> s >> d;
	LL n; cin >> n;

	q *= 4;
	h *= 2;

	LL one = min(q, h);
	one = min(one, s);

	LL ans = 0;

	if (n >= 2) {
		ans += (n / 2)*(min(one * 2, (LL)d));
	}

	if (n % 2 == 1) {
		ans += one;
	}
	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
ll n, k, q, a[2020], ans;
vector<ll> V, W;
const ll INF = 10000000000;
int main(void){
    // Your code here!
    ans = INF;
    cin >> n >> k >> q;
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n; i++){
        for (ll j = 0; j <= n; j++){
            if (j != n && a[j] >= a[i]){
                V.push_back(a[j]);
            } else {
                if (V.size() >= k){
                    sort(V.begin(), V.end());
                    for (ll l = 0; l < V.size() - k + 1; l++){
                        W.push_back(V[l]);
                    }
                }
                V.erase(V.begin(), V.end());
            }
        }
        if (W.size() >= q){
            sort(W.begin(), W.end());
            ans = min(ans, W[q - 1] - W[0]);
        }
        W.erase(W.begin(), W.end());
    }
    cout << ans << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int result = 0;

  for (int i = A; i <= B; i++) {
	int tmp = i;
    int reverse = 0;
    while (tmp !=0) {
      reverse *= 10;
      reverse = reverse + tmp % 10;
      tmp /= 10;
    }
    if (reverse == i) {
      result++;
    }
  }
  
  cout << result << endl;
}



Measured memory_bytes: 256