akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));

	
	








	
return 0;
}


Measured memory_bytes: 256
/*
ID: little_10
LANG: C++
TASK: exam
*/
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <vector>
using namespace std;

typedef long long LL;

#define gc() getchar()
#define digit(x) (x >= '0' && x <= '9')
int read()
{
	int x = 0, f = 1; char c = gc();
	while(!digit(c)){if(c == '-') f = -1; c=gc();}
	while(digit(c)){x = (x<<3)+(x<<1)+c-'0'; c=gc();}
	return x*f;
}

const int N = 2e5;

struct node
{
	int p;
	int s, t;
	
	inline bool operator < (const node &b)const
	{
		return p > b.p;
	}
}a[N+5];

struct Segment_Tree
{
	#define lch (i<<1)
	#define rch (i<<1|1)
	#define mid ((l+r)>>1)
	
	struct Node
	{
		int l, r;
		int col, tg;
	}tr[(N<<4)+5];
	
	inline void Update(int i)
	{
		if(tr[lch].col == tr[rch].col)
			tr[i].col = tr[lch].col;
		else
			tr[i].col = -1;
	}
	
	inline void Pushdown(int i)
	{
		if(~tr[i].tg)
		{
			tr[lch].tg = tr[lch].col = tr[rch].tg = tr[rch].col = tr[i].tg;
			tr[i].tg = -1;
		}
	}
	void Build(int i, int l, int r)
	{
		tr[i].l = l; tr[i].r = r; tr[i].tg = -1;
		if(l == r)
		{
			tr[i].col = 0;
			return ;
		}
		
		Build(lch, l, mid);
		Build(rch, mid+1, r);
		
		Update(i);
	}
	
	void Insert(int i, int l, int r, int c)
	{
		if(tr[i].l > r || tr[i].r < l)
			return ;
		if(l <= tr[i].l && tr[i].r <= r)
		{
			tr[i].tg = c;
			tr[i].col = c;
			return ;
		}
		
		Pushdown(i);
		Insert(lch, l, r, c);
		Insert(rch, l, r, c);
		Update(i);
	}
	
	int Find(int i, int x)
	{
		if(tr[i].l > x || tr[i].r < x)
			return -1;
		
		if(~tr[i].col)
			return tr[i].col;
		
		Pushdown(i);
		int tmp = Find(lch, x);
		if(~tmp)
			return tmp;
		return Find(rch, x);
	}
	
}Tree;

int rk[3*N+5];
int x[N+5];
int l;

int n, m;

void Init()
{
	n=read(); m=read();
	
	for(register int i=1; i<=n; i++)
	{
		a[i].s = read();
		a[i].t = read()-1;
		a[i].p = read();
		rk[i*2-1] = a[i].s-a[i].p;
		rk[i*2] = a[i].t-a[i].p;
	}
	
	for(register int i=1; i<=m; i++)
		rk[n*2+i] = x[i] = read();
	
	sort(rk+1, rk+n*2+m+1);
	l = unique(rk+1, rk+n*2+m+1) - (rk+1);
	
	Tree.Build(1, 0, l);
	
	for(register int i=1; i<=m; i++)
		x[i] = lower_bound(rk+1, rk+l+1, x[i]) - rk;
	
	
	sort(a+1, a+n+1);
	
	int t1, t2;
	for(register int i=1; i<=n; i++)
	{
		t1 = lower_bound(rk+1, rk+l+1, a[i].s-a[i].p) - rk;
		t2 = lower_bound(rk+1, rk+l+1, a[i].t-a[i].p) - rk;
		Tree.Insert(1, t1, t2, a[i].p);
	}
}

int main()
{
	//freopen("road.in", "r", stdin);
	//freopen("road.out", "w", stdout);
	Init();
	
	for(register int i=1; i<=m; i++)
	{
		int tmp = Tree.Find(1, x[i]);
		if(!tmp) printf("-1\n");
		else printf("%d\n", tmp);
	}
	return 0;
}


Measured memory_bytes: 42240
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define out(a) cout<<a<<" "
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int ctoi(const char c){
    if ('0' <= c && c <= '9')
        return (c - '0');
    return -1;
}

