akhauriyash/Code-Regression huggingface dataset:
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut x =
        iterator.next().unwrap().chars().collect::<std::collections::VecDeque<char>>();

    let x_len = x.len();

    let mut count: usize = 0;
    let mut sc: usize = 0;
    while !x.is_empty() {
        let c = x.pop_front().unwrap();
        if c == 'S' {
            sc += 1;
        } else {
            if sc > 0 {
                count += 1;
                sc -= 1;
            }
        }
    }

    let ans = x_len - (count * 2);
    return ans.to_string();
}


Measured memory_bytes: 4352
import java.io.InputStream;
import java.util.Scanner;

// https://atcoder.jp/contests/abc148/tasks/abc148_b
public class Main {
  public static void main(String[] args){
    System.out.println(new Main().excute(System.in)); 
  }
  public String excute(InputStream f) {
    Scanner scan = new Scanner(f);
    int N = scan.nextInt();
    scan.nextLine();
    String[] S = scan.nextLine().split(" ");
    
    StringBuffer r = new StringBuffer();
    for (int i = 0;  i < N; i++) {
      r.append(S[0].charAt(i));
      r.append(S[1].charAt(i));
    }
    return  r.toString();
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int toIndex(char x){
    return (x - 97);
}

int main(){
    vector<int> conv1(26);
    vector<int> conv2(26);

    string s, t;
    cin >> s;
    cin >> t;

    for(int i = 0; i < 26; i++){
        conv1[i] = -1;
        conv2[i] = -1;
    }

    for(int i = 0; i < s.size(); i++){
        int sc = toIndex(s[i]);
        int tc   = toIndex(t[i]);

        if(conv1[sc] == -1){
            conv1[sc] = tc;
        }
        else{
            if(conv1[sc] != tc){
                cout << "No" << endl;
                return 0;
            }
        }

        if(conv2[tc] == -1){
            conv2[tc] = sc;
        }
        else{
            if(conv2[tc] != sc){
                cout << "No" << endl;
                return 0;
            }
        }


    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main()
{
    ll n, d, dist, x, y, count = 0;
    cin >> n >> d;
    dist = d * d;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        if (x * x + y * y <= dist)
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
#include<iostream>

int main(){
    
    int a, b;
    std::cin >> a >> b;
    
    if (a>b){
        std::cout << "a > b" << std::endl;
    }
    else if (a<b){
        std::cout << "a < b" << std::endl;
    }
    else{
        std::cout << "a == b" << std::endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    int len = s.size();
    auto rec = [&](auto &&rec, ll m, ll n, int now) -> ll {
        if (now == len) {
            // cout << m+n << endl;
            return m+n;
        }
        int a = s[now]-'0';
        ll res = 0;
        res += rec(rec, m+n, a, now+1);
        if (now > 0) {
            res += rec(rec, m, n*10+a, now+1);
        }
        return res;
    };

    cout << rec(rec, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, sum int
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		switch {
		case i%15 == 0:
		case i%3 == 0:
		case i%5 == 0:
		default:
			sum += i
		}
	}
	fmt.Println(sum)
}


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

const int MAX = 1000005;
const ll MOD = 1000000007;

ll 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() {
    COMinit();
    int N;cin>>N;
    vector<int> a(N+1);
    REP(i,N+1){cin>>a[i];a[i]--;}
    map<int,int> m;
    int b;
    REP(i,N) m[i]=0;
    REP(i,N+1){
        if(m[a[i]]==1){b=a[i];break;}
        m[a[i]]++;
    }
    int i1,i2,cnt=0;
    REP(i,N+1){
        if(cnt==0 && a[i]==b){cnt++;i1=i;}
        if(cnt==1 && a[i]==b){i2=i;}
    }
    cout<<N<<endl;
    FOR(k,2,N+1){
        cout<<(COM(N-1,k)+COM(N-1,k-2)+2*COM(N-1,k-1)+MOD-COM(i1+N-i2,k-1))%MOD<<endl;
    }
    cout<<1<<endl;
    return 0;
}

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

using namespace std;

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

    vector<int> cnt(3, 0);
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        cnt[x - 1] += 1;
    }

    vector<vector<double>> dp(cnt[0] + cnt[1] + cnt[2] + 2, 
            vector<double>(cnt[1] + cnt[2] + 2)), pdp(dp);
            
    for (int k = 0; k <= cnt[2]; ++k) {
        for (int j = 0; j <= cnt[1] + cnt[2]; ++j) {
            for (int i = 0; i <= cnt[0] + cnt[1] + cnt[2]; ++i) {
                if (i == 0 && j == 0 && k == 0) continue;

                int total = i + j + k;
                
                dp[i][j] = 1;
                if (i > 0) {
                    dp[i][j] += 1.0 * i / n * (dp[i - 1][j]);
                }
                if (j > 0) {
                    dp[i][j] += 1.0 * j / n * (dp[i + 1][j - 1]);
                }
                if (k > 0) {
                    dp[i][j] += 1.0 * k / n * (pdp[i][j + 1]);
                }

                dp[i][j] /= 1 - 1.0 * (n - total) / n;
            }
        }
        swap(dp, pdp);
    }

    cout << fixed << setprecision(20) << pdp[cnt[0]][cnt[1]] << endl;

     
    return 0;
}


Measured memory_bytes: 1664
import scala.annotation.tailrec
object Main extends App {

  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val sum = readLine.trim.split(' ').map(_.toInt).sum
  println(
    math.max(n - sum, -1)
  )

}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, k);
    int nrt = sqrt(n) + 1;
    vi inc;

    for (int i = 1; i * i <= n; i++) {
        inc.pb(n / i);
    }
    
    vi table = inc;
    for (int i = inc.size()-1; i >= 0; i--) {
        if (inc[i] == i+1) continue;
        table[i] = i+1;
        table.pb(inc[i]);
    }

    //rep(i, table.size()) cout << table[i] << " "; cout << endl;

    vi mm(table.size(), 0);
    mm[0] = 1;
    Rep(i, mm.size()) {
        mm[i] = table[i] - table[i-1];
    }
    //rep(i, mm.size()) cout << mm[i] << " "; cout << endl; // kai

    vi mmn = mm; // seni

    Rep(i, k) {
        vi nxt = mm;
        int sm = 0;
        rep(j, mmn.size()) {
            sm = (sm + mm[j]) % MOD;
            //nxt[nxt.size()-1-j] = (sm + nxt[nxt.size()-1-j]) % MOD;
            nxt[nxt.size()-1-j] = (sm * mmn[nxt.size()-1-j]) % MOD;
        }
        //rep(j, nxt.size()) cout << nxt[j] << " "; cout << endl;
        /*
        rep(j, mm.size()) {
            mm[j] = (mm[j] * mmn[j]) % MOD;
        }
        */
        mm = nxt;
    }

    int ans = 0;
    rep(i, mm.size()) ans = (ans + mm[i]) % MOD;

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2564
while true
    m,f,r = gets.chomp.split(" ").map{|item| item.to_i}
    if m==-1 && f==-1 && r==-1
        break
    end
    
    if m==-1 || f==-1
        puts "F"
    elsif m+f>=80
        puts "A"
    elsif m+f>=65
        puts "B"
    elsif m+f>=50
        puts "C"
    elsif m+f>=30
        if r>=50
            puts "C"
        else
            puts "D"
        end
    else
        puts "F"
    end
end

Measured memory_bytes: 8720
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		char ch;
		Scanner s = new Scanner(System.in);
		ch = s.next().charAt(0);
		int i = (int)ch + 1;
		ch = (char)i;
		PrintStream p = new PrintStream(System.out);  
		p.print(ch);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
     
    using namespace std;
     
    #define all(x) x.begin(), x.end()
    typedef vector<int> vi;
    typedef pair<int,int> ii;
    typedef long long ll;
     
    const ll inf = 3e18 + 5;
     
    const int MAXN = 1 << 19;
    int N = 400000;
    int seg[2 * MAXN], A[MAXN];
    typedef vector<vi> vvi;
    
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
    
        int n;
        cin >> n;
        vi t(n);
        int suma=0;
        for(int i=0; i<n; i++){
            cin >> t[i];
            suma+=t[i];
        }
        int m;
        cin >> m;
        vi p(m), x(m);
        for(int i=0; i<m; i++){
            cin >> p[i] >> x[i];
            p[i]--;
        }
        
        for(int i=0; i<m; i++){
            int sol=suma;
            sol-=t[p[i]];
            sol+=x[i];
            cout << sol << endl;
        }
    }

Measured memory_bytes: 256
#pragma region Header
#define _CRT_SECURE_NO_WARNINGS
#define FOR(i,s, e) for(int i = s; i<e; ++i)
#define rFOR(i,s, e) for(int i=s-1; i>=e; --i)
#define loop(len) for(int i=0; i<len; ++i)
#define rloop(len) for(int i=len-1; i>=0; --i)
#define iPair pair<int,int>
#define LPair pair<ll,ll>
#define vecP(t,t2) vector<pair<t,t2>>
#define uoMP(t, t2) unordered_map<t, t2>
#define pb push_back
#define pp pop_back
#define beg_end(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define MrN ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long  ll;
typedef long double  ld;
#include<bits/stdc++.h>
using namespace std;
#pragma endregion

int n, w;
vector<ll> v[2];
const int SIZE = 1e5 + 5;
ll DP[101][SIZE];

ll solve(int i, ll t_weight){

	ll curWeight = v[0][i];
	ll curValue  = v[1][i];


	if(i == n-1) {
		if(curWeight + t_weight <= w)
			return DP[i][t_weight] = curValue;
		return DP[i][t_weight] = 0;
	}
	
	if(DP[i][t_weight] != -1)
		return DP[i][t_weight];


	if(curWeight + t_weight <= w)
		DP[i][t_weight] = solve(i+1, curWeight + t_weight) + curValue;
	

	DP[i][t_weight] = max(DP[i][t_weight], solve(i+1, t_weight));

	return DP[i][t_weight];

}

int main() {
	MrN;
	// freopen("input.txt", "r", stdin);
	cin >> n >> w;

	FOR(i, 0, n)
		FOR(j, 0, w)
			DP[i][j] = -1;
	

	loop(n){
			ll weight, value;
			cin >> weight >> value;
			v[0].pb(weight);
			v[1].pb(value);
	}

	cout << solve(0, 0) << '\n';

	return 0;
}


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

using namespace std;

int main()	{
  	string a, b, c;
  	cin >> a >> b >> c;
  	char play;
  	char to_play = 'a';
  	while (1)	{
		switch(to_play)	{
          case 'a': if (a.empty()) { cout << "A" << endl; return 0;}
            		to_play = a[0];
            		a.erase(a.begin());
            		break;
          case 'b': if (b.empty()) { cout << "B" << endl; return 0;}
            		to_play = b[0];
            		b.erase(b.begin());
            		break;
          case 'c': if (c.empty()) { cout << "C" << endl; return 0;}
            		to_play = c[0];
            		c.erase(c.begin());
            		break;
        }
    }
	return 0;
}

Measured memory_bytes: 256
#define m(a,b)((a)<(b)?(a):(b))
#define M(a,b,c)m(m(a,b),c)
B[11250][2],D[10002][3];main(n,x){for(scanf("%*d");~scanf("%d\n",&n);printf("%d\n",*D[n+1])){for(memset(B,x=0,9e4);x<4*n;x++)B[(x%(2*n)+1)/2][x/n/2]|=getchar()>78;for(D[0][D[0][2[*D]=1]=0]=x=-1;x++<n;*D[x+1]=1+M(*D[x]+(B[x][1]?3:*B[x]),D[x][1]+1+B[x][1],D[x][2]+2))D[x+1][1]=2+M(*D[x]+B[x][1],D[x][1]-1+*B[x]+B[x][1],D[x][2]+*B[x]),D[x+1][2]=1+M(*D[x]+2,D[x][1]+1+*B[x],D[x][2]+(*B[x]?3:B[x][1]));}}

Measured memory_bytes: 0
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp;
    }
    
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll ain;
    vector<ll> a;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>ain;
        a.push_back(ain);
    }
    sort(a.begin(),a.end());
    ll dd;
    ll d=gcd(a.at(0),a.at(1));
    ll d1=a.at(0);
    ll d2=a.at(1);
    int k=0;
    for(int i=2;i<n;i++){
        if(a.at(i)%d!=0) {
            if(k==1) {
                d=gcd(d,a.at(i));
                d=gcd(d,dd);
                k=0;
            }
            else {
                dd=gcd(d,a.at(i));
                k++;
            }
        }
        d1=gcd(d1,a.at(i));
        d2=gcd(d2,a.at(i));
        
    }
    if(d>d1) d1=d;
    if(d1>d2) d2=d1;
    cout<<d2<<endl;
}


