akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
def solve():
    s = int(stdin.readline())
    mod = 10**9+7
    if s < 3: return 0
    dp = [0]*(s+1)
    dp[0] = 1
    for i in range(3,s+1):
        dp[i] = dp[i-1] + dp[i-3]
    return dp[s]%mod
print(solve())

Measured memory_bytes: 63380
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


double SUM;

double calc_S(double y){

	if(y == 0)return 0;

	double x = (SUM*y-y*y)/(2*y);

	return x*y*(SUM-(x+y));
}

int main(){

	scanf("%lf",&SUM);

	double L = 0,R = SUM;

	for(int loop = 0; loop < 100; loop++){

		double mid1 = (2.0*L+R)/3.0;
		double mid2 = (1.0*L+2.0*R)/3.0;

		if(calc_S(mid1) > calc_S(mid2)){

			R = mid2;
		}else{

			L = mid1;
		}
	}

	printf("%.10lf\n",calc_S((L+R)/2));

	return 0;
}


Measured memory_bytes: 256
from collections import deque
s  = input()[::-1]
lsts = [0] * 2019
kai = 1
cou = 0
st = 0
lsts[0] = 1
for i in s:
  st += int(i) * kai
  st %= 2019
  cou += lsts[st]
  lsts[st] += 1  
  kai = kai * 10 % 2019

print(cou)

Measured memory_bytes: 9752
#include <iostream>