int main() {
    string s;
    int n,mod;
    mod=1000000007;
    cin >> s;
    n=s.size();
    vector<vector<int>> dp(100005,vector<int>(13));
    dp[0][0]=1;
    for (int i=1;i<=n;i++){
        if (s[i-1]=='?'){
            rep(j,13)rep(k,10){
                dp[i][(j*10+k)%13]+=dp[i-1][j];
                dp[i][(j*10+k)%13]%=mod;
            }
        }else{
            int num=ctoi(s[i-1]);
            rep(j,13){
                dp[i][(j*10+num)%13]+=dp[i-1][j];
                dp[i][(j*10+num)%13]%=mod;
            }
        }
    }
cout << dp[n][5] << endl;
return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s;
  cin >> s;
  ll n=s.size();
  ll ans[n];
  memset(ans,-1,sizeof(ans));

  for(int i=0;i<n;i++){
    if(ans[i]!=-1)continue;
    ll k=1;
    if(s[i]=='R'){
      while(s[i+k]==s[i]){
        k++;
      }
      if(k%2==0)ans[i]=i+k;
      else ans[i]=i+k-1;
      for(int j=i+1;j<i+k;j++){
        if(i%2==j%2)ans[j]=ans[i];
        else ans[j]=(i+k)+(i+k-1)-ans[i];
      }
    }
  }

  
  for(int i=n-1;i>0;i--){
    if(ans[i]!=-1)continue;
    ll k=1;
    if(s[i]=='L'){
      while(s[i-k]==s[i]){
        k++;
      }
      if(k%2==0)ans[i]=i-k;
      else ans[i]=i-k+1;
      for(int j=i;j>i-k;j--){
        if(i%2==j%2)ans[j]=ans[i];
        else ans[j]=(i-k)+(i-k+1)-ans[i];
      }
    }
  }

  ll b[n]={};
  for(int i=0;i<n;i++)b[ans[i]]++;
  for(int i=0;i<n;i++)cout << b[i] << " ";

  

}

Measured memory_bytes: 5272
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	sort(all(s));
	cout << (s == "abc" ? "Yes" : "No") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
from collections import deque
n=int(input())
a=list(map(int,input().split()))

ans=deque()

if n%2==0:
    for i in range(n):
        if i%2==0:
            ans.append(a[i])
        else:
            ans.appendleft(a[i])
else:
    for i in range(n):
        if i%2==1:
            ans.append(a[i])
        else:
            ans.appendleft(a[i])

print(" ".join(map(str, ans)))

Measured memory_bytes: 123476
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,M;
int A[100005];
int sum[200005],sum2[200005];
signed main(){
	cin>>N>>M;
	int ans=0;
	rep(i,N){
		cin>>A[i];A[i]--;
		if(i){
			sum[A[i-1]+2]++;
			if(A[i-1]<A[i]){
				int p=A[i]-A[i-1];
				ans+=p;
				sum[A[i]+1]-=p;
				sum[A[i]+2]+=p-1;
			}
			else {
				int p=A[i]+M-A[i-1];
				ans+=p;
				sum[A[i]+M+1]-=p;
				sum[A[i]+M+2]+=p-1;
			}
		}
	}
	rep(i,2*M)sum[i+1]+=sum[i];
	int mx=0;
	rep(i,2*M){
		sum2[i%M]+=sum[i];
		sum[i+1]+=sum[i];
	}
	rep(i,M)chmax(mx,sum2[i]);
	cout<<ans-mx<<endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  set<ll> st;
  REP(i, n) st.insert(a[i]);

  if (st.size() == n)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
int n, val[100005], dp[100005];
int main()
{
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> val[i];
    }
    dp[1]=0;
    dp[2]=abs(val[2]-val[1]);
    for(int i=3; i<=n; i++){
        dp[i]=min(dp[i-1]+abs(val[i]-val[i-1]), dp[i-2]+abs(val[i]-val[i-2]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
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 c = sc.nextInt();
		int x = sc.nextInt();
		int count = 0;

		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					if (500 * i + 100 * j + 50 * k == x) {
						count++;
					}
				}
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import sys
x,n=map(int,input().split())
if n==0:
  print(x)
  sys.exit()
b=list(map(int,input().split()))
a=list(range(-1,102))
for i in b:
  a.remove(i)
mn=1000
j=1000
for i in a:
  c=abs(x-i)
  if c<mn:
    j=i
    mn=c    
  elif c==mn:
    j=min(j,i)
print(j)
    

Measured memory_bytes: 61808
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n,a,b,c;
	string s;
	cin >> a >> b;
	cout << max(a-2*b,0) << endl;
}


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

	public static void main(String[] args)throws IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
		int n = in.nextInt();
    	int arr[] = new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i] = in.nextInt();
		}
        int ans = 0;
        for(int i=1;i<n-1;i++)
        {
            if(arr[i]>arr[i+1] && arr[i]>arr[i-1])
                continue;
            else if(arr[i]<arr[i+1] && arr[i]<arr[i-1])
                continue;
            ans++;
        }
        out.println(ans);
        out.close();
	}
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}

