akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

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

  std::vector<int64_t> towns(n + 1);
  std::vector<int64_t> knights(n + 1);
  
  for (int i = 0; i < n + 1; i++) {
    std::cin >> towns[i];
  }
  for (int i = 0; i < n; i++) {
    std::cin >> knights[i];
  }
  knights[n] = 0;

  int64_t sum = 0;
  int64_t prev_knights = 0;
  for (int i = 0; i < knights.size(); i++) {
    int64_t killed = std::min(towns[i], prev_knights + knights[i]);
    prev_knights = knights[i] - std::max((killed - prev_knights), 0l);
    sum += killed;
  }

  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#define M 0
using namespace std;

int n,q;
int c[300100],x;

int main(){
  scanf("%d%d",&n,&q);
  int lim = 0;
  for(int i=0;i<n;i++){ scanf("%d",&c[i]); lim = max(lim,c[i]); }
  sort(c,c+n);
  int m[M+1] = {0};
  for(int i=1;i<=M;i++){
    for(int j=0;j<n;j++)m[i] = max(m[i],c[j]%i);
  }

  for(int i=0;i<q;i++){
    scanf("%d",&x);
    if(x<=M)printf("%d\n",m[x]);
    else{
      int res = 0;
      for(int j=1;(j-1)*x<=lim;j++){
	int tmp = lower_bound(c,c+n,j*x) - c;
	if(tmp)res = max(res,c[tmp-1]%x);
      }
      printf("%d\n",res);
    }
  }
}

Measured memory_bytes: 2212
N = int(input())

for h in range(1, 3501):
	for n in range(h, 3501):
		wb = 4*h*n - N*n - N*h
		if wb <= 0:
			continue
		w = N*h*n / wb
		if w.is_integer():
			print(h, n, int(w))
			exit()

