akhauriyash/Code-Regression huggingface dataset:
function D173(_input) {
    var lines = _input.split("\n");
    var num = lines.shift()*1;
    var nums = lines[0].split(' ').map(v => v*1).sort((v1, v2) => v2 - v1);
    var result = 0;

    if (num === 2) {
        console.log(nums[0]);
        return;
    }

    let index = 0;
    let c = 1;

    for(let i = 0; i < num - 1; i++) {
        result+=nums[index];
        if (c % 2 === 1) {
            index++;
        }
        c++;
    }

    console.log(result);
}
D173(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 52976
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b;
    char op;
    while(1){{
    cin >> a >> op >>b;
    if(op=='?')break;
    if(op=='+'){
        cout << a+b;
    }
    else if(op=='-'){
        cout <<a-b;
    }
    else if(op=='*'){
        cout <<a*b;
    }
    else if(op=='/'){
        cout << a/b;
    }
    cout << endl;}}
}



Measured memory_bytes: 3080
w = list(input())
tmp1 = sorted(list(set(w)))
flag = 1
for i in range(len(tmp1)):
    count = 0
    for j in range(len(w)):
        if w[j] == tmp1[i]:
            count += 1
    if count%2 != 0:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import sys

class Node:
    """
    key: Value of the node
    next: Pointer to the next node
    prev: Pointer to the previous node
    """

    def __init__(self, key):
        self.key = key
        self.next = None
        self.prev = None


class DoublyLinkedList:
    def __init__(self):
        """
        next always point to the very first node in a list
        prev always point to the last node in a list
        """
        self.next = None
        self.prev = None

    def insert(self, key):
        """
        :param key: key to insert into a list (inserted to the first place in the list)
        :return: None
        """
        newNode = Node(key)
        # First node ever added to the list
        if self.next is None:
            newNode.next = None
            newNode.prev = self
            self.next = newNode
            self.prev = newNode
        # Second nodes and forth
        else:
            newNode.next = self.next
            newNode.prev = self
            self.next.prev = newNode
            self.next = newNode

    def listSearch(self, key):
        """
        :param key: key of a note to search for
        :return: Node (the first Node from the beginning of a list)
        """
        cur = self.next
        while cur is not None and cur.key != key:
            cur = cur.next
        return cur

    def deleteNode(self, node):
        """
        :param node: Node to delete
        :return: None
        """
        if node is None:
            return
        # If the node is the last node
        elif node.next is None:
            node.prev.next = None
            self.prev = node.prev
        # If the node is not the last node
        else:
            node.prev.next = node.next
            node.next.prev = node.prev

    def delete(self, key):
        """
        Delete the first node that has the key.
        :param key: key that the node to be deleted has
        :return: None
        """
        self.deleteNode(self.listSearch(key))

    def deleteFirst(self):
        """
        Delete the first node in a list
        :return: None
        """
        cur = self.next
        self.deleteNode(cur)

    def deleteLast(self):
        """
        Delete the last node in a list
        :return: None
        """
        cur = self.prev
        self.deleteNode(cur)

    def showKeys(self):
        """
        Print keys of nodes in a list divided by a space
        :return: None
        """
        cur = self.next
        keys = []
        while cur is not None:
            keys.append(cur.key)
            cur = cur.next
        keys = map(str, keys)
        print(' '.join(keys))

n = int(input())
d = DoublyLinkedList()

# input() seems to be too slow for this (result in TLE for large inputs)
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        d.insert(x)
    elif 'deleteFirst' in i:
        d.deleteFirst()
    elif 'deleteLast' in i:
        d.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        d.delete(x)
    else:
        pass

d.showKeys()


Measured memory_bytes: 227620
N,Q=map(int,input().split())
S=input()
L=[]
R=[]
for i in range(Q):
    LR=list(map(int,input().split()))
    L.append(LR[0]-1)
    R.append(LR[1]-1)

cnt_AC=[0]*N
for i in range(1,N):
    cnt_AC[i]=cnt_AC[i-1]
    if S[i]=='C':
        if S[i-1]=='A':
            cnt_AC[i]+=1

for i in range(Q):
    ans=cnt_AC[R[i]]-cnt_AC[L[i]]
    print(ans)

