akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;


ll a[maxn];
ll pref[maxn];
ll dp[maxn];

int main()
{
  int n;
  ios::sync_with_stdio(false);
  cin >> n;

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

  pref[1] = a[1]; 

  for(int i = 3 ; i <= n ; i += 2)
  {
    pref[i] += pref[i - 2] + a[i];
  }

  for(int i = 2 ; i <= n; i++)
  {
    if(i & 1)
    {
      dp[i] = max(dp[i-1], dp[i-2] + a[i]);
    }
    else
    {
      dp[i] = max(dp[i - 2] + a[i], pref[i-1]);
    }
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#define N 32768
long a[N],b[N],n,k,i=N;int main(){for(std::cin>>n>>k;--i;b[i]=i<n?i:n)a[i]=n/i;while(--k){for(std::swap(a,b);++i<N;)b[i]+=b[i-1];for(*b=b[n/--i];*a=--i;a[i]=*b%=0x3B9ACA07)*b+=a[i]*(n/i-n/(i+1));}std::cout<<*b;}

Measured memory_bytes: 768
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[202020], b[202020];
LL ans;

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	REP(j, n)cin >> b[j];
	for (int v = 28; v >= 0; v--) {
		REP(i, n)a[i] %= (1 << (v + 1));
		REP(i, n)b[i] %= (1 << (v + 1));
		sort(a, a + n), sort(b, b + n);
		LL cnt = 0;
		REP(i, n) {
			if (1 << v&a[i]) {
				cnt += n;
				cnt += lower_bound(b, b + n, (1 << (v + 1)) - a[i]) - b;
				cnt -= lower_bound(b, b + n, (1 << (v + 1)) + (1 << v) - a[i]) - b;
			}
			else {
				cnt += lower_bound(b, b + n, (1 << (v + 1)) - a[i]) - b;
				cnt -= lower_bound(b, b + n, (1 << v) - a[i]) - b;
			}
		}
		if (cnt & 1)ans += 1 << v;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
# we input the number of animals(A)
# we then input the number of legs(B)
# we set the number of crane = 2 and turtle = 4
# we then compute (crane * i + turtle * j) to see if it's = B
A, B = map(int, input().split())

crane = 2
turtle = 4
ans = 'No'

for i in range(A + 1):
    j = A - i
    if crane * i + turtle * j == B:
        ans = 'Yes'
print(ans)

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

int main() {
	int n,amin=1000000001,amax=1;cin>>n;
  	vector<int> a(n);for(int i=0;i<n;i++) cin>>a[i];
  	for(int i=0;i<n;i++){
    	amin=min(amin,a[i]);
      	amax=max(amax,a[i]);
    }
  	cout<<amax-amin<<endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 1; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool f = true;
  int cnt_C = 0;
  if(s[0] != 'A') f = false;
  REP(i,s.size()) {
    if(s[i] == 'C' && i > 1 && i < s.size() - 1) cnt_C++;
    else if(isupper(s[i])) f = false;
  }
  if(cnt_C != 1) f = false;
  cout << (f ? "AC" : "WA") << endl;;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 {
		fmt.Println("Possible")
		return
	}
	fmt.Println("Impossible")
}


Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n - 1) cin >> c[i];
  ll ans = 0;
  rep(i, n) { ans += b[a[i] - 1]; }
  rep(i, n - 1) {
    if (a[i] + 1 == a[i + 1]) {
      ans += c[a[i] - 1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Function2 func = new Function2();
        int num1, num2;

        while(true) {
            num1 = Integer.parseInt(scan.next());
            num2 = Integer.parseInt(scan.next());

            if (num1 == 0 && num2 == 0) {
                break;
            }

            func.printRct(num1, num2);
        }
    }
}

class Function2 {
    public void printRct(int num1, int num2) {
        for (int i = 0; i < num1; i++) {
            for (int j = 0; j < num2; j++) {
                if (i != 0 && i != num1 - 1 && j != 0 && j != num2 - 1) {
                    System.out.print(".");
                } else {
                    System.out.print("#");
                }
            }
            System.out.print("\n");
        }
        System.out.print("\n");
    }
}


Measured memory_bytes: 36972
#include <iostream>
using namespace std;
int main(){
  int n,ans4=0,ans2=0;
  cin>>n;
  int k[112345];
  for(int i=0;i<n;i++){
    cin>>k[i];
    if(k[i]%4==0){
      ans4+=1;
    }
    else if(k[i]%4!=0&&k[i]%2==0){
      ans2+=1;
    }
  }
  if(n%2==0){
  if(ans2+ans4>=n/2&&ans2%2==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  }
  else{
    if(ans4+ans2>=n/2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 640
S = list(input())

#print(S)
len = len(S)
loop = len//2
count = 0
#print(loop)

#print(S[0])
#print(S[-1])

for i in range(1,loop+1):
    #print(S[i-1])
    #print(S[-i])

    if S[i-1]!=S[-i]:
        count = count + 1
        #S[-i] = S[i-1]

print(count)

Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define L 20
#define Gard NULL

struct Tree{
  int nodekey;
  struct Tree *parent;
  struct Tree *leftch;
  struct Tree *rightch;
};

typedef struct Tree  *Search;
Search road;

void Insert(int );
void Pre(Search );
void In(Search );


int main(){
  int loop,numnode;
  char order[L];
  int i;
    
  scanf("%d",&loop);
  
  for(i=0;i<loop;i++){
    scanf("%s",order);
    
    if(order[0]=='i'){
      scanf("%d",&numnode);
      Insert(numnode);
    }
    
    else if(order[0]=='p'){
      In(road);
      printf("\n");
      Pre(road);
      printf("\n");
    }
  }
  
  return 0;
}

void Insert(int numnode){
  Search x,y,z;
  
  x=road;
  y=Gard;
  z=malloc(sizeof(struct Tree));
  z->nodekey=numnode;
  z->leftch=Gard;
  z->rightch=Gard;
  
  while(x!=Gard){
    y=x;
    
    if(z->nodekey<x->nodekey){
      x=x->leftch;
    }
    
    else{
      x=x->rightch;
    }
  }
  
  z->parent=y;
  
  if(y==Gard){
    road=z;
  }
  
  else if(z->nodekey<y->nodekey){
    y->leftch=z;
  }
  
  else{
    y->rightch=z;
  }
    
}

void Pre(Search road){

  if(road==Gard){
    return;
  }
  
  printf(" %d",road->nodekey);
 
  Pre(road->leftch);
  Pre(road->rightch);
  
}

void In(Search road){

  if(road==Gard){
    return;
  }
  
  In(road->leftch);
  
  printf(" %d",road->nodekey);
  
  In(road->rightch);
}



Measured memory_bytes: 25168
n =int(input())


for i in range(3,n+1):
  x=i
  if x%3==0:
    print("",i,end="")
  elif x%10==3:
    print("",i,end="")
  else:
    while x:
      if x % 10 == 3:
        print("",i,end="")
        break
      else:
        x = x // 10
print()


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

const double PI=acos(-1.0);
const int N=100001;
const int MOD=1e9+7;

int a[N];

int MinimumNumIncreasingSubsequences(int n)
{
    multiset<int> last;

    for (int i = 0; i < n; i++) {

        multiset<int>::iterator it = last.lower_bound(a[i]);

        if (it == last.begin())
            last.insert(a[i]);

        else {
            it--;
            last.erase(it);
            last.insert(a[i]);
        }
    }
    return last.size();
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    for(int i = 0; i < n; i++)
        cin>>a[i];
    cout<<MinimumNumIncreasingSubsequences(n);


}





Measured memory_bytes: 5376
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int s[m],c[m];
    rep(i,0,m-1){
        cin>>s[i]>>c[i];
    }

    int ans = -1;
    rep(i,0,1000){
        string hoge = to_string(i);
        if(hoge.length()!=n) continue;
        bool flag = true;
        rep(j,0,m-1){
            if(hoge[s[j]-1]-'0'!=c[j]) flag = false;
        }
        if(flag){
            ans = i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

def cal(x, a):
    for aa in a:
        if aa > x:
            return aa
    return False

li = [[] for _ in range(10)]
for i, n in enumerate(S):
    num = int(n)
    li[num].append(i)
    
cnt = 0
flag = True
for i in range(10):
    if len(li[i]) > 0:
        for j in range(10):
            if len(li[j]) > 0:
                ret = cal(li[i][0], li[j])
                if  ret == False:
                    flag = False
                else: 
                    flag = True
                for k in range(10):
                    if len(li[k]) > 0 and flag == True:
                        ret2=cal(ret, li[k]) 
                        if  ret2 != False:
                            cnt += 1
print(cnt)

Measured memory_bytes: 42224
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
G = [0] * (N + 1)
for L, R in X:
    G[L - 1] += 1
    G[R] -= 1
for i in range(N):
    G[i + 1] += G[i]
print(sum([1 if g == M else 0 for g in G]))


Measured memory_bytes: 32220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	int n; cin>>n;
	int fib[n+1]; fib[0]=fib[1]=1;
	for(int i=2;i<n+1;i++){
		fib[i]=fib[i-1]+fib[i-2];
	}
	cout<<fib[n]<<endl;
	return 0;
}



Measured memory_bytes: 3084
import numpy as np
from collections import defaultdict
from functools import reduce

s = input()
# n = int(input())
# A = list(map(int, input().split()))
# a, b = map(int, input().split())

# print((n-2)*180)

if 15 - len(s) + s.count('o') >= 8:
  print('YES')
else:
  print('NO')


Measured memory_bytes: 20852
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int x;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x;
  cout << (8 - ((x - 400) / 200)) << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;
    std::vector<int> p(n);
    rep(i,n) cin >> p[i];

    int cnt = 0;

    for(int i =1; i<n-1; ++i){
        if(p[i]!= max(p[i-1], max(p[i],p[i+1])) && p[i]!= min(p[i-1], min(p[i],p[i+1]))) cnt++;
    }
    
    cout << cnt << endl;

    return 0;
}

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

int  main(){
  int N;
  cin>>N;
  if(N<1200) cout<<"ABC"<<endl;
  if(1200<=N && N<2800) cout<<"ARC"<<endl;
  if(2800<=N) cout<<"AGC"<<endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

bool mon(char c1, char c2) {
  if (c1 == '0' && c2 > '0') return true;
  if (c1 == '1' && c2 <= '2') return true;
  return false;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool ok1;
  bool ok2;

  ok1 = mon(s[0], s[1]);
  ok2 = mon(s[2], s[3]);

  if (ok1 && ok2) {
    cout << "AMBIGUOUS" << endl;
  } else if (ok1) {
    cout << "MMYY" << endl;
  } else if (ok2) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
count_ac=0
count_wa=0
count_tle=0
count_re=0
n=int(input())
for i in range(n):
    s=input()
    if s == "AC":
        count_ac += 1
    elif s == "WA":
        count_wa += 1
    elif s == "TLE":
        count_tle += 1
    else:
        count_re += 1
print("AC x "+str(count_ac))
print("WA x "+str(count_wa))
print("TLE x "+str(count_tle))
print("RE x "+str(count_re))

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

using ll = long long;
#define rep(i,n) for(int i = 0;i < (n);++i)

int main() {
  ll N, K;
  std::cin >> N >> K;
  ll answer {1};
  while (N / K != 0) {
    N /= K;
    ++answer;
  }
  std::cout << answer << '\n';
}


Measured memory_bytes: 888
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

void solve()
{
	ll n;
 	cin>>n;
 	vector<ll> v;
 	ll i;
 	for(i=0;i<n-1;i++)
 	{
 		ll x;
 		cin>>x;
 		v.pb(x);
 	}
 	ll sum;
 	sum+=v[0];
 	for(i=1;i<v.size();i++)
 	{
 		sum+=min(v[i],v[i-1]);
 	}
 	sum+=v[v.size()-1];
 	cout<<sum<<'\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import sys

n, y = map(int, input().split())

for a in range(0,n+1):
    for b in range(0,n-a+1):
        c = n - a - b
        if a*10000 + b*5000 + c*1000 == y:
            if c >= 0:
                print("{} {} {}".format(a, b, c))
                sys.exit()

print('-1 -1 -1')


Measured memory_bytes: 9176
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include<vector>
#include<cstring>
#include<set>
#include <cstdio>
#include<queue>
#include<map>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define endl '\n'
#define forup(i,a,n) for( int i =a; i < n; i++)
#define llforup(i,a,n) for( ll i =a; i < n; i++)
#define fordown(i,a,n) for( int i =a; i >= n; i--)
#define fornot(i,a,n) for( int i=a;!n;i++)
#define mod  (ll)(1e9+7)
#define ifempty(a)  if(!a)
using namespace std;
typedef long long ll;
inline int readnum() 
{
 int p, data = 0;char ch = 0;
 while ((ch != ' - ') && ch<'0' || ch>'9') ch = getchar();//相当于正则表达式的搜索，跳过不需要的字符
 if (ch == '- ')p = -1, ch = getchar();
 else p = 1;
 while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();//搜索需要的字符
 return data * p;
}
//E-mail 374656045@qq.com

int T[50001];//开全局自动初始化为0,T[0][j]用来存储硬币的种类
int C[21];
class solve {
private:int n, m;
public:
	solve() 
	{
		cin >> n >> m;
		forup(i, 1, m + 1)cin >> C[i];
		forup(i, 0, n + 1)T[i] = i;
		//注意必须包括面值为1的硬币，如果没有这个条件，我们可以先二分搜索找出最小值，再用最小值初始化第一行，避免使用INFTY
		forup(i, 2, m + 1)
			for (int j = 0; j + C[i] < n + 1; j++)//从0开始,滚动数组中化减为加可以避免越界
				if (T[j + C[i]] > T[j] + 1)//利用if可以减少dp继承中的写入操作，dp继承指T[i][j]=T[i-1][j];
					T[j + C[i]] = T[j] + 1;
		cout << T[n] << endl;

	}
	   
};
int main(void)
{
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	solve solution;
#ifdef DEBUG
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
#endif
	return 0;
	
}



Measured memory_bytes: 3400
import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def main():
    h,n=map(int,input().split())
    lis=np.array([list(map(int,input().split())) for _ in range(n)])
    dp=np.zeros(10**4+1,int)
    dp[0]=0
    for i in range(1,h+1):
        dp[i]=np.min(dp[i-np.minimum(lis[:,0],i)]+lis[:,1])
    print(dp[h])

if __name__=='__main__':
    main()

Measured memory_bytes: 12564
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1

    def __call__(self, n):
        return self.fact(n)

    def fact(self, n):
        ''' n! % mod '''
        if n >= self.mod:
            return 0
        self._make(n)
        return self._factorial[n]

    def fact_inv(self, n):
        ''' n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self._make_inv(n)
        return self._factorial_inv[n]

    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self.fact_inv(n-r)*self.fact_inv(r) % self.mod
        return self(n)*t % self.mod

    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self.fact_inv(n-1)*self.fact_inv(r) % self.mod
        return self(n+r-1)*t % self.mod

    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod

    @staticmethod
    def xgcd(a, b):
        '''
        Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)
        '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0

    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod

    def _make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1

    def _make_inv(self, n):
        if n >= self.mod:
            n = self.mod
        self._make(n)
        if self._size_inv < n+1:
            for i in range(self._size_inv, n+1):
                self._factorial_inv.append(self.modinv(self._factorial[i]))
            self._size_inv = n+1

x, y = sorted(map(int, input().split()))
q, r = divmod(x+y, 3)
if r != 0:
    print(0)
else:
    fact = Factorial()
    fact._make(q)
    fact._make(y-q)
    print(fact.comb(q, y-q))


Measured memory_bytes: 48484
_,s=io.read("*l","*l")
Max=0
for i=1,#s-1 do
	a,cnt={},0
	for j=1,i do
		a[s:sub(j,j)]=1
	end
	for j=i+1,#s do
		if a[s:sub(j,j)]then
			cnt=cnt+1 a[s:sub(j,j)]=nil
		end
	end
	Max=math.max(Max,cnt)
end
print(Max)

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	string S,T;
	cin>>S>>T;
	for(int i=0;i<N;i++){
		if(S.substr(i)==T.substr(0,N-i)){
			cout<<N+i<<endl;
			return 0;
		}
	}
	cout<<2*N<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    vl num(n+1,0);
    vl a(n);
    rep(i,n) cin >> a[i], num[a[i]]++;
    vl num2 = num;
    sort(rall(num));
    sort(all(num2));
    vl sum(n+1,0);
    rep(i,n) sum[i+1] += sum[i] + num[i];
    REP(i,1,n+1){
        ll ok = 0, ng = n/i+1;
        while(ng-ok>1){
            ll mid = (ng+ok)/2;
            auto itr = upper_bound(all(num2),mid);
            ll d = num2.end() - itr;
            ll rest = sum[d] - d*mid;
            //print3(i,d,rest);
            if((n-rest) >= i*mid) ok = mid;
            else ng = mid;
        }
        cout << ok << endl;
    }
}

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

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

#define sim template <class c
#define ris return *this
#define dor > debug& operator<<
#define eni(x)                                                                 \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(   \
              c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mem(a, s) memset(a, s, sizeof(a))
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; --i)

typedef vector<int> vi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};

const int mod = 1e6 + 7;

void solve();
void pre();

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int t = 1;
    // cin >> t;
    rep(i, 1, t) {
        // cout << "Case # " << i << ": ";
        solve();
    }
    return 0;
}

void pre() {}

void solve() {
    int n;
    cin >> n;
    vi v(n), pre(n);
    rep(i, 0, n - 1) {
        cin >> v[i];
        if (i == 0)
            pre[i] = v[i];
        else
            pre[i] = max(pre[i - 1], v[i]);
    }
    int ans = 0;
    rep(i, 0, n - 1) {
        if (v[i] >= pre[i])
            ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3620
n,m=map(int,input().split())
a=[list(input()) for _ in range(n)]
b=[list(input()) for _ in range(m)]
r=n-m+1
print('Yes' if any([all([a[x//r+y//m][x%r+y%m]==b[y//m][y%m] for y in range(m**2)]) for x in range(r**2)]) else 'No')

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

#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 2e5 + 5, LN = 17, MOD = 998244353, INF = 0x3f3f3f3f, BSZ = 320;
int N, M, K;
ll fact[MN], inv[MN];

ll fp(ll x, ll y, ll m = MOD) {
    ll ret = 1;
    for (x %= MOD; y > 0; y >>= 1, x = (x * x) % m)
        if (y & 1) ret = (ret * x) % m;
    return ret;
}

ll c(ll n, ll k) {
    return fact[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> M >> K;
    /*
     * Since there are N-1 different pairs, and K have to be the same, then N-1-K pairs have to be different.
     * This will create N-K blocks, since we can correspond each color break to the left block, then add one for the
     * one to right of the last break. We can then color this in M*(M-1)^(N-K-1) ways.
     */
    fact[0] = 1;
    for (int i = 1; i <= N; i++) fact[i] = (fact[i - 1] * i) % MOD;
    inv[N] = fp(fact[N], MOD - 2);
    for (int i = N - 1; i >= 0; i--) inv[i] = (inv[i + 1] * (i + 1)) % MOD;

    ll ret = 0;
    for (int i = 0; i <= K; i++) {
        ll add = c(N - 1, i) * M % MOD * fp(M - 1, N - i - 1) % MOD;
        ret = (ret + add) % MOD;
    }
    cout << ret << '\n';
    return 0;
}


Measured memory_bytes: 6792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
using ll = long long;


int main(){
    int H,W; cin >> H >> W;
    int sx,sy;
    int gx,gy;
    cin >> sy >> sx;
    cin >> gy >> gx;
    sy--; sx--; gy--; gx--;
    string S;
    int iii=10101010;
    vector<vector<int> > c(H,vector<int>(W,iii));
    bool f=false;
    for(int i=0;i<H;i++){
        cin >> S;
        for(int j=0;j<W;j++){
            if(S[j]=='#') c[i][j]=-1;
        }
    }
    queue<pair<int,int>> q;
    q.push(make_pair(sy,sx));
    c[sy][sx]=0;
    while(!q.empty()){
        pair<int,int> now = q.front(); q.pop();
        int y=now.first;
        int x=now.second;
        int n=c[y][x];
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int dy = y+i;
                int dx = x+j;
                int ttt=0;
                if(dy<0 || dx<0 || dy>=H || dx>=W) continue;
                int nn=n;
                int dd=c[dy][dx];
                if(abs(i)>1 || abs(j)>1){
                    nn++;
                }else if(abs(i)==1 && abs(j)==1){
                    nn++;
                }
                if(dd==-1){
                    continue;
                }else if(dd>nn){
                    c[dy][dx] = nn;
                    q.push(make_pair(dy,dx));
                }else{
                    continue;
                }   
            }
        }
        
    }
    if(c[gy][gx]!=iii){
        cout << c[gy][gx] << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


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

long long f(long long b, long long n) {
	if (n < b)return n;
	else return f(b, n / b) + n % b;
}

int main() {
	long long n, s; cin >> n >> s;

	if (n!=s && (n+1)/2 < s)cout << -1 << endl;
	else {
		long long ans = n + 1;
		long long x = 2;
		for(int i=1;i<=sqrt(n);i++){
			long long y = n / i; if (y == 1)continue;
			long long z = f(y, n);
			if (z > s)continue;
			if ((s - z) % i)continue;

			long long tmp = y - (s - z) / i;
			if (tmp <= n / (i + 1))continue;

			ans = min(ans, tmp);
		}
		for (int i = 2; i<=sqrt(n); i++) {
			long long y = i;
			if (f(y, n) == s)ans = min<long long>(ans, i);
		}

		cout << ans << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 0x3f3f3f3f
using namespace std;
vector <tuple<int,int,int>>relation;
long long n,d,ans,x,y;

int main(){
    scanf("%lld%lld",&n,&d);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d)
            ans++;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	cout << n * n * n;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n;
    int MIN=100000000;
    int MAX=-100000000;
    long long SUM=0;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        int t;
        scanf("%d",&t);
        if(t<MIN) MIN=t;
        if(t>MAX) MAX=t;
        SUM+=t;
    }
    printf("%d %d %ld\n",MIN,MAX,SUM);
    return 0;
}


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

long long N, M;

int main(){
	cin >> N >> M;

	for(long long i = 0; i < M; i++) {
		long long tmp;
		cin >> tmp;
		N-=tmp;
	}
	if(N >= 0) {
		cout << N << endl;
	}else{
		cout << -1  << endl;
	}
}



Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
#include <algorithm>    
using namespace std;

int n,dp[1 << 16];
int stage[17][17];

int rec(int bit){
    if(dp[bit] != 0) return dp[bit];
    if(bit == (1 << n)-1) return 0;
    int res = 1 << 25;
    for(int i=0;i<n;i++){
        if(bit & (1 << i)) continue;
        int mini = stage[i][0];
        for(int j=1;j<n+1;j++){
            if(bit & (1 << j-1)) mini = min(mini,stage[i][j]);
        }
        res = min(res,mini + rec(bit | (1 << i)));
    }
    return dp[bit] = res;
}

int main(){
    while(cin >> n,n){
        for(int i=0;i<n;i++){
            for(int j=0;j<n+1;j++) cin >> stage[i][j];
        }
        memset(dp,0,sizeof(dp));
        cout << rec(0) << endl;
    }
}

Measured memory_bytes: 1424
#include<iostream>
using namespace std;
int main(){
  int k,x;
  cin >> k >> x;
 
  for(int i=1;i<=k;i++){
    cout << (x-(k-i)) << endl;
  }
  
  for(int i=1;i<k;i++){
    cout << (x+i) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 3005
#define LL long long
using namespace std;
int n,m,a[maxn][maxn],ans,s[maxn],pre[maxn],q[maxn],tp;
char c[maxn];
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<max(max(a-b,a+b),a*b);
}


Measured memory_bytes: 256
// 2020/05/18 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool is_prime[60000];

	is_prime[0] = is_prime[1] = false;
	for(int i=2; i<60000; i++){
		is_prime[i] = true;
	}

	for(int i=2; i*i<60000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<60000; j+=i){
				is_prime[j] = false;
			}
		}
	}

	while(true){
		int n;
		cin >> n;

		if(cin.eof())
			break;

		int pre;
		for(pre=n-1; !is_prime[pre]; pre--);

		int pos;
		for(pos=n+1; !is_prime[pos]; pos++);

		cout << pre << ' ' << pos << endl;
	}

	return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n, m;
	cin >> n >> m;
	vector<int> l(m);
	vector<int> r(m);
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
	}
	int al = l[0];
	int ar = r[0];
	for (int i = 1; i < m; i++) {
		if (l[i] > al)
			al = l[i];
		if (r[i] < ar)
			ar = r[i];
	}
	cout << max(ar - al + 1, 0) << endl;
}


Measured memory_bytes: 1024
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v < 10050:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 9100
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    int r, D;
    int x[11];
    cin >> r >> D >> x[0];

    for(int i = 0; i < 10; i++) {
        x[i+1] = r*x[i] - D;
        cout << x[i+1] << "\n";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> h(n + 3);
	rep(i, n) cin >> h[i];

	vector<int> dp(n + 3 , 100000000000);

	//0-index
	dp[0] = 0;
	for (int i = 0; i < n + 1; ++i) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}

	dunk(dp[n - 1]);

	return 0;
}

Measured memory_bytes: 1024
/**
     
       Author : sea_26
     
    **/
     
     
    #pragma GCC optimize("03")
    #include <bits/stdc++.h>
     
    using namespace std;
     
    const int M = 1000000007;
    const double PI = acos(-1.0);
     
    // const double pi = atan2(0, -1);
    // const double PI = 4 * atan(1);
    // const double pi = 2*cos(0.0);
     
    typedef long long ll;
    typedef long double ld;
     
    const int iinf = 0x3f3f3f3f;
    const ll linf = 0x3f3f3f3f3f3f3f3f;
     
    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define ln(x) (int)x.size()
     
    #define bp(n)  __builtin_popcount(n)
    #define bclz(n) __builtin_clzll(n)
    #define bctz(n) __builtin_ctzll(n)
    #define bip(n) __builtin_parity(n)
     
    #define vsort(v) sort(v.begin(),v.end())
    #define rvsort(v) sort(v.begin(),v.end(),greater<int>())
     
    #define rep(n) for(int i=0; i<n; i++)
    #define rrep(n) for(int i=n-1; i>=0; i--)
    #define lrep(p,q) for(int i=p; i<=q; i++)
    #define prep(n) for(int i=1; i*i<=n; i++)
    #define it(a, x)  for(auto &a : x)
    #define yes cout << "YES" << endl
    #define no cout << "NO" << endl
     
    priority_queue<int> pq;
     
    #define fs   ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     
    template< typename T> inline T lcm(T a, T b){ return (a / gcd(a,b)) * b; }
    template< typename T> inline T MAX(T a, T b){ return a ^ ((a ^ b) & -(a < b)); }
    template< typename T> inline T MIN(T a, T b){ return b ^ ((a ^ b) & -(a < b)); }
    template< typename T> void tpns(T n){ rrep(30){ if(n & (1 << i)) pq.push(1 << i); } }
    template< typename T> void SWAP(T &a, T &b){ a = ((a) ^= (b)),  b = ((b) ^= (a)),  a = ((a) ^= (b)); }
    template< typename T> inline T ABS(T a){ int x = a >> sizeof(int) * CHAR_BIT - 1; return (a + x) ^ x; }
    template< typename T> inline T mod(T a, T b){ return a >= b ? a % b : a; }
    template< typename T> inline T gcd(T a, T b){ while (b) b ^= a ^= b ^= a %= b; return a; }
     
    ll gcdextd(ll a, ll b, ll& x, ll& y) {
        if (!a) { x = 0; y = 1; return b; }
        ll y1,d;
        d = gcdextd(b % a, a, y, y1);
        x = y1 - (b / a) * y;
        return d;
    }
     
     
     
    double WT() {
    	return double(clock()) / CLOCKS_PER_SEC;
    }
     
    void ReT(){
     
    	cout << "\nTime = " << fixed << setprecision(3) << WT()  << " Sec"<< endl;
     
    exit(0);
    }
     
     
    int main(){
     
            fs;
            int a,b;
      		cin >> a >> b;
      		if(a > b) return cout << a + (a-1) << endl, 0;
      		else if(b > a) return cout << b + (b-1) << endl, 0;
      		else return cout << a + b << endl, 0;
     
         //   ReT();
     
    }

Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys


def comb(n, r, mod=10 ** 9 + 7):
    r = min(r, n-r)
    upper = 1

    for i in range(n, n-r, -1):
        upper = (upper * i) % mod

    lower = 1

    for i in range(1, r+1):
        lower = (lower * i) % mod

    lower_inv = pow(lower, mod - 2, mod)

    return (upper * lower_inv) % mod


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, a, b = MI()

    ttl = pow(2, n, 10**9+7) - 1

    a_ttl = comb(n, a)
    b_ttl = comb(n, b)

    print((ttl - a_ttl - b_ttl) % (10**9+7))


main()


Measured memory_bytes: 65756
#include <stdio.h>

int main(){
    int s,h,m,sec;
    scanf( "%d" , &s );
    h = s / 3600;
    s = s % 3600; 
    m = s / 60;
    sec = s % 60;
    printf( "%d:%d:%d\n" , h , m , sec );
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, a, b; cin >> n >> a >> b;
    int ans = 0;
    Rep(i, 1, n + 1)
    {
        int sum = 0;
        int l = i;
        while(l > 0)
        {
            sum += l % 10;
            l /= 10;
        }
        if (sum >= a && sum <= b)
        {
            ans += i;
            //COUT(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N,A,B = map(int, input().split())
S = input()

for i in range(N):
  if S[i] == 'c':
    print('No')
  elif S[i] == 'a' and (A+B) > 0:
    print('Yes')
    A -= 1
  elif S[i] == 'b' and (A+B) > 0 and B > 0:
    print('Yes')
    B -= 1
  else:
    print('No')

Measured memory_bytes: 4024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll N,K,ans=0;
  cin>>N>>K;
  vector<ll> L;
  REP(i,N){
    ll a;
    cin>>a;
    L.push_back(a);
  }
  SORT(L);
  for(int i=0; i<N-K; ++i) ans+=L.at(i);
  cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include<stdio.h>
#include<stdlib.h>
#define INF 999999999

int i, j, k;
int n;
int l;
int q;
int A[101], m[101][101];

void  matrixChainorder()
{
    for (i = 1; i <= n; i++)
  m[i][i] = 0;

 for (l = 2; l <= n; l++) 
 {
     for (i = 1; i <= n - l + 1; i++)
      {
          j= i + l - 1;
          m[i][j] = INF;

   for (k = i; k <=j - 1; k++)
    {
        q = m[i][k] + m[k + 1][j] + A[i - 1] * A[k] * A[j];
        if (q < m[i][j])
        m[i][j] = q;
   }
  }
 }

 printf("%d\n", m[1][n]);
}

int main() 
{
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
    scanf("%d%d", &A[i - 1], &A[i]);
    
    
    matrixChainorder();
    return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

const int MAX = 10000000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k){
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////

int main(){
    ll x,y;cin>>x>>y;
    COMinit();
    ll tmp = (x+y)/3, cnt = -1;
    rep(i,0,tmp+1){
        if(i*2+(tmp-i)*1 == x && i*1+(tmp-i)*2 == y){
            cnt = i;
            break;
        }
    }
  	if(cnt == -1){
      cout << 0 << ednl;
      return 0;
    }
  	//cout << cnt << ednl;
    cout << COM((x+y)/3,cnt) % MOD << ednl;
}


Measured memory_bytes: 234752
#include<bits/stdc++.h>
using namespace std;
const int nm=305;
double p[nm][nm][nm],ev[nm][nm][nm];
int main()
{
    int n;
    vector<int>cnt(4);
    int x;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        cnt[x]++;
    }
    p[cnt[1]][cnt[2]][cnt[3]]=1;
    for(int c=n;c>=0;c--)
    {
        for(int b=n;b>=0;b--)
        {
            for(int a=n;a>=0;a--)
            {
                if(a==0 &&b==0&& c==0)
                    continue;
                if(a+b+c>n)
                    continue;
                double p_waste=(double)(n-(a+b+c))/n;
                double ev_waste=p_waste/(1-p_waste) + 1;
                ev[a][b][c]+=ev_waste*p[a][b][c];

                if(a!=0)
                {
                    double p_go=(double)a/(a+b+c);
                    p[a-1][b][c]+=p[a][b][c]*p_go;
                    ev[a-1][b][c]+=ev[a][b][c]*p_go;
                }

                if(b!=0)
                {
                    double p_go=(double)b/(a+b+c);
                    p[a+1][b-1][c]+=p[a][b][c]*p_go;
                    ev[a+1][b-1][c]+=ev[a][b][c]*p_go;
                }

                if(c!=0)
                {
                    double p_go=(double)c/(a+b+c);
                    p[a][b+1][c-1]+=p[a][b][c]*p_go;
                    ev[a][b+1][c-1]+=ev[a][b][c]*p_go;
                }
            }
        }
    }
    printf("%.10lf\n",ev[0][0][0]);
    return 0;
    
}

Measured memory_bytes: 438528