Measured memory_bytes: 1400
N, M = map(int, input().split())
broken = []
for i in range(0, N+1):
	broken.append(False)
for i in range(0, M):
	broken[int(input())] = True
dp = [1, 1]
if broken[1]: dp[1] = 0
for i in range(2, N+1):
	if broken[i]: dp.append(0)
	else: dp.append(dp[-1]+dp[-2])
print(dp[N]%1000000007)

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2")

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()

#define EPS 1e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int a, b;
	
	cin >> a >> b;
	
	cout << string(max(b, a), min(a, b) + '0') << '\n';
	
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    string A, B, C;
    cin >> A >> B >> C;

    if(*(A.end()-1) == *B.begin() && *(B.end()-1) == *C.begin()){
      cout << "YES";
    }else{
      cout << "NO";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n - 1):
    for j in range(i + 1, n):
        k = j + j - i

        if k >= n:
            break

        if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):
            ans -= 1
            
print(ans)

Measured memory_bytes: 9208
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	string s;
	cin >> s;
	if(s=="SUN"){
		cout << 7 << endl;
	}
	else if(s=="MON")
	{
		cout << 6 << endl;
	}
	else if(s=="TUE")
	{
		cout << 5 << endl;
	}
	else if(s=="WED")
	{
		cout << 4 << endl;
	}
	else if(s=="THU")
	{
		cout << 3 << endl;
	}
	else if(s=="FRI")
	{
		cout << 2 << endl;
	}
	else if(s=="SAT")
	{
		cout << 1 << endl;
	}

	return 0;
}



