akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, A, B, C, D;
string S;
//---------------------------------------------------------------------------------------------------
bool dp[201010];
bool isOk(int s, int t) {
	rep(i, s, t + 1) dp[i] = false;
	dp[s] = true;
	rep(i, s, t + 1) if (dp[i]) rep(d, 1, 3) if (S[i] == '.') dp[i + d] = true;
	return dp[t];
}
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
	if (!isOk(A, C)) return no;
	if (!isOk(B, D)) return no;

	if (C < D) return yes;


	rep(i, B - 1, D) if (S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.') return yes;
	return no;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> A >> B >> C >> D >> S;
	A--; B--; C--; D--;
	cout << solve() << endl;
}







Measured memory_bytes: 720
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
signed main()
{
    R(n);
    RA(a,n);
    int xorr=0;
    fr(i,1,n+1)
    {
        xorr=(xorr^a[i]);
    }
    fr(i,1,n+1)
    {
        cout<<(xorr^a[i])<<" ";
    }
    cout<<endl;
    return 0;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	ll n,k,q;
	cin>>n>>k>>q;
	int m[alength]={};
	fori(q){
		int hoge;cin>>hoge;
		++m[hoge-1];
	}
	fori(n){
		if(m[i]-q+k>0){
			cout<<"Yes\n";
		}else{
			cout<<"No\n";
		}
	}
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define spc        ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0)
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   vector<long long> v,v1;

    char s;
    cin>>a>>s>>b;
    if(s=='+') cout<<a+b<<endl;
    else cout<<a-b<<endl;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // ll tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {  
  string s;
  cin >> s;

  ll n = s.size();

  vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));

  ll d = s[n - 1] - '0';
  dp[1][0] = d;
  dp[1][1] = 10 - d;

  for (ll i = 2; i <= n; i++) {
    ll d = s[n - i] - '0';
    if (d != 9) {
      dp[i][0] = min(dp[i - 1][0] + d,        dp[i - 1][1] + d        + 1);
      dp[i][1] = min(dp[i - 1][0] + (10 - d), dp[i - 1][1] + (10 - d - 1));
    } else {
      dp[i][0] = dp[i - 1][0] + d;
      dp[i][1] = min(dp[i - 1][0] + (10 - d), dp[i - 1][1]);
    }
  }
  
  cout << min(dp[n][0], dp[n][1] + 1) << endl;
}


Measured memory_bytes: 55940
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  ll count = 1;
  rep_s(i, 1, 7){
    if (N>=pow(2, i)) count = pow(2,i);
  }
  cout << count << endl;

}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

#define MOD (1000000007)

int N;
int T[100000], A[100000];
int h[100000];
bool d[100000];