using namespace std;


    int A, B, K;

    int main() {

        cin >> A >> B >> K;

        if (B - A + 1 <= K * 2){

            for (int j = 0; j <= B-A; j++){

                cout << A + j << endl;

            }

        }else{

                for (int j = 0; j < K; j++){

                    cout << A + j << endl;

                }

                for (int k = 0; k < K; k++){

                    cout << B - K + 1 + k << endl;

                }
            }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef pair <int,int> P;
typedef long long int ll;

int A[SIZE],B[SIZE];

int main()
{
	int a,b,n;
	scanf("%d %d %d",&a,&b,&n);
	for(int i=0;i<a;i++) scanf("%d",&A[i]);
	for(int i=0;i<b;i++) scanf("%d",&B[i]);
	int ma=A[0],mb=B[0];
	for(int i=0;i<a;i++) ma=min(ma,A[i]);
	for(int i=0;i<b;i++) mb=min(mb,B[i]);
	int ret=ma+ma;
	for(int i=0;i<n;i++)
	{
		int x,y,c;
		scanf("%d %d %d",&x,&y,&c);x--,y--;
		ret=min(ret,A[x]+B[y]-c);
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
B = [[0] * (2 * K) for _ in range(2 * K)]
for _ in range(N):
    x, y, c = input().split()
    if c == "B":
        B[int(x) % (2 * K)][int(y) % (2 * K)] += 1
    else:
        B[int(x) % (2 * K)][(int(y) + K) % (2 * K)] += 1

SB = [[0] * (4 * K + 1) for _ in range(4 * K + 1)]
for x in range(4 * K):
    for y in range(4 * K):
        SB[x][y] = B[x % (2 * K)][y % (2 * K)]
for x in range(4 * K):
    for y in range(4 * K):
        SB[x + 1][y] += SB[x][y]
for y in range(4 * K):
    for x in range(4 * K):
        SB[x][y + 1] += SB[x][y]

ans = 0
for x in range(2 * K):
    for y in range(2 * K):
        cand = SB[x + K][y + K] - SB[x][y + K] - SB[x + K][y] + SB[x][y]
        cand += SB[x + 2 * K][y + 2 * K] - SB[x + K][y + 2 * K] - \
            SB[x + 2 * K][y + K] + SB[x + K][y + K]
        ans = max(ans, cand)

print(ans)


Measured memory_bytes: 197084
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <cstdio>
#include <sstream>
#include <algorithm>
#define endl '\n'
#define all(var) var.begin(), var.end()
int const MOD = 1e9+7;
typedef long long ll;
using namespace std;
 
int main(){
    int n; cin >> n;
    vector < int > v(n);
    for(auto &i: v)
        cin >> i;

    for(auto i: v){
        if(i % 2 == 0){
            if(i % 3 == 0 || i % 5 == 0)
                continue;
            else
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
/*C - Maximal Value*/

#include <bits/stdc++.h>
using namespace std;

int main(){

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

	int tam;
	
	cin >> tam;
	
	vector <int> A(tam);
	vector <int> B(tam - 1);

	for (int i = 0; i < tam - 1; ++i)
		cin >> B[i];

	int ans = 0;

	if(tam == 2){
		ans = B[0] * 2;
	}
	else{

		ans = B[0];

		for (int i = 1; i < tam - 1 ; ++i)
		{
			ans += min(B[i], B[i-1]);
		}

		ans += B[tam - 2];
	}

	cout << ans;


	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>k;
    long a,b,c;
    a=k/50+50;     //要特别处理的数的大小
    b=k%50;       //要特别处理的数的个数
    c=a-b-1;      //正常相等的个数
    cout<<50<<endl;
    for(int i=0;i<50;i++)
    {
        if(i<b)
        {
            if(i==0)
            cout<<a;
            else
            cout<<" "<<a;
        }
        else
        {
            if(i==0)
            cout<<c;
            else
            cout<<" "<<c;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
max_size = 0

def get_max_rectangle(field):
    for i in range(len(field)):
        for j in range(len(field[0])):
            if field[i][j] == 1:
                max_rectangle_right(field, {'x0':j, 'y0':i, 'x1':j, 'y1':i})

def check_expandable(field, rect, a0, a1, b, c):
    return rect[a1] - rect[a0] + 1 == len([i for i in range(rect[a0], rect[a1]+1) if field[rect[b]+c][i] == 1])

def check_fill_ones(field, rect):
    for i in range(rect['x0'], rect['x1']+1):
        for j in range(rect['y0'], rect['y1']+1):
            if field[j][i] == 0:
                return False
    return True

def max_rectangle_right(field, rect):
    #右拡張
    if rect['y1'] - rect['y0'] + 1 == len([i for i in range(rect['y0'], rect['y1']+1) if field[i][rect['x1']+1] == 1]):
        tmp_rect = dict(rect)
        tmp_rect['x1'] += 1
        max_rectangle_right(field, tmp_rect)

    #下拡張
    if rect['x1'] - rect['x0'] + 1 == len([i for i in range(rect['x0'], rect['x1']+1) if field[rect['y1']+1][i] == 1]):
        tmp_rect = dict(rect)
        tmp_rect['y1'] += 1
        max_rectangle_right(field, tmp_rect)

    global max_size
    if check_fill_ones(field, rect):
        max_size = max(max_size, (rect['x1']-rect['x0']+1) * (rect['y1']-rect['y0']+1))

def input_field(y, x):
    field = []
    for i in range(y):
        field.append(map(int, raw_input().split()))
    return pack_field(field, y, x)

def pack_field(field, y, x):
    packed_field = []
    for i in range(y + 2):
        packed_field.append([])
        if i == 0 or i == y + 1:
            for j in range(x + 2):
                packed_field[i].append(0)
        else:
            packed_field[i].append(0)
            for j in range(x):
                packed_field[i].append(field[i-1][j])
            packed_field[i].append(0)
    return packed_field

maxs = []
num = int(raw_input())
first = True
for i in range(num):
    if not first:
        raw_input()

    max_size = 0
    field = input_field(5, 5)
    get_max_rectangle(field)
    maxs.append(max_size)
    first = False

for i in range(num):
    print(maxs[i])

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{

    int n, m;
    cin >> n >> m;

    if(n > m)
        swap(n, m);

    if(n == 1){
        if(m == 1)
            return cout << 1 << '\n', 0;
        return cout << m - 2 << '\n', 0;
    }

    if(n == 2)
        return cout << 0 << '\n', 0;

    cout << 1ll * (n - 2) * (m - 2) << '\n';
    return 0;
}


Measured memory_bytes: 3604
if __name__ == "__main__":
    num_int = int(input())
    numbers = list(map(lambda x: int(x), input().split()))
    num_query = int(input())

    for _ in range(num_query):
        begin, end, num = map(lambda x: int(x), input().split())
        count = 0
        for elem in numbers[begin: end]:
            if (elem == num):
                count += 1
        print(count)



Measured memory_bytes: 5632
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                cnt += 1
print(cnt)


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

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

    char[] S = scanner.next().toCharArray();
    int N = S.length;
    int[] count = new int[3];
    for (char ch : S) count[ch - 'a']++;
    Arrays.sort(count);
    if (count[2] > (N - 1) / 3 + 1) {
      System.out.println("NO");
    } else {
      System.out.println("YES");
    }
  }
}


Measured memory_bytes: 25840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,n,arr[200001];
    cin >> k >> n;
    int i;
    for(i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    int m = k - (arr[n-1] - arr[0]);
    //cout<<m;
    for(i=1;i<n;i++)
    {
        if(arr[i]-arr[i-1] > m)
        {
            m = arr[i] - arr[i-1];
        }
    }
    cout<<k-m<<endl;
    return 0;
}


Measured memory_bytes: 1024
s = [int(i) for i in list(input())]
n = len(s)
start0 = []
start1 = []
for i in range(n):
    if i % 2 == 0:
        start0.append(0)
        start1.append(1)
    else:
        start0.append(1)
        start1.append(0)

idx = 0
tmp0 = 0
tmp1 = 0
for i in s:
    if i != start0[idx]:
        tmp0 += 1
    if i != start1[idx]:
        tmp1 += 1
    idx += 1

print(min(tmp0,tmp1))

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

double dist(int x1, int y1, int x2, int y2){
  double xdiff2 = (x1 - x2)*(x1 - x2);
  double ydiff2 = (y1 - y2)*(y1 - y2);
  double s = sqrt(xdiff2+ydiff2);
  return s;
}

int beki(int x){
  int s=1;
  for(int i = x; i>=1; i--){
    s*=i;
  }
  return s;
}

int main() {
  int n; cin >> n;
  int town[10][2];
  rep(i,n){
    cin >> town[i][0] >> town[i][1];
  }
  /*rep(i,n){
    printf("%d %d\n",town[i][0], town[i][1]);
  }*/

  queue<double> que;
  for(int i = 0; i<n-1; i++){
    for(int j = i+1; j<n; j++){
      que.push(dist(town[i][0],town[i][1],town[j][0],town[j][1]));
      //cout << dist(town[i][0],town[i][1],town[j][0],town[j][1]) << endl;
    }
  }

  double sum=0;
  while(!que.empty()){
    sum += que.front();
    que.pop();
  }

  int hoge = 2*beki(n-1);
  int hoge2 = beki(n);
  double hoge3 = double(hoge)/hoge2;

  //cout << sum << endl;
  //cout << hoge3 << endl;
  printf("%.10f\n",sum*hoge3);

  //((2*beki(n-1))/beki(n))
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

template<class S, class T> inline
ostream& operator<<(ostream&os, pair<S,T> p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template<class S, class T, class U> inline
ostream& operator<<(ostream&os, tuple<S,T,U> t) {
  return os << '('
    << get<0>(t) << ", "
    << get<1>(t) << ", "
    << get<2>(t) << ')';
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) { return os << "(empty)"; }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

typedef vector<int> vi;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);

  int k; cin >> k;
  rep (_, k) {
    int x,y,w,h; cin >> x >> y >> w >> h;
    int z; cin >> z;
    int ans = 0;
    rep (i, z) {
      int u, v; cin >> u>> v;
      if (x <= u and u <= (x+w) and y <= v and v <= (y+h)) ++ans;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1188
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 404;
const int mod = 1e9 + 7;

int n, c, a[N], b[N];

int sum(int x, int y) {
    return (x + y) % mod;
}

int diff(int x, int y) {
    return (x - y + mod) % mod;
}

int mult(int x, int y) {
    return (ll)x * y % mod;
}

int binpow(int x, int y) {
    if (!y) {
        return 1;
    }
    if (y & 1) {
        return mult(x, binpow(x, y - 1));
    } else {
        return binpow(mult(x, x), y >> 1);
    }
}

int pwpref[N][N];

void prepare() {
    for (int x = 0; x < N; ++x) {
        pwpref[x][0] = 0;
        for (int y = 1; y < N; ++y) {
            pwpref[x][y] = sum(pwpref[x][y - 1], binpow(y, x));
        }
    }
}

int getPw(int l, int r, int pw) {
    return diff(pwpref[pw][r], pwpref[pw][l - 1]);
}

int g[N][N];

void solve() {
    cin >> n >> c;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }

    prepare();

    for (int ci = 0; ci <= c; ++ci) {
        g[ci][n] = getPw(a[n], b[n], ci);
    }

    for (int i = n - 1; i > 0; --i) {
        for (int ci = 0; ci <= c; ++ci) {
            for (int li = 0; li <= ci; ++li) {
                g[ci][i] = sum(g[ci][i], mult(g[ci - li][i + 1], getPw(a[i], b[i], li)));
            }
        }
    }

    cout << g[c][1] << "\n";
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 4860
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int mod=998244353;
const int N=1e6+5;
int n,ma,Ans,a[N],ans[N],inv[N],A[N],B[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		A[a[i]]=(A[a[i]]+a[i])%mod;
		B[a[i]]=(B[a[i]]+a[i]*a[i]%mod)%mod;
		ma=max(ma,a[i]);
	}
	inv[0]=inv[1]=1;
	for(int i=2;i<=ma;i++)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=ma;i++)
	{
		int sum=0;
		for(int j=i;j<=ma;j+=i)
		{
			sum=(sum+A[j])%mod;
			ans[i]=(ans[i]-B[j]+mod)%mod;
		}
		ans[i]=(ans[i]+sum*sum%mod)%mod;
		ans[i]=ans[i]*inv[2]%mod;
//		if(i==2)cout<<"###"<<sum<<endl;
	}
	for(int i=ma;i;i--)
		for(int j=i+i;j<=ma;j=j+i)
			ans[i]=(ans[i]-ans[j]+mod)%mod;
	for(int i=1;i<=ma;i++)
	{
		if(ans[i]==0)continue;
		ans[i]=ans[i]*inv[i]%mod;
		Ans=(Ans+ans[i])%mod;
//		cout<<ans[i]<<endl;
	}
	cout<<Ans;
}


Measured memory_bytes: 35072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n;
long long tambah,a[100005],b[100005],ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i],&b[i]);
	tambah=0;
	for(int i=n;i>=1;i--)
	{
		a[i]+=tambah;
		a[i]%=b[i];
		if(a[i]!=0)
		{
			ans+=b[i]-a[i];
			tambah+=b[i]-a[i];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    result = 10000000000
    for i in range(2**(N*2) -1):
        bitBase = i | 2**(N*2)
        debug = False
        # if i == 4626:
        #     debug = True
        mergeCost = 0
        a = 0
        b = 0
        c = 0
        invalid = False
        debugStr = ""
        for j in range(N):
            flag = ((3 << (j * 2)) & bitBase) >> (j * 2)
            if flag == 1:
                if a != 0:
                    mergeCost+= 10
                if debug:
                    debugStr += "A"
                a += l[j]
            elif flag == 2:
                if b != 0:
                    mergeCost += 10
                if debug:
                    debugStr += "B"
                b += l[j]
            elif flag == 3:
                if c != 0:
                    mergeCost += 10 
                if debug:
                    debugStr += "C"               
                c+= l[j]
            else:
                if debug:
                    debugStr += "X"
        if a == 0 or b == 0 or c == 0:
            continue
        cost = mergeCost + abs(A-a) + abs(B - b) + abs(C - c)
        if debug:
            print(debugStr)
        # if cost == 120:
        #     print(i)
        result = min(cost,result)
    print(result)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B, C, l)

if __name__ == '__main__':
    main()


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    V<int> s(N, K - Q);
    rep(i, Q) {
        int p; cin >> p; --p;
        ++s[p];
    }
    rep(i, N) puts(s[i] > 0 ? "Yes" : "No");
    return 0;
}

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

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for(ll& i : a) cin >> i;
    for(ll& i : b) cin >> i;
    a.push_back(0);
    exclusive_scan(a.begin(), a.end(), a.begin(), 0LL);
    b.push_back(0);
    exclusive_scan(b.begin(), b.end(), b.begin(), 0LL);
    ll ans = 0;
    for(ll i = 0; i <= n; i++){
        if(a[i] > k) break;
        ll dist = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin() - 1;
        chmax(ans, i + dist);
    }
    cout << ans << endl;
}

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

void Main() {
    int N;
    cin >> N;
    vector<int> a(N);
    vector<bool> c(N);

    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int light = 0;
    int ans = 0;
    while (light != 1) {
        if (c[light]) {
            ans = -1;
            break;
        }
        c[light] = true;
        light = a[light] - 1;
        ans += 1;
    }
    cout << ans << endl;
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}

Measured memory_bytes: 640
#!/usr/bin/ruby
#encoding: utf-8

require 'prime'

def getNumofDivisor(n)
  num = 1
  factor = Prime.prime_division(n)
  (0..factor.size-1).each do |i|
    num *= (factor[i][1] + 1)
  end
  return num
end

n = gets.to_i

ans = 0
(1..n).each do |i|
  if i.odd?
    if getNumofDivisor(i) == 8
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 2300
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;     //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/

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

//-----Template---------
LL n, tmpA,ans=0;
vector<pair<int, int>> a;

int main() {
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> tmpA;
        a.push_back(MP(tmpA, i));
    }
    sort(ALL(a));
    set<int> memo;
    memo.insert(-1);
    memo.insert(n);
    for (int i = 0; i < n; ++i) {
        auto it = memo.lower_bound(a[i].second);
        int bb = *it;
        int aa = (*(--it));
        int r = bb - a[i].second;// + (bb == n ? 0 : 1);
        int l = a[i].second - aa;// + (aa == -1 ? 0 : 1);
        ans+= 1LL*r*l*a[i].first;
        memo.insert(a[i].second);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11248
p = 10 ** 9 + 7
N = (10 ** 5)*2 +10  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    mm = 1
    for i in range(n,n-r,-1):
        mm *= i
        mm %= p
    return mm*factinv[r]%p



def pwr(n,k): #nのk乗高速版 n^k
    mod = 10**9+7
    memo = chng2(k)
    lng = len(memo)

    li = [0 for i in range(lng-1)]
    li[0] = 1
    
    a = 2
    ans = 1
    for i in range(1,lng-1):
        li[i] = a
        a *= a
        a %= mod 
 
    for i in range(1,lng-1):
        if memo[-i]=='1':
            ans *= li[i]%mod

    return ans%mod

def chng2(n): #10進数nを2進数に変換(配列)
    ans = list(bin(n))
    return ans


mod = 10**9+7
N,A,B = map(int,input().split())
mm1 = pwr(2,N)
mm2 = cmb(N,A,mod)
mm3 = cmb(N,B,mod)

ans = mm1-mm2-mm3-1
if ans < 0:
    ans += mod

print(ans%mod)


Measured memory_bytes: 27128
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n, y := nextInt(), nextInt()

	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j
			if 10000*i+5000*j+1000*k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


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


struct RollingHash {
    const int base = 9973;
    const vector<int> mod = {999999937LL, 1000000007LL};
    string S;
    vector<long long> hash[2], power[2];

    // construct
    RollingHash(){}
    RollingHash(const string &cs) { init(cs); }
    void init(const string &cs) {
        S = cs;
        int n = (int)S.size();
        for (int iter = 0; iter < 2; ++iter) {
            hash[iter].assign(n+1, 0);
            power[iter].assign(n+1, 1);
            for (int i = 0; i < n; ++i) {
                hash[iter][i+1] = (hash[iter][i] * base + S[i]) % mod[iter];
                power[iter][i+1] = power[iter][i] * base % mod[iter];
            }
        }
    }
    // get hash of S[left:right]
    inline long long get(int l, int r, int id = 0) const {
        long long res = hash[id][r] - hash[id][l] * power[id][r-l] % mod[id];
        if (res < 0) res += mod[id];
        return res;
    }
    // get lcp of S[a:] and S[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)S.size()-a, (int)S.size()-b);
        int low = -1, high = len + 1;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (get(a, a+mid, 0) != get(b, b+mid, 0)) high = mid;
            else if (get(a, a+mid, 1) != get(b, b+mid, 1)) high = mid;
            else low = mid;
        }
        return low;
    }
    // get lcp of S[a:] and T[b:]
    inline int getLCP(const RollingHash &t, int a, int b) const {
        int len = min((int)S.size()-a, (int)S.size()-b);
        int low = -1, high = len + 1;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (get(a, a+mid, 0) != t.get(b, b+mid, 0)) high = mid;
            else if (get(a, a+mid, 1) != t.get(b, b+mid, 1)) high = mid;
            else low = mid;
        }
        return low;
    }
};



int main() {
    int N, M; cin >> N >> M;
    string S; cin >> S;
    RollingHash rh(S);

    set<pair<long long, long long> > res;
    int left = 0, right = 1;
    for (int q = 0; q < M; ++q) {
        string query; cin >> query;
        if (query == "R++") ++right;
        else if (query == "R--") --right;
        else if (query == "L++") ++left;
        else --left;
        pair<long long, long long> val(rh.get(left, right, 0), rh.get(left, right, 1));
        res.insert(val);
    }
    cout << res.size() << endl;
}



Measured memory_bytes: 31580
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	ll n, a, b;
	cin >> n >> a >> b;
	ll diff = b - a;
	if(diff % 2 == 0)
	cout << diff / 2;
	else{
		if(a == b - 1){
			if(a == 1 || b == n)
			cout << 1;
			else
			cout << min(b - 1, n - a);
		}
		else{
			if(a - 1 < n - b)
			cout << a + (b - a - 1) / 2;
			else
			cout << n - b + 1 + (b - a - 1) / 2;
		}
	}
}

Measured memory_bytes: 256
import math
a, b , x = map(int, input().split())
harf = a*b/2
s = x/a
if s <= harf:
    l = s * 2 / b
    print(math.degrees(math.atan(b / l)))
else:
    l = s * 2 / a - b
    l2 = b - l
    print(math.degrees(math.atan(l2 / a)))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
		int N = Integer.parseInt(str);
		char[] ary = reader.readLine().toCharArray();
		
		char[] alphabet = new char[26];
		char c = 'A';
		for (int i = 0; i < 26; i++) {
			alphabet[i] = c++;
		}
		
		for (int i = 0; i < ary.length; i++) {
			int a = (int)ary[i] - (int)'A';
			a += N;
			a %= 26;
			System.out.print(alphabet[a]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 24020
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long H, W;
    scan(H, W);
    writeln(repeat('#').take(W + 2));
    foreach (_; 0 .. H)
        writefln("#%s#", readln().chomp);
    writeln(repeat('#').take(W + 2));
}


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

using namespace std;

string s;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
}


Measured memory_bytes: 256
def main():
	N = int(input())
	S1 = input()
	S2 = input()
	p = 1000000007
	dominoes = []
	pattern = 0
	i = 0
	while i < N:
		if S1[i] == S2[i]:
			if len(dominoes) == 0:
				pattern = 3
			elif dominoes[-1] == "|":
				pattern = (pattern * 2) % p
			elif dominoes[-1] == "-":
				pattern = (pattern * 1) % p
			dominoes.append("|")
			i += 1
		else:
			if len(dominoes) == 0:
				pattern = 6
			elif dominoes[-1] == "|":
				pattern = (pattern * 2) % p
			elif dominoes[-1] == "-":
				pattern = (pattern * 3) % p
			dominoes.append("-")
			i += 2
	print(pattern)

main()

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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

int N, K;
int a[101];
int dp[123456];

int solve(int k){
	if (dp[k] != 0) return dp[k];

	if (k == 0) return dp[k] = -1;

	// k以下を全パターン引いて、次の手番が全部勝ちなら負け
	// 次の手番に負けがあるなら、勝ち
	for (int i = 0; i < N; i++){
		if (k-a[i]>=0 && solve(k - a[i]) == -1)
			return dp[k] = 1;
	}
	return dp[k]=-1;
}

signed main(){

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

	solve(K);

	if (dp[K] == 1) cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define ll long long


using namespace std;

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

    int n;cin>> n;
    double sum=0;
    for(int i=0;i<n;i++)
    {
        double x;cin >> x;
        sum+=(1/x);
    }
    cout << 1/sum;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
typedef long long LL;
typedef __int128 IL;
typedef map <LL,LL> Map;
typedef Map :: iterator it_m;

const int RLEN=1<<18|1; const LL mod=998244353998244353LL;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
} 
inline LL rd() {
	char ch=nc(); LL i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}
inline LL mul(LL a,LL b,LL md) {return (IL)a*b%md;}
inline LL power(LL a,LL b,LL md,LL rs=1) {for(;b;b>>=1,a=mul(a,a,md)) if(b&1) rs=mul(rs,a,md); return rs;}

Map s1,s2; int bz=0;
namespace RHO {
	const int pr[]={2,3,5,7,11,13,17,19,23};
	vector <LL> vec;
	inline LL gcd(LL a,LL b) {return b ? gcd(b,a%b) : a;}
	inline LL rho(LL nn,LL c) {
		LL x=rand()%nn+1, y=x, k=2;
		for(int i=1;;i++) {
			x=(mul(x,x,nn)+c)%nn;
			LL p=gcd(abs(y-x),nn);
			if(p!=1) return p;
			if(i==k) k<<=1, y=x;
		}
	}
	inline bool mr(LL nn) {
		if(nn<=3) return true;
		if((nn%6)!=1 && (nn%6)!=5) return false;
		LL s1=nn-1, s2=0;
		while(!(s1&1)) s1>>=1, ++s2;
		for(int i=0;i<=8;i++) {
			if(nn==pr[i]) return true;
			LL p=power(pr[i],s1,nn);
			for(int j=1;j<=s2 && p!=1;++j) {
				LL t=mul(p,p,nn);
				if(t==1 && p!=nn-1 && p!=1) return false;
				p=t;
			}
			if(p!=1) return false;
		} return true;
	}
	inline void solve(LL nn) {
		if(mr(nn)) {vec.push_back(nn%mod); return;}
		LL g=rho(nn,rand()%nn); 
		while(g==nn) g=rho(nn,rand()%nn);
		solve(nn/g); solve(g);
	}
	inline void fac(LL nn) {
		if(nn==1) return (void)(bz++);
		vec.clear();
		solve(nn);
		sort(vec.begin(),vec.end());
		LL a1=1, a2=1;
		for(int i=0,lst=0;i<vec.size();++i) {
			++lst;
			if(i!=vec.size()-1 && vec[i+1]==vec[i]) continue;
			lst%=3;
			if(lst) a1=mul(a1,power(vec[i]%mod,lst,mod),mod), a2=mul(a2,power(vec[i]%mod,3-lst,mod),mod);
			lst=0;
		} 
		if(a1==1) return (void)(bz++);
		s2[a1]=a2; s2[a2]=a1; ++s1[a1];
	}
}

int main() {
	int n=rd();  srand(time(0));
	for(int i=1;i<=n;i++) RHO::fac(rd());
	int ans=0;
	for(it_m it=s1.begin();it!=s1.end();++it) 
		if((it->second)>s1[s2[it->first]] || ((it->second)==s1[s2[it->first]] && it->first>=s2[it->first])) ans+=it->second;
	cout<<ans+(bz>0)<<'\n'; 
} 

Measured memory_bytes: 25472
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


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


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int n,q;
  lint total=0;
  cin>>n>>q;
  queue<pair<string,int> > que;
  rep(i,n){
    pair<string,int> j;
    cin>>j.first>>j.second;
    que.push(j);
  }
  while(que.empty() == false){
    pair<string,int> g = que.front();
    if(g.second > q){
      g.second-=q;
      total+=q;
      que.pop();
      que.push(g);
    }
    else{
      total+=g.second;
      cout<<g.first<<" "<<total<<endl;
      que.pop();
    }
  }
}


Measured memory_bytes: 6224
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(RALL(x))
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i,n) cin >> h[i];

  int ans = 0;
  rep(i,n) {
    if (h[i]>=k) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a == c && c == b) {
    cout << "No" << endl;
    return 0;
  }

  if (a == b || a == c || c == b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3552
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
d=read()
c=list(reads())
s=[[]for i in range(d)]
for i in range(d):
    s[i]=list(reads())
contestcount=26
last=[0 for i in range(contestcount)]
maxscore=0
backup=()
score=0
for i in range(d):#日にち
  dele=0
  for j in range(contestcount):
        dele-=c[j]*(i+1-last[j])
  for j in range(contestcount):#貪欲法
    hoge=maxscore
    hoge+=s[i][j]
    hoge-=dele
    hoge+=c[j]*(i+1-last[j])
    if hoge>=score:
      backup=(j,last[j])
      score=hoge  
    #print(score,backup)
  maxscore=score
  last[backup[0]]=backup[1]
  print(backup[0]+1)


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  string S;
  cin >> S;
  ll K;
  cin >> K;
  int n = S.size();
  if (S[n - 1] != S[0] || K == 1) {
    S.push_back('B');
    int pans = 0;
    char tmp ='A';
    int tmpn = 0;
    rep(i, 0, n+1) {
      char ch = S[i];
      if (tmp != ch) {
        pans += (tmpn / 2);
        tmpn = 1;
        tmp = ch;
      } else if (tmp == ch) {
        tmpn++;
      }
    }

    ll ans = pans * K;
    cout << ans << endl;
    return 0;
  } else {
    int sidx;
    int eidx;
    char jch = S[0];

    int sn = 0;
    int en = 0;

    for (int i = 0; i < n; i++) {
      if (S[i] != jch) {
        break;
      } else {
        sidx = i;
        sn++;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (S[i] != jch) {
        break;
      } else {
        eidx = i;
        en++;
      }
    }

    if (sidx == n - 1) {
      ll ans = (n * K) / 2;
      cout << ans << endl;
      return 0;
    }

    string S1 = string (S.begin(), S.begin() + eidx);
    string S2 = string (S.begin() + sn, S.end());
    string S3 = string (S.begin() + sn, S.begin() + eidx);

    S1.push_back('B');
    S2.push_back('B');
    S3.push_back('B');

    int pans1 = 0;
    int pans2 = 0;
    int pans3 = 0;
    char tmp1 ='A';
    char tmp2 ='A';
    char tmp3 ='A';
    int tmpn1 = 0;
    int tmpn2 = 0;
    int tmpn3 = 0;
    rep(i, 0, S1.size()) {
      char ch = S1[i];
      if (tmp1 != ch) {
        pans1 += (tmpn1 / 2);
        tmpn1 = 1;
        tmp1 = ch;
      } else if (tmp1 == ch) {
        tmpn1++;
      }
    }
    rep(i, 0, S2.size()) {
      char ch = S2[i];
      if (tmp2 != ch) {
        pans2 += (tmpn2 / 2);
        tmpn2 = 1;
        tmp2 = ch;
      } else if (tmp2 == ch) {
        tmpn2++;
      }
    }
    rep(i, 0, S3.size()) {
      char ch = S3[i];
      if (tmp3 != ch) {
        pans3 += (tmpn3 / 2);
        tmpn3 = 1;
        tmp3 = ch;
      } else if (tmp3 == ch) {
        tmpn3++;
      }
    }

    ll ans = pans1 + pans2 + (K - 2) * pans3 + (K - 1) * ((sn + en) / 2);
    cout << ans << endl;
  }
};


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	double v;
	while(cin>>v){
		double t=v/9.8;
		double y = 4.9*t*t;
		
		out(ceil((y+5.0)/5.0));
	}
	
	return 0;
}