Measured memory_bytes: 21204
const MOD: usize = 998244353;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let k: usize = sc.read();
    let n: usize = sc.read();

    let combination = Combination::new(k + n, MOD);
    for sum in 2..(2 * k + 1) {
        println!("{}", solve(sum, k, n, &combination));
    }
}

fn solve(sum: usize, max_value: usize, num_dice: usize, combination: &Combination) -> usize {
    let mut pairs = 0;
    for i in 1.. {
        if i * 2 > sum {
            break;
        }
        let other = sum - i;
        if other > max_value {
            continue;
        }
        pairs += 1;
    }

    let mut ans = combination.h(max_value, num_dice);
    for used_pairs in 1..(pairs + 1) {
        if num_dice < used_pairs * 2 {
            break;
        }

        let mut tmp = combination.get(
            num_dice - used_pairs * 2 + max_value - 1,
            num_dice - used_pairs * 2,
        ) * combination.get(pairs, used_pairs);
        tmp %= MOD;
        if used_pairs % 2 == 1 {
            ans += MOD - tmp;
        } else {
            ans += tmp;
        }
        ans %= MOD;
    }
    ans
}

pub struct Combination {
    fact: Vec<usize>,
    inv_fact: Vec<usize>,
    modulo: usize,
}

impl Combination {
    pub fn new(max: usize, modulo: usize) -> Combination {
        let mut inv = vec![0; max + 1];
        let mut fact = vec![0; max + 1];
        let mut inv_fact = vec![0; max + 1];
        inv[1] = 1;
        for i in 2..(max + 1) {
            inv[i] = inv[modulo % i] * (modulo - modulo / i) % modulo;
        }
        fact[0] = 1;
        inv_fact[0] = 1;
        for i in 0..max {
            fact[i + 1] = fact[i] * (i + 1) % modulo;
        }
        for i in 0..max {
            inv_fact[i + 1] = inv_fact[i] * inv[i + 1] % modulo;
        }
        Combination {
            fact: fact,
            inv_fact: inv_fact,
            modulo: modulo,
        }
    }

    pub fn get(&self, x: usize, y: usize) -> usize {
        assert!(x >= y);
        self.fact[x] * self.inv_fact[y] % self.modulo * self.inv_fact[x - y] % self.modulo
    }

    pub fn h(&self, n: usize, r: usize) -> usize {
        self.get(n + r - 1, r)
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())
Sp = []
for i in range(N):
    S,p = inpl_str()
    p = int(p)
    Sp.append([S,-p,i])
Sp.sort()
for s,p,i in Sp:
    print(i+1)


Measured memory_bytes: 4592
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var a = new List<int>();
        GeneratePrime(a, 105000);
        var b = new int[10001];
        b[0] = a[0];
        for (int i = 1; i <= 10000; i++)
            b[i] = a[i] + b[i - 1];
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            Console.WriteLine(b[n - 1]);
        }
    }
public static void GeneratePrime(List<int> primeList, int m)
{
    int prime;
    var sqrtMax = Math.Sqrt(m);
    var searchList = Enumerable.Range(2, m - 1).ToList();
    do
    {
        prime = searchList.First();
        primeList.Add(prime);
        searchList.RemoveAll(n => n % prime == 0);
    }
    while (prime < sqrtMax);
    primeList.AddRange(searchList);
}
}

Measured memory_bytes: 10444
#include <iostream>
using namespace std;
#include <string>
#include <algorithm>
 
int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	
	string result =s1.substr(0,1)+s2.substr(0,1)+s3.substr(0,1);
	
	transform(result.begin(), result.end(), result.begin(), ::toupper);
	cout << result;
	cout << endl;
	
	return 0;
}

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

using namespace std;