int main(int argc, char **argv) {
	cin >> N;
	REP(i, N) cin >> T[i];
	REP(i, N) cin >> A[i];
	int p = 0;
	bool w = false;
	REP(i, N) {
		d[i] = (T[i] > p);
		h[i] = T[i];
		p = T[i];
	}
	p = 0;
	REP(temp, N) {
		int i = N - 1 - temp;
		if (A[i] > p) {
			if ((d[i] && h[i] != A[i]) || (!d[i] && h[i] < A[i])) {
				w = true;
			}
			d[i] = true;
			h[i] = A[i];
		}
		else {
			h[i] = min(h[i], A[i]);
		}
		p = A[i];
	}
	if (w) {
		cout << 0 << endl;
		return 0;
	}
	ll res = 1;
	REP(i, N) if (!d[i]) {
		res = (res * h[i]) % MOD;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int M;
    int D;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        M = sc.nextInt();
        D = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        
        for (int i=1; i<=M; i++) {
        	for (int j=1; j<=D; j++) {
        		int d1 = j % 10;
                int d10 = j / 10;
                int dd = d1 * d10;
        		
        		if (d1 >= 2 && d10 >= 2 && dd == i) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }
}


Measured memory_bytes: 35672
# -*- coding: utf-8 -*-

n=int(input())
dic={}
for i in range(n):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
m=max(dic.values())
ans=[]
for s in dic:
    if dic[s]==m:
        ans.append(s)
ans.sort()
for s in ans:
    print(s)



Measured memory_bytes: 32096
N,K=map(int,input().split())
t=[0 for i in range(N)]
d=[0 for i in range(N)]
for i in range(N):
    t[i],d[i]=map(int,input().split())
D=dict()
for i in range(N):
    if not(t[i] in D):
        D[t[i]]=[]
    D[t[i]].append((d[i],i))
E=[0 for i in range(N)]
for key in D:
    D[key].sort(reverse=True)
    E[D[key][0][1]]=1
A=[]
B=[]
for i in range(N):
    if E[i]==1:
        A.append(d[i])
    else:
        B.append(d[i])
A.sort(reverse=True)
B.sort(reverse=True)
X=len(A)
Y=len(B)
S=[0 for i in range(X+1)]
T=[0 for i in range(Y+1)]
for i in range(X):
    S[i+1]=A[i]+S[i]
for i in range(Y):
    T[i+1]=B[i]+T[i]
L=[]
for i in range(1,K+1):
    if i<=X and K-i<=Y:
        L.append(S[i]+T[K-i]+i*i)
print(max(L))

Measured memory_bytes: 43880
def main(s):
    #s=10**17-0
    a=10**9
    if s<=10**9:
        x1,y1,x2,y2,x3,y3=0,0,s,0,0,1
    elif s%a==0:
        x1,y1,x2,y2,x3,y3=0,0,a,0,a,s//a
    else:
        x1,y1=0,0
        x2,y2=s//a+1,a-s%a
        x3,y3=1,a
    print(x1,y1,x2,y2,x3,y3)
if __name__=='__main__':
    s=int(input())
    main(s)

Measured memory_bytes: 3064
package main

import "fmt"

func min(vs ...int) int {
	min := vs[0]
	for _, v := range vs {
		if v < min {
			min = v
		}
	}
	return min
}

func step(x, y int) int {
	if y-x >= 0 {
		return y - x
	}
	return 10000000000
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	fmt.Println(min(step(x, y), step(-x, y)+1, step(x, -y)+1, step(-x, -y)+2))
}

Measured memory_bytes: 512
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
vector<vector<int>> g;

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

    g.resize(n);

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

        g[a].push_back(b);
        g[b].push_back(a);
    }

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

    for(int i = 0; i < n; i++){
        if(i != 0) m += c[i];
    }

    vector<int> d(n);
    
    queue<pair<int,int>> q;
    q.push(make_pair(0, -1));
    int cnt = 0;

    while(!q.empty()){
        int now = q.front().first;
        int pa = q.front().second;
        q.pop();
        d[now] = c[cnt];
        cnt++;
        for(int i = 0; i < g[now].size(); i++){
            int next = g[now][i];
            if(next == pa) continue;
            q.push(make_pair(next, now));
        }
    }
    cout << m << endl;
    for(int i = 0; i < n; i++){
        cout << d[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int min(int x, int y){return x<y?x:y;}
int main(void){
	int  a,b,k,i,l=0;
	scanf("%d %d %d",&a,&b,&k);
	i = min(a,b);
	while(1){
		if(a%i==0 && b%i==0){
			l++;		
			if(l==k)break;
		}
		i--;
	}
	printf("%d",i);
	return 0;
}

Measured memory_bytes: 128
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

const int D = 1000;

int n, m;
int a[D][D], b[D][D], u[D][D];
set < int > c[D];

int get(int x){
  return (x - 1) / m;
}

set < int > g[D];
int mt[D], used[D];

inline int dfs(int v){
  if(used[v]){
    return 0;
  }
  used[v] = 1;
  for(int i : g[v]){
    if(mt[i] == -1 || dfs(mt[i])){
      mt[i] = v;
      mt[v] = i;
      return 1;
    }
  }
  return 0;
}

void solve(int c){
  for(int i = 1; i <= n; ++i){
    g[i].clear();
  }
  for(int i = 1; i <= n; ++i){
    for(int j = c; j <= m; ++j){
      g[i].insert(get(a[i][j]) + n + 1);
    }
  }
  for(int i = 1; i <= 2 * n; ++i){
    mt[i] = -1;
    used[i] = 0;
  }
  for(int i = 1; i <= n; ++i){
    fill(used, used + D, 0);
    dfs(i);
  }
  for(int i = 1; i <= n; ++i){
    for(int j = c; j <= m; ++j){
      if(mt[i] - n - 1 == get(a[i][j])){
        swap(a[i][c], a[i][j]);
        break;
      }
    }
  }
}


int main(){
  cin >> n >> m;
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      cin >> a[i][j];
    }
  }
  for(int i = 1; i <= m; ++i){
    solve(i);
  }
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      printf("%d ", a[i][j]);
    }
    printf("\n");
  }
  for(int j = 1; j <= m; ++j){
    for(int i = 1; i <= n; ++i){
      b[get(a[i][j]) + 1][j] = a[i][j];
    }
  }
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      printf("%d ", b[i][j]);
    }
    printf("\n");
  }



  return 0;
}


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