Measured memory_bytes: 19400
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)

	if n < k {
		fmt.Println("1")
		return
	}

	ans := 0
	for n > 0 {
		n = (n - n%k) / k
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int , int>
#define vi vector<int>
#define inf 1e18 //(10^18
#define pqmax priority_queue<int>
#define mii map<int , int>
#define ps(x, y) fixed<<setprecision(y)<<x
// double ans = 1.012345668992
//cout<<ps(ans , 6)
// ans = 1.012345 // 6 decimal places
#define pqmin priority_queue<int , vi , greater<int> >
#define mk(arr , n , type) type *arr = new type[n];
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
// 48->11000(4) (returns no. of zeros after first one)
#define mod 1000000007 //1e9 +7
#define w(t) int t; cin>>t;while(t--)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//shuffle(arr , arr +n , rng)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pbds;
//pbds s;
//s.order_of_key(4);
//*s.find_by_order(4);
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    
        int n ;
        cin >> n;
        int flag = 0;
        while (n > 0) {
            int r = n % 10;
            if (r == 7) {
                flag = 1;
                break;
            }
            n = n / 10;
        }

        if (flag == 1)cout << "Yes" << "\n";
        else cout << "No" << "\n";


    
    return 0;


}





Measured memory_bytes: 3612
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,k,h[1 << 17],ans[1 << 17];

int32_t main(){_
    //freopen("in","r",stdin);
	cin >> n;
    k = 2;
	for(int i = 1;i <= n;i++)
	{
		cin >> h[i];
	}
	ans[n] = 0;
	for(int i = n - 1;i >= 1;i--)
	{
		ans[i] = 1e18;
		for(int j = i + 1;j <= min(n,i + k);j++)
		{
			ans[i] = min(ans[i],abs(h[i] - h[j]) + ans[j]);
		}
	}
	rc(ans[1]);
}

Measured memory_bytes: 1792
package main
import (
  "fmt"
)