Measured memory_bytes: 3064
function Main(input) {
  input = input.trim().split(" ");
  var data = input.map((n) => parseInt(n, 10));

  data = data.filter((v, i) => {
    return data.indexOf(v) === i;
  });
  console.log(data.length);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int a,b,n; cin>>a>>b>>n;
    if(n<b){
    	cout<<floor(a*n/double(b))-a*floor(n/double(b))<<'\n';
    }
    else{
    	cout<<floor(a*(b-1)/double(b))-a*floor((b-1)/double(b))<<'\n';
    }
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

lli func(int a)
{
    lli ans=1;
    for(int i=0;i<5;i++)
        ans*=a;
    return ans;
}

int main()
{
    fastio;
    lli x;
    cin >> x;
    int f=0;
    for(int i=0;i<=80 and f==0;i++)
    {
        for(int j=i;j<=80;j++)
        {
            lli a=func(i)+func(j);
            if(a==x)
            {
                cout << i << " " << -j << endl;
                f=1;
                break;
            }
        }
    }
    for(int i=0;i<=200 and f==0;i++)
    {
        for(int j=0;j<=i;j++)
        {
            lli a=func(i)-func(j);
            if(a==x)
            {
                cout << i<< " " << j << endl;
                f=1;
                break;
            }
        }
    }
}

Measured memory_bytes: 3668
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <boost/multi_array.hpp>

/*
 後ろから選んでいく
 最後の一つを決めたら、その仕事の報酬に、残りの仕事n-1をday-1で受けることのできる報酬を加えれば良い
 が、これはTLE
 間に合う仕事のうち、報酬が出るまでが最も長く、かつ報酬の高いものから取り出していけば効率的。
 */

int main() {
    long long ans = 0;
    int N, M;
    std::cin >> N >> M;
    std::vector<int> arr[M+1];
    //入力
    for (int i = 0; i < N; i++) {
        int a, b;
        std::cin >> a >> b;
        //入力の段階で日数で整理したほうが良い、日数に対応するベクトルに保存する
        //上位互換がいればそちらを取る
        if (a > M) { continue; }//間に合わないものは無視
        arr[a].push_back(b);//a日のベクトルの末尾に追加
    }
    std::priority_queue<int> que;
    
    //報酬が出るまでの日数が小さいものから、priority_queに入れて報酬最大を取り出していく
    for (int day = 1; day <= M; day++) {
        //
        while (!arr[day].empty()) {
            que.push(arr[day].back()); //末尾を加え
            arr[day].pop_back(); //消去
        }
        if (!que.empty()) { //報酬が出るまでその日数の仕事があればそのうち最大を選ぶ
            ans += que.top();
            que.pop();
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	rep(i, n)
	{
		cin >> a[i];
	}
	rep(i, n)
	{
		cin >> b[i];
	}
	rep(i, n - 1)
	{
		cin >> c[i];
	}

	ll ans = b[a[0] - 1];
	for(int i=1;i<n;i++)
	{
		ans += b[a[i] - 1];
		if (a[i] - 1 == a[i - 1])
			ans += c[a[i] - 2];
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var takoyakis []int
	var takoyaki int
	for i := 0; i < n; i++ {
		fmt.Scan(&takoyaki)
		takoyakis = append(takoyakis, takoyaki)
	}
	result := 0
	for index, x := range takoyakis {
		for _, y := range takoyakis[index+1:] {
			result += x * y
		}
	}
	fmt.Println(result)
}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  int B;
  B = N % 500;
  
  if (B <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] ary = new int[3];
        for (int i = 0; i < 3; i++) {
            ary[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(ary);
        System.out.println(ary[0] + ary[1]);
    }
}

Measured memory_bytes: 21716
from math import sqrt

N = int(input())

rn = int(sqrt(N))
sieve = [0] * (rn + 1)
sieve[0] = -1
sieve[1] = -1
t = [0] * (rn + 1)
for i in range(2, rn + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    j = i
    while j < rn + 1:
        t[j] = 1
        j *= i
    for j in range(i * i, rn + 1, i):
        if sieve[j] == 0:
            sieve[j] = i

result = 0
last = -1
for i in range(2, rn + 1):
    if t[i] == 0:
        continue
    if N % i == 0:
        result += 1
        N //= i
        last = i
if N != 1 and N > rn:
    result += 1
print(result)

Measured memory_bytes: 84168
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int K,X;
		K = scanner.nextInt();
		X= scanner.nextInt();
		int xplus=X+K;
		int xminus=X-K;
		for(int i=xminus+1;i<xplus;i++) {
			System.out.print(i);
			if(i != xplus-1) {
			System.out.print(" ");
			}
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int a = 0, b = 1;

void fib(int n) {
	int ans = 1;
	for (int i = 0; i < n && n >= 2; ++i) {
		ans = a + b;
		a = b;
		b = ans;
	}
	cout << ans << endl;
}

int main() {
	int n; cin >> n;
	fib(n);
	return 0;
}

Measured memory_bytes: 1160
import sys

n,k = list(map(int,input().split()))

Input = []
while True:
    try:
        d = int(input())
        i = list(map(int, input().split()))
        Input += i
        #print(d,i)
    except Exception as e:
        break

#count=0
# for i in n:
#     if i not in Input:
#         count+=1

N=[]
for i in range(n):
    N.append(i+1)
    #print(N)

print(len(list(set(N)-set(Input))))

Measured memory_bytes: 67508
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int r;
	cin >> r;
	
	if( r < 1200 ) cout << "ABC" << endl;
	else if( r < 2800 ) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	
	return 0;
}


Measured memory_bytes: 256
a = int(input()) 
b = int(input()) 
c = int(input()) 
x = int(input()) 
z = 0 
number = 0 
for i in range(a+1):
     for g in range(b+1):
         for h in range(c+1):
             z = 500*i + 100*g + 50*h
             if x == z:
                 number += 1  
print(number)  


Measured memory_bytes: 2692
// C_ext.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 110;

int n, B[MAX_N], A[MAX_N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n - 1; i++)
		scanf("%d", &B[i]);
	for (int i = 1; i <= n; i++)
		A[i] = 1e9;
	for (int i = 1; i <= n - 1; i++)
		A[i] = min(A[i], B[i]), A[i + 1] = min(A[i + 1], B[i]); 
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		ans += A[i];
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
#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 all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;
 
int main( void ){
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if( abs( a - c ) <= d or abs( a - b ) <= d and abs( b - c ) <= d ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int x[10][10];

string tos(int num){
  string res;
  while(num){
    res+=num%10+'0';
    num/=10;
  }
  reverse(res.begin(),res.end());
  while(res.size()!=4)res='0'+res;
  return res;
}

bool check2(string s){
  int n=0;
  for(int i=0;i<s.size();i++)
    n=x[n][s[i]-'0'];
  return n==0;
}

bool check(int num){
  string s=tos(num);
  int e=0;
  for(int i=0;i<s.size();i++)
    e=x[e][s[i]-'0'];
  s+=e+'0';
  string temp=s;
  bool res=false;
  for(int i=0;i<s.size();i++){
    char t=s[i];
    for(int j=0;j<10;j++){
      s[i]=j+'0';
      if(temp==s)continue;
      if(check2(s))res=true;
    }
    s[i]=t;
  }
  for(int i=0;i<s.size()-1;i++){
    swap(s[i],s[i+1]);
    if(temp==s){
      swap(s[i],s[i+1]);
      continue;
    }
    if(check2(s))res=true;
    swap(s[i],s[i+1]);
  }
  return res;
}

int main(){
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      cin>>x[i][j];
  int ans=0;
  for(int i=0;i<10000;i++)
    if(check(i))ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3184
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;
 

ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}

//高速nCk
#define N 100010
int fac[N+1];
int inv[N+1];
ll COM(ll n,ll k){
	if(n < k)return 0;
    return fac[n]*inv[k]%MOD*inv[n-k]%MOD;
}
    

/*----------------------------------------------------------------*/
signed main(){

	int n,k;
	cin >> n >> k;
	vll a(n);
	rep(i,n)cin >> a[i];
	SORT(a);

	fac[0] = 1;
    inv[0] = 1;
    for(int i = 1;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = bitpow(fac[i],MOD-2)%MOD;
    }
	int ans = 0;
	for(int i = 1;i <= n;i++){
		int x = a[i-1];
		ans += x*(COM(i-1,k-1) - COM(n-i,k-1) + MOD)%MOD;
		ans = (ans+MOD)%MOD;
		cerr << i <<" : " <<  COM(i-1,k-1) << " " << COM(n-i,k-1) << endl;
	}
	cout << ans << endl;


	

	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc151.contest.atcoder.jp/tasks/abc151_b

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

int main()
{
    string a, b;
    cin >> a >> b;
    string ab;
    ab = a + b;
    bool fin = false;
    int c;
    c = stoi(ab);
    rep(i, 320)
    {
        if ((i * i) == c)
        {
            cout << "Yes" << endl;
            fin = true;
            break;
        }
    }
    if (!fin)
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;

using namespace std;
int main(){
   int N;
   char s[100];
   cin>>N;
   REP(i,N) cin>>s[i];
   REP(i,N) if(s[i]=='Y'){
      cout<<"Four"<<endl;
      return 0;
   }
   cout<<"Three"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

#define rep(i,n) for(int i=1;i<(n);i++)

typedef long long ll;
using namespace std;

int main() {

	int r;
	cin >> r;
	
	cout << r*r << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[1003][5003];
int n,m;
int main(){
	cin>>n>>m;
	for (int i=0;i<1003;i++)for(int j=0;j<5003;j++)dp[i][j]=1e9;dp[0][0]=0;
	for (int i=1;i<=m;i++){
		int masks=0;
		int a,b;cin>>a>>b;
		for (int k=0;k<b;k++){
			int x;cin>>x;masks|=(1<<(x-1)); 
		}
		for (int j=0;j<(1<<n);j++){
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			dp[i][j|masks]=min(dp[i][j|masks],dp[i-1][j]+a);
		}
	}
	if (dp[m][(1<<n)-1]==1e9)cout<<"-1";
	else cout<<dp[m][(1<<n)-1];
}

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

using namespace std;

void addPoint(int *point, int *a, int*b) {
  if (*a > *b) {
    *point += *a;
    *a -= 1;
  } else {
    *point += *b;
    *b -= 1;
  }
}

int main() {
  int a, b;
  int point = 0;
  cin >> a >> b;

  addPoint(&point, &a, &b);
  addPoint(&point, &a, &b);

  cout << point << endl;

  return 0;
}

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

using namespace std;

const int N = 100000 + 3;

bool case_insensitive_compare(string s, string t) {
  if(s.size() != t.size()) return false;
  for(int i = 0; i < s.size(); ++i) {
    if(isalpha(s[i]) && isalpha(t[i])) {
      //convert to uppercase
      if(s[i] > 'Z') s[i] += 'A' - 'a';
      if(t[i] > 'Z') t[i] += 'A' - 'a';
      if(s[i] != t[i]) return false;
    } else if(!isalpha(s[i]) && isalpha(t[i])) return false;
    else if(isalpha(s[i]) && !isalpha(t[i])) return false;
    //else continue
  }
  return true;
}

bool editOne(string s, string t) {
  if(s.size() < t.size()) swap(s, t);
  if(s.size() == t.size()) return case_insensitive_compare(s, t);
  if(s.size() - 1 != t.size()) return false;
  for(int i = 0; i < s.size(); ++i) {
    string u = s.substr(0, i) + s.substr(i + 1); //linear memory
    if(case_insensitive_compare(u, t)) return true;
  }
  return false;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  cout << min(n * a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
x=0
y=0
b=0
for i in range(0,n):
  x+=i
  y+=n-i
  b+=y-x+1
s=b+1
l=0
m=0
c=0
for j in range(0,k-1):
  l+=j
  m+=n-j
  c+=m-l+1
print((s-c)%1000000007)

Measured memory_bytes: 9200
from scipy.sparse.csgraph import floyd_warshall, csgraph_from_dense

# 入力
H, W = map(int, input().split())
G = [[int(i) for i in input().split()] for j in range(10)]
G = csgraph_from_dense(G)

dist = floyd_warshall(G)
ans = 0
for h in range(H):
    line = [int(i) for i in input().split()]
    for w in range(W):
        if line[w] == -1:
            continue
        ans += dist[line[w]][1].astype(int)

print(ans)

Measured memory_bytes: 13760
let () = Scanf.scanf "%d %d %d\n%d %d\n%s\n%s\n" @@ fun h w n sr sc s t ->
  let racc_u = Array.make_matrix (n + 1) 2 sr in
  let racc_d = Array.make_matrix (n + 1) 2 sr in
  let cacc_l = Array.make_matrix (n + 1) 2 sc in
  let cacc_r = Array.make_matrix (n + 1) 2 sc in
  for i = 0 to n - 1 do
    racc_u.(i + 1).(0) <- racc_u.(i).(1) - if s.[i] = 'U' then 1 else 0;
    racc_u.(i + 1).(1) <- min h (racc_u.(i + 1).(0) + if t.[i] = 'D' then 1 else 0);

    racc_d.(i + 1).(0) <- racc_d.(i).(1) + if s.[i] = 'D' then 1 else 0;
    racc_d.(i + 1).(1) <- max 1 (racc_d.(i + 1).(0) - if t.[i] = 'U' then 1 else 0);

    cacc_l.(i + 1).(0) <- cacc_l.(i).(1) - if s.[i] = 'L' then 1 else 0;
    cacc_l.(i + 1).(1) <- min w (cacc_l.(i + 1).(0) + if t.[i] = 'R' then 1 else 0);

    cacc_r.(i + 1).(0) <- cacc_r.(i).(1) + if s.[i] = 'R' then 1 else 0;
    cacc_r.(i + 1).(1) <- max 1 (cacc_r.(i + 1).(0) - if t.[i] = 'L' then 1 else 0)
  done;
  print_endline @@
  if
    Array.fold_left (Array.fold_left ( && )) true @@
    Array.init (n + 1) @@ fun i ->
      Array.init 2 @@ fun j ->
        0 < racc_u.(i).(j) && racc_d.(i).(j) <= h &&
        0 < cacc_l.(i).(j) && cacc_r.(i).(j) <= w
  then "YES"
  else "NO"



Measured memory_bytes: 36672
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

a, b, c = inl()
if a + b >= c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3572
# -*- coding: utf-8 -*-
N = input()

if N[0] == N[1] and N[1] == N[2] and N[1] == N[2]:
    print("Yes")
elif N[1] == N[2] and N[1] == N[2] and N[2] == N[3]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

const int MAX = 2000010;
//const int MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int R1,R2,C1,C2;cin>>R1>>C1>>R2>>C2;
  COMinit();
  ll s1=0,s2=0,s3=0,s4=0;
  rep(i,R2+1) {
    s1 = (s1 + COM(i+1+C2,C2)) % MOD;
    s3 = (s3 + COM(i+C1,C1-1)) % MOD;
  }
  rep(i,R1) {
    s2 = (s2 + COM(i+1+C2,C2)) % MOD;
    s4 = (s4 + COM(i+C1,C1-1)) % MOD;
  }
  //  cout<<s1<<" "<<s2<<" "<<s3<<" "<<s4<<endl;
  ll ans = (((s1 - s2 + MOD) % MOD) + ((s4 - s3 + MOD) % MOD)) % MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 50504
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int data1[n+2];
    int data2[n+2];
    int ans = 1000000;
    data1[0] = 0; //East
    data2[0] = 0; //West
    for(int i=1;i<n+1;i++) {
        if(s[i-1] == 'E') {
            data1[i] = data1[i-1] + 1;
            data2[i] = data2[i-1];
        } else {
            data2[i] = data2[i-1] + 1;
            data1[i] = data1[i-1];
        }
    }

    for(int i=1;i<=n;i++) {
        if(ans > data2[i-1] + data1[n] - data1[i]) ans = data2[i-1] + data1[n] - data1[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int d[30];
char s[110];
int main()
{
	
	
	scanf("%s", s);
	int x = strlen(s);
	for (int i = 0; i < x; i++) {
		d[s[i] - 'a']++;
	}
	int fg = 1;
	for (int i = 0; i < 26; i++) {
		if (d[i] & 1) {
			fg = 0;
			break;
		}
	}
	puts(fg ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




void solve(){
	int n; 
	cin >> n ;
	int cnt = 0 ; 
	int nct = 0  ; 
	cnt=(n/500*1000);
	n%=500;
	cnt+=n/5*5;
	cout << cnt << endl;
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    vi primes;
    rp(i,1853){
        for(int a:{1,11}){
            int b=30*i+a;
            if(b==1) continue;
            bool prime=true;
            for(int div=2; div*div<=b; div++){
                if(b%div==0) prime=false;
            }
            if(prime) primes.pb(b);
        }
    }
    int n;
    cin >> n;
    rp(i,n){
        print(primes.at(i));
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'g') ans++;
        else ans--;
    }
    printf("%d\n", ans/2);
    return 0;
}

Measured memory_bytes: 512
#C
n,k,s = map(int,input().split())

ans = [1 for _ in range(n)]

for i in range(k):
    ans[i] = s

for j in range(n-k):
    if s != 1:
        ans[k+j] = s//2 + 1
    else:
        ans[k+j] = s//2 + 2
print(*ans)

Measured memory_bytes: 11288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		String s1 = stdIn.next();
		String s2 = stdIn.next();
		String s3 = stdIn.next();
		
		System.out.print(s1.charAt(0));
		System.out.print(s2.charAt(1));
		System.out.println(s3.charAt(2));

	}

}


Measured memory_bytes: 35488
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    x = I()
    k = I()
    r = LI()
    q = I()
    t = [LI() for _ in range(q)]
    a = [[0,0,0,x,0,0]]
    d = 0
    for i in range(k):
        c = a[-1][:]
        rr = r[i] - d
        d = r[i]
        if i % 2 == 0:
            c[1] -= rr
            c[3] -= rr
            c[4] -= rr
            if c[0] > c[1]:
                c[0] = c[1]
        else:
            c[1] += rr
            c[3] += rr
            c[4] += rr
            if c[2] < c[1]:
                c[2] = c[1]
        if c[3] > x:
            c[3] = x
        if c[3] < 0:
            c[3] = 0
        if c[4] > x:
            c[4] = x
        if c[4] < 0:
            c[4] = 0

        c[5] = r[i]

        a.append(c)
    def bs(i):
        ma = k
        mi = 0
        mm = 0
        while ma > mi and (ma+mi) // 2 != mm:
            mm = (ma+mi) // 2
            if a[mm][5] < i:
                mi = mm
            else:
                ma = mm - 1
        if a[mm][5] > i:
            return mm-1
        if mm == k:
            return k
        if a[mm+1][5] <= i:
            return mm+1
        return mm

    #print(a)
    rr = []
    for c,d in t:
        ti = bs(c)
        ai = a[ti]
        e = x-d
        #print(c,d,e,ti,ai)
        if d + ai[0] <= 0:
            tt = ai[4]
        elif e - ai[2] <= 0:
            tt = ai[3]
        else:
            tt = d + ai[1]
        #print('tt',tt)
        if ti % 2 == 0:
            tt -= c - ai[5]
        else:
            tt += c - ai[5]
        #print('tt2',tt)
        if tt < 0:
            tt = 0
        elif tt > x:
            tt = x
        rr.append(tt)

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 62936
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
ll b1,b2,b3,b4,b5,b6,b7,b8;

int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> z(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    vector<ll> a1(N);
    vector<ll> a2(N);
    vector<ll> a3(N);
    vector<ll> a4(N);
    vector<ll> a5(N);
    vector<ll> a6(N);
    vector<ll> a7(N);
    vector<ll> a8(N);
    for(int i = 0; i < N; i++){
        a1.at(i) = x[i] + y[i] + z[i];
        a2.at(i) = x[i] + y[i] - z[i];
        a3.at(i) = x[i] - y[i] + z[i];
        a4.at(i) = x[i] - y[i] - z[i];
        a5.at(i) = -x[i] + y[i] + z[i];
        a6.at(i) = -x[i] + y[i] - z[i];
        a7.at(i) = -x[i] - y[i] + z[i];
        a8.at(i) = -x[i] - y[i] - z[i];
    }
    sort(a1.begin(), a1.end());
    reverse(a1.begin(), a1.end());
    
    sort(a2.begin(), a2.end());
    reverse(a2.begin(), a2.end());
    
    sort(a3.begin(), a3.end());
    reverse(a3.begin(), a3.end());
    
    sort(a4.begin(), a4.end());
    reverse(a4.begin(), a4.end());
    
    sort(a5.begin(), a5.end());
    reverse(a5.begin(), a5.end());
    
    sort(a6.begin(), a6.end());
    reverse(a6.begin(), a6.end());
    
    sort(a7.begin(), a7.end());
    reverse(a7.begin(), a7.end());
    
    sort(a8.begin(), a8.end());
    reverse(a8.begin(), a8.end());
    
    
    for(int i = 0; i < M; i++){
        b1 += a1[i];
        b2 += a2[i];
        b3 += a3[i];
        b4 += a4[i];
        b5 += a5[i];
        b6 += a6[i];
        b7 += a7[i];
        b8 += a8[i];
    }
    ll a = max(b1, b2);
    a = max(a, b3);
    a = max(a, b4);
    a = max(a, b5);
    a = max(a, b6);
    a = max(a, b7);
    a = max(a, b8);
    cout << a << endl;
    
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    int n, m;
    cin >> n >> m;
    int sx, sy;
    cin >> sx >> sy;
    int dx, dy;
    cin >> dx >> dy;
    var(sx, sy, dx, dy);
    // return;
    vector<vector<char>> a(n, vector<char>(m));
    for (auto &it: a) {
        for (auto &ch: it) {
            cin >> ch;
        }
    }
    deque<array<int, 3>> q;
    // return;

    --sx, --sy;
    --dx, --dy;
    q.push_back({0, sx, sy});
    vector<vector<bool>> vis(n, vector<bool> (m));
    const int inf = 1e9;
    vector<vector<int>> dist(n, vector<int> (m, inf));
    // return;
    var(sx, sy);
    while (!q.empty()) {
        auto it = q.front();
        q.pop_front();
        // var(it[0], it[1], it[2]);
        int r = it[1], c = it[2], cost = it[0];
        var(r, c, ':', cost);

        dist[r][c] = min(dist[r][c], it[0]);
        if (vis[r][c]) continue;
        vis[r][c] = true;
        for (int x = -2; x <= 2; ++x) {
            for (int y = -2; y <= 2; ++y) {
                    int new_r = x + r;
                    int new_c = y + c;
                    if (new_c < 0 or new_c >= m or new_r < 0 or new_r >= n) {
                        continue;
                    }
                    int cost = ((abs(r - new_r) + abs(c - new_c)) > 1);
                    dist[new_r][new_c] = min(dist[new_r][new_c], cost + it[0]);
                    if (vis[new_r][new_c]) continue;

                    if (cost == 0) {
                        if (a[new_r][new_c] == '#')
                            continue;
                        // var(new_r, new_c, it[0]);
                        q.push_front({it[0], new_r, new_c});
                        continue;
                    }
                    assert(cost == 1);
                    if (a[new_r][new_c] == '.')
                        q.push_back({cost + it[0], new_r, new_c});

            }
        }
        // stl(q);
    }
    stl(dist);
    assert(dist[sx][sy] == 0);
    cout << (dist[dx][dy] == inf ? -1 : dist[dx][dy]) << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

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

namespace _0513
{
    class Program
    {
        static LinkedList<int> cards = new LinkedList<int>();
        static void cut(int x)
        {
            for (int i = 0; i < x; i++)
            {
                cards.AddLast(cards.First());
                cards.RemoveFirst();
            }
        }
        static void Rifle()
        {
            var a = new List<int>();
            var b = new List<int>();
            int len = cards.Count();
            for (int i = 0; i < len / 2; i++)
            {
                a.Add(cards.First());
                cards.RemoveFirst();
            }
            for (int i = 0; i < len / 2; i++)
            {
                b.Add(cards.First());
                cards.RemoveFirst();
            }
            for (int i = 0; i < len; i++)
            {
                if (i % 2 == 0) cards.AddLast(a[i / 2]);
                else cards.AddLast(b[i / 2]);
            }
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine()); n *= 2;
            for (int i = 1; i <= n; i++) cards.AddLast(i);
            int m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                int x = int.Parse(Console.ReadLine());
                if (x == 0) Rifle();
                else cut(x);
            }
            foreach (var item in cards)
            {
                Console.WriteLine(item);
            }
        }
    }
}


Measured memory_bytes: 10556
#include<iostream>
#include<vector>
int main(void) {
	unsigned long x, y,z,MAX, d=1;
	std::cin >> x >> y;
	MAX = x;
	if (x < y) { MAX = y;
	y = x;
	x = MAX;
	}else if(x==y){ std::cout << x << std::endl; 
	return 0;
	}
	z = x%y;
		unsigned long Range = y;
	if (y > z) { Range = z; }
	for (int i = Range; i > 0; --i) {
		if (y%i == 0 && z%i == 0) { d = i;
		break;
		}
	}
	std::cout << d << std::endl;
		//system("pause");
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int rate[9] = {};
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        if(a < 3200)
        {
            rate[a / 400]++;
        }
        else
        {
            rate[8]++;
        }
    }
    int min = 0,max = 0;
    for(int i = 0;i < 9;i++)
    {
        if(rate[i])
        {
            min++;
            max++;
        }
    }
    if(!rate[8])
    {
        cout << min << " " << min;
    }
    else if(min > 1)
    {
        cout << min - 1 << " " << max - 1 + rate[8];
    }
    else
    {
        cout << min << " " << max - 1 + rate[8];
    }
    
    return 0;
}

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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

int main(){
    int N,M;
    cin >> N >> M;
    cout << N*(N-1)/2+M*(M-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int k; cin>>k;
	if(k<10) return cout<<k<<endl,0;
	queue<ll> q;
	ll ret = 0;
	reps(i,9) q.push((ll)i);
	rep(i,k){
		ret = q.front(); q.pop();
		ll next = ret*10+ret%10;
		if(ret%10!=0) q.push(next-1);
		q.push(next);
		if(ret%10!=9) q.push(next+1);
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define MOD 1000000007 //998244353


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

    // solution comes here

    ll N, M;
    cin >> N >> M;
    vl dp(N+1, 0);
    vector<bool> ok(N+1, true);
    rep(i, M) {
        ll a;
        cin >> a;
        ok[a] = false;
    }
    dp[0] = 1;
    if(ok[1]) dp[1] = 1;
    for(ll i=2; i<=N; i++) {
        if(ok[i]) dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= MOD;
    }

    cout << dp[N] << nl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 1e5+2;
int dp[MAXN], h[MAXN], n;
 
int main(){
    int N;
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> h[i];
 
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i=3; i<=n; i++)
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]) );
 
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 100005;
const int MM = 1000000007;

int D[MX], O[MX];
int N, C, K;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	for(int i = 1; i <= N; i++) O[i] = i;
	sort(O+1, O+N+1, [](int l, int r){
		return D[l] < D[r];
	});
	vector<int> L;
	ll tot = 0;
	for(int i = 1; i <= N; i++){
		int c = O[i];
		if( tot*2 < D[c] ){
			vector<int> X;
			swap(X, L);
		}
		tot += D[c];
		L.push_back(c);
	}
	printf("%d\n", L.size());
}


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

int N,M,K;

void bfs(int k, pair<int,int> p, vector<vector<bool>> &V, mcf_graph<int,int> &G){
  priority_queue<pair<int,int>> PQ;
  vector<vector<int>> W(N,vector<int>(M,-1));
  
  queue<pair<int,int>> Q;
  Q.push(p);
  W[p.first][p.second] = 0;
  PQ.push(make_pair(0,p.first*M+p.second));
  while(!Q.empty()){
    pair<int,int> u = Q.front();Q.pop();
    int ux = u.first, uy = u.second;
    if(V[ux+1][uy] && W[ux+1][uy]==-1){
      W[ux+1][uy] = W[ux][uy] + 1;
      Q.push(make_pair(ux+1,uy));
      PQ.push(make_pair(W[ux+1][uy],(ux+1)*M+uy));
    }
    if(V[ux][uy+1] && W[ux][uy+1]==-1){
      W[ux][uy+1] = W[ux][uy] + 1;
      Q.push(make_pair(ux,uy+1));
      PQ.push(make_pair(W[ux][uy+1],ux*M+uy+1));
    }
  }
  
  for(int i=0;i<K;i++){
    if(PQ.empty()) break;
    pair<int,int> now = PQ.top();PQ.pop();
    G.add_edge(N*M+k, now.second, 1, N+M-now.first);
  }
  
  return;
}

int main(){
  cin >> N >> M;
  vector<string> S(N);
  for(int i=0;i<N;i++) cin >> S[i];
  vector<vector<bool>> V(N+1,vector<bool>(M+1,false));
  vector<pair<int,int>> P(0);
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(S[i][j]!='#') V[i][j] = true;
      if(S[i][j]=='o') P.push_back(make_pair(i,j));
    }
  }
  K = P.size();
  
  mcf_graph<int,int> G(N*M + K + 2);
  for(int i=0;i<K;i++) G.add_edge(N*M+K, N*M+i, 1, 0);
  for(int i=0;i<N*M;i++) G.add_edge(i, N*M+K+1, 1, 0);
  
  for(int i=0;i<K;i++){
    bfs(i,P[i],V,G);
  }
  
  auto ans = G.flow(N*M+K,N*M+K+1);
  cout << (N+M)*K - ans.second << endl;
  return 0;
}


Measured memory_bytes: 4396
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<chrono>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<numeric>
#include<queue>
#include<stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
constexpr double PI = 3.14159265358979323846;

int main()
{
	int n = 0;
	cin >> n;
	std::string str;
	std::vector<std::string>v;
	for (int i = 0; i < n; i++)
	{
		cin >> str;
			v.push_back(str);
	}
	std::sort(v.begin(), v.end());
	
	v.erase(std::unique(v.begin(), v.end()), v.end());
	std::cout << v.size() << std::endl;

}

Measured memory_bytes: 11552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A_500,B_100,C_50;
  int X;

  cin >> A_500;
  cin >> B_100;
  cin >> C_50;
  cin >> X;

  int cnt = 0;
  for(int a = 0; a <= A_500; a++){
    for(int b = 0; b <= B_100; b++){
        for(int c = 0; c <= C_50; c++){
            if(a*500 + b*100 + c*50 == X) cnt++;
        }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,t;
int a[101];
int main(void){
	scanf("%d%d",&n,&t);
	for(int i=0;i<t;i++){
		scanf("%d",&a[i]);
	}
	int prev=-1,cnt=0;
	for(int i=0;i<n;i++){
		int mostbig=-1;
		for(int j=0;j<t;j++){
			if(prev!=j && a[j]!=0){
				if(mostbig==-1)mostbig=j;
				if(a[j]>a[mostbig])mostbig=j;
			}
		}
		if(mostbig==-1){
			a[prev]--;
			cnt++;
		}else{
			prev=mostbig;
			a[mostbig]--;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    if(a<=9 && b<=9){
        cout<<a*b<<endl;
    }
    else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
typedef long long int ll;
#define REP(i,n) for (int i = 1; i <= n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
const double pi = 3.14159265358979323846;


void solve()
{
	int i=0,j=0,n=0,m=0;
	ll prod=1;
    ll a;
    cin>>a;
    long double b;
    cin>>b;
    //cout<<a<<endl<<b<<endl;
    cout<<(ll)(floor(a*b));
    
}

int main() {
    fast
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}


Measured memory_bytes: 3744
#include<stdio.h>

int main(){
    char S[100001];
    scanf("%s", S);

    //0 start
    int na = 0;
    int nb = 0;
    for(int i=0; S[i]!='\0'; i++){
        //0101010101...
        if(i%2==0 && S[i]=='1'){
            na++;
        }
        else if(i%2==1 && S[i]=='0'){
            na++;
        }

        //101010101.....
        if(i%2==0 && S[i]=='0'){
            nb++;
        }
        else if(i%2==1 && S[i]=='1'){
            nb++;
        }
    }

    printf("%d\n", na<nb?na:nb);

    return 0;
}

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

int main(){

	int N;
	cin >> N;
	int V[N];
	int C[N];
	for(int i = 0; i < N; i++){
		cin >> V[i];
	}
	for(int j = 0; j < N; j++){
		cin >> C[j];
	}
	int value = 0;
	int cost = 0;
	for(int k = 0; k < N; k++){
		if(V[k] > C[k]){
			value = value + V[k];
			cost = cost + C[k];
		}
	}
	int ans = value - cost;
	cout << ans << endl;

}

Measured memory_bytes: 256
from math import inf
A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))


L=[0]*(A+1)
for d in range(1,D+1):
    M=-inf
    E=0

    for j in range(1,A+1):
        X=0
        for k in range(1,A+1):
            if j!=k:
                X-=C[k]*(d-L[k])
                
        if M<=X+S[d][j]:
            M=X+S[d][j]
            E=j

    print(E)
    
    for j in range(1,A+1):
        if j!=E:
            L[j]+=1
        else:
            L[j]=0


Measured memory_bytes: 74636