int main() {
    int n, m, a, b, ans = 0;
    cin >> n >> m;
    vector<vector<bool>> v(n, vector<bool>(n, false));
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        v.at(a - 1).at(b - 1) = true;
        v.at(b - 1).at(a - 1) = true;
    }
    vector<int> casee(n - 1);
    for (int i = 0; i < n - 1; i++) {
        casee.at(i) = i;
    }
    /*for (int i = 0; i < n - 1; i++) cout << casee.at(i) << " ";
    cout << endl;*/

    bool each;
    do {
        each = true;
        if (!v.at(0).at(casee.at(0) + 1)) each = false;
        else {
            for (int i = 0; i < n - 2; i++) {
                if (v.at(casee.at(i) + 1).at(casee.at(i + 1) + 1)) continue;
                else  {
                    each = false;
                    break;
                }
            }
        }
        if (each) {
            /*for (int i = 0; i < n - 1; i++) cout << casee.at(i) << " ";
            cout << endl;*/
            ans++;
        }
    } while (next_permutation(begin(casee), end(casee)));

/*    while (next_permutation(casee.begin(), casee.end())) {
        each = true;
        for (int i = 0; i < n - 1; i++) {
            if (v[casee[i]][casee[i + 1]]) continue;
            else  {
                each = false;
                break;
            }
        }
        if (each) ans++;
    }*/
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n ;
    cin >> n;
    int a = n % 10;
    if(a == 2 or a == 4 or a == 5 or a ==7 or a == 9) cout << "hon";
    else if( a == 0 or a == 1 or a == 6 or a == 8) cout << "pon";
    else cout << "bon";
    return 0;
}

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

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

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

    int cnt = 0;
    while (cnt < n)
    {
        cout << s[cnt];
        cout << t[cnt++];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();
		int[] a = GetInts(N);

		Array.Sort(a);
		Array.Reverse(a);
		
		int ok = -1;
		int ng = N;
		while(Abs(ok - ng) > 1)
		{
			int mid = (ok + ng) / 2;
			if(need(N, K, a, mid))
				ok = mid;
			else
				ng = mid;
		}
		WriteLine(N - ok - 1);
	}

	private bool need(int N, int K, int[] a, int pos)
	{
		bool[,] dp = new bool[N, K];
		dp[0, 0] = true;
		int offset = 0;
		int prevMax = 0;
		int max = 0;
		for(int i = 0; i < N - 1; i++)
		{
			if(i == pos)
				offset++;

			max = prevMax;
			for(int j = 0; j <= prevMax; j++)
			{
				if(!dp[i, j])
					continue;

				dp[i + 1, j] = true;
				if(j + a[i + offset] < K)
				{
					dp[i + 1, j + a[i + offset]] = true;
					max = Max(max, j + a[i + offset]);
				}
			}
			prevMax = max;
		}

		int cnt = 0;
		for(int i = K - 1; i >= 0; i--)
		{
			if(dp[N - 1, i])
			{
				cnt = i;
				break;
			}
		}
		return (cnt + a[pos] >= K);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 39104
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    d1_0, d2_0 = -1, -2
    d1_1, d2_1 = -1, -2
    d1_2, d2_2 = -1, -2
    for i in range(n):
        d1_2, d2_2 = d1_1, d2_1
        d1_1, d2_1 = d1_0, d2_0
        d1_0, d2_0 = map(int,input().split())
        if d1_0 == d2_0 and d1_1 == d2_1 and d1_2 == d2_2:
            print("Yes")
            sys.exit()
    print("No")

if __name__=='__main__':
    main()

Measured memory_bytes: 62120
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

ok_set = set()
for i in range(1, 10):
    for j in range(1, 10):
        ok_set.add(i*j)

print("Yes" if n in ok_set else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n,x;
    cin>>n>>x;
    long long int a[n];
    for(long long int i=0;i<n;i++)cin>>a[i];
    long long int ans=0;
    sort(a,a+n);
    for(long long int i=0;i<n;i++)
    {
        if(a[i]<=x){if(i==n-1)
        {if(a[i]==x)ans++;
        break;}
        x-=a[i];ans++;}
        else break;
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
const ll MOD = 1000000007;
int main(){
  string Z;
  cin>>Z;
  int cnt=0;
  for(int i=0;i<Z.size();i++){
    if(Z[i]=='o')cnt++;
  }
  if(cnt+(15-Z.size())>=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,x,y; cin >> n >> x >> y;
	--x; --y;
	vvi to(n);
	rep(i,n-1){
		to[i].push_back(i+1);
		to[i+1].push_back(i);
	}
	to[x].push_back(y);
	to[y].push_back(x);
	vvi cnt(n,vi(n-1,0));
	
	rep(i,n){
		vi d(n,-1);
		d[i] = 0;
		queue<int> q;
		q.push(i);
		while(q.size()){
			int u = q.front(); q.pop();
			for(auto v: to[u]){
				if(d[v]!=-1) continue;
				d[v] = d[u] + 1;
				cnt[i][d[v]-1]++;
				q.push(v);
			}
		}
	}
	rep(k,n-1){
		int ans = 0;
		rep(i,n) ans += cnt[i][k];
		ans /= 2;
		cout << ans << endl;
	}
}




Measured memory_bytes: 16128
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let n: i32 = read(&mut s).unwrap();
    let m: i32 = read(&mut s).unwrap();
    if n == m {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#!usr/bin/env python3

import sys


def init_card_deck():
    # S: spades
    # H: hearts
    # C: clubs
    # D: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    n = int(sys.stdin.readline())

    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    return card_deck


def print_missing_cards(card_deck):
    card_symbols = ['S', 'H', 'C', 'D']

    for i in card_symbols:
        for card in range(1, 14):
            if not str(card) in card_deck[i]:
                print(i, card)


def main():
    print_missing_cards(init_card_deck())


if __name__ == '__main__':
    main()

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), v;
    v.push_back(0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i > 0) {
            if (a[i - 1] < a[i])v.push_back(v.back() + 1);
            else if (a[i - 1] > a[i])v.push_back(v.back() - 1);
        }
    }

    int m = (int) v.size();
    int ans = 1;
    for (int i = 1; i < m - 1; ++i) {
        if ((v[i] - v[i - 1]) * (v[i] - v[i + 1]) > 0){
            ++ans;
            ++i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;

    int ans = INF;
    for(int i = 0; i <= 2 * max(x, y); i++) {
        int cntA = max(x - i / 2, (int)0);
        int cntB = max(y - i / 2, (int)0);
        int tmp = i * c + cntA * a + cntB * b;
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    class Permutation<T> private constructor(private val baseIndex: Int, private var index: Int, val target: Array<T>?) {
        private var subPermutation: Permutation<T>? = null

        constructor(objs: Array<T>) : this(0, 0, objs.clone())

        init {
            if (target == null || target.isEmpty()) {
                throw IllegalArgumentException()
            }

            if (this.index < this.target.size - 1) {
                this.subPermutation = Permutation(this.baseIndex + 1, this.index + 1, this.target)
            }
        }

        operator fun next(): Boolean {
            if (this.subPermutation == null) {
                return false
            }
            val result = this.subPermutation!!.next()
            if (result) {
                return true
            }
            this.swap(this.baseIndex, this.index)
            ++this.index
            if (this.target!!.size <= this.index) {
                this.index = this.baseIndex
                return false
            }
            this.swap(this.index, this.baseIndex)
            return true
        }

        private fun swap(index1: Int, index2: Int) {
            val tmp = this.target!![index1]
            this.target[index1] = this.target[index2]
            this.target[index2] = tmp
        }
    }

    val n = readLine()!!.toInt()
    val pList = readLine()!!.split(' ').map(String::toLong).joinToString("")
    val qList = readLine()!!.split(' ').map(String::toLong).joinToString("")

    val per = Permutation((1..n).toList().toTypedArray())
    val list = mutableListOf<String>()
    do {
        val s = per.target!!.joinToString("")
        list.add(s)
    } while (per.next())
    list.sort()

    println(Math.abs(list.indexOf(pList) - list.indexOf(qList)))
}

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

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

vector<mint> factorial;

void calc_factorials(ll n){
    factorial.resize(n + 1, 0);
    factorial.at(0) = 1;
    for(ll i = 1; i <= n; ++i){
        factorial.at(i) = factorial.at(i - 1) * i;
    }
}

mint comb(ll n, ll k){
    if(n < k){
        return 0;
    }else{
        return factorial.at(n) / factorial.at(k) / factorial.at(n - k);
    }
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> count(n, 0);
    ll dup_num;
    for(int i = 0; i < n + 1; ++i){
        cin >> a.at(i);
        a.at(i)--;
        count.at(a.at(i))++;
        if(count.at(a.at(i)) == 2){
            dup_num = a.at(i);
        }
    }

    vector<ll> len(3, 0);
    int i = 0;
    for(int j = 0; j < n + 1; ++j){
        if(a.at(j) == dup_num){
            i++;
        }else{
            len.at(i)++;
        }
    }

    calc_factorials(n);

    for(ll k = 1; k <= n + 1; ++k){
        mint tmp = 0;
        tmp += comb(len.at(0) + len.at(1) + len.at(2), k);
        if(k >= 2){
            tmp += comb(len.at(0) + len.at(1) + len.at(2), k - 2);
        }
        if(k >= 1){
            tmp += 2 * (
                comb(len.at(0) + len.at(1) + len.at(2), k - 1)
                - comb(len.at(0) + len.at(2), k - 1)
            );
            tmp += comb(len.at(0) + len.at(2), k - 1);
        }
        cout << tmp.v << endl;
    }
    return 0;
}


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

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

int main(){
    string str;
    cin >> str ;
    
    
    while (1)
    {
        if (str.at(str.size()-1) == '0')
        {
            str.pop_back() ;
        }else
        {
            break ;
        }
        
        
    }
    if (str.size() == 1)
    {
        int a = str.at(0) - '0' ;
        cout << min(a,11-a) << endl ;
        return 0 ;
    }
    vector<int> n(str.size()) ;
    for (size_t i = 0; i < n.size(); i++)
    {
        n.at(i) = str.at(i) - '0' ;
    }
    vector<int> m(str.size()) ;
    for (size_t i = 0; i < m.size()-1; i++)
    {
        m.at(i) = 9 - n.at(i) ;
    }
    m.at(m.size()-1) = 10 - n.at(m.size()-1) ;
    int64_t ans = 0 ;
    vector<int> s1(str.size()) ;
    vector<int> s2(str.size()) ;
    s1.at(n.size()-1) = n.at(n.size()-1) ;
    s2.at(m.size()-1) = m.at(m.size()-1) ;
    for (size_t i = n.size()-2; 1; i--)
    {
        s1.at(i) = min(s1.at(i+1), s2.at(i+1)+1 ) +n.at(i) ;
        s2.at(i) = min(s2.at(i+1), s1.at(i+1)+1 ) +m.at(i) ;
        if (i == 0)
        {
            break ;
        }
        
    }
    ans = min (s1.at(0), s2.at(0)+1) ;
    cout << ans << endl ;
    
}

Measured memory_bytes: 17028
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n, k;
    ll ans = 0;
    cin >> n >> k;
    for (int i = k + 1; i <= n; ++i) {
        ans += n / i * (i - k) + max(n % i - k + 1, 0) - (k == 0);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> d(a);
  rep(i,a)
    cin>>d[i];
  int e=c;
  rep(i,a){
  e+=1;
    e+=(b-1)/d[i];
  }
  out(e);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
    int N,x,y,sum=0;
    int D[50];
    scanf("%d",&N);
    for (x=0;x<N;x++)
    {
    	scanf("%d",&D[x]);
	}
	for (x=0;x<N-1;x++)
	{
		for (y=x+1;y<N;y++)
		{
			sum+=D[x]*D[y];
		}
	}
	printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>//toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    forn(i,n) cin >> a[i];
    int i,j;
    map<int,int> cnt;
    set<int> s;
    for(i=0;i<n;i++){
        cnt[a[i]]++;
        s.insert(a[i]);
    }
    int ans = 0;
    for(i=0;i<n;i++){
        j = 1;
        int f = 0;
        while(j*j<=a[i]){
            if(a[i]%j==0){
                int d1 = j;
                int d2 = a[i]/j;
                if(s.count(d1) && d1!=d2){
                    f = 1;
                    break;
                }
                if(d2==a[i]){
                    if(cnt[d2]>1){
                        f = 1;
                        break;
                    }
                }
                else if(s.count(d2)){
                    f = 1;
                    break;
                }
            }
            j++;
        }
        if(f==0){
            ans++;
            // cout << i << endl;
        }
    }
    cout << ans << endl;
}   

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 22628
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

#define ulong unsigned long
#define ll long long
#define ull unsigned long long

using namespace std;

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

	int n;
	cin >> n;

	map<ulong, ulong> ls;
	for (int i = 0; i < n; i++)
	{
		int a_;
		cin >> a_;
		ls[a_]++;
	}

	pair<ulong, ulong> sides(0, 0);

	for (auto it = ls.rbegin(); it != ls.rend(); ++it)
	{
		if (sides.first == 0 && it->second >= 4) {
			sides.first = sides.second = it->first;
			break;
		}

		if (it->second >= 2)
		{
			if (sides.first == 0) {
				sides.first = it->first;
			}
			else
			{
				sides.second = it->first;
				break;
			}
		}
	}

	cout << sides.first * sides.second;
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX=1000000000;
vector<int>prime;
bool primetable[MAX];
void PrimeTable(int x)
{
    primetable[0]=false;
    primetable[1]=false;
    for(int i=2;i<x;i++)
        primetable[i]=true;
    for(int i=2;i<sqrt(x);i++)
        if(primetable[i])
        {
            int j=i+i;
            while(j<x)
            {
                primetable[j]=false;
                j+=i;
            }
        }
}
bool isPrime(int x){
    if(x==2)return true;
    //if(x<2)return false;
    if(x<2 || x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2)
        if(x%i==0)return false;
    return true;
}
void prime_factor(int x,vector<int> &res){
    if(isPrime(x)){
        res.push_back(x);
        return;
    }
    int i=2;
    while(x!=1){
        while(x%i==0)
        {
            res.push_back(i);
            x/=i;
        }
        i++;
    }

}
int main()
{
    int n;
    vector<int>res;
    cin>>n;
    prime_factor(n,res);
    //cout<<count<<endl;
    cout<<n<<':';
    for(int i=0;i<res.size();i++)
        cout<<' '<<res[i];
    cout<<endl;
}


Measured memory_bytes: 3148
AB = list(map(int, input().split())) 
A = AB[0]
B = AB[1]
count = 0
for i in range(A,B+1):
	a = int(i / 10000) 
	b = int(i / 1000 % 10)
	c = int(i / 10 % 10)
	d = int(i % 10)
	if ( a== d and b == c):
		count += 1

print(count)

Measured memory_bytes: 3060
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] H = new int[N];
		for (int i = 0; i < N; H[i++] = sc.nextInt())
			;
		int[] C = new int[N];
		for (int i = 0; i < N; C[i++] = Integer.MAX_VALUE)
			;
		C[0] = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 1; j <= K; j++) {
				if (i + j < N) {
					C[i + j] = Math.min(C[i + j], C[i] + Math.abs(H[i] - H[i + j]));
				}
			}
		}
		System.out.println(C[N - 1]);

	}
}