Measured memory_bytes: 888
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        if ( x < y && y < z){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26064
def resolve():
    N = int(input())
    S = [str(input()) for _ in range(N)]
    words = dict(zip(set(S), [0] * len(S)))
    for s in S:
        if s in words:
            words[s] += 1

    words = sorted(words.items(), key=lambda x: x[1], reverse=True)
    mx = words[0][1]
    words = sorted(words, key=lambda x: x[0])
    for word in words:
        if word[1] == mx:
            print(word[0])

    return


resolve()

Measured memory_bytes: 53096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;
const ll INFTY = 1e10+1;

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

  vl shrine(a+2), temple(b+2);
  shrine[0] = -INFTY; temple[0] = -INFTY;
  shrine[a+1] = 2*INFTY; temple[b+1] = 2*INFTY;
  rep(i,a) cin >> shrine[i+1];
  rep(i,b) cin >> temple[i+1];
  
  ll x;
  vl s_near(2), t_near(2);
  ll distance, tmp, ans;
  rep(i,q) {
    cin >> x;
    auto itr = lower_bound(ALL(shrine), x);
    s_near[0] = *itr; --itr; s_near[1] = *itr;
    itr = lower_bound(ALL(temple), x);
    t_near[0] = *itr; --itr; t_near[1] = *itr;
    ans = 2*INFTY;
    rep(j,(1<<2)) {
      bitset<2> bit(j);
      distance = min(abs(x - s_near[bit[0]]), abs(x - t_near[bit[1]]));
      tmp = distance + abs(s_near[bit[0]] - t_near[bit[1]]);
      ans = min(ans, tmp);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;
const lint INF = 1e18;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  struct edge {int from, to, d; };
  vector<edge> es(m);
  for (int i = 0; i < m; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    es[i] = edge{a, b, c};
  }
  vector<lint> s(n, -INF);
  s[0] = 0;
  for (int j = 0; j < n - 1; j++) {
    for (int i = 0; i < m; i++) {
      if (s[es[i].from] + es[i].d > s[es[i].to] ) {
        s[es[i].to] = s[es[i].from] + es[i].d;
      }
    }
  }
  lint res = s[n - 1];
  for (int i = 0; i < m; i++) {
    if (s[es[i].from] + es[i].d > s[es[i].to]) {
      s[es[i].to] = s[es[i].from] + es[i].d;
    }
  }
  if (s[n - 1] == res) {
    cout << res << '\n';
  } else {
    cout << "inf" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, m;
    cin >> n >> m;
    string a[n], b[m];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j + m > n) continue;
            if (i + m > n) continue;
            int jud = 2500;
            for (int k = 0; k < m; k++) {
                for (int l = 0; l < m; l++) {
                    if(b[k][l] != a[i + k][j + l]) jud--;
                }
            }
            if (jud == 2500) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
//#include <math>
#include <stdio.h>
#include <vector>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int N;
int main() {
  cin >> N;
  vector< int > a(N);
  REP(i, N) { cin >> a[i]; }
  sort(ALL(a));
  int val = a[N - 1] - a[0];
  int index = N - 1;
  FOR(i, 1, N - 1) {
    if (a[i] > 0 && index == N - 1) {
      index = i;
    }
    val += abs(a[i]);
    // printf("xxx%d\n", a[i]);
  }
  printf("%d\n", val);

  int tmp = a[0];
  FOR(i, index, N - 1) {
    printf("%d %d\n", tmp, a[i]);
    tmp -= a[i];
  }
  printf("%d %d\n", a[N - 1], tmp);
  tmp = a[N - 1] - tmp;
  FOR(i, 1, index) {
    printf("%d %d\n", tmp, a[i]);
    tmp -= a[i];
  }
  // printf("%d\n", tmp);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

const ll INF = 1e13;
int main()
{
    int n, m;
    cin >> n >> m;
    vvll dp(m + 1, vll(1 << n, INF));
    vp key(m);
    rep(i, m)
    {
        int a, b, x = 0;
        cin >> a >> b;
        rep(i, b)
        {
            int c;
            cin >> c;
            x |= 1 << (c - 1);
        }
        key[i] = P(a, x);
    }
    // for (P p : key)
    // {
    //     cout << p.first << " " << bitset<10>(p.second) << endl;
    // }

    dp[0][0] = 0;
    rep(i, m)
    {
        rep(j, 1 << n)
        {
            int now = j | key[i].second;
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][now], dp[i][j] + key[i].first);
        }
    }
    ll ans = dp[m][(1 << n) - 1];

    if (ans == INF)
    {
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}

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

public class Main {

  void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    int ans = 0;

    int min = n + 1;
    for (int i = 0; i < n; ++i) {
      int x = in.nextInt();
      if (x < min) {
        ++ans;
      }

      min = Math.min(min, x);
    }

    out.println(ans);
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

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

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

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


Measured memory_bytes: 46040
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))
P = list(map(int, sys.stdin.buffer.readline().split()))

P = np.array(P, dtype=float)
E = (P + 1) / 2
cs = E.cumsum()

ans = cs[K - 1]
if K < N:
    ans = max(ans, (cs[K:] - cs[:-K]).max())
print(ans)


Measured memory_bytes: 30852
#include<stdio.h>
#include<string.h>


int main(void){

  char x[100];
  int i;


  while(scanf("%[a-z .]", x)!=EOF){
    getchar();   

    while(1){
      if(strstr(x, "the")==NULL && strstr(x, "this")==NULL && strstr(x, "that")==NULL){
	
	for(i=0; i<strlen(x); i++){
	  if(x[i]!=' ' && x[i]!='.'){	
	    x[i]++;
	  }
	  if(x[i]>'z') x[i]='a';
	
	}
      }
      else{
	break;
      }
    }
    printf("%s\n", x);

  }
  return(0);
}



Measured memory_bytes: 1984
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace ConsoleAppAtCoderABC170
{
    class Program
    {
        static void Main(string[] args)
        {
            var xn = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var (x, n) = (xn[0], xn[1]);
            var p = ReadLine().Split(' ').Select(s => { if (int.TryParse(s, out int n)) { return n; } else { return -1; } }).ToArray();

            var ans = Enumerable.Range(0, 102).Except(p).OrderBy(n => Math.Abs(x - n)).ThenBy(n => n).First();

            WriteLine(ans);
        }
    }
}


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

int main(void) {
  int h,w;
  cin >> h >> w;
  string board[50];
  for (int i = 0; i < h; ++i) cin >> board[i];
  
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (board[i][j] == '#') continue;
      int num = 0;
      
      for (int d = 0; d < 8; ++ d) {
        const int ni = i + dy[d];
        const int nj = j + dx[d];
        
        if (ni < 0 or h <= ni) continue;
      	if (nj < 0 or w <= nj) continue;
      	if (board[ni][nj] == '#') num++;
      }
      board[i][j] = char(num + '0');
    }
  }
  for (int i = 0; i < h; ++i) cout << board[i] << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

string s,t;

bool is_sam(char x, char y){
	if(x == '?')return true;
	if(x == y)return true;
	return false;
}

string make_st(int pos){
	string ans;
	rep(i,s.size()){
		if(i==pos){ans+=t; i += t.size()-1;}
		else if(s[i]=='?')ans+='a';
		else ans+=s[i];
	}
	return ans;
}

int main(){
	cin>>s>>t;
	bool al = false;
	vector<string> ans;
	rep(i,s.size()-t.size()+1){
		for(int j = 0; j<t.size(); ++j){
			if(is_sam(s[i+j],t[j])){if(j == t.size()-1){ans.push_back(make_st(i)); al=true;}}
			else break;
		}
	}
	if(!al){cout<<"UNRESTORABLE"<<endl; return 0;}
	sort(all(ans));
	cout<<ans[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
def dfs(u, g, visited):
    res = 0
    stack = [u]

    while(len(stack)):
        u = stack.pop()
        if (visited[u]): continue
        visited[u] = True
        res += 1

        for v in g[u]:
            stack.append(v)

    return res


def main():
    n,m = map(int, input().split())
    g = [ [] for _ in range(n+1) ]
    for _ in range(m):
        a,b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)

    visited = [False] * (n+1)
    ans = 0;
    for i in range(1, n+1):
        if (visited[i]): continue
        ans = max(ans, dfs(i, g, visited))

    print(ans)

main()


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

int main(){
    long long n, k; cin >> n >> k;
    double res = 0.0;
    for(long long i=1; i<n+1; ++i){
        double tmp = 1.0;
        long long d = i;
        while(d<k){d *= 2; tmp /= 2.0;}
        res += tmp;
    }
    res /= n;
    cout << fixed << setprecision(15) << res << endl;
    return 0;
}

Measured memory_bytes: 3780
n, p = map(int, input().split())
nodes = [x for x in range(n)]
answer = []

def get_root(idx) :
    if idx == nodes[idx] :
        return idx
    else :
        nodes[idx] = get_root(nodes[idx])
        return nodes[idx]
        
for i in range(p) :
    q, a, b = map(int, input().split())
    
    # union 
    if q == 0 :
        parent_min = min(get_root(a), get_root(b))
        nodes[get_root(a)] = nodes[get_root(b)] = parent_min
        
    # check
    else :
        if get_root(a) == get_root(b) : answer.append(1)
        else : answer.append(0)
            
for i in answer :
    print(i)


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

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

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    k,s = LI()
    r = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s-x-y
            if z > k:
                continue
            if z < 0:
                break
            r += 1

    return r


print(main())


Measured memory_bytes: 6564
dp = [float('inf')]*100010
dp[0] = 0
N = int(input())
for i in range(1,N+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i],dp[i-power]+1)
        power *=6
    power = 1
    while power <= i:
        dp[i] = min(dp[i],dp[i-power]+1)
        power *=9
print(dp[N])


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

int main() {
	
	int A, B;
	cin >> A >> B;
	A--;
	B--;
	
	cout << "100 100" << endl;
	
	for(int i = 0; i < 50; i++){
		for(int j = 0; j < 100; j++){
			if(i % 2 == 0 && j % 2 == 0 && A > 0){
				cout << ".";
				A--;
			}else{
				cout << "#";
			}
		}
		cout << endl;
	}
	
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 100; j++){
			cout << ".";
		}
		cout << endl;
	}
	
	for(int i = 0; i < 48; i++){
		for(int j = 0; j < 100; j++){
			if(i % 2 == 0 && j % 2 == 0 && B > 0){
				cout << "#";
				B--;
			}else{
				cout << ".";
			}
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll x;
int main(){
    cin>>x;

    ll quot=x/100;
    ll rem=x%100;
    if(rem <= quot*5) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool ans (int a, int b, int c);

int main(){
	
	int a, b, c;
	cin >> a >> b >> c;
	
	if (a==b && b==c){
		cout << "No";
	}
	else if (a==b || a==c || b==c){
		cout << "Yes";
	}
	else {
		cout << "No";

	}

	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
int main() {
    ll n, m;
    L2(n, m);
    cout<<(n-m+1)<<endl;
}

Measured memory_bytes: 3588
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#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 ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, r;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> r;
   if (n >= 10) cout << r, exit (0);
   cout << r + 100 * (10 - n);
}

int main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main()
{
  long long x;
  scanf("%lld", &x);

  if (x == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;

  return 0;
}


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

int dp[100005][2];
int A[100005];
int N;
void upmin(int &a,int b){
  a = min( a, b );
}
const int INF = (1<<29);
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    dp[i+1][0] = dp[i+1][1] = INF;
  }
  dp[0][0] = dp[0][1] = 1;
  for (int i = 1; i < N; i++) {
    if( A[i-1] <= A[i] ) upmin( dp[i][0], dp[i-1][0] );
    if( A[i-1] >= A[i] ) upmin( dp[i][1], dp[i-1][1] );
    upmin( dp[i][1], dp[i-1][0]+1 );
    upmin( dp[i][0], dp[i-1][1]+1 );
    upmin( dp[i][0], dp[i-1][0]+1 );
    upmin( dp[i][1], dp[i-1][1]+1 );
  }
  cout << min( dp[N-1][0], dp[N-1][1] ) << endl;
}

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

int main()
{
    long int a,b,k,j,i,l,store;
    cin >> a >> b >> k;
    if(k>=b)
    {
        for(long int i=a; i<=b; i++)
            cout << i << endl;
    }
    else
    {
        for( i=a; i<=a+k-1 && i<=b; i++)
        {
            store = i;
            cout << i << endl;

        }
        //cout << "bal falao" << endl;
     //   cout << "store is " << store << endl;
        for(i=b-k+1; i<=b; i++)
        {
            if(store<i)
            {
                cout << i << endl;
            }

        }
    }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	a, b, c := io.NextInt(), io.NextInt(), io.NextInt()
	a, b = b, a
	a, c = c, a
	io.Println(a, b, c)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// abc143D
int main(){
    int n;
    cin >> n; 
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    rep(i, n-2){
        for(int j=i+1; j<n-1; j++){
            if (l[i] >= l[j] + l[j-1]) break;
            for(int k=j+1; k<n; k++){
                if(l[i] < l[j] + l[k]) ans++;
                else break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] v = new int[m];
		for (int i = 0; i < m; i++) v[i] = sc.nextInt();
		int[] dp = new int[n + 1];
		Arrays.fill(dp, Integer.MAX_VALUE / 2);
		dp[0] = 0;
		for (int i = 0; i <= n; i++) {
			if (dp[i] != Integer.MAX_VALUE / 2) {
				for (int j = 0; j < m; j++) {
					if (i + v[j] <= n) dp[i + v[j]] = Math.min(dp[i + v[j]], dp[i] + 1);
				}
			}
		}
		System.out.println(dp[n]);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26988
#include <stdio.h>
int main()
{
    int X,A,B,c;
    scanf("%d %d %d",&X,&A,&B);
    c=A-B;
    c=fabs(c);
    if (c<=X)
    {
        if(B>A)
            printf("safe");
        else
            printf("delicious");
    }
    else
        printf("dangerous");

}


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

/*
   AtCoder contest code
   coder : yoichidon
 */
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Long[] bestSushi = new Long[N];
        Arrays.fill(bestSushi, 0L);
        List<Long> otherSushi = new ArrayList<>(N);

        int sushiKind = 0;

        for(int n=0; n<N; n++){
            int t=sc.nextInt()-1;
            long d = sc.nextLong();
            if(bestSushi[t]==0) sushiKind++;
            if(bestSushi[t]>=d) otherSushi.add(d);
            else{

                otherSushi.add(new Long(bestSushi[t]));
                bestSushi[t] = d;
            }
        }
        Arrays.sort(bestSushi, Comparator.reverseOrder());
        Collections.sort(otherSushi, Comparator.reverseOrder());

        long[] bestSum = new long[K+1];
        bestSum[0] = 0L;
        for(int k=1; k<=K; k++){
            bestSum[k] = bestSum[k-1]+bestSushi[k-1];
        }
        long[] otherSum = new long[K+1];
        otherSum[0] = 0L;
        for(int k=1; k<=K; k++){
            otherSum[k] = otherSum[k-1]+otherSushi.get(k-1);
        }

//        System.err.println(Arrays.toString(bestSushi));
//        System.err.println(Arrays.toString(bestSum));
//
//        System.err.println(otherSushi);
//        System.err.println(Arrays.toString(otherSum));

        long ans = 0;
        for(int kind=1; kind<=Math.min(K,sushiKind); kind++){
            int other = K-kind;
            ans = Math.max(ans, bestSum[kind]+otherSum[other]+((long)kind)*kind );
            //System.err.printf("%d %d\n", kind, ans);
        }

        System.out.println(ans);



    }
}


Measured memory_bytes: 96716
import java.util.Scanner;
public class Main {
	public static String sarch(int in[]){
		int i;
		//four
		for(i=1;i<4;i++){
			if(in[0]!=in[i]){
				break;
			}
		}
		if(i==4)
			return "four card";
		for(i=2;i<5;i++){
			if(in[1]!=in[i]){
				break;
			}
		}
		if(i==5)
			return "four card";
		//full house
		if(in[0]==in[1] && in[2]==in[3] && in[3]==in[4])
			return "full house";
		if(in[0]==in[1] && in[1]==in[2] && in[3]==in[4])
			return "full house";
		//straight
		for(i=1;i<5;i++){
			if(in[i-1]+1!=in[i]) break;
		}
		if(i==5) return "straight";
		if(in[0]==1 && in[1]==10 && in[2]==11 && in[3]==12 && in[4]==13){
			return "straight";
		}
		//three
		for(i=1;i<3;i++){
			if(in[0]!=in[i]){
				break;
			}
		}
		if(i==3)
			return "three card";
		for(i=2;i<4;i++){
			if(in[1]!=in[i]){
				break;
			}
		}
		if(i==4)
			return "three card";
		for(i=3;i<5;i++){
			if(in[2]!=in[i]){
				break;
			}
		}
		if(i==5)
			return "three card";
		//two pair
		if(in[0]==in[1] && in[2]==in[3])
			return "two pair";
		if(in[0]==in[1] && in[3]==in[4])
			return "two pair";
		if(in[1]==in[2] && in[3]==in[4])
			return "two pair";
		//one
		if(in[0]==in[1])
			return "one pair";
		if(in[1]==in[2])
			return "one pair";
		if(in[2]==in[3])
			return "one pair";
		if(in[3]==in[4])
			return "one pair";
		
		//null
		return "null";
	}

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int in[]=new int[5],i,j,min,tmp;
		while(sc.hasNext()){
			String str[]=sc.next().split(",");
			for(i=0;i<5;i++){
				in[i]=Integer.parseInt(str[i]);
			}
			//sort
			for(i=0;i<5;i++){
				min=i;
				for(j=i;j<5;j++){
					if(in[j]<in[min]) min=j;
				}
				tmp=in[i];
				in[i]=in[min];
				in[min]=tmp;
			}
			System.out.println(sarch(in));
		}
	}
}

Measured memory_bytes: 11000
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#ifdef bhartiya
#define endl '\n'
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define inf 200000000000000ll
// #define inf 10000000000ll
#define mod 1000000007ll
// #define mod 998244353ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 212345;
// ll n;
ll a[maxn];
ll b[maxn];


int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    // cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        rep(i,n){
            cin>>a[i];
            b[i]= inf;
        }
        b[0] = 0;
        rep(i,n){
            fr(j,1,k){
                if(i+j < n){
                    b[i+j] = min(b[i+j], b[i] + abs(a[i+j]-a[i]));
                }
            }
        }
        cout<<b[n-1];
    }
}

Measured memory_bytes: 1792