akhauriyash/Code-Regression huggingface dataset:
def main():
    MOD = 1000000007
    s = int(input())
    dp = [0] * (s + 1)
    dp[0] = 1
    tot = 0
    for i in range(1, s + 1):
        if i >= 3:
            tot += dp[i - 3]
            tot %= MOD
        dp[i] = tot
    print(dp[s])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9112
import sys
N = int(input())
A = [int(x) for x in input().split()]

if A.count(0) > 0:
    print(0)
    sys.exit()
    
ans = 1
for i in range(N):
    ans *= A[i]
    # print("A[i] = {}, ans = {}".format(A[i], ans))
    if ans > 10 ** 18:
        print(-1)
        sys.exit()

print(ans)

Measured memory_bytes: 21648
while(1):
    a, op, b = input().split()

    if op == "?":
        break

    if op == "+":
        print(int(a) + int(b))
    if op == "-":
        print(int(a) - int(b))
    if op == "*":
        print(int(a) * int(b))
    if op == "/":
        print(int(a) // int(b))

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> p(m);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        p.at(i) = make_pair(a,b);
    }
    int point = 0;
    vector<int> able(m*2);
    for(int i = 0; i < m*2; i++){
        able.at(i) = 200001;
    }
    for(int i = 0; i < m; i++){
        if(p.at(i).first == 1){
            able[point] = p.at(i).second;
            point++;
        }
    }
    int flag = 0;
    for(int i = 0; i < m; i++){
        if(p.at(i).second == n){
            able[point] = p.at(i).first;
            point++;
        }
    }
    sort(able.begin(),  able.end());
    for(int i = 0; i < point-1; i++){
        if(able[i] == able[i+1]){
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        cout << "IMPOSSIBLE";
    } else {
        cout << "POSSIBLE";
    }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<ll, ll>;
const int INF = 1001001001;

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<P> points(n);
  vector<ll> x(n), y(n);
  REP(i, n){
    cin >> x[i] >> y[i];
    points[i] = P(x[i], y[i]);
  }
  sort(ALL(x));
  sort(ALL(y));
  ll ans = (ll)(9e18);
  REP(y1, n) FORr(y2, n, y1){
    ll h = y[y2] - y[y1];
    REP(x1, n) FORr(x2, n, x1){
      ll w = x[x2] - x[x1];
      ll m = 0;
      REP(i, n){
        ll a = points[i].first;
        ll b = points[i].second;
        if(a < x[x1] || x[x2] < a || b < y[y1] || y[y2] < b) continue;
        m++;
      }
      if(m >= k) chmin(ans, h*w);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;cin>>n;
    vector<vector<int>> C(n+1,vector<int>(n+1,0));
    //↑pの為に一つ多く作った。index番号が行列の番号と一致。
    vector<int> p(n+1);
    rep(i,n){
        int a,b;cin>>a>>b;
        if(i == 0){
            p[0] = a;
            p[1] = b;
        }else{
            p[i+1] = b;
        }
    }
    for(int l = 2;l<=n;l++){
        //lは行列の個数.
        for(int i = 1; i+l-1 <= n; i++){
            int j = i+l-1;//左端のindex
            int mn = INF;
            for(int k = i;k<j;k++){
                mn = min(mn,C[i][k]+C[k+1][j]+p[i-1]*p[k]*p[j]);
            }
            C[i][j] = mn;
        }
    }
    cout<<C[1][n]<<endl;
    return 0;
}


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

int main()
{
    int A, B, C, D, E, X1, X2, X3, X4, X5, Y, Z;
    cin >> A >> B >> C >> D >> E;

    X1 = 10 - A % 10;
    X2 = 10 - B % 10;
    X3 = 10 - C % 10;
    X4 = 10 - D % 10;
    X5 = 10 - E % 10;
    if (X1 == 10)
    {
        X1 = 0;
    }
    if (X2 == 10)
    {
        X2 = 0;
    }
    if (X3 == 10)
    {
        X3 = 0;
    }
    if (X4 == 10)
    {
        X4 = 0;
    }
    if (X5 == 10)
    {
        X5 = 0;
    }
    Y = max(max(X1, X2), max(X3, max(X4, X5)));
    Z = (X1 + X2 + X3 + X4 + X5 + A + B + C + D + E) - Y;
    cout << Z << endl;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
if (N == 1):
    L = int(input())
elif (N == 2):
    L = list(map(int, input().split()))
elif (N == 3):
    L = list(map(int, input().split()))
    L.sort()
    if (L[0]+L[1]>L[2]):
        if (L[0]!=L[1]) and (L[2]!=L[1]):
            ans += 1
else:
    L = list(map(int, input().split()))
    if len(L)>=3:
        L.sort()
        for i in range(len(L)-2):
            for j in range(i+1, len(L)-1):
                if (L[i] - L[j] == 0):
                    continue
                else:
                    for k in range(j+1, len(L)):
                        if (L[j] - L[k] ==0):
                            continue
                        else:
                            if (L[i]+L[j]>L[k]):
                                ans += 1
print(ans)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for(int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  bool hantei[n];
  for(int i = 0; i < n; i++) {
    hantei[i] = false;
  }
  vector<vector<int>> road(m, vector<int>(2));
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < 2; j++) {
      cin >> road.at(i).at(j);
    }
    if(h.at(road.at(i).at(0) - 1) < h.at(road.at(i).at(1) - 1)) {
      hantei[road.at(i).at(0) - 1] = true;
    }
    else if(h.at(road.at(i).at(0) - 1) == h.at(road.at(i).at(1) - 1)) {
      hantei[road.at(i).at(0) - 1] = true;
      hantei[road.at(i).at(1) - 1] = true;
    }
    else if(h.at(road.at(i).at(0) - 1) > h.at(road.at(i).at(1) - 1)) {
      hantei[road.at(i).at(1) - 1] = true;
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(hantei[i] == false) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
vector<int> dp(100001, 1e8);
int main() {
    int n;
    cin >> n;
    dp[0] = 0;
    rep(i,n) {
        if ( dp[i] == 1e8 ) continue;
        if ( i + 1 <= n ) dp[i+1] = min(dp[i+1], dp[i] + 1);
        int tmp_num = 6;
        while(1) {
            if ( i + tmp_num > n ) break;
            dp[i+tmp_num] = min(dp[i+tmp_num], dp[i] + 1);
            tmp_num *= 6;
        }
        tmp_num = 9;
        while(1) {
            if ( i + tmp_num > n ) break;
            dp[i+tmp_num] = min(dp[i+tmp_num], dp[i] + 1);
            tmp_num *= 9;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(i+1,n):
		if i==j:
			continue
		xi, yi = xy[i]
		xj, yj = xy[j]
		pq.append((xi - xj, yi - yj))
ans = n
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)

Measured memory_bytes: 3188
// AOJ 1082: 11224111122411
// 2017.11.1 bal4u@uu

#include <stdio.h>

#define N 100000
#define M 100000007

int a[N+2] = {0,1,2,4,8,16};
int b[N+2] = {0,1,2,4};

char buf[N+2], *p, *q;

int main()
{
	int i, j;
	long long ans;

	for (i = 6; i <= N; i++) {
		for (a[i] = 1, j = 1; j < 6; j++) a[i] = (a[i] + a[i-j]) % M;
	}
	for (i = 4; i <= N; i++) {
		for (b[i] = 1, j = 1; j < 4; j++) b[i] = (b[i] + b[i-j]) % M;
	}
	while (fgets(buf, sizeof(buf), stdin) && *buf != '#') {
		ans = 1;
		p = buf; while (*p >= '0') {
			q = p; while (*q >= '0' && *q == *p) q++;
			if (*p == '8' || *p == '0') ans = (ans * b[q-p]) % M;
			else						ans = (ans * a[q-p]) % M;
			p = q;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2708
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	string s;

	cin >> s;

	if (s == "ABC") {
		printf("ARC\n");
	}
	else {
		printf("ABC\n");
	}

	return 0;
}

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

int main () {
  int N;
  cin >> N;
  vector<int>a(N);
  int count0 = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    if (a.at(i) == 0){
      count0++;
    }
  }
  if (count0 == N){
    cout << "Yes" << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  
  int diff = 1;
  
  for (int i = 1; i < N; i++) {
    if (a.at(i) != a.at(i-1)){
      diff++;
    }
  }
  
  if (diff > 3){
    cout << "No" << endl;
    return 0;
  }
  
  vector<int>count(3,0);
  count.at(0) = 1;
  vector<int>A(3);
  A.at(0) = a.at(0);
  int j = 1;
  if (diff == 3){
    for (int i = 1; i < N; i++) {
      if (a.at(i) != a.at(i-1)){
        A.at(j) = a.at(i);
        j++;
      }
      count.at(j-1)++;
    }
    if (count.at(1) != count.at(2) || count.at(0) != count.at(1)){
      cout << "No" << endl;
      return 0;
    }
    
    bitset<30>X(A.at(0));
    bitset<30>Y(A.at(1));
    bitset<30>Z(A.at(2));
    bitset<30>B = (X^Y)^Z;
    int C = B.to_ullong();
    if (C == 0){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
    return 0;
  }
  
  if (diff == 2 && count0 * 3 == N){
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
}
    



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

using namespace std;

int bfs(int now,int n,vector<int> *v,bool *visited){
    visited[now] = true;
    int path = 0;
    //cout << "Now=" << now <<endl;
    for(int i=0;i<n;i++){
        if(!visited[i]){
            break;
        }
        if(i==n-1){
            return 1;
        }
    }

    for(int i=0;i<v[now].size();i++){
        if(visited[v[now][i]] == true){
            continue;
        }
        path += bfs(v[now][i],n,v,visited);
        visited[v[now][i]] = false;
    }
    return path;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector <int>  v[n];
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    } 
    bool visited[n];
    for(int i=0;i<n;i++){
        visited[i] = false;
    }
    /*
    for(int i=0;i<n;i++){
        for(int j=0;j<v[i].size();j++){
            cout << v[i][j] << " " ;
        }
        cout << endl;
    }*/
    int ans = bfs(0,n,v,visited);
    cout << ans <<endl;return 0;
}

Measured memory_bytes: 256
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.sort()
l,r=data[0]
lst=[0]*n
lst[0]=r-l+1
for i in range(1,n):
    a,b=data[i]
    l=a
    if b<r:
        r=b
    lst[i]=max(0,r-l+1)
li=[0]*n
l,r=data[n-1]
li[n-1]=r-l+1
for i in range(1,n):
    a,b=data[n-1-i]
    if b<r:
        r=b
    li[n-1-i]=max(0,r-l+1)
k=0
s=0
for i in range(n):
    l,r=data[i]
    if k<=r-l+1:
        k=r-l+1
        s=i
l=0
r=10**9+1
for i in range(n):
    if i==s:
        continue
    a,b=data[i]
    l=max(l,a)
    r=min(r,b)
ans=k+max(0,r-l+1)
for i in range(n-1):
    ans=max(ans,lst[i]+li[i+1])
print(ans)

Measured memory_bytes: 64472
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1  << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int a, b;
  cin >> a >> b;
  if (a <= b) {
    cout << a << endl;
  } else {
    cout << a - 1 << endl;
  }
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)
    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)
    def __mul__(self, other):
        return Point(self.x * other, self.y * other)
    def __floordiv__(self, other):
        return Point(self.x / other, self.y / other)
    def __repr__(self):
        return str(self.x) + ' ' + str(self.y)

class Vector(Point):
    pass

class Line:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

class Segment(Line):
    pass

def points_to_vector(p1, p2):
    x = p1.x - p2.x
    y = p1.y - p2.y
    return Vector(x, y)

def vector(p):
    return Vector(p.x, p.y)

def dot(v1, v2):
    return v1.x * v2.x + v1.y * v2.y

def cross(v1, v2):
    return v1.x * v2.y - v1.y * v2.x

def norm(v):
    return v.x**2 + v.y**2

def distance(v):
    return math.sqrt(norm(v))

def project(s, p):
    base = points_to_vector(s.p1, s.p2)
    hypo = points_to_vector(p, s.p1)
    r = dot(hypo, base) / norm(base)
    return s.p1 + base * r

def reflect(s, p):
    return p + (project(s, p) -p) * 2

def get_distance(s1, s2):
    if intersect_s(s1, s2):
        return 0
    d1 = get_distance_sp(s1, s2.p1)
    d2 = get_distance_sp(s1, s2.p2)
    d3 = get_distance_sp(s2, s1.p1)
    d4 = get_distance_sp(s2, s1.p2)
    return min(d1, min(d2, min(d3, d4)))

def get_distance_pp(p1, p2):
    return distance(p1 - p2)

def get_distance_lp(l, p):
    return abs(cross(l.p2 - l.p1, p - l.p1) / distance(l.p2 - l.p1))

def get_distance_sp(s, p):
    if dot(s.p2 - s.p1, p - s.p1) < 0:
        return distance(p - s.p1)
    elif dot(s.p1 - s.p2, p - s.p2) < 0:
        return distance(p - s.p2)
    else:
        return get_distance_lp(s, p)

def ccw(p0, p1, p2):
    EPS = 1e-10
    COUNTER_CLOCKWISE = 1
    CLOCKWISE = -1
    ONLINE_BACK = 2
    ONLINE_FRONT = -2
    ON_SEGMENT = 0
    v1 = p1 - p0
    v2 = p2 - p0
    if cross(v1, v2) > EPS:
        return COUNTER_CLOCKWISE
    elif cross(v1, v2) < -EPS:
        return CLOCKWISE
    elif dot(v1, v2) < -EPS:
        return ONLINE_BACK
    elif norm(v1) < norm(v2):
        return ONLINE_FRONT
    else:
        return ON_SEGMENT

def intersect_p(p1, p2, p3, p4):
    return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersect_s(s1, s2):
    return intersect_p(s1.p1, s1.p2, s2.p1, s2.p2)

def get_cross_point(s1, s2):
    base = s2.p2 - s2.p1
    d1 = abs(cross(base, s1.p1 - s2.p1))
    d2 = abs(cross(base, s1.p2 - s2.p1))
    t = d1 / (d1 + d2)
    return s1.p1 + (s1.p2 - s1.p1) * t


import sys
# sys.stdin = open('input.txt')

q = int(input())
for i in range(q):
    temp = list(map(int, input().split()))
    points = []
    for j in range(0, 8, 2):
        points.append(Point(temp[j], temp[j+1]))
    s1 = Segment(points[0], points[1])
    s2 = Segment(points[2], points[3])
    print(get_cross_point(s1, s2))


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



int main(int argc, char const* argv[])
{
  int N;
  int ans = 0;
  cin >> N;
  vector<int> h(N);

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

  while(*max_element(h.begin(), h.end()) > 0){
    int repeat = h.size();
    bool iszero = true;
    bool existnonezero = false;
    for (int i = 0; i < repeat; i++) {
      if(iszero){
        if(h[i]>0){
          h[i]--;
          ans++;
          iszero = false;
        }
      }
      else{
        if(h[i] > 0) h[i]--;
        else iszero = true;
      }
      if(h[i] != 0)existnonezero= true;
      }
    if(!existnonezero) break;
    }

  cout << ans << endl;

  return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void dk()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

char a[1000][1000];
int dp[1000][1000];
int32_t main()
{
    //dk();
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = m - 1; j >= 0; j--)
        {
            if (a[i][j] == '#')
                continue;
            else if (i == n - 1 && j == m - 1)
                dp[i][j] = 1;
            else if (i == n - 1)
                dp[i][j] = dp[i][j + 1];
            else if (j == m - 1)
                dp[i][j] = dp[i + 1][j];
            else
                dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    cout << dp[0][0];
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
 
using namespace std;
long long mod = 1e9+7;
long long dp[1000+3][24];
int main(){
#ifdef LOCAL
	freopen("input.txt","r",stdin);
#endif
   int n;
  cin >> n;
  vector<int>val(n,0);
  for(int i=0;i<n;i++)
  cin >> val[i];
  int max = val[0];
  int min = val[0];
  int ans = 1;
  for(int i=1;i<n;i++){

    if(val[i]<=min)
      ans++;

    if(val[i]>max)
      max = val[i];
    if(val[i]<min)
      min = val[i];
  }
  cout << ans;
      return 0;
}

Measured memory_bytes: 1024
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let x: Vec<i32> = read_vec();
    let ans = x.iter().enumerate().find(|(_, &x)| x == 0).unwrap().0 + 1;
    println!("{}", ans);
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, max=-1, maxi=1;
	
	cin>>n;

	repr(i, 1, n+1){
		int temp=i, count=0;
		while(1){
			if(temp%2){
				break;
			}
			temp/=2;
			count++;
		}
		if(max<count){
			max=count;
			maxi=i;
		}
	}
	cout<<maxi<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc082/tasks/abc082_b

int main() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    cout << ((s<t)?"Yes":"No") << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
int main(){
     int n;
     cin >> n;
     vector<int> a(n);
     for (int i = 0; i < n; i++)
          cin >> a[i];
     int ans = -1;
     int cnt = 0;
     for (int i = 0; i < n - 1; i++) {
          if(a[i + 1] <= a[i]) {
//               cout << i << " ";
//               cout << cnt << endl;
               cnt++;
          }
          else {
               ans = max(cnt, ans);
               cnt = 0;
          }
               
     }
     ans = max(cnt, ans);
     cout << ans;
     return 0;
}


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

int sum;
int t[6] = {1,5,10,50,100,500};

int main(){
	for(int i = 0; i < 6; i++){
		int c;
		cin >> c;
		sum += c*t[i];
	}
	if(sum >= 1000) cout << "1" << endl;
	else cout << "0" << endl;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()) {
			int N = sc.nextInt(), L = sc.nextInt();
			int[] taste = new int[N];
			int sum = 0;
			for(int i = 0; i < N; i++) {
				taste[i] = L + (i + 1) - 1;
				sum += taste[i];
			}
			int ans = 0, abs = Integer.MAX_VALUE;
			for(int i = 0; i < N; i++) {
				if(Math.abs(taste[i]) < abs) {
					abs = Math.abs(taste[i]);
					ans = sum - taste[i];
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 23508
from collections import Counter

n = int(input())
c = Counter(map(int, input().split()))
c = sorted(c.items())

if len(c) == 1:
    print(c[0][1])
    exit()

if len(c) == 2:
    if c[1][0] - c[0][0] == 1:
        print(c[0][1]+c[1][1])
    else:
        print(max(c[0][1], c[1][1]))
    exit()

ans = 1
for i in range(1, len(c)-1):
    cnt = c[i][1]
    if c[i+1][0] - c[i][0] == 1:
        cnt += c[i+1][1]
    if c[i][0] - c[i-1][0] == 1:
        cnt += c[i-1][1]
    ans = max(cnt, ans)

print(ans)


Measured memory_bytes: 16620
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  int k;
  cin >> s;
  cin >> k;

  int n = s.length();

  for(int i = 0; i < n && k > 0; i++){
    int d = ('z' - s[i] + 1) % 26;
    if(d <= k){
      s[i] = 'a';
      k -= d;
    }
  }

  s[n - 1] = 'a' + (s[n - 1] - 'a' + (k % 26)) % 26;

  cout << s << endl;

  return 0;
}


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

#define MOD 1000000007
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}
#define MAX 100002

int n;
int rem;
int hated[MAX];
bool die[MAX];
int hate[MAX];
set<int> ava;
bool check(int node){
	if(die[hate[node]]==false&&hated[hate[node]]>=rem-1){
		return false;
	}
	if(rem-1>=3)return true;
	int a=*ava.begin();
	if(a==node)a=*ava.rbegin();
	int b=hate[a];
	int c=hate[b];
	int d=hate[c];
	if(rem==3&&die[c]==false&&die[d]==false&&c!=node&&d!=node&&c!=d&&hate[c]==d&&hate[d]==c){
		return false;
	}
	return true;
	//ng:
	//only 2-cycle
	//exist a_{v}, and everyone dislike a_{v}
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		a--;
		hate[i]=a;
		hated[a]++;
	}
	if(n==2){
		puts("-1");
		return 0;
	}
	rem=n;
	set<int> ng;
	for(int i=0;i<n;i++)ava.insert(i);
	vector<int> ret;
	for(int i=0;i<n;i++){
		int id=-1;
		cerr<<i<<endl;
		for(auto el:ava){
			if(ng.count(el)==0&&check(el)){
				id=el;
				ng.clear();
				ng.insert(hate[el]);
				ava.erase(el);
				die[el]=true;
				rem--;
				hated[hate[el]]--;
				break;
			}
		}
		if(id==-1){
			puts("-1");
			return 0;
		}
		ret.push_back(id);
	}
	for(int i=0;i<n;i++){
		if(i)printf(" ");
		printf("%d",ret[i]+1);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>

void
calc_line_params(double x1, double y1, double x2, double y2, double *ap, double *bp, double *cp)
{
    *ap = y1 - y2;
    *bp = x2 - x1;
    *cp = y1*x2 - y2*x1;
}

/*
 * Determinant for maxrix:
 *   |a  b|
 *   |d  e|
 */
double
det_for(double a, double b, double d, double e)
{
    return a*e - b*d;
}

/*
 * Crossing point of 2 lines:
 *   a*x + b*y = c
 *   d*x + b*y = f
 */
void
calc_cross_point(double a, double b, double c, double d, double e, double f, double *cxp, double *cyp)
{
    double det = det_for(a, b, d, e);
    *cxp = (c*e - b*f) / det;
    *cyp = (a*f - c*d) / det;
}

int
judge_cross_point_is_valid(double x1, double y1, double x2, double y2, double x3, double y3, double xp, double yp)
{
        double a, b, c, d, e, f, cx, cy;

        calc_line_params(x1, y1, x2, y2, &a, &b, &c);
        calc_line_params(x3, y3, xp, yp, &d, &e, &f);

        if (!det_for(a, b, d, e)) return 0;
        calc_cross_point(a, b, c, d, e, f, &cx, &cy);

        if ((x1 < cx) && (x2 < cx)) return 0;
        if ((cx < x1) && (cx < x2)) return 0;
        if ((y1 < cy) && (y2 < cy)) return 0;
        if ((cy < y1) && (cy < y2)) return 0;
        return 1;
}

int
main(int argc, char *argv[])
{
    double x1, y1, x2, y2, x3, y3, xp, yp;

    while (EOF != scanf("%lf %lf %lf %lf %lf %lf %lf %lf\n", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp)) {
        if (judge_cross_point_is_valid(x1, y1, x2, y2, x3, y3, xp, yp)
            && judge_cross_point_is_valid(x2, y2, x3, y3, x1, y1, xp, yp)
            && judge_cross_point_is_valid(x3, y3, x1, y1, x2, y2, xp, yp)
            ) {
            puts("YES");
            continue;
        }
        puts("NO");
    }

    return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    int ans = 0;
    rep(i,n) {
        int input, tmp;
        tmp = 0;
        rep(j,m) {
            cin >> input;
            tmp += input * b[j];
        }
        if (tmp + c> 0)
            ans++;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define SET(p,k) memset(p, k, sizeof(p));
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

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

	int a, b;

	cin >> a >> b;

	cout << (a + b + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  

void solve(void)
{
  int N,M,K;
  cin>>N>>M>>K;
  int C = N*M;
  set<int> SET;
  int Dec = M;
  for (int i = 0; i < M; i++)
  {

    for (int j = 0; j <= N; j++)
    {
      SET.insert(C - j*Dec);
    }
    C -=N;
    Dec -= 2;
  }

  if(SET.find(K) != SET.end())
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  

  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n; cin >> n;
    n = n % 10;
    string ans;
    if(n==3) ans = "bon";
    else if(n==0||n==1||n==6||n==8) ans = "pon";
    else ans = "hon";
    cout << ans << endl;
}


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

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

	int n;
	cin >> n;
	string color, bag;
	for (int i = 0; i < n; i++) {
		cin >> color;
		bag += color;
	}
	int count = 0;
	if (bag.find("P") != string::npos) {
		count++;
	}
	if (bag.find("W") != string::npos) {
		count++;
	}
	if (bag.find("G") != string::npos) {
		count++;
	}
	if (bag.find("Y") != string::npos) {
		count++;
	}

	if (count == 3) {
		cout << "Three" << "\n";
	}
	else if (count == 4) {
		cout << "Four" << "\n";
	}

	return 0;
}

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

int main()
{
	int n, T[300];
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> T[i];

	for (int i = 1; i <= n; i++)
	{
		cout << "node " << i << ": key = " << T[i] << ", ";

		if (i != 1)cout << "parent key = " << T[i / 2] << ", ";
		if (i * 2  <= n)cout << "left key = " << T[2 * i] << ", ";
		if (2 * i + 1 <= n)cout << "right key = " << T[2 * i+1] << ", ";
	cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define LL long long
using namespace std;
/*int ans_now;
int n,m;
bool flag[51][51];
void dfs(int u, int distance)
{
    if(distance>ans_now)
        return;
    if(u==n)
    {
        ans_now=distance;
        return ;
    }
    for(int i=1;i<=n;i++)
    {
        if(flag[u][i])
            dfs(i,distance+1);
    }
}
int fun()
{
    ans_now=0x3f3f3f3f;
    dfs(1,0);
    return ans_now;
}*/
int t[110000],x[110000],y[110000];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    /*while(cin>>n>>m)
    {
        memset(flag,0,sizeof(flag));
        for(int i=0;i<m;i++)
        {
            int a,b;
            cin>>a>>b;
            flag[a][b]=1;
        }
        cout<<fun()<<endl;
    }*/
    int n;
    while(cin>>n)
    {
        t[0]=0,x[0]=0,y[0]=0;
        for(int i=1;i<=n;i++)
        {
            cin>>t[i]>>x[i]>>y[i];
        }
        bool flag=1;
        for(int i=1;i<=n;i++)
        {
            int dis=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
            int time=t[i]-t[i-1];
            if(time>=dis&&(time-dis)%2==0)
            {

            }
            else
            {
                flag=0;
                break;
            }
        }
        if(flag)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;
using ll = long long;

int main() {
  int N;
  cin>>N;
 vector<ll> A ={2,1};
   for(int i=2;i<=N;i++){
    ll L = A[i-2] + A[i-1] ;
     A.push_back(L);
   }
cout << A[N] << endl;
}
  


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using std::min;
using std::max;
using std::sort;
#define MAXN 103

int main(void)
{
    int N, K, R;
    int a[MAXN],plate[MAXN];
    scanf("%d%d",&N,&K);
    int i,j,res=0;
    
    for(i=0;i<N;i++)
    {
        scanf("%d",a+i);
    }

    R=min(N,K);
    for(int A=0;A<=R;A++)
    {
        for(int B=0;B<=R-A;B++)
        {
            for(i=0;i<A;i++)
            {
                plate[i]=a[i];
            }
            for(j=0;j<B;j++)
            {
                plate[i+j]=a[N-1-j];
            }
            sort(plate,plate+A+B);
            i=0;
            while(i<K-(A+B) && plate[i]<0)
            {
                i++;
            }
            int s = 0;
            for(;i<A+B;i++)
            {
                s+=plate[i];
            }
            res = max(s,res);
        }
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;



int32_t main(){    
	#ifdef XOX
		freopen("Input.txt", "r", stdin);
		freopen("Output.txt", "w", stdout);
	#endif
 
	ios::sync_with_stdio(!cin.tie(NULL));

	int n;
	cin >> n;
	if(n % 1000 == 0)	{
		cout << 0;
		return 0;
	}
	cout << 1000 - (n % 1000);
}

Measured memory_bytes: 3648
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=998244353;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}
 
int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
 
const int N=2000002;

void solve(){
  int n;
  cin>>n;
  vi a(n);
  cin>>a;
  vi b(n);
  cin>>b;
  int ans=0;
   // (2**i)-1 <x<2**(i+1)
   // 2**i+2**(i+1) <=x
   for(int i=0;i<29;i++){
     vector<int>a2=a,b2=b;
     for(int j=0;j<n;j++){
       a2[j]%=(1<<(i+1));
       b2[j]%=(1<<(i+1));
     }
     sort(all(b2));
     int tot=0;
     for(int j=0;j<n;j++){
       int cnt2=lower_bound(all(b2),(1<<(i+1))-a2[j])-b2.begin();
       cnt2-=(upper_bound(all(b2),(1<<(i))-a2[j]-1)-b2.begin());
       cnt2-=(upper_bound(all(b2),(1<<i)+(1<<(i+1))-a2[j]-1)-b2.begin());
       cnt2+=n;
       tot+=cnt2;
     }
     if(tot&1){
       ans|=1<<i;
     }
     debug(i,tot);
   }
   cout<<ans;
}
 
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}


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

int main(){
long long int  a,ans;
long long int b,c;
cin>>a;
b=(a/100);
if((a%100)%5==0){
  c=(a%100)/5;
}else{
  c=(a%100)/5+1;
}
if(b>=c){
  cout<<"1"<<endl;
}else{
  cout<<"0"<<endl;
}
}




Measured memory_bytes: 256
s = input()
K = int(input())

S = set([])
for i in range(len(s)):
    for j in range(i + 1, i + 1 + K):
        # print(f'{s[i:j]=}')
        S.add(s[i:j])
# print(f'{S=}')
# print(f'{sorted(S)=}')
ans = sorted(S)[K - 1]
print(ans)


Measured memory_bytes: 10436
#include <stdio.h>
 
int main(int argc, char **argv)
{
    int w,h,x,y,r;
 
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if ((x >= r) && (x+r <= w) &&
        (y >= r) && (y+r <= h)) {
        printf("Yes\n");
    } else printf("No\n");
 
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
    out << "[";
    for (auto it = a.begin(); it != a.end(); ++it) {
        if (it != a.begin())
            out << ", ";
        out << *it;
    }
    return out << "]";
}
const int N=3001;
ll dp[N][N][2],a[N];
ll go(ll i,ll j,ll cur){
    if(i>j) return 0;
    ll &ans=dp[i][j][cur];
    if(ans!=-1) return ans;
    if(cur==0){
        ans=0;
        ans=max(ans,a[i]+go(i+1,j,1));
        ans=max(ans,a[j]+go(i,j-1,1));
    }
    else{
        ans=inf;
        ans=min(ans,go(i+1,j,0));
        ans=min(ans,go(i,j-1,0));
    }
    return ans;
}
int main()
{
    boost;
    ll n,i,j,x,t,y;
    cin>>n;
    ll s=0;
    for(i=0;i<n;i++) cin>>a[i],s+=a[i];
    SET(dp,-1);
    x=go(0,n-1,0);
    cout<<2*x-s;
}

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

int main() {
    long H;
    cin>>H;
    long k = 0;
    long tmp = 1;
    while(tmp <= H){
        tmp *= 2;
        k++;
    }
    long ans = 1;
    long two = 1;
    for(long i=1;i<k;++i){
        ans += two*2;
        two *= 2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d){
		cout<<"Balanced";
	}
	if(a+b>c+d){
		cout<<"Left";
	}
	if(a+b<c+d){
		cout<<"Right";
	}
} 

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split( )))
ans = 0
mod = 10**9+7
Bit = [0 for j in range(60)]# for i in range(n+1)
for j in range(60):#ループ交換
    for i in range(1,n):##1から
        if not ((a[i-1]>>j)&1):#a[i-1]のjビット目0
            Bit[j] += 1
        if ((a[i]>>j)&1):#aiのjビット目1
            ans += Bit[j]<<j
            ans %=mod
        else:
            ans += (i-Bit[j])<<j
            ans %= mod
    
print(ans)


Measured memory_bytes: 122936
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count =0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define ll long long
const int maxm=2e6+5;
int n,x;
int cal(int a,int b){
    if(b%a==0){//
        return (b/a*2-1)*a;
    }
    int ans=b/a*2*a;
    ans+=cal(b%a,a);
    return ans;
}
signed main(){
    cin>>n>>x;
    int a=x,b=n-x;
    if(a>b)swap(a,b);
    int ans=cal(a,b)+n;//外面两条边的长度=x+(n-x)=n
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
int N;

bool isSame(int P[], int v[]){
    for(int i = 0; i < N; i++){
        if(P[i] != v[i]) return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    
    int P[8];
    int Q[8];
    int p, q;
    int v[8];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> P[i];
    for(int i = 0; i < N; i++) cin >> Q[i];
    for(int i = 0; i < N; i++) v[i] = i+1;
    int cur = 1;
    do {
        if(isSame(P, v)) p = cur;
        if(isSame(Q, v)) q = cur;
        cur++;
    } while (std::next_permutation(v, v+N));
    cout << abs(p-q) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
#define clr0(n) (memset(n,0,sizeof n))
#define clr1(n) (memset(n,-1,sizeof n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
int main()
{
	vector<int>v(3);
	cin >> v[0] >> v[1] >> v[2];

	sort(all(v));
	if (v[2] == 7 && v[0] == 5 && v[1] == 5)
		cout << "YES" << endl;
	else cout << "NO" << endl;
	

}

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

const double eps = 1e-9;

int main() {
    double d;
    cin >> d;
    
    double mx = d;

    // x軸,y軸上になる場合
    mx = max(mx, d*2.0/sqrt(2.0));

    // 両方がx軸上になる場合
    for (double y=1; y<d+eps; ++y) {
        double x = sqrt(d*d - y*y);
        if (x < 1) {
            mx = max(mx, 1+y);
        } else {
            mx = max(mx, x+y);
        }
    }

    printf("%.12f\n", mx);

    return 0;
}


Measured memory_bytes: 3296
#include <stdio.h>
#include <string.h>
#define M 1000

int comp(int a,int b){
  if(a>b) return a;
  else return b;
}

int gudge(char x[],char y[]){
  int z[M+1][M+1];
  int i,j,count=0,n1,n2;

  n1=strlen(x);
  n2=strlen(y);
  

  for(i=1;i<=n1;i++){
    z[i][0]=0;
  }
  for(i=1;i<=n2;i++){
    z[0][i]=0;
  }

  for(i=1;i<=n1;i++){
    for(j=1;j<=n2;j++){
      if(x[i-1]==y[j-1]){
	z[i][j]=z[i-1][j-1]+1;
      } else{
	z[i][j]=comp(z[i-1][j],z[i][j-1]);
      }
      count=comp(count,z[i][j]);
    }
  }

  return count;
}
       
  


int main(){
  int x,i;
  char in_1[M],in_2[M];

  scanf("%d",&x);

  for(i=0;i<x;i++){
    scanf("%s",in_1);
    scanf("%s",in_2);

    printf("%d\n",gudge(in_1,in_2));
  }

  return 0;
}
    



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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int i=0;i<n;i++) {
	    cin>>h[i];
	}
	vector<int> dp(n,INT_MAX);
	dp[0] = 0;
	for(int i=0;i<n;i++) {
	    for(int j=1;j<=k;j++) {
	        if(i+j<n) {
	            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
	        }
	    }
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 4036
#include<stdio.h>
#include<stdlib.h>

typedef struct {
  int mass;
  int number;
} set;

int cmp( const void *p, const void *q ) {
    return ((set*)q)->number - ((set*)p)->number;
}

int main(){
  int i,j;
  long k=0;
  
  int N,M;
  scanf("%d %d",&N,&M);
  set A[N+M];
  for(i=0;i<N;i++){
    scanf("%d ",&A[i].number);
    A[i].mass = 1;
  }
  for(i=N;i<M+N;i++){
    scanf("%d %d",&A[i].mass,&A[i].number);
  }
  
  qsort(A,sizeof(A) / sizeof(set),sizeof(set),cmp);

  i=0;
  while(N > 0){
    if(A[i].mass > N){
      k += (long)((long)A[i].number*(long)N);
      N = 0;
      i++;
    }
    else{
      k += (long)((long)A[i].number*(long)A[i].mass);
      N -= A[i].mass;
      i++;
    }
  }
  printf("%ld\n",k);
  return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int count_two_factor(int num) {
  int count = 0;
  int tmp_num = num;

  while(tmp_num % 2 == 0) {
    count++;
    tmp_num /= 2;
  }

  return count;
}

int main() {
  int n;
  V<int> a;
  cin >> n;
  a.resize(n);

  rep(i, n) {
    cin >> a[i];
  }

  int min_two_factor_count = 1e9;
  rep(i, n) {
    int current_count = count_two_factor(a[i]);
    min_two_factor_count = min(min_two_factor_count, current_count);
  }

  cout << min_two_factor_count << endl;
}

Measured memory_bytes: 3652