vector<int> divisor(int n) {
    vector<int> v;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    return v;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m[a[i]]++;
    }

    int cnt = n;
    for (int i = 0; i < n; i++) {
        if (m[a[i]] > 1) {
            cnt--;
            continue;
        }
        vector<int> v = divisor(a[i]);
        for (auto e : v) {
            if (e == a[i]) {
                continue;
            }
            if (m.find(e) != m.end()) {
                cnt--;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 13436
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;
const int N=2e3,mod=1e9+7;
ll p[N];
ll t[N];
int32_t main(){
    for (int i=2;i<N;i++){
        if (p[i]==0){
            for (int j=i;j<N;j+=i){
                p[j]=i;
            }
        }
    }
    ll n;
    cin >> n;
    for (int i=2;i<=n;i++){
        ll k=i;
        while(k>1){
            t[p[k]]++;
            k/=p[k];
        }
    }
    ll ans=1;
    for (int i=0;i<N;i++){
        ans*=t[i]+1;
        ans%=mod;
    }
    cout << ans;

}


Measured memory_bytes: 256
def main():
    N = int(input())
    lst_A = list(map(int, input().split()))
    lst_B = list(map(int, input().split()))
    lst_C = list(map(int, input().split()))

    ret = sum(lst_B)
    for i in range(N - 1):
        a1 = lst_A[i]
        a2 = lst_A[i + 1]
        diff = a2 -a1

        if diff == 1:
            ret += lst_C[a1 - 1]
    
    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3064
N = int(input())
H = [int(x) for x in input().split(' ')]

i = 0
count = 0
max_count = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
        if max_count < count:
            max_count = count
    else:
        count = 0
    
print(max_count)

Measured memory_bytes: 14252
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
const int mod=1e9+7;
int main (){ 
    string s ;
    cin >> s ;
    int n = s.length() ;

    
    if(s[0] != 'D'&&s[0] !='P'){
         s[0] = 'D' ;
         rep(j , n-1 ){
             if(s[j+1] == '?'){
              if(s[j] == 'P'){
                  s[j+1] = 'D' ;
              }else{
                  if(s[j +2]=='?'||s[j+ 2]=='D'){
                  s[j+1] = 'P' ;
                  }else{
                  s[j+1] = 'D' ;
                  }
              }
          }

         }

    
    }else{
        rep(i,n){
          if(s[i] == '?'){
              if(s[i-1] == 'P'){
                  s[i] = 'D' ;
              }else{
                 if(s[i+ 1]=='?' ||s[i+ 1]=='D'){
                  s[i] = 'P' ;
                  }else{
                  s[i] = 'D' ;
                  }
                 
              }
          }
        }
    }
    

    cout << s << endl;
    return 0 ;
}

 


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

int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> w.at(i);
        count += w.at(i);
    }
    int wa=0;
    int ans=1000000;
    for(int i=0;i<n;i++){
        wa+=w.at(i);
        count-=w.at(i);
        ans=min(ans,abs(wa-count));


    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
Mod = 10**9 + 7
N,M = gets.split.map &:to_i
X = gets.split.map &:to_i
Y = gets.split.map &:to_i

def ar(xs)
  dx = (1...xs.size).map{ |i| xs[i] - xs[i-1] }
  sx = [0]
  ax = 0
  (0...dx.size).each{ |i| 
    sx << (sx[-1] + dx[i]) % Mod
  }
  ssx = [0]
  (1...sx.size).each{ |i| 
    ssx << (ssx[-1] + sx[i]) % Mod
    v = i*sx[i] % Mod
    v = (v - ssx[-2] + Mod) % Mod
    ax = (ax + v) % Mod
  }
  ax
end
  
p ar(X) * ar(Y) % Mod


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

int main(){
    int N, D, X;
    cin >> N >> D >> X;

    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    
    int output = 0;
    for (int i = 0; i < N; i++)
    {
        int cnt = 1;
        while(cnt <= D){
            output++;
            cnt += A[i];
        }
    }

    //out
    cout << output + X << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
#define ARRAY_MAX 100

/*dp[i+1][j]:i問目まで解いて得点がj点*/

int n;
int p[ARRAY_MAX+1];
int dp[ARRAY_MAX + 1][ARRAY_MAX*ARRAY_MAX + 1];

void solve(){

    dp[0][0] = 0;/*0問で0点はありえる*/
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= ARRAY_MAX*ARRAY_MAX;j++){
            if(j < p[i]){
                dp[i+1][j] = dp[i][j];//ない
            }else{
                dp[i+1][j] = max(dp[i][j],dp[i][j-p[i]]+p[i]);//解くか解かないか
            }
        }

    }
    
    int ans = 0;
    for(int i = 0;i < ARRAY_MAX*ARRAY_MAX;i++){
        if(dp[n][i] % 10 != 0){/*1なら得点パターンが存在*/
            //cout << "a" << endl;
            ans = max(ans,dp[n][i]);
        }
        //cout << "b" << endl;
    }
    cout << ans << endl;

}

int main(){    

    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> p[i];
    }
    solve();

    return 0;
}

Measured memory_bytes: 4096
// fahadmd16(IIEST Shibpur)

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

#define ll                          long long
#define pb                          push_back
#define pf                          push_front
#define eb                          emplace_back
#define mp                          make_pair
#define ff                          first
#define ss                          second
#define db                          double
#define pll                         pair<ll, ll>
#define ALL(a)                      (a).begin(),(a).end()
#define endl                        "\n"

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define ford(i, n) for (ll i = n - 1; i >= 0; i--)
#define forab(i, a, b) for(ll i = a; i < b; i++)
#define eps 1e-10

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)