Measured memory_bytes: 3172
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int a, b; cin >> a >> b;

	int ans = ceil((a+b)/2.0);
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
using namespace std;
#define F first
#define S second
typedef pair<string ,int> P;

int main(void){
	string tmp;
	int now=0;
	P list[1000];
	P cmax,lmax;
	cmax.S=0,lmax.S=0;
	for(int i=0;i<1000;i++)
		list[i].S=0;
	while(true){
		if(cin.eof())
			break;
		cin >> tmp;
		bool check=false;
		for(int i=0;i<now;i++){
			if(tmp==list[i].F){
				list[i].S++;
				check=true;
				break;
			}
		}
		if(check)
			continue;
		else
			list[now].F=tmp,list[now].S++,now++;
	}
	for(int i=0;i<now;i++){
		if(list[i].S>cmax.S)
				cmax.S=list[i].S,cmax.F=list[i].F;
		if(list[i].F.size()>lmax.S)
				lmax.S=list[i].F.size(),lmax.F=list[i].F;
	}
	cout << cmax.F <<  ' ' << lmax.F << endl;
	return 0;
}

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

int main(){
  int N,a,b,c;
  cin>>N;
  a=N%10;
  if(a==7){
    cout<<"Yes"<<endl;
    return 0;
  }
  N=N/10;
  b=N%10;
  if(b==7){
    cout<<"Yes"<<endl; 
    return 0;
  }
  
   N=N/10;
  c=N%10;
    if(c==7) {
      cout<<"Yes"<<endl; 
      return 0;
    }
  cout<<"No"<<endl;
  return 0;
}

  
  


 


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n,k,ans=0;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        a.at(b-1)++;
    }
    sort(a.begin(),a.end(),greater<int>());
    for(int i=k;i<n;i++){
        ans+=a.at(i);
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
const ll MOD = 1000 * 1000 * 1000 + 7;
char s[2][12345];
int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	scanf("%d", &n);
	scanf("%s", s[0]);
	scanf("%s", s[1]);
	vector<int> go;
	int ptr = 0;
	while (ptr < n) {
		if (s[0][ptr] == s[1][ptr]) {
			go.push_back(1);
			ptr++;
		} else {
			go.push_back(2);
			ptr += 2;
		}
	}
	ll res = 1;
	if (go[0] == 2) {
		res *= 6;
	} else {
		res *= 3;
	}
	for (int i = 1; i < (int)go.size(); i++) {
		if (go[i] == 1) {
			if (go[i - 1] == 1) {
				res *= 2;
			} else {
				res *= 1;
			}
		} else {
			if (go[i - 1] == 1) {
				res *= 2;
			} else {
				res *= 3;
			}
		}
		res %= MOD;
	}
	cout << res << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
const int INF=100000000;

LL a[200010];
LL b[200010];
int main(){
	LL n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		b[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		sum+=(b[i]*(b[i]-1)/2);
	}
	for(int i=0;i<n;i++)
	{
		cout<<sum-b[a[i]]+1<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
char s[20];
int main() {
	int flag = 0;
	scanf("%s", s);
	int n = strlen(s);
	if(n >= 4) {
		if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')flag = 1;
	}
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
	string s;
	cin>>s;
	
	int cnt=0;
	int cntt=0;
	
	REP(i,s.size()){
		if(s[i]-'0'==i%2) cntt++;
		else cnt++;
	}
	
	cout<<min(cnt,cntt)<<endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = input().rstrip()
    ans = sum(map(int, list(n)))
    if int(n) == 10 ** (len(n) - 1):
        ans = 10
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39152
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        System.out.println(n*a > b ? b : n*a);
    }
}


Measured memory_bytes: 23124