Measured memory_bytes: 51028
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            out.println(Math.max(0, C - (A - B)));
        }

    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N, A,B;cin >> N >> A >> B;
  vector<ll> v(N);
  rep(i,N)cin >> v[i];
  ll sum = 0;
  ll cur = v[0];
  repp(i,1,N){
    sum += min((v[i]-cur)*A,B);
    cur = v[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();

		Scanner scan = new Scanner(System.in);

		int max = 0;
		while(scan.hasNext()) {
			Integer input = scan.nextInt();
			Integer count = 1;

			if(map.containsKey(input)) count += map.get(input);
			if(max < count) max = count;
			map.put(input, count);
		}

		for(Integer key : map.keySet()) {
			int count = map.get(key);
			if(max == count) {
				System.out.println(key);
			}
		}

		scan.close();
	}

}



Measured memory_bytes: 26120
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int se, mmin=INT_MAX;
    char s[11], at[4];
    
    scanf("%s", s);
    
    rep(i, strlen(s)-2){
        at[0]=s[i];
        at[1]=s[i+1];
        at[2]=s[i+2];
        se=atoi(at);
        if (mmin>abs(se-753)) {
            mmin=abs(se-753);
        }
    }
    
    printf("%d\n", mmin);
    
    return 0;
}


Measured memory_bytes: 1724
#include <stdio.h>
#include <math.h>