#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;


const ll sz = 1e5 + 3;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9;


typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;

ll power(ll n, ll k, ll m) {
    ll ans = 1;
    while (k) {
        if (k & 1)ans = (ans * n) % m;
        k /= 2;
        n = (n * n) % m;
    }
    return ans;
}

void solver() {
    ll n; cin >> n;
    db pi = 2 * acos(0.0);
    cout << fixed << setprecision(5) << 2 * pi*n << endl;

}


int main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    IOS;
    ll T = 1; //cin >> T;
    forn1(i, T + 1) {
        clock_t z = clock();
        solver();
        debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
    }
    return 0;
}


Measured memory_bytes: 3824
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_109
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            long x = long.Parse(input[1]);
            input = Console.ReadLine().Split(' ');
            var xs = new long[n];
            for (int i = 0; i < n; i++)
            {
                xs[i] = Math.Abs(long.Parse(input[i])-x);
            }

            Array.Sort(xs);
            long distMax = xs[0];
            for (int i = 1; i < n; i++)
            {
                distMax = GCD(xs[i], distMax);
            }

            Console.WriteLine(distMax);
        }

        static long GCD(long a, long b)
        {
            long c = b;
            do
            {
                c = a % b;
                a = b;
                b = c;
            } while (c > 0);
            return a;
        }
    }
}


Measured memory_bytes: 19040
import java.util.Scanner;

//Rectangular Searching
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if((h|w)==0)break;
			char[][] m = new char[h][w];
			for(int i=0;i<h;i++)m[i]=sc.next().toCharArray();
			int[][] c = new int[h][w];
			for(int i=0;i<h;i++){
				int x = 1;
				for(int j=w-1;j>=0;j--){
					if(m[i][j]=='.'){
						c[i][j] = x++;
					}
					else{
						c[i][j] = 0;
						x = 1;
					}
				}
			}
			int max = 0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(0<i&&c[i][j]==c[i-1][j]||c[i][j]==0)continue;
					int k = 1;
					int min = c[i][j];
					max = Math.max(max, k*min);
					while(i+k<h&&c[i+k][j]>0){
						min = Math.min(min, c[i+k][j]);
						k++;
						max = Math.max(max, k*min);
					}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 41588
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

ll solver(int N, int K, vector<int> P, vector<ll> C){
    ll ans = -1 * INF;
    rep(i, N){
        int now = i;
        ll score = 0;
        int cnt = 0;
        rep(j, K){
            now = P[now];
            score += C[now];
            ans = max(ans, score);
            cnt++;
            if(now == i){//一周してしまった
                if(score < 0)break;
                ll tmp = score;
                score = (K/cnt) * tmp;
                ans = max(ans, score);
                rep(k, K%cnt){
                    now = P[now];
                    score += C[now];
                    ans = max(ans, score);
                }

                score = (K/cnt - 1) * tmp;
                // cout << "score:" <<score << endl;
                ans = max(ans, score);
                rep(k, cnt){
                    now = P[now];
                    score += C[now];
                    ans = max(ans, score);
                }
                break;
            }
        }
    }
    return ans;
}

