akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,m,ans=0;
int main(){
	cin>>n>>m;
	if(n>=3&&m>=3){
		cout<<(n-2)*(m-2)<<endl;
		return 0;
	}
	if(n==1){
		if(m==1)cout<<1<<endl;
		else cout<<m-2<<endl;
		return 0;
	}
	if(m==1){
		cout<<n-2<<endl;
		return 0;
	}
	if(n==2){
		cout<<0<<endl;
		return 0;
	}
	if(m==2){
		cout<<0<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	string t;
	cin>>s;
	cin>>t;
	int c=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		c++;
	}
	cout<<c;
}

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

using namespace std;

typedef long long ll;

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

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

	if((a < c && c < b) || (a > c && c > b)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
a_list = sorted(list(map(int, input().split(' '))))

score_list = [0] * 2

available_cards = deque(a_list)

while len(available_cards) != 0:
    score_list[0] += available_cards.pop()
    try:
        score_list[1] += available_cards.pop()
    except:
        break

print(score_list[0] - score_list[1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  = vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    int x, y;
    cin >> x >>y;

    rep(i, x+1){
        rep(j, x+1){
            if(i + j == x && i * 2 + j * 4 == y){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3624
#include<stdio.h>
int bubbleSort(int A[],int n){
	int flag,c=0,j,tmp;
    flag=1;
    while(flag){
    	flag=0;
    	for(j=n-1;j>0;j--){
    		if(A[j]<A[j-1]){
    			tmp=A[j];
    			A[j]=A[j-1];
    			A[j-1]=tmp;
    		
    		flag=1;
            c++;
    	}
    }
}
return c;
}

int main(){
	int i,n,A[100],j,c;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	c = bubbleSort(A,n);
	for(j=0;j<n;++j){
	if(j>0) {printf(" ");}
printf("%d",A[j]);
}
printf("\n");
printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 2124
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
 
ans = 0
for i in range(N):
    d = min(A[i], B[i])
    ans += d
    A[i] -= d
    B[i] -= d
    d = min(A[i + 1], B[i])
    ans += d
    A[i + 1] -= d
    B[i] -= d
    
print(ans)


Measured memory_bytes: 19648
import java.util.*;
 
public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> data = new TreeMap<String, Integer>();


        for(int i=1; i<n+1; i++){
            String town = sc.next();
            int point = sc.nextInt();
            data.put(town+(200-point), i);
        }

        for(String key: data.keySet()){
            System.out.println(data.get(key));
        }

        sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    int main() {
      int n;
      cin >> n;
      ll sum = 0;
      ll c1, c2;
      for (int i = 1; i <= n; i++) {
        if (i % 3 != 0) {
          if (i % 5 != 0) {
            sum = sum + i;
          }
        }
      }
      cout << sum;
    }
     
    // g++ lo.cpp
    // ./a.exe
    // g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp

Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int> > hw(h+1,vector<int>(w+1,0));
  int all=0;
  for(int i=0;i<h;i++){
    int tmp=0;
    for(int j=0;j<w;j++){
      cin>>hw[i][j];
      tmp+=hw[i][j];
      all+=hw[i][j];
    }
    hw[i][w]=tmp;
  }
  hw[h][w]=all;
  for(int i=0;i<w;i++){
    int tmp=0;
    for(int j=0;j<h;j++){
      tmp+=hw[j][i];
    }
    hw[h][i]=tmp;
  }

  for(int i=0;i<h+1;i++){
    for(int j=0;j<w+1;j++){
      cout<<hw[i][j];
      if(j!=w)cout<<" ";
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int A;
  int B;
  cin >>A>>B;
  if((A<=8) &&(B<=8)) {
cout << "Yay!" << endl;
  }
else {
cout << ":(" << endl;
}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> V(N);
  for(int i=0;i<N;i++)cin>>V[i];
  int ans=0;
  for(int L=0;L<N;L++){
    for(int R=L;R<=N;R++){
      if(L+N-R>K)continue;
      vector<int>t;
      int res=0;
      for(int i=0;i<L;i++)t.push_back(V[i]),res+=V[i];
      for(int i=R;i<N;i++)t.push_back(V[i]),res+=V[i];
      sort(t.begin(),t.end());
      for(int i=0;i<K-L-N+R&&i<(int)t.size()&&t[i]<0;i++)res-=t[i];
      ans=max(ans,res);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
[n,m] = [int(i) for i in input().split()]
k = []
s = []
for i in range(m):
    tmp = [int(j) for j in input().split()]
    k.append(tmp[0])
    s.append(tmp[1:])
p = [int(i) for i in input().split()]
ans = 0

for i in range(2 ** n):
    all = 1
    switch = [0] * n
    st = bin(i)[2:]
    st = "0" * (n - len(st))+st
    #print(i,st)
    for j in range(n):
        if st[j] == "1":
            switch[j] = 1
    for j in range(m):
        tmp = 0
        for check in s[j]:
            if switch[check-1] == 1:
                tmp += 1
        if tmp % 2 != p[j]:
            all *= 0
    if all:
        ans += 1
print(ans)


Measured memory_bytes: 3064
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']
Yn=['Yes','No']
 
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
#ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

a,b=LI()
for i in range(1,10**6):
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i)
        exit()

print(-1)

Measured memory_bytes: 40552
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    if (n == 2){
        cout << 2 << endl;
        return 0;
    }
    repp(i,1e7,n){
        bool t = true;
        if (i % 2 == 0) continue;
        for (int j = 3; j <= sqrt(i); j += 2){
            if (i % j == 0){
                t = false;
                break;
            }
        }
        if (t){
            cout << i << endl;
            return 0;
        }
    }
}

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

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
  // magic spell--------------
  cin.tie(0);
  ios::sync_with_stdio(false);
  //--------------------------

  int ret=0;
  int N;
  cin >> N;
  VI h(N);
  REP(i,N) cin>> h[i];  

  // simulate roller
  while(1){
    int first = -1; // a coordinate of the first flower which no need to be grown
    int last = -1; // a coordinate of the last flower which no need to be grown
    REP(i,N){ 
      // determine the watering range
      if(first == -1 && h[i] != 0) first = i;
      if(first != -1 && h[i] == 0){
        last = i;
        break;
      }
    }
    if (first == -1) break; // there are no flowers should be grown
    if (last == -1) last = N; // there is a flower should be grown at last
    
    FOR(i,first,last) h[i]--; // decrement h[i] values instead of watering flowers
    ret++;
  }
  cout << ret << endl;
  return 0;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    
    vector<int> d(K);

    int count=0;
    vector<int> A(100000);

    for(int i=0; i<K; i++){
        cin >> d.at(i);
        for(int j=count; j<count + d.at(i); j++){
            cin >> A.at(j);
        }
        count += d.at(i);
    }
    sort(A.begin(), A.end());//小さい順にソート
    int ans=1;
    for(int i=0; i<A.size()-1; i++){
        if(A.at(i) != A.at(i+1)){
            ans ++;
        }
    }
    cout << N-ans+1 << endl;
}

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

int main() {
  int cnt[26] = {0};
  std::string w;

  std::cin >> w;

  for (int i = 0; i < w.length(); i++)
  {
    cnt[w[i] - 'a']++;
  }
  bool isOdd = false;

  for (int i = 0; i < 26; i++)
  {
    if (cnt[i] % 2 == 1) {
      std::cout << "No" << "\n";
      isOdd = true;
      break;
    }
  }
  if (!isOdd) {
    std::cout << "Yes" << "\n";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  int left=N/2-1;
  int right=N/2;
  int ans=0;
  for(int i=d[left]+1; i<=d[right]; i++){
//    cout<<i<<endl;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long double ld;


int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	
	ll arr[a],brr[b],crr[c];
	
	for(ll i=0;i<a;i++)cin>>arr[i];
	
	for(ll i=0;i<b;i++)cin>>brr[i];
	
	for(ll i=0;i<c;i++)cin>>crr[i];
	
	//cout<<"*"<<endl;
	
	sort(arr,arr+a);
	sort(brr,brr+b);
	sort(crr,crr+c);
	
	vector <ll> vec;
	
	for(ll i=0;i<x;i++)
	{
		vec.push_back(arr[a-i-1]);
	}
	
	for(ll i=0;i<y;i++)
	{
		vec.push_back(brr[b-i-1]);
	}
	
	for(ll i=0;i<c;i++)vec.push_back(crr[i]);
	
	sort(vec.begin(),vec.end());
	
	ll ans = 0;
	for(ll i=0;i<x+y;i++)
	{
		ans += vec[vec.size()-i-1];
	}
	
	cout<<ans;

	
	
}


Measured memory_bytes: 8688
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int k,n; cin >> k >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ma = 0;
    rep(i,n-1) ma = max(ma, a[i+1]-a[i]);
    ma = max(ma, a[0]+k-a[n-1]);
    cout << k - ma << endl;
    return 0;
}

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

int main() {
	int n,ans;
	string s;
	cin >> n >> s;
	ans=0;
	for(int i=0; i<s.size()-2; i++){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let s=t.s(),c=0,r=0
  for(let i=0;i<s.length;i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')c++
    else{
      r=t.max(c,r)
      c=0
    }
  }
  t.o(t.max(c,r))
}
main()


Measured memory_bytes: 7372
let rec tabulate n f = 
  let rec loop acc m =
    if m < n then loop (f m :: acc) (m + 1)
    else List.rev acc in
  loop [] 0

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let ls = tabulate (2 * n) (fun _ -> Scanf.scanf "%d " (fun l -> l)) in
  List.sort compare ls
  |> List.fold_left (fun (prev, acc) l ->
      match prev with
      | None -> (Some l, acc)
      | Some l' -> (None, (l, l') :: acc)) (None, [])
  |> snd
  |> List.map (fun (l, l') -> min l l')
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n"


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める ,b
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
const int mod = 1000000007;
ll n,b=0,h=0,ans=mod; bool m=false;
string s;
int main(){
  cin >> n >> s; s += " ";
  for (size_t i = 0; i < n; i++)if(s[i] == '.')h++;
  for (size_t i = 0; i < n+1; i++) {
    ans = min(ans,b+h);
    if(s[i] == '#')b++;
    if(s[i] == '.')h--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

int main(){
    string s; cin >> s;
    int n = s.length();
    rep(i,n){
        if(s[i] != s[n-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    int left_n = (n-1)/2;
    rep(i,left_n){
        if(s[i] != s[left_n-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    int right_n = (n+3)/2;
    for(int i = right_n; i < n; i++){
        if(s[i] != s[n-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
public static void main (String [] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int x=sc.nextInt();int y=sc.nextInt();
int []a=new int [n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
int max=Math.abs(a[n-1]-y);
if(n!=1)
max=Math.max(max,Math.abs(a[n-1]-a[n-2]));
System.out.println(max);
}
}

Measured memory_bytes: 25812
from math import ceil

def solve(n, A):
    p = 10 ** 9 + 7
    nums = {n - 2 * i - 1: 0 for i in range(ceil(n / 2))}
    for a in A:
        if (a not in nums) or (a == 0 and nums[a] == 1) or (nums[a] == 2):
            return 0
        nums[a] += 1
    ret = 1
    for _ in range(n // 2):
        ret = (ret * 2) % p
    return ret

_n = int(input())
_A = map(int, input().split())
print(solve(_n, _A))


Measured memory_bytes: 16344
N,K = map(int,input().split())

# K = 1の時の最小値
wa = 0
# 場合の数の総数
souwa = 0

# 余りを求めるための大きな素数
dprime = 10**9 + 7


for k in range(1,N+2):
#     print("k:",k)
#     print("wa:",wa,"souwa:",souwa)
    # min = wa
    
    if k >= K:
        # max
        mx = N*k-wa
#         print("mx:",mx)
        souwa += (mx - wa + 1) % dprime
#     print("souwa after:",souwa)
    wa += k
        
print(souwa%dprime)
        



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

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        

def main():
    N, M = map(int, input().split())
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())

    ans = [0] * M
    ans[-1] = N * (N-1) // 2
    # 逆順に橋が出来ると不便さが変わるか調べる
    uf = UnionFind(N)
    for i in range(M-1):
        # aとbが連結か調べる
        a, b = A[M-1-i]-1, B[M-1-i]-1
        if uf.find(a) == uf.find(b):
            ans[M-i-2] = ans[M-i-1]
        else:
            ans[M-i-2] = ans[M-i-1] - abs(uf.parents[uf.find(a)]) * abs(uf.parents[uf.find(b)])
            uf.union(a, b) 

    [print(a) for a in ans]
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 18952
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  REP(i,n) {
    cin >> a[i];
  }
  ll x=a[0];
  REP1(i,n-1) {
    x=x^a[i];
  }
  REP(i,n) {
    ll temp=a[i]^x;
    cout << temp << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4700
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    int n,m; cin>>n>>m; cin.ignore();

    int totvotes = 0;
    vector<int> a(n);
    for (int i =0; i<n; ++i) {
        cin>>a[i];
        totvotes += a[i];
    }
    sort(a.begin(),a.end(),greater<int>());

    int x = a[m-1];

    if (4*x*m < totvotes) {
        cout<<"No";
    } else {
        cout<<"Yes";
    } cout<<el;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string O,E;
  cin>>O>>E;
  for(int i=0;i<E.size();i++)cout<<O.at(i)<<E.at(i);
  if(O.size()!=E.size())cout<<O.at(O.size()-1);
  cout<<endl;
}

Measured memory_bytes: 256
H, W, h, w = [ int(v) for v in input().split() ]
if H % h == 0 and W % w == 0:
    print("No")
else:
    print("Yes")
    grid = [ [ -h*w*1000+999 if i % h == h-1 and j % w == w-1 else 1000 for j in range(W) ] for i in range(H) ]
    for i in grid:
        print(*i)

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;

  int dp[n+1][3];
  memset(dp, 0, sizeof dp);

  for (int i = 1; i <= n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;

    dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = c + max(dp[i-1][0], dp[i-1][1]);
  }

  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n';
}


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

int main()
{
    int N;
    long long K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i], --A[i];
    vector<bool> visit(N, false);
    vector<int> citynum;
    int i = 0;
    int restart = 0;
    while (true)
    {
        visit[i] = true;
        citynum.push_back(i);
        int next = A[i];
        if (visit[next])
        {
            restart = next;
            break;
        }
        else
        {
            i = next;
        }
    }
    bool ok = false;
    vector<int> loopvec;
    for (auto e : citynum)
    {
        if (e == restart)
        {
            ok = true;
        }

        if (ok)
        {
            loopvec.push_back(e);
        }
    }
    long long p = loopvec.size();
    if (K < citynum.size())
    {
        cout << citynum[K] + 1 << endl;
        return 0;
    }
    else
    {
        K -= citynum.size();
        long long r = K % p;
        cout << loopvec[r] + 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 6252
N=int(input())
ABC=[[0,0,0]]
for i in range(N):
	ABC+=[[int(i) for i in input().split()]]
DP=[[0,0,0] for i in range(N+1)]
for i in range(N):
	for j in range(3):
		DP[i+1][j]=ABC[i+1][j]+max(DP[i][(j+1)%3],DP[i][(j+2)%3])
print(max(DP[N]))

Measured memory_bytes: 76376
#include <stdio.h>

int main(void){
  int x, y;
  int i, j;
  while(1){
    scanf("%d %d", &x, &y);
    if(x==0 && y==0)break;
    for(i=0; i<x; i++){
      for(j=0; j<y; j++){
        if((i%2==0 && j%2==0) || (i%2==1 && j%2==1)){
          printf("#");
        }else{
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


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

int main()
{
    int n;
    int a[100];
    cin >> n;
    float avg = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        avg += a[i];
    }
    avg /= n;

    int frame = 0;
    float diff_min = abs(avg - a[0]);
    for (int i = 1; i < n; i++)
    {
        float diff = abs(avg - a[i]);
        if (diff < diff_min)
        {
            frame = i;
            diff_min = diff;
        }
    }
    cout << frame;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
const int INF = 1001001001;
using namespace std;
///////////////////////////////////////
struct edge {
	int to, cost;
	edge(int a, int b) :to(a), cost(b) {}
};
int n, m;
vector<edge>G[15];
int dp[1 << 16][15];
int solve(int s) {
	fill_n(*dp, (1 << 16) * 15, INF);
	dp[0][s] = 0;
	for (int i = 0; i < (1 << n); ++i) {
		for (int j = 0; j < n; ++j) {
			if (dp[i][j] == INF)continue;
			for (int k = 0; k < G[j].size(); ++k) {
				edge  &e = G[j][k];
				if (i>>e.to&1)continue;
				dp[i | (1 << e.to)][e.to] = min(dp[i | (1 << e.to)][e.to], dp[i][j] + e.cost);
			}
		}
	}
	return dp[(1 << n) - 1][s];
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b, c; cin >> a >> b >> c;
		G[a].push_back(edge(b,c));
	}
	int mi = INF;
	for (int i = 0; i < n; ++i)mi = min(mi, solve(i));
	if (mi == INF)cout << -1 << endl;
	else cout << mi << endl;
	return 0;
}


Measured memory_bytes: 6960
#include <iostream>
#include <vector>
#include <numeric>


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

    std::vector<std::vector<int>> gcd(N + 1, std::vector<int>(N + 1, -1));
    int sum = 0;
    
    for (int i = 1; i <= N; i++) {
        for (int j = i; j <= N; j++) {
            for (int k = j; k <= N; k++) {
                if (gcd[i][j] == -1) {
                    gcd[i][j] = std::gcd(i, j);
                }
                int g_ij = gcd[i][j];
                if (gcd[g_ij][k] == -1) {
                    gcd[g_ij][k] = std::gcd(g_ij, k);
                }
                int g_ijk = gcd[g_ij][k];
                if (i == k) {
                    sum += g_ijk;
                } else if (i == j || j == k) {
                    sum += g_ijk * 3;
                } else {
                    sum += g_ijk * 6;
                }
            }
        }
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll mod = 1e9+7;
ll fact[200009];
ll inversefact[200009];

ll inverse(ll x){
    ll y = mod-2;
    ll ret = 1;
    while(y > 0){
        if(y % 2)
            ret = ret*x%mod;
        x = x*x%mod;
        y /= 2;
    }
    return ret;
}
ll invfact(ll x){
    if(inversefact[x] != 0)
        return inversefact[x];
    return inversefact[x] = inverse(fact[x]);
}
ll comb(ll x, ll y){
    return fact[x]*invfact(y)%mod*invfact(x-y)%mod;
}
ll h, w, n;
ll dist(pll x, pll y){
    return comb(abs(y.ff-x.ff)+abs(y.ss-x.ss), abs(y.ss-x.ss));
}
vector<pll> v;
ll dp[6000];
ll func(ll idx){
    if(dp[idx] != -1)
        return dp[idx];
    dp[idx] = 0;
    for(ll i = 1; i < n-1; ++i){
        if(i == idx || v[i].ff > v[idx].ff || v[i].ss > v[idx].ss)
            continue;
        dp[idx] -= dist(v[i], v[idx])*func(i);
        dp[idx] %= mod;
    }
    dp[idx] += dist(v[idx], v[0]);
    dp[idx] %= mod;
    if(dp[idx] < 0)
        dp[idx] += mod;
    //cout << idx << " " << dp[idx] << "\n";
    return dp[idx];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    fact[0] = 1;
    for(ll i = 1; i <= 200000; ++i)
        fact[i] = i*fact[i-1]%mod;
    cin >> h >> w >> n;
    v.pb({1, 1});
    for(ll i = 0; i < n; ++i){
        ll t1, t2;
        cin >> t1 >> t2;
        v.pb({t1, t2});
    }
    v.pb({h, w});
    n += 2;
    for(ll i = 0; i < n; ++i)
        dp[i] = -1;
    cout << func(n-1) << "\n";
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m, q;
	cin >> n >> m >> q;
	vector<int> A(q), B(q), C(q), D(q);
	rep(i, q) cin >> A[i] >> B[i] >> C[i] >> D[i];
	
	int now[11] = {};
	int ans = 0;

	REP(a, 1, m+1) {
		now[1] = a;
		REP(b, a, m+1) {
			now[2] = b;
			REP(c, b, m+1) {
				now[3] = c;
				REP(d, c, m+1) {
					now[4] = d;
					REP(e, d, m+1) {
						now[5] = e;
						REP(f, e, m+1) {
							now[6] = f;
							REP(g, f, m+1) {
								now[7] = g;
								REP(h, g, m+1) {
									now[8] = h;
									REP(i, h, m+1) {
										now[9] = i;
										REP(j, i, m+1) {
											now[10] = j;
											int sum = 0;
											// rep(i, 11) cout << now[i];
											// cout << endl;
											rep(k, q) {
												if(now[B[k]] - now[A[k]] == C[k]) {
													sum += D[k];
													//puts("hoge");
												}
											}
											chmax(ans, sum);
											//cout << sum << endl;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
        int n, m;
        string s;
        vector<string> a, b;
        cin >> n >> m;
        for (int i = 0; i < n; i++) {
                cin >> s;
                a.push_back(s);
        }
        for (int i = 0; i < m; i++) {
                cin >> s;
                b.push_back(s);
        }

        bool flg;
        for (int i = 0; i < n - m + 1; i++) {
                for (int j = 0; j < n - m + 1; j++) {
                        flg = true;
                        for (int k = 0; k < m; k++) {
                                for (int l = 0; l < m; l++) {
                                        if (a[i+k][j+l] != b[k][l]) {
                                                flg = false;
                                                break;
                                        }
                                }
                                if (flg == false)
                                        break;
                        }
                        if (flg == true) {
                                cout << "Yes" << endl;
                                exit(0);
                        }
                }
        }
        cout << "No" << endl;

        return 0;
}

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

int cmpnum(const void * n1, const void * n2){
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}
long modpow(long a, long n, long mod){
  long size;
  for (long i = 1; ; i++) {
    if (pow(2,i) > n) {
      size = i;
      break;
    }
  }
  long bit[size];
  bit[0] = n;
  for (long i = 1; i < size; i++) {
    bit[i] = bit[i-1]/2;
    bit[i-1] %= 2;
  }
  long powa[size];
  powa[0] = a;
  for (long i = 1; i < size; i++) {
    powa[i] = powa[i-1]*powa[i-1];
    powa[i] %= mod;
  }
  long answer = 1;
  for (long i = 0; i < size; i++) {
    if (bit[i] == 1) {
      answer *= bit[i]*powa[i];
      answer %= mod;
    }
  }
  return answer;
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long d[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &d[i]);
  }
  long mod = 998244353;
  if (d[0] != 0) {
    printf("0\n");
    return 0;
  }
  qsort(d, n, sizeof(long), cmpnum);
  if (d[1] != 1) {
    printf("0\n");
    return 0;
  }
  long answer = 1;
  long end = 1;
  long add = 1;
  for (long i = 2; i < n; i++) {
    if (d[i] == d[i-1]) {
      add++;
    } else {
      if (d[i] == d[i-1]+1) {
        answer *= modpow(end,add,mod);
        answer %= mod;
        end = add;
        add = 1;
      } else {
        printf("0\n");
        return 0;
      }
    }
  }
  answer *= modpow(end,add,mod);
  answer %= mod;
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 1788
require"prime"
z=Prime.take(20000)
def f i
(i==$u[i])?i:($u[i]=f($u[i]))
end
while gets
$_=="\n"&&next
n=$_.to_i
n>0||exit
c=[a=0]*26
e=[nil]*26
$u=*0..25
n.times{
s=gets.chomp
a=s[0].ord-?a.ord
b=s[s.size-1].ord-?a.ord
c[a]+=1
c[b]-=1
e[a]=e[b]=1
$u[f a]=f b
}
puts (0..25).any?{|i|e[i]&&(c[i]!=0||f(a)!=f(i))}?"NG":"OK"
end

Measured memory_bytes: 6408
//#pragma GCC optimize ("-O3","unroll-loops")
#include<bits/stdc++.h>
 
using namespace std;
 
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
 
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


void solve() {
	int X,Y;cin>>X>>Y;
	ll ans=0;
	ans+=max((ll)0,400000-X*100000);
	ans+=max((ll)0,400000-Y*100000);
	if(X==1&&Y==1)ans+=400000;
	print(ans);
}
 
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                int k = Integer.parseInt(sc.next());
                sc.close();
                long yono = 0;
                for(int i = k ; i <= n + 1 ; i++){
                        yono += i * (long)(n - i + 1) + 1;
                        yono %= 1000000007;
                }
                ou.print(yono + "\n");
                ou.flush();
        }
}

Measured memory_bytes: 38644
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9 + 7;
	string s;
	cin >> s;
	int k;
	cin >> k;
	vector<vector<vector<int>>> dp(s.size() + 1, vector<vector<int>>(k+1, vector<int>(2, 0)));
	dp[0][0][1] = 1;
	rep(i, s.size()) {
		rep(j, k+1) {
			int it = s[i] - '0';
			//0
			dp[i + 1][j][0] += dp[i][j][0];
			if (it == 0) {
			    //0-true
				dp[i + 1][j][1] += dp[i][j][1];
			}
			else{
			    //0-false
			    dp[i+1][j][0]+=dp[i][j][1];
			    if(j){
			        //n-true
			        dp[i+1][j][1]+=dp[i][j-1][1];
			        dp[i+1][j][0]+=dp[i][j-1][1]*(it-1);
			    }
			}
			if(j){
			    dp[i+1][j][0]+=dp[i][j-1][0]*9;
			}
		}
	}
	cout<<dp[s.size()][k][1]+dp[s.size()][k][0]<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		double minDiff;
		int minId;

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			minDiff = Double.MAX_VALUE;
			minId = 0;
			for (int i = 0; i < n; i++) {
				int number = sc.nextInt();
				int height = sc.nextInt();
				int weight = sc.nextInt();

				if (Math.abs(22.0 - (1.0 * weight) / (1.0 * height / 100) / (1.0 * height / 100)) < minDiff) {
					minDiff = Math.abs(22.0 - (1.0 * weight) / (1.0 * height / 100) / (1.0 * height / 100));
					minId = number;
				}
			}
			
			System.out.println(minId);
		}
	}
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  int n ; 
  cin >> n ;
  int list[9]={};
  rep(i,n){
    int a; cin>>a;
    if(1<=a && a<400) list[0]++;
    if(400<=a && a<800) list[1]++;
    if(800<=a && a<1200) list[2]++;
    if(1200<=a && a<1600) list[3]++;
    if(1600<=a && a<2000) list[4]++;
    if(2000<=a && a<2400) list[5]++;
    if(2400<=a && a<2800) list[6]++;
    if(2800<=a && a<3200) list[7]++;
    if(3200<=a) list[8]++;   
  }
  
  int sum=0;
  rep(i,8){
    if(list[i]>0)sum++;
  }
  if(sum>0) cout<<sum<<" "<<sum+list[8]<<endl;
  else cout<<1<<" "<<list[8]<<endl;
  
}



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

const double PI = 2 * acos(0.0);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long double r;
	cin >> r;
	cout << fixed << setprecision(20) << 2.0 * PI * r << "\n";
	return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string S;
    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
import math
t = 1
# t = input()
# t = int(t)
def max(a,b):
	if a > b:
		return a
	return b
while t > 0:
	t -= 1
	s = input()
	ans = ""
	if s == "Sunny":
		ans = "Cloudy"
	elif s == "Cloudy":
		ans = "Rainy"
	else:
		ans = "Sunny"
	print(ans)
	# n = int(input())
	# v = list(map(int,input().strip().split()))[0:n]
	# # m = {}
	# l = []
	# for i in range(n):
	# 	l.append(0)
	# # ans = 0
	# j = 1
	# for i in v:
	# 	l[i-1] = j
	# 	j += 1
	# # print(ans)
	# for i in l:
	# 	print(i,end=" ")


Measured memory_bytes: 61884
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
		 
        int a = sc.nextInt();
        int b = sc.nextInt();

		int S = a * b;
		int T = 2 * (a + b);
		System.out.println(S + " " + T);
	}

}



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

void quicksort(vector<pair<string,int> > &sp){
    if(sp.size()==0){
        return;
    }
    else{
        pair<string,int> pivot_pair=sp.at(0);
        int pivot=sp.at(0).second;
        vector<pair<string,int> > left(0);
        vector<pair<string,int> >right(0);
        for(int i=1;i<sp.size();i++){
            if(sp.at(i).second>pivot){
                left.push_back(sp.at(i));
            }
            else{
                right.push_back(sp.at(i));
            }
        }
        quicksort(left);
        quicksort(right);
        int leftlen=left.size();
        for(int i=0;i<leftlen;i++){
            sp.at(i)=left.at(i);
        }
        sp.at(leftlen)=pivot_pair;
        for(int i=0;i<right.size();i++){
            sp.at(leftlen+1+i)=right.at(i);
        }
        return;
    }
}


int main(){
    int N;
    cin>>N;
    vector<pair<string,int> > SP(N);
    vector<pair<string,int> > sp(N);
    for(int i=0;i<N;i++){
        cin>>SP.at(i).first>>SP.at(i).second;
    }
    sp=SP;
    sort(sp.begin(),sp.end());
    string S=sp.at(0).first;
    vector<pair<string,int> > sppart(0);
    for(int i=0;i<N;i++){
        if(sp.at(i).first==S){
            sppart.push_back(sp.at(i));
        }
        else{
            int len=sppart.size();
            quicksort(sppart);
            for(int j=0;j<len;j++){
                sp.at(i-len+j)=sppart.at(j);
            }
            S=sp.at(i).first;
            sppart.clear();
            sppart.push_back(sp.at(i));
        }
        if(i==N-1){
            int len=sppart.size();
            quicksort(sppart);
            for(int j=0;j<len;j++){
                sp.at(i+1-len+j)=sppart.at(j);
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(sp.at(i).second==SP.at(j).second){
                cout<<j+1<<endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b;
    set<int>st;
    set<int>::iterator it;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&a,&b);
        if(a==0)
        {
            st.insert(b);
            printf("%d\n",st.size());
        }
        else
        {
            it = st.find(b);
            if(it!=st.end()) printf("1\n");
            else  printf("0\n");
        }
    }

    return 0;
}



Measured memory_bytes: 12528
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    char s;
    int ans = 0, g=0, p=0;
    while(cin >> s){
        if(s == 'g'){
            if(p+1 <= g){
                ans++;
                p++;
            }else{
                g++;
            }
        }else{
            if(p+1 <= g){
                p++;
            }else{
                g++;
                ans--;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

typedef long long llint;
typedef pair<llint, llint> P;

int main() {
  llint n, m;
  while (cin >> n >> m, n) {
    vector<P> v;
    for (int i = 0; i < n; i++) {
      llint d, p;
      cin >> d >> p;
      v.emplace_back(p, d);
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < n; i++) {
      if (v[i].second <= m) {
        m -= v[i].second;
        v[i].second = 0;
      } else {
        v[i].second -= m;
        m = 0;
      }
      if (m == 0) break;
    }

    llint ans = 0;
    for (auto &w : v) {
      ans += w.first * w.second;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3292