func main() {
  var a,b,c int
  fmt.Scan(&a, &b, &c)
  if (a == 5 && b == 5 && c == 7) ||
     (a == 5 && b == 7 && c == 5) ||
  (a == 7 && b == 5 && c == 5) {
    fmt.Println("YES")
  }else {
    fmt.Println("NO")
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

vvin edge(1e6);
vin deep(1e6,-1);
vbo visited(1e6,false);

int dfs(int v){
    if(deep[v]!=-1){
        if(!visited[v])return -1;
        return deep[v];
    }
    deep[v]=1;
    int tmp;
    for(auto e:edge[v]){
        tmp=dfs(e);
        if(tmp==-1)return -1;
        deep[v]=max(deep[v],tmp+1);
    }
    visited[v]=true;
    return deep[v];
}

int main(){
    int n;cin>>n;
    vin a(n-1);
    int x1,x2,y1,y2;
    //x vs y = n(x-1)-x(x-1)/2+y-x-1(x<y)
    rep(i,n)rep(j,n-1){
        cin>>a[j];
        if(j>0){
            x1=min(i+1,a[j-1]);
            y1=max(i+1,a[j-1]);
            x2=min(i+1,a[j]);
            y2=max(i+1,a[j]);
            edge[n*(x1-1)-x1*(x1-1)/2+y1-x1-1].push_back(n*(x2-1)-x2*(x2-1)/2+y2-x2-1);
        }
    }
    int ans=-1,tmp;
    rep(i,n*(n-1)/2){
        tmp=dfs(i);
        if(tmp==-1){
            ans=-1;
            break;
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 46328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
const ll m=1e9+7;
const ll N=1e6+7;
bool prime[N];
vector<int> p;
void sieve(int n)
{
	fill(prime, prime+n, true);
	for(int i=2;i<n;i++)
	{
		if(prime[i])p.pb(i);
		for(int j=0;j<p.size() and i*p[j]<n;j++)
		{
			prime[i*p[j]]=false;
			if(i%p[j]==0)break;
		}
	}
}
ll modp(ll a, ll b)
{
	if(b==0)return 1;
	ll u=modp(a, b>>1);
	u=(u*u)%m;
	if(b&1)
	return (u*a)%m;
	return u;
}
ll fac[N<<1 +5];
ll invfac[N<<1 + 5];
void init_fact(int n)
{
	fac[0]=fac[1]=1;
	for(int i=2;i<=n;i++)
	{
		fac[i]=i*fac[i-1];	
	}
	for(int i=0;i<=n;i++)
	{
		invfac[i]=modp(fac[i],m-2);
	}
	
	
}
long double dis(pii a, pii b)
{
	long double X=(double)(a.x-b.x);
	long double Y=(double)(a.y-b.y);
	
	X=X*X;Y=Y*Y;
	return sqrt(X+Y);
}
int main()
{
	int x,y;
	//init_fact(2*N+1);
	cin>>x>>y;
	int tot=x+y;
	int mi=min(x,y);int M=tot-mi;
	if(tot%3)
	{cout<<0;return 0;}
	
	int g=tot/3;
	if(g>mi)
	{
		cout<<0;
		return 0;
	}
	int t=mi-g;
	int o=g-t;
	int ot=min(o,t);
	ll ans=1;
	for(ll i=o+t;i>ot;i--)
	{
		
		ans=(ans*i)%m;
		ll z=o+t-i+1;
		z=modp(z, m-2);
		ans=(ans*z)%m;
		
		
	}
	
	cout<<ans;
	
	
	
	
	
	
}

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

int main(){

  int N;
  cin >> N;
  long double ans = 0.0;
  for(int i=0; i < N; i++){
    string u;
    long double x;
    cin >> x >> u;
    if(u == "JPY"){
      ans += x;
    } else {
      ans += x * 380000.0;
    }
  }

  cout << setprecision(20) << ans << endl;

}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> P;
const int MAXN=1e5+10;
int n,m,S,T,x,y,a,b;
ll res[MAXN],INF=1e15,d1[MAXN],d2[MAXN];
vector<P> G1[MAXN],G2[MAXN];

void dijkastra(vector<P> *G,ll *d,int start)
{
	priority_queue<P,vector<P>,greater<P> > q;
	for(int i=0;i<MAXN;i++) d[i]=INF;
	q.push(P(0,start));d[start]=0;
	while(!q.empty())
	{
		P t=q.top();q.pop();
		int u=t.Y;ll cost=t.X;
		if(cost>d[u]) continue;
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i].X;
			if(d[v]>d[u]+G[u][i].Y)
				d[v]=d[u]+G[u][i].Y,q.push(P(d[v],v));
		}
	}
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&S,&T);
	for(int i=1;i<=m;i++)
		scanf("%d%d%d%d",&x,&y,&a,&b),
		G1[x].push_back(P(y,a)),G1[y].push_back(P(x,a)),
		G2[x].push_back(P(y,b)),G2[y].push_back(P(x,b));
	
	dijkastra(G1,d1,S);dijkastra(G2,d2,T);
	for(int i=1;i<=n;i++) res[i]=d1[i]+d2[i];
	for(int i=n-1;i>=1;i--) res[i]=min(res[i],res[i+1]);
	for(int i=1;i<=n;i++) printf("%lld\n",INF-res[i]);
	return 0;
}

Measured memory_bytes: 19140
#include <cstdio>
#include <algorithm>

int main() {
  int a[3];
  scanf("%d %d %d", a, a+1, a+2);
  std::sort(a, a+3);

  int k;
  scanf("%d", &k);
  printf("%d\n", a[0]+a[1]+(a[2]<<k));
}


Measured memory_bytes: 128
#import <stdio.h>
#import <stdlib.h>
#import <limits.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

long CEIL(double x) {
    long i = (long)x;
    return i + (((x != i) && (x > 0)) ? 1 : 0);
}

int main(int argc, const char * argv[]) {
    long N, K;
    scanf("%ld %ld", &N, &K);
    
    long n;
    long i = 0;
    while (scanf("%ld", &n) != EOF) {
        if (n==1) {
            break;
        }
        i++;
    }
    
    long JMIN = MAX(0,-N+K+i);
    long JMAX = MIN(K-1,i);
    long min = LONG_MAX;
    for(long j=JMIN;j<=JMAX;j++){
        min = MIN(min, 1 + CEIL((double)(i-j)/(K-1)) + CEIL((double)(N-i-K+j)/(K-1)) );
    }
    
    printf("%ld", min);
    
    return 0;
}


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

const int Nmax=200010;

int main() {
	int N,L[200];
	cin >> N;
	for(int i=0;i < 2*N;i++) cin >> L[i];
	sort(L, L+2*N);
	int sum=0;
	for(int i=2*N-1;i >= 0;i--)
		if(i%2 == 0) sum += L[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int ruiseki[30][500030] = {};
int main() {
	int n;
	string s;
	int q;
	cin >> n;
	cin >> s;
	cin >> q;
	for (int i = 1; i <= s.size(); i++) {
		int a1 = s[i - 1] - 'a';
		ruiseki[a1][i]++;
		for (int j = 0; j < 30; j++) {
			ruiseki[j][i] = ruiseki[j][i] + ruiseki[j][i-1];
		}
		
	}
	vector<tuple<int,char,char>> change;
	for (int i = 0; i < q; i++) {
		int a;
		cin >> a;
		if (a == 1) {
			int number;
			char ato;
			cin >> number >> ato;
			char mae = s[number - 1];
			for (auto x : change) {
				if (get<0>(x) == number-1) {
					mae = get<2>(x);
				}
			}
			change.emplace_back(number-1, mae, ato);

		}
		else {
			int start, end;
			int moji[30] = {};
			int ans = 0;
			cin >> start >> end;
			for (int j = 0; j < 30; j++) {
				moji[j] = ruiseki[j][end] - ruiseki[j][start-1];
			}
			for (auto x : change) {
				if (start - 1 <= get<0>(x) && get<0>(x) <= end - 1) {
					int a1 = get<1>(x) - 'a';
					int a2 = get<2>(x) - 'a';
					moji[a1]--;
					moji[a2]++;
				}
			}
			for (int j = 0; j < 30; j++) {
				if (moji[j] > 0) {
					ans++;
				}
			}
			cout << ans<<endl;
		}
	}
}


Measured memory_bytes: 60548
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

ll x,y;
vector<ll>t,a;
void solve(ll i){
    ll nx = (x+t[i]-1)/t[i]*t[i];
    ll ny = (y+a[i]-1)/a[i]*a[i];
    if(nx/t[i]==ny/a[i]){
        x = nx;y = ny;
        return;
    }
    if(nx/t[i]<ny/a[i]){
        x = ny/a[i]*t[i];
        y = ny;
        return;
    }
    else{
        x = nx;
        y = nx/t[i]*a[i];
        return;
    }
}
int main(){
    ll n;
    cin >> n;
    t.resize(n);
    a.resize(n);
    rep(i,n)cin>>t[i]>>a[i];
    x = 1; y = 1;
    rep(i,n){
        solve(i);
    }
    cout << x+y << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";



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

    int n;
    ll d;
    cin >> n >> d;
    int count = 0;
    for (size_t i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        ll dist = ceil(sqrt(x * x + y * y));
        if (dist <= d){
            count++;
        }
    }
    cout << count << "\n";

    return 0;
}


Measured memory_bytes: 3732
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    _, s, _ = in_s().split()

    print("A" + s[0] + "C")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9108
def main():
    n = int(input())
    L = [list(map(int,input().split())) for _ in range(n)]
    L.sort(key = lambda x: x[1])
    time = 0
    for a, b in L:
        time += a
        if time > b:
            print('No')
            return
    print('Yes')
main()

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

int main() {
	int n,m,x,y;
	cin >> n >> m >> x >> y;
	for(int i = 0;i < n;i++)
	{
		int xd;
		cin >> xd;
		x = max(x,xd);
	}
	for(int i = 0;i < m;i++)
	{
		int yd;
		cin >> yd;
		y = min(y,yd);
	}
	string k = "War";
	if(x < y)
	{
		k = "No War";
	}
	cout << k << endl;
	return 0;
}


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

using namespace std;

int main()
{
  int N;
  bool able[1000];
  char s[30001];
  int lf[30000], rg[30000];
  
  scanf("%d", &N);
  scanf("%s", s);
  
  fill(able, able + 1000, false);
  
  for (int i = 0; i < N; i++) s[i] -= '0';
  
  for (int i = 0; i < N; i++) {
    lf[i] = 1 << s[i];
    rg[N - i - 1] = 1 << s[N - i - 1];
    if (i) {
      lf[i] |= lf[i - 1];
      rg[N - i - 1] |= rg[N - i];
    }
  }
  
  for (int i = 1; i + 1 < N; i++) {
    for (int l = 0; l < 10; l++) {
      for (int r = 0; r < 10; r++) {
        if (((lf[i - 1] >> l) & 1) && ((rg[i + 1] >> r) & 1)) {
          able[l * 100 + s[i] * 10 + r] = true;
        }
      }
    }
  }
  
  printf("%d\n", accumulate(able, able + 1000, 0));
  
  return 0;
}

Measured memory_bytes: 512
using System;
//using System.Collections.Generic;
//using System.Linq;
using Vector = CGL.Point;
//using Line = CGL.Segment;
//using Polygon = System.Collections.Generic.List<CGL.Point>;


namespace CGL
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = scan;
            var p1 = new Point(p[0], p[1]);
            var p2 = new Point(p[2], p[3]);
            var s = new Segment(p1, p2);
            var q = scan[0];
            for (int i = 0; i < q; i++)
            {
                p = scan;
                var P = new Point(p[0], p[1]);
                var Q = Projection(s, P);
                Console.WriteLine(Q.x+" "+Q.y);
            }
        }
        static Point Projection(Segment s, Point p)
        {
            Vector b = s.p2 - s.p1;
            double r = b.Dot(p - s.p1) / b.Norm;
            return s.p1 + r * b;

        }
        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
    
    struct Point
    {
        static readonly double EPS = 1E-10;
        public double x, y;
        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public static Point operator +(Point a, Point b) { return new Point(a.x + b.x, a.y + b.y); }
        public static Point operator -(Point a, Point b) { return new Point(a.x - b.x, a.y - b.y); }
        public static Point operator *(double k, Point a) { return new Point(k * a.x, k * a.y); }
        public static Point operator /(double k, Point a) { return new Point(a.x / k, a.y / k); }
        
        public double Abs { get { return Math.Sqrt(Norm); } }  
        public double Norm { get { return x * x + y * y; } }

        public static bool operator <(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x < b.x : a.y < b.y; }
        public static bool operator >(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x > b.x : a.y > b.y; }
        public static bool operator ==(Point a, Point b) { return Math.Abs(a.x - b.x) < EPS && Math.Abs(a.y - b.y) < EPS; }
        public static bool operator !=(Point a, Point b) { return Math.Abs(a.x - b.x) >= EPS || Math.Abs(a.y - b.y) >= EPS; }

        public override bool Equals(object p){  return Math.Abs(x - ((Point)p).x) < EPS && Math.Abs(y - ((Point)p).y) < EPS; }
        public override int GetHashCode(){ return x.GetHashCode() ^ y.GetHashCode(); }

        public double Dot(Point p) { return x * p.x + y * p.y; }
        public double Cross(Point p) { return x * p.y - y * p.x; }

    }
    struct Segment
    {
        public Point p1, p2;
        public Segment(Point p1, Point p2)
        {
            this.p1 = p1;
            this.p2 = p2;
        }
    }
    /*struct Circle
    {
        public Point c; double r;
        public Circle(Point c, double r)
        {
            this.c = c;
            this.r = r;
        }

    }*/
}

Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int m1,d1;
cin>>m1>>d1;
int m2,d2;
cin>>m2>>d2;

cout<<m2-m1<<endl;


 return 0;
}
/*
11 16
11 17

0

11 30
12 1

1
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int  main()
{
    string S;
    cin >> S;
    int N = S.length(); 
    if (N == 3) {cout << "Yes" << "\n";}
    else {
        string S_1 = S.substr(0, (N-1)/2);
        string S_2 = S.substr(((N+1)/2), (N-1)/2);
        cerr << S_1 << " " << S_2 << "\n";
        bool check_1 = true, check_2 = true, check_3 = true;;
        
        int N_1 = S_1.size();
        int N_2 = S_2.size();
        for(int i = 0; i < N_1; i++) {
            cerr << S_1[i] << " " << S_1[(((N-1)/2) - 1) - i] << "\n";
            
            if (S_1[i] != S_1[(((N-1)/2) - 1) - i]) {
                check_1 = false;
                break;
            }
        }
        for(int i = 0; i < N_2; i++) {
            if (S_2[i] != S_2[(((N-1)/2) - 1) - i]) {
                check_2 = false;
                break;
            }
        } 

        for(int i = 0; i < N; i++) {
            if (S[i] != S[N-1-i]) {
                check_3 = false;
                break;
            }
        }
        cerr << check_1 << " "  << check_2 << "\n";
        if(check_1==1 && check_2==1 && check_3==1) cout << "Yes" << "\n";
        else cout << "No" << "\n";
        }    
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if(10<=A || 10<=B){
    cout << "-1" << endl;
  }
  else if(1<=A<=9&&1<=B<=9){
    cout << A*B << endl;
  }
}

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


int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0, memo1, memo2;
  for (int i = 0; i < 10; i++) {
    if (s.find(i + '0') != string::npos) {
      memo1 = s.find(i + '0');
      for (int j = 0; j < 10; j++) {
        if (s.find(j + '0', memo1 + 1) != string::npos) {
          memo2 = s.find(j + '0', memo1 + 1);
          for (int k = 0; k < 10; k++) {
            if (s.find(k + '0', memo2 + 1) != string::npos) {
              cnt++;
            }
          }
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        
        if((S.charAt(2)==S.charAt(3))&&(S.charAt(4)==S.charAt(5))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 1000005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef map<ll, ll> Map;

int main(void) {
    ll N, K;
    cin >> N >> K;
    ll x, y;
    char c;
    ll i, j;
    ll cnt[4*K+2][4*K+2];
    ll sum[4*K+2][4*K+2];
    memset(cnt, 0, sizeof(cnt));
    memset(sum, 0, sizeof(sum));
    
    for(i=0; i<N; i++) {
        cin >> x >> y >> c;
        if(c=='W') {
            y+=K;
        }
        x%=2*K; y%=2*K;
        x++; y++;
        cnt[x][y]++;
        cnt[x][y+2*K]++;
        cnt[x+2*K][y]++;
        cnt[x+2*K][y+2*K]++;
    }
    
    
    
    
    for(i=1; i<=4*K; i++) {
        for(j=1; j<=4*K; j++) {
            sum[i][j]=cnt[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
        }
    }
    
    ll ans=0;
    for(i=1; i<=2*K+1; i++) {
        for(j=1; j<=2*K+1; j++) {
            ll sqr1=sum[i+K-1][j+K-1]-sum[i-1][j+K-1]-sum[i+K-1][j-1]+sum[i-1][j-1];
            ll sqr2=sum[i+2*K-1][j+2*K-1]-sum[i+K-1][j+2*K-1]-sum[i+2*K-1][j+K-1]+sum[i+K-1][j+K-1];
            ans=max(ans, sqr1+sqr2);
        }
    }
    
    prin(ans);
}

Measured memory_bytes: 250496
n, m = map(int, input().split())

xy = [i for i in range(n + 1)]


def root(x):
    i = x
    a = []
    while i != xy[i]:
        i = xy[i]
        a += [i]
    for b in a:
        xy[b] = i
    return i


for _ in range(m):
    x, y = map(int, input().split()[:2])
    xy[root(x)] = root(y)

ans = sum(i == v for i, v in enumerate(xy)) - 1

print(ans)


Measured memory_bytes: 7088
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int main(){
	
	while(1){
		int n,m; cin >> n >> m;
		if (n == 0 and m == 0) break;
		vector<int> T(n);
		vector<int> H(m);
		int Tsum = 0;
		int Hsum = 0;
		for (int i = 0; i < n; i++){
			cin >> T[i];
			Tsum += T[i];
		}
		for (int i = 0; i < m; i++){
			cin >> H[i];
			Hsum += H[i];
		}
		int dis = Tsum - Hsum;
		int Tans,Hans;
		int min = 100000;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				if (dis == (T[i] - H[j]) * 2 and min > T[i] + H[j]){
					Tans = i;
					Hans = j;
					min = T[i] + H[j];
				}
			}
		}
		if (min == 100000){
			cout << -1 << endl;
		}else{
			cout << T[Tans] << " " << H[Hans] << endl;
		}

	}


	
return 0;
}

Measured memory_bytes: 2992
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] B = new int[N];
		for(int i=0; i < N-1; i++) {
			B[i] = A[i + 1] - A[i];
		}
		B[N-1] = A[0] + (K - A[N-1]);
		int sumB = 0;
		for(int i=0; i < N; i++) {
			sumB += B[i];
		}
		
		
		int maxL = 0;
		
		for(int i = 0; i < N; i++) {
			maxL = Math.max(maxL, B[i]);
		}


		System.out.println(sumB - maxL);

	}


}




Measured memory_bytes: 84420
#include <iostream>
#include <vector>
#include <algorithm>
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];
	sort(h.begin(), h.end());
	
	int mind = 1000000001;
	for(int i = 0; i < n - k + 1; i++) {
//		cout << h[i+k-1] << " " << h[i] << endl;
		mind = min(mind, h[i+k-1] - h[i]);
	}
	cout << mind << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll n;
  cin >> n;
  ll answer = 0;
  for (ll i = 1; i <= n; i++){
    if(i%3!=0&&i%5!=0){
      answer += i;
    }
    else{
      continue;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 3624
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M = imn()
sc = [iln() for _ in range(M)]

ans = [-1 for _ in range(N)]

for i in range(M):
    if ans[sc[i][0]-1] != -1 and ans[sc[i][0]-1] != sc[i][1]:
        print(-1)
        exit()
    else:
        ans[sc[i][0]-1] = sc[i][1]
d = ''
if N == 1 and (ans[0] == -1 or ans[0] == 0):
    print(0)
    exit()
for i in range(N):
    if i == 0 and ans[i] == 0:
        print(-1)
        exit()
    if ans[i] != -1:
        d += str(ans[i])
    else:
        if i != 0:
            d += '0'
        else:
            d += '1'
print(d)

Measured memory_bytes: 5552
N, M = map(int,input().split())
AB = sorted([list(map(int,input().split())) for _ in range(N)])

money = 0
for a, b in AB:
  if M <= 0:
    break
  if M-b >= 0:
    money += a*b
    M -= b
  else:
    money += a*M
    M -= M
print(money)

Measured memory_bytes: 28652
#include<stdio.h>
#include<stdlib.h>
#include<stdarg.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define reps(i,n,k) for((i)=0;(i)<(n);(i)+=(k));
#define MOD ((int)1e9+7)
#define INF INFINITY
typedef long long ll;
typedef unsigned long long ull;
typedef struct pair_{int x,y;}pair_t;
void swap(int *x, int *y){int tmp=*x;*x=*y;*y=tmp;}
void debug(char *f, ...){va_list a;va_start(a,f);vfprintf(stderr,f,a);va_end(a);}
int asc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return -1;else if(X>Y)return 1;else return 0;}
int desc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return 1;else if(X>Y)return -1;else return 0;}
int main(){
  	char s[4];scanf("%s",s);
    for(int i=0;i<10;i++){
        debug("%d is %s number\n",i,i%2?"Odd":"Even");
    }
  	if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
      	printf("Yes\n");
    }else{
      	printf("No\n");
    }
}
    

Measured memory_bytes: 1740
from collections import deque
d = deque(input())
Q = int(input())

# 逆フラグ
r = 1  # 1==正
for q in range(Q):
  s = input()
  if len(s) == 1:
    r *= -1
  else:
    s, f, c = s.split()
    if (f == '1' and r == -1) or (f == '2' and r == 1):
      d.append(c)
    else:
      d.appendleft(c)
ans = ''.join(d)
if r == -1:
  #d = d[::-1]
  print(ans[::-1])
else:
  print(ans)

Measured memory_bytes: 8436
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
    
  string S, T;
  cin >> S >> T;
  ll ans = 0;
  ll N = S.size();
  for(int i=0; i<N; i++){
    if(S[i] != T[i]) ans++;
  }


  cout << ans << endl;

}


Measured memory_bytes: 3824
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int a, b, C;
    double c, S, L, h, rad;
    cin >> a >> b >> C;
    
    double PI = acos(-1);
    rad = C*PI/180.0;
    
    S = a*b*sin(rad)/2.0;
    c = sqrt(a*a + b*b - 2*a*b*cos(rad));
    L = a+b+c;
    h = 2*S/a;
    
    printf("%f\n", S);
    printf("%f\n", L);
    printf("%f\n", h);
    
    return 0;
}

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

int main()
{
     int K;
     string s;
  
    cin>>K;
    cin>>s;
    string r="";
   if(K >=s.length())
   {
         cout<<s<<endl;
   }
   else
   {
        for(int i=0;i<K;i++)
        {
             r += s[i];
        }
       
        r +="...";
     
       cout<<r<<endl;
   }
  



}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define reep(i,a,b) for(int i=a; i<b; i++)
#define MOD 1000000007
#define INFL 0x3f3f3f3f3f3f3f3f

using ll = long long;

int main(){
	string s;
	cin>>s;
	string p;
	cin>>p;
	int n = s.size();
	int m = p.size();
	vector<int> pos1(p.size(),-1);
	auto pos2 = pos1;
	int cnt = 0;
	rep(i,n){
		if(cnt<m){
			if(p[cnt] == s[i]){
				pos1[cnt] = i;
				cnt++;
			}
		}
	}
	cnt = m-1;
	for(int i=n-1; i>=0; i--){
		if(cnt>=0){
			if(p[cnt] == s[i]){
				pos2[cnt] = i;
				cnt--;
			}
		}
	}
	if(pos1[m-1]>=0&&pos2[0]>=0){
		rep(i,m){
			if(pos1[i] != pos2[i]){
				cout<<"no"<<endl;
				return 0;
			}
		}
		cout<<"yes"<<endl;
		return 0;
	}
	cout<<"no"<<endl;
}

Measured memory_bytes: 7864
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int l, r, d; cin >> l >> r >> d;
  int cnt = 0;
  for(int i = l; i <= r ; ++i){
    if(i%d==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3624
# coding: utf-8
N = int(input())
A = input()
B = input()
C = input()
n = 0
for i in range(N):
    a, b, c = A[i], B[i], C[i]
    if a != b:
        n += 1
        if a == c or b == c:
            continue
        else:
            n += 1
    elif b != c:
        n += 1
print(n)


Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    let mut nums: Vec<u64> = Vec::new();
    for n in s.chars() {
        nums.push(n as u64 - 48);
    }
    let mut ret = 0;
    for bit in 0..(1 << nums.len() - 1) {
        let mut buf = 0;
        for i in 0..(nums.len() - 1) {
            if (bit & (1 << i) != 0) {
                buf = 10*buf + nums[i];
            }else {
                ret += 10*buf + nums[i];
                buf  = 0;
            }
        }
        ret += 10 * buf + nums[nums.len() - 1];
    }
    println!("{}",ret);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int T = sc.nextInt();
    int max = 0;
    int sum = 0;
    for (int i = 0; i < T; i++) {
      int a = sc.nextInt();
      max = Math.max(max, a);
      sum += a;
    }
    int others = sum - max;
    
    System.out.println(Math.max(max-1-others, 0));
  }
}

Measured memory_bytes: 23892
using System;
using System.Collections.Generic;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }


    public class Pair{
        public char f;
        public int s;
    }

    public class Test
    {
        public static void Run()
        {
            Input input = new Input(' ');
            input.ReadLine();
            int A = input.Next<int>();
            int B = input.Next<int>();
            int K = input.Next<int>();
            int j = 0;
            List<int> list = new List<int>();
            for (int i = 0; i < Math.Min(A,B); i++)
            {
                do
                {
                    if (j == Math.Min(A,B)) break;
                    j++;
                }
                while (A % j != 0 || B % j != 0);
                if (A % j == 0 && B % j == 0) list.Add(j);
                if (j == Math.Min(A, B)) break;
            }
            Console.WriteLine(list[list.Count-K]);
        }
    }







    public class Input
    {
        int arg;
        int length;
        string s;
        string[] ss;
        char sep;
        public Input(char _sep = '\0')
        {
            sep = _sep;
        }
        public void ReadLine()
        {
            s = Console.ReadLine();
            if (sep != '\0') ss = s.Split(sep);
            else
            {
                ss = new string[1];
                ss[0] = s;
            }
            arg = 0;
            length = ss.Length;
        }
        public T Next<T>()
        {
            if (arg == length) throw new IndexOutOfRangeException();
            return (T)Convert.ChangeType(ss[arg++], typeof(T));
        }
        public void SetSeparater(char _sep)
        {
            sep = _sep;
        }
    }
}

Measured memory_bytes: 11220
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x, y = map(int, input().split())

    if x % y == 0:
        print(-1)
        exit()

    for res in range(x, 10 ** 18, x):
        if res % y:
            print(res)
            break


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<int>

using namespace std;
using ll = long long;
using veci = vec(int);
using vecll = vec(ll);

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

    int N, K;

    cin >> N >> K;
    string S;
    cin >> S;
    S.push_back('1' - S.back());
    char cur = S[0];
    int c = 0;
    int num0 = 0;
    int acc = 0;
    int ans = -1;
    deque<pair<char,int>> deq;
    rep(i, 0, S.size()-1) {
        if (i==0 || S[i] != cur) {
            if (i!=0) {
                // cout << "cc " << c << endl;
                if (cur=='0') num0++;
                if (num0 > K) {
                    while (!deq.empty() && deq.front().first != '0') {
                        acc -= deq.front().second;
                        deq.pop_front();
                    }
                    if (deq.empty()) break;
                    num0--;
                    acc -= deq.front().second;
                    deq.pop_front();
                }
                deq.push_back({cur, c});
            }

            cur = S[i];
            acc += c;
            ans = max(ans, acc);
            c = 1;
        } else c++;
    }

    cout << ans << endl;


}

Measured memory_bytes: 832
N, M = map(int, input().split())
INF = 1001001001
key = []

for i in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    s = 0
    for j in range(b):
        c[j] -= 1
        s |= 1 << c[j]
    key.append([s, a])

dp = [INF] * (1<<N)
dp[0] = 0
for s in range(1<<N):
    for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)

if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])


Measured memory_bytes: 45800
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    S = input()
    T = input()
    print(sum(s != t for s, t in zip(S, T)))
resolve()

Measured memory_bytes: 73552
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a == b && b == c {
		fmt.Println(1)
	} else if a == b || b == c || a == c {
		fmt.Println(2)
	} else {
		fmt.Println(3)
	}
}


Measured memory_bytes: 512
import collections
path = []
for i in range(3):
    path += list(map(int, input().split()))
path = collections.Counter(path)
if len(path.most_common()) == 4:
    if path.most_common()[0][1] == 2 and path.most_common()[1][1] == 2 and path.most_common()[2][1] == 1 and path.most_common()[3][1] == 1:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int main()
{
  ll n,s=0,i,x;
  cin>>n;
  x=n-1;
  for(i=1;i<=n;i++)
  {
    s+=(x/i);
  }
  cout<<s<<endl;

}


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

struct data {
  long long r, w;
  bool operator<(const data &p) { return r > p.r; }
};

long long n;
vector<data> v;
vector<vector<bool>> dp;

long long solve();

int main() {
  while(cin >> n, n) {
    v.resize(n);
    for(int i = 0; i < n; ++i) cin >> v[i].r >> v[i].w;
    sort(v.begin(), v.end());
    cout << solve() << endl;
  }
  return 0;
}

long long solve() {
  long long rsum = 0, wsum = 0, now = 0;
  for(int i = 0; i < n; ++i) {
    rsum += v[i].r;
    wsum += v[i].w;
  }
  now = max(0LL, 2 * v[0].r - rsum);
  dp.assign(n + 1, vector<bool>(now + 1, 0));
  dp[1][0] = 1;
  for(int i = 1; i < n; ++i)
    for(int j = 0; j <= now; ++j) {
      dp[i + 1][j] = dp[i][j];
      if(j >= v[i].w && dp[i][j - v[i].w]) dp[i + 1][j] = 1;
    }
  for(int i = now; i >= 0; --i)
    if(dp[n][i]) {
      now -= i;
      break;
    }
  return max(rsum + wsum, rsum + wsum + now);
}


Measured memory_bytes: 3240
import Data.List
import Data.Function (on)
import Control.Applicative

main = do
  n <- readLn :: IO Int
  xs <- group . sort . map read . words <$> getLine :: IO [[Int]]
  print $ solve xs n
  where
    solve :: [[Int]] -> Int -> Int
    solve [[x]] 1 | x == 0 = 1
                | otherwise = 0
    solve xs n | length [x | x <- xs, length x /= 2 && head x /= 0] > 0 = 0
               | otherwise = pow 2 (div n 2)
    pow x 1 = x
    pow x n = x * (pow x (n - 1)) `mod` 1000000007



Measured memory_bytes: 36604