ll solver2(int N, int K, vector<int> P, vector<ll> C){
    ll ans = -1*INF;
    rep(i, N){
        int now = i;
        ll score = 0;
        rep(j, K){
            now = P[now];
            score += C[now];
            ans = max(ans, score);
        }
    }
    return ans;
}

int main(){
    int N, K; cin >> N >> K;
    vector<int> P(N);
    vector<ll> C(N);
    rep(i, N){
        int p; cin >> p;
        p--;
        P[i] = p;
    }
    rep(i, N)cin >> C[i];

    cout << solver(N, K, P, C) << endl;

    // random_device seed_gen;
    // mt19937_64 engine(seed_gen());
    // while(1){
    //     int N = engine() % 5 + 2;
    //     int K = engine() % (int)1e2 + 1;
    //     vector<int> P(N);
    //     rep(i, N) P[i] = i;
    //     rep(i, N){
    //         int j = engine()%N;
    //         if(P[i] == P[j]){
    //             i--;
    //             continue;
    //         }
    //         swap(P[i],P[j]);
    //     }
    //     vector<ll> C(N);
    //     rep(i, N){
    //         C[i] = engine() % (ll)1e3;
    //         int j = engine() % 2;
    //         if(j == 0)C[i] *= -1;
    //     }

    //     ll ans1 = solver(N, K, P, C);
    //     ll ans2 = solver2(N, K, P, C);
    //     if(ans1 != ans2){
    //         cout << N << " " << K << endl;
    //         rep(i, N) cout << P[i] << " ";
    //         cout << endl;
    //         rep(i, N) cout << C[i] << " ";
    //         cout << endl << endl;
    //         cout << "solver1:" << ans1 << endl;
    //         cout << "solver2:" << ans2 << endl;

    //         break;
    //     }else{
    //         cout << "OK!" << endl;
    //     }
        
    // }
    
    
    
}


Measured memory_bytes: 3776
#pragma GCC optimize ("O3")

#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;

const int maxn=200010;

int n,tr[maxn][2],bg[maxn],tot=1;ll L;
bool num[100];
char s[maxn];

int lowbit(ll x){
    int r=0;
    for(;!(x&1);r++,x>>=1);
    return r;
}

void ins(int v,int id,int d,int len){
    if(tr[v][s[bg[id]+d-1]-'0']==0)     tr[v][s[bg[id]+d-1]-'0']=++tot;
    if(d!=len) ins(tr[v][s[bg[id]+d-1]-'0'],id,d+1,len);
}

void dfs(int v,int d){
    for(int k=0;k<=1;k++)
        if(tr[v][k]==0) {if(L-d>0) num[lowbit(L-d)]^=1;}
        else dfs(tr[v][k],d+1);
}