int main(){
    int N;
    scanf("%d",&N);
    
    int count=0;
    int x;
    int flg=0;

    for(int i=0;i<N;i++){
        scanf("%d",&x);
        if(x==2){
            count++;
            continue;
        }
        if(x%2==0){
            continue;
        }
        for(int j=3;j<=sqrt(x);j++){
            if(x%j==0)
                flg=1;
        }
        if(flg==0)
            count++;
        flg=0;
    }

    printf("%d\n",count);
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back
#define fir first
#define sec second

int main() {
	ios :: sync_with_stdio(0);
	
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll n; cin >> n; n *= 4;
	
	b = min(b, 2 * a);
	c = min({c, 2 * b, 4 * a});
	d = min({d, 2 * c, 4 * b, 8 * a});
	
	ll e[4] = {a, b, c, d};
	ll ans = 0;
	for(int i = 3; i >= 0; i --) {
		ll t = 1 << i;
		ans += n / t * e[i];
		n %= t;
	}
	cout << ans << '\n';
	
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int Count(int n,int k)
{
	int i;

	if(n==0)
	{
		i=1;
	}

	for(i=0;n!=0;i++)
	{
		n/=k;
	}
	return i;
}

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	printf("%d",Count(n,k));

	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())

ans = 0
for n in range(1, N + 1):
    ans += n % 2
print("{:.12f}".format(ans / N))
    




Measured memory_bytes: 7880
#include<cstdio>
#include<algorithm>
int a[100000];
int main()
{
int n,t,i;
scanf("%d%d",&n,&t);
for(i=0;i<n;i++)scanf("%d",a+i);
std::sort(a,a+n);
for(i=0;i<n&&t>0;i++)t-=a[i];
if(i==n)printf("%d\n",t?n-1:n);
else printf("%d\n",t?i-1:i);
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

n, w = map(int, input().split())
item = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] + [0]*w] + [[-float("inf")]*(w+1) for _ in range(n)]
wei, val = 0, 1

for i in range(n):
    for j in range(w+1):
        if item[i][wei] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-item[i][wei]] + item[i][val])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[n][w])


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

using namespace std;

int main()
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    string ans;
    if (A1 + A2 + A3 >= 22) {
        ans = "bust";
    } else {
        ans = "win";
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256