int main(){
    scanf("%d%lld",&n,&L);
    int top=0;
    for(int i=1;i<=n;i++){
        bg[i]=top+1;
        scanf("%s",s+bg[i]);
        top+=strlen(s+bg[i]);
        ins(1,i,1,strlen(s+bg[i]));
    }
    dfs(1,0);
    for(int i=0;i<=60;i++) if(num[i]) {puts("Alice");return 0;}
    puts("Bob");
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
    using namespace std;
    int N,A[3][3],b[10];
     
    bool appear[3][3];
     
    int main() 
    {
      for(int i= 0;i< 3;i++) {
        for(int j= 0;j< 3;j++)
          cin>>A[i][j];}
      cin>>N;
      for(int i= 0;i<N;i++)
        cin>>b[i];
      for(int i= 0;i<N;i++) {
        for(int j= 0;j<N;j++) {
          appear[i][j] =false;
          for(int k= 0;k<N;k++) {
            if(A[i][j] ==b[k])appear[i][j] =true;
          }
        }
      }
      string ANS="No";
      for(int i= 0;i< 3;i++) {
        if(appear[i][0]and appear[i][1]and appear[i][2])
          ANS="Yes";
      }
      for(int i= 0;i< 3;i++) {
        if(appear[0][i]and appear[1][i]and appear[2][i])
          ANS="Yes";
      }
      if(appear[0][0]and appear[1][1]and appear[2][2])
        ANS="Yes";
      if(appear[0][2]and appear[1][1]and appear[2][0])
        ANS="Yes";
      cout<<ANS<<endl;
      return 0;
    }

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

ll dp[305][305];

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

    int n, k;
    cin >> n >> k;
    vector<int> h(n + 1);
    h[0] = 0;
    for(int i = 1; i <= n; ++i) cin >> h[i];
    constexpr ll inf = 1e+15;
    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= n; ++j){
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j < n; ++j){
            for(int x = 0; x < i; ++x){
                if(dp[x][j] == inf) continue;
                chmin(dp[i][j + 1], dp[x][j] + max(0, h[i] - h[x]));
            }
        }
    }
    ll ans = inf;
    for(int i = 0; i <= n; ++i){
        for(int j = n - k; j <= n; ++j){
            chmin(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
int cnt[10][10];
int main() {
  int n;
  cin >> n;
  long long res = 0;
  for(int i = 1; i <= n; ++i) {
    int x = floor(log10(i) + 1); 
    int f = i / pow(10, x-1);
    int l = i % 10;
    ++cnt[f][l];
  }
  for(int i = 1; i <= n; ++i) {
    int x = floor(log10(i) + 1); 
    int f = i / pow(10, x-1);
    int l = i % 10;
    res += cnt[l][f];
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

class Problem0009
{
    static void Main(string[] args)
    {
        int[] primes = Enumerable.Range(1, 999999).Where(IsPrime).ToArray();
        
        foreach (int n in GetInputLines().Select(int.Parse))
        {
            Console.WriteLine(primes.TakeWhile(p => p <= n).Count());
        }
    }

    static bool IsPrime(int n)
    {
        if (n < 2)
        {
            return false;
        }
        else
        {
            return Enumerable.Range(2, (int)Math.Sqrt(n) - 1).All(i => n % i != 0);
        }
    }

    static IEnumerable<string> GetInputLines()
    {
        string line;
        while (!string.IsNullOrEmpty(line = System.Console.ReadLine()))
        {
            yield return line;
        }
    }
}

Measured memory_bytes: 11140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
  if (N >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    cin>>N;
    vector<int> d(N);
    rep(i,N) cin>>d[i];
    ll ans=0;
    rep(i,N){
        rep(j,N){
            if(i==j) continue;
            ans+=d[i]*d[j];
        }
    }
    cout<<ans/2<<endl;
}

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

#define ll long long int

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n];
    if(n == 1){
        cout<<a[0];
        return 0;
    }
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-2] + abs(a[i-2]-a[i]), dp[i-1] + abs(a[i-1]-a[i]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] l = new int[n];

        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }

        Arrays.sort(l);

        int ans = 0;
        for (int i = n-1; i > 1; i--) {
            int x = i-2;
            int y = 0;
            for (int j = i-1; j > 0; j--) {
                int max = l[i] + l[j];
                int min = l[i] - l[j];

                if (x == j)
                    x--;
                for (int k = x; k >= 0; k--) {
                    if (l[k] < max) {
                        x = k;
                        break;
                    }
                }
                if (l[x] >= max)
                    break;

                if (y == x || y == j)
                    y = Math.max(y-1, 0);
                for (int k = y; k <= x; k++) {
                    if (l[k] > min) {
                        y = k;
                        break;
                    }
                }
                if (l[y] <= min)
                    break;

                ans += x - y + 1;
            }
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 25044
#include<stdio.h>
char f[6][6],s[6],i,j,a,y,x,p,b;
int main()
{
	for(;i<9;++i,b=!b){
		scanf("%s",s);
		for(j=4+b;j--;)
			a=s[j]-48,f[i/2][j]|=a<<1+b,f[i/2+b][j+!b]|=a<<3-b*3;
	}
	do{
		while(!((f[y][x]>>(p=(p+1)%4))&1));
		putchar("URDL"[p]);
		x+=p?2-p:0;
		y+=p==3?0:p-1;
		p=(p+2)%4;
	}while(y|x|**f==6&p==3);
	return!puts(""); 
}

Measured memory_bytes: 0
#include <stdio.h>

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

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = a + b;
  ll ans = n / c * a;
  n %= c;
  ans += min(a, n);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

int main(){
    std::string S;
    std::cin >> S;
    int m = 10000;
    for(int i=0;i<S.length()-2;i++){
        int a = S[i]-48;
        int b = S[i+1]-48;
        int c = S[i+2]-48;
        std::cerr << a << " " << b << " " << c << " ";
        if(m>abs(753-(int)(a*100+b*10+c))){
            m = abs(753-(int)(a*100+b*10+c)) ;
            std::cerr << (int)(a*100+b*10+c)<< " " << abs(753-(int)(a*100+b*10+c)) << " " << m <<std::endl;
        }
    }
    std::cout << m << std::endl;
	return 0;
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    int K = A;
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
        K = max(K, x[i]);
    }
    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(K * N + 1, 0)));
    dp[0][0][0] = 1;
    for (int j = 0; j < N + 1; ++j) {
        for (int k = 0; k < N + 1; ++k) {
            for (int s = 0; s < K * N + 1; ++s) {
                if (x[j - 1] > s && j >= 1) {
                    dp[j][k][s] = dp[j - 1][k][s];
                }
                if (x[j - 1] <= s && j >= 1 && k >= 1) {
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
                }
            }   
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += dp[N][i][i * A];
    }
    cout << ans << endl;
}


Measured memory_bytes: 52224
fun main(args: Array<String>) {
    val (n, k) = readIntList()

    var ans = 0.0
    for (i in 1..n) {
        var tmp = n.toLong()
        var score = i.toDouble()
        while (score < k.toDouble()) {
            tmp *= 2L
            score *= 2.0
        }
        ans += 1.0 / tmp
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 36316
def main(str)
  lines = str.split("\n").map { |x| x.split(" ").map(&:to_i) }
  n = lines[0][0]
  ps = lines[1]
  qs = lines[2]
  perm = []
  sub(perm, n, [], n.times.map { |i| i + 1 })
  ((perm.find_index { |x| x == qs } - perm.find_index { |x| x == ps })).abs
end

def sub(ret, n, cur, src)
  if cur.count == n
    ret << cur
    return
  end
  src.each do |i|
    dst = src.clone
    dst.delete(i)
    sub(ret, n, cur + [i], dst)
  end
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(3, main("3
1 3 2
3 1 2"))
    assert_equal(17517, main("8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1"))
    assert_equal(0, main("3
1 2 3
1 2 3"))
  end
end




Measured memory_bytes: 20712
def main():
    s = input()
    x, y = map(int, input().split())
    if solve(s, x, y):
        print('Yes')
    else:
        print('No')

def solve(s, x, y):
    moves = split_moves(s)
    if not match(x - moves[0][0], moves[0][1:]):
        return False
    if not match(y, moves[1]):
        return False

    return True

def match(x, moves):
    s = sum(moves)
    if x > s:
        return False

    if (s - x) % 2 != 0:
        return False

    return knapsack((s - x) // 2, moves)

def knapsack(x, moves):
    if x == 0:
        return True

    prev = set([0])
    for m in moves:
        curr = set(i + m for i in prev if i + m <= x)
        if x in curr:
            return True
        curr |= prev
        prev = curr
    return False

def split_moves(s):
    moves = [[0], []]
    i = 0

    for c in s:
        if c == 'F':
            moves[i][-1] += 1
        else:
            i = 1 - i
            moves[i].append(0)

    return moves

main()


Measured memory_bytes: 4032
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
	//cin>>t;
	while(t--)
	{
	string a,b;
	cin>>a>>b;
	if(-a.length()+b.length()!=1)
        cout<<"No";
    else{
        for(int i=0;i<a.length();i++)
        if(a[i]!=b[i]){
            cout<<"No";
            return 0;
        }
        cout<<"Yes";
    }
	}
return 0;
}


Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys
from functools import reduce
from operator import add

def solve(a: int, b: int):
    if a <= b:
        a_str = str(a)
        for _ in range(b - 1):
            a_str += str(a)
        print(a_str)
    else:
        b_str = str(b)
        for _ in range(a - 1):
            b_str += str(b)
        print(b_str)

    return

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec),xx)-vec.begin();
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
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;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
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 modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i*i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int n,a,ans=0;
	cin >> n;
	map<int, int>ma;
	rep(i, n) {
		cin >> a;
		if (!ma.count(a)) {
			ma[a] = 1;
		}
		else {
			ma[a]++;
		}
	}
	for (auto p : ma) {
		auto k = p.first;
		auto v = p.second;
		if (k > v)ans += v;
		else ans += v - k;
	}
	cout << ans << endl;
}


Measured memory_bytes: 9568