akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
    string a;
    string b;
    cin >> a >> b;
    int s = a.size();
    rep(i,s){
        if(a[i] == b[0]){
            int check = i;
            rep(j,s){
                if(b[j] != a[check])break;
                if(j == s-1){
                    cout << "Yes" << endl;
                    return 0;
                }
                check++;
                if(check == s)check = 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : B - Battle
// Contest : AtCoder - AtCoder Beginner Contest 164
// URL : https://atcoder.jp/contests/abc164/tasks/abc164_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){
	int a,b,c,d;cin>>a>>b>>c>>d;
	swap(a,b);
	swap(c,d);
	int cur=0;
	while(1){
		if(cur==0){
			cur=1;
			d-=a;
			if(d<=0){
				cout<<"Yes";r0
			}
		}
		else{
			cur=0;
			b-=c;
			if(b<=0){
				cout<<"No";r0
			}
		}
	}



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


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

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var X = int.Parse(input[1]);
            var T = int.Parse(input[2]);

            var count = (Math.Ceiling((double)N / X));
            System.Console.WriteLine(count * T);
        }
    }
}


Measured memory_bytes: 27456
import bisect

def next_int():
    return int(input())

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

n = next_int()
a = next_ints()
a.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        pos = bisect.bisect_right(a, a[i] + a[j] - 1)
        ans += pos - j - 1
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define Khela_Sesh ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
const int sz =  1e3+10;
const ll mod= 1e9+7;
int n,m;
ll dp[sz][sz];
char str[sz][sz];
bool check(int x,int y)
{
    if(0<=x && x<n && 0<=y && y<m)  return true;
    else return false;
}
ll cholo(int p,int q)
{
    ll &ret=dp[p][q];
    if(~ret) return ret;
    ret=0ll;
    if(p==(n-1) && q==(m-1))  return (ret=1ll);
    if(str[p][q]=='#')  return (ret=0ll);
    else{
        ll x=0ll,y=0ll;
        if(check(p,q+1)) x=(cholo(p,q+1))%mod;
        if(check(p+1,q)) y=cholo(p+1,q)%mod;
        ret=(x+y)%mod;
        return ret;
    }

}
int main()
{
    Khela_Sesh
    int a,b,c,i,j,k,q,x,y,sum,ct,ct1,l,r,len,x1,y1,mn,t,mx;
    char ch;
    double d;
    string str1,str2;
    bool bl,bl1;
    while(cin>>n>>m)
    {
        for(i=0;i<n;i++)
            for(j=0;j<m;j++) cin>>str[i][j];
        memset(dp,-1,sizeof dp);
        ll p=cholo(0,0);
        pf("%lld\n",p);
    }


}



Measured memory_bytes: 9472
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        
        
        int n = sc.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        
        
        int maxp = values[1]-values[0];
        		int minv = Math.min(values[1], values[0]);
        		for(int i = 2; i < n; i ++) {
        			maxp = Math.max(maxp, values[i] - minv);
        			minv = Math.min(minv, values[i]);
        		}
        
        
		System.out.println(maxp);
	}
}


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

int main() {
  long long num;
  long long kekka = 1;
  
  cin >> num;
  
  for(int i = 1; i <= num; i++){
    kekka *= i;
    kekka %= 1000000007;
  }
  
  cout << kekka;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
ll power(ll x,ll y,ll p) 
{ 
    ll res=1;  
    x=x%p;
    while (y > 0) 
    { 
        if(y&1) 
            res=(res*x)%p; 
        y=y>>1;
        x=(x*x)%p;   
    } 
    return res; 
}
ld dp[305][305][305];
ll n;
ld rec(ll t1, ll t2, ll t3)
{
	if(t1 < 0 || t2 < 0 || t3 < 0)
		return 0;
	if(t1 == 0 && t2 == 0 && t3 == 0)
		return 0;
	if(dp[t1][t2][t3] != 0)
		return dp[t1][t2][t3];
	ld a = rec(t1-1,t2,t3);
	ld b = rec(t1+1,t2-1,t3);
	ld c = rec(t1,t2+1,t3-1);
	ld te = t1 + t2 + t3;
	dp[t1][t2][t3] += (t1 / te) * 1.0 * a;
	dp[t1][t2][t3] += (t2 / te) * 1.0 * b;
	dp[t1][t2][t3] += (t3 / te) * 1.0 * c;
	dp[t1][t2][t3] += (n * 1.0) / te;
	return dp[t1][t2][t3];
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,k,x;
    cin >> n;
    ll t1=0,t2=0,t3=0;
    for(i=0;i<n;i++)
    {
    	cin >> x;
    	if(x == 1)
    		t1++;
    	else if(x == 2)
    		t2++;
    	else if(x == 3)
    		t3++;
    }
    ld ans = rec(t1,t2,t3);
    cout << fixed << setprecision(10);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 345984
N = int(input())
S = input()

cnt = 0
for i in range(1000):
    n = '{:03d}'.format(i)
    i = 0
    for d in n:
        try:
            i = S.index(d, i) + 1
        except ValueError:
            break
    else:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define bg(x) (x).begin()
#define ed(x) (x).end()
#define ar array
#define ll long long int

ll cnt(int n) {
    ll c = 0;
    for (int i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) {
            ++c;
            if (i != n / i)
                ++c;
        }
    }
    return c;
}

const ll mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        ll ans = 0;
        for (int i = 1; i < n; ++i) {
            int tar = n - i;
            ans += cnt(tar);
        }
        cout << ans;
    }
    

    return 0;
}

Measured memory_bytes: 3676
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		double p = sc.nextDouble();
		p /= 100;
		if (x % 2 == 1) {
			++x;
		}
		x /= 2;
		System.out.println(x / p);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
const int uchiha=1e3+5;
map<int,int> mp;
int main(){
int n,a,c1=0;
cin>>n;
while(n--){
    cin>>a;
    mp[a]++;
}
for(auto r : mp){
    if(r.second<r.first)
        c1+=r.second;
    else
        c1+=r.second-r.first;
}
cout<<c1<<"\n";
}


Measured memory_bytes: 4736
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();
        Deque<Character> deq = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            deq.addLast(c[i]);
        }
        int ans = 0;
        while(true) {
            if(deq.isEmpty()) {
                System.out.println(ans);
                return;
            } else {
                if(deq.pollFirst() == 'W') {
                    if(deq.isEmpty()) {
                        System.out.println(ans);
                        return;
                    } else {
                        while(true) {
                            if(deq.isEmpty()) {
                                System.out.println(ans);
                                return;
                            } else {
                                if(deq.pollLast() == 'R') {
                                    ans++;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 44084
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

int main(void){
	
	std::string s;

	std::cin >> s;

	std::sort(s.begin(), s.end());

	if (s == "abc") {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}


	return 0;
}

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

#define ll long long int

ll n, a[3005], dp_mx[3005][3005], dp_mn[3005][3005];

ll f(ll i, ll j){

    if(i > j) return 0;
    if(i == j+1) return dp_mx[i][j] = max(a[i], a[j + 1]) - min(a[i], a[j + 1]);

    if(dp_mx[i][j] != -1) return dp_mx[i][j];

    ll p = a[i] + min(f(i+2,j), f(i+1,j-1));
    ll q = a[j] + min(f(i+1, j-1), f(i, j-2));

    return dp_mx[i][j] = max(p,q);
}

ll g(ll i, ll j){

    if(i > j) return 0;
    if(i == j+1) return dp_mn[i][j] = max(a[i], a[j + 1]) - min(a[i], a[j + 1]);

    if(dp_mn[i][j] != -1) return dp_mn[i][j];

    ll p = a[i] + min(f(i+2,j), f(i+1,j-1));
    ll q = a[j] + min(f(i+1, j-1), f(i, j-2));

    return dp_mn[i][j] = max(p,q);
}

int main() {

    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

    cin>>n;
    for(ll z=0;z<n;z++) cin>>a[z];

    memset(dp_mx, -1, sizeof dp_mx);

    ll j = f(0,n-1);
    ll j1 = f(1,n-1), j2 = f(0, n-2);
    if(j1 < j2) cout<<j - j1;
    else cout<<j - j2;

    return 0;
}


Measured memory_bytes: 74280
import sys, itertools, collections
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

w, h, x, y = lmi()

if w % 2 == h % 2 == 0 and x == w//2 and y == h//2:
    c = 1
else:
    c = 0

print((w*h)/2, c)    


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int ab = Integer.parseInt(sc.next());
        int bc = Integer.parseInt(sc.next());
//        int ca = Integer.parseInt(sc.next());

        System.out.println(ab * bc / 2);
    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

const int N=5e5+5;
int n,d,x[N],a[N],b[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>d;
	for(int i=0;i<n;++i) cin>>x[i];
	a[0]=d;
	for(int i=0;i<n;++i)
		a[i+1]=min(abs(a[i]-x[i]),a[i]);
	b[n]=1;
	for(int i=n-1;i;--i){
		b[i]=b[i+1];
		if(2*b[i+1]>x[i]) b[i]+=x[i];
	}
	int T;
	cin>>T;
	while(T--){
		int q;
		cin>>q;
		--q;
		cout<<(a[q]>=b[q+1]?"YES\n":"NO\n");
	}
}




Measured memory_bytes: 9484
def f():
    n, a, b, c, d = list(map(int, input().split(" ")))
    h = abs(b-a)
    for m in range(n):
        if c*m-d*(n-m-1)<=h<=d*m - c*(n-m-1):
            print("YES")
            return
    print("NO")

f()

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include <cstdlib>

using namespace std;
int main(){
  int n;
  int a[100100] = {0};

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

  int all_price=0;
  for(int i=0; i <= n; i++){
    all_price += abs(a[i] - a[i+1]);
  }

  for(int i=1; i <= n; i++){
    int diff_price = all_price + abs(a[i+1]-a[i-1]) - (abs(a[i-1]-a[i])+abs(a[i]-a[i+1]));
    cout << diff_price << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <memory>
#include <utility>

template <class Key, class T> class splay_associative_array {
public:
	using key_type = Key;
	using value_type = T;
	using reference = value_type &;

private:
	class node_type {
	public:
		typename splay_associative_array::key_type key;
		typename splay_associative_array::value_type value;
		::std::unique_ptr<node_type> left, right;
		node_type(const key_type &key) : key(key), value(), left(), right() {}
	};
	using pointer = ::std::unique_ptr<node_type>;

	pointer root;

public:
	splay_associative_array() : root() {}

	reference operator[](const key_type &key) {
		pointer left, right;
		pointer *next_l = &left, *next_r = &right;
		while (1) {
			if (!root)
				root = ::std::make_unique<node_type>(key);
			if (!(root->key <= key)) {
				if (!root->left)
					root->left = ::std::make_unique<node_type>(key);
				if (!(root->left->key <= key)) {
					*next_r = ::std::move(root->left);
					root->left = ::std::move((*next_r)->right);
					(*next_r)->right = ::std::move(root);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
				else if (!(key <= root->left->key)) {
					*next_r = ::std::move(root);
					next_r = &(*next_r)->left;
					*next_l = ::std::move(*next_r);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
				else {
					*next_r = ::std::move(root);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
			}
			else if (!(key <= root->key)) {
				if (!root->right)
					root->right = ::std::make_unique<node_type>(key);
				if (!(root->right->key <= key)) {
					*next_l = ::std::move(root);
					next_l = &(*next_l)->right;
					*next_r = ::std::move(*next_l);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
				else if (!(key <= root->right->key)) {
					*next_l = ::std::move(root->right);
					root->right = ::std::move((*next_l)->left);
					(*next_l)->left = ::std::move(root);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
				else {
					*next_l = ::std::move(root);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
			}
			else {
				*next_l = ::std::move(root->left);
				root->left = ::std::move(left);
				*next_r = ::std::move(root->right);
				root->right = ::std::move(right);
				return root->value;
			}
		}
	}
};

#include <cstdio>
#include <map>
using i64 = long long;
void scan(i64 &d) {
	d = 0;
	bool f = 0;
	int c;
	while (c = fgetc(stdin), c == ' ' || c == '\n');
	if (c == '-') f = 1, c = fgetc(stdin);
	do d = d * 10 + c - '0'; while (c = fgetc(stdin), c != ' '&&c != '\n');
	if (f) d = -d;
}

int main() {
	using i64 = long long;
	i64 n;
	scan(n);

	splay_associative_array<i64, i64> mp;
	i64 a, sum = 0, ans = 0;
	mp[0] = 1;

	while (n--) {
		scan(a);
		
		sum += a;
		ans += mp[sum]++;
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int main() {
  int k;
  cin >> k;
  int mod = 7 % k;
  int i = 0;
  for (; i < 1000000 && mod != 0; i++) {
    mod = (mod * 10 + 7) % k;
  }
  if (i == 1000000)
    cout << -1 << endl;
  else
    cout << i + 1 << endl;
  return 0;
}


Measured memory_bytes: 3540
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n, m;
	while(true)
	{
		vint v(101, 0);
		while(cin >> n >> m && (n || m))
		{
			v[n]++;
			v[m]++;
		}

		if(cin.eof()) break;

		int o = 0;
		rep(i, 101) if(v[i] % 2) o++;

		cout << (o != 2 ? "NG" : (v[1] % 2 && v[2] % 2) ? "OK" : "NG") << endl;
	}
}

Measured memory_bytes: 0
N,M = map(int,input().split())
k = 0
t = 0
j = 0
before = N
for i in range(1,M+1):
    if N - before + i == N//2 and N%2 == 0:
        j = 1
    else:
        if N - before + t + i == k:
            t = 1
        k = before - t - i
        print(i,before-t)
        before -= 1
if j == 1:
    i += 1
    print(i,before-t)

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

int  main(){

  int x;
  cin>>x;

  //
  // X%60
  int h = x / 3600;
  int m = (x / 60) % 60;
  int s = x % 60;
  cout<<h<<":"<<m<<":"<<s<<endl;

  return 0;
}	   



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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MAX_N = 100;

vector<int> primes;
bool is_prime[MAX_N + 1];

// eratosthenesの篩 O(nloglogn)
// n以下の素数を列挙して、n以下の素数の数を返す
int sieve(int n){
  for(int i=0;i<=n;i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      primes.push_back(i);
      for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
    }
  }
  return (int)(primes.size());
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    sieve(100);
    int lenp = primes.size();
    // for(int p: primes) cout << p << endl;

    // n! の素因数
    vector<int> num;
    for(int p: primes){
        int tp = p;
        int sum = 0;
        while(tp <= n){
            sum += (n / tp);
            tp = tp * p;
        }
        num.push_back(sum);
    }
    int ans = 0;
    for(int i=0;i<lenp;i++){
        if(num[i] >= 74) ans++;
    }
    for(int i=0;i<lenp;i++){
        for(int j=i+1;j<lenp;j++){
            if(num[i] >= 24 && num[j] >= 2){
                ans++;
            }
            if(num[i] >= 2 && num[j] >= 24){
                ans++;
            }
            if(num[i] >= 14 && num[j] >= 4){
                ans++;
            }
            if(num[i] >= 4 && num[j] >= 14){
                ans++;
            }
        }
    }
    for(int i=0;i<lenp;i++){
        for(int j=i+1;j<lenp;j++){
            for(int k=j+1;k<lenp;k++){
                if(num[i] >= 4 && num[j] >= 4 && num[k] >= 2){
                    ans++;
                }
                if(num[i] >= 4 && num[j] >= 2 && num[k] >= 4){
                    ans++;
                }
                if(num[i] >= 2 && num[j] >= 4 && num[k] >= 4){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, m, ite;
    cin >> n >> m;
    while(m){
        cin >> ite;
        n -=  ite;
        if(n < 0){
            n = -1;
            break;
        }
        m--;
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 3640
// ARC096B.cpp
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 200;

int n, q[MAX_N];
ll prefix[2][MAX_N], C, ans, f[MAX_N], g[MAX_N];

int main()
{
    scanf("%d%lld", &n, &C);
    for (int i = 1; i <= n; i++)
        scanf("%lld%lld", &prefix[0][i], &prefix[1][i]);
    for (int i = 1; i <= (n << 1); i++)
        prefix[1][i] += prefix[1][i - 1];
    for (int i = 1; i <= n; i++)
        f[i] = prefix[1][i] - prefix[0][i], ans = max(ans, f[i]);
    for (int i = n; i >= 1; i--)
        g[i] = prefix[1][n] - prefix[1][i - 1] - (C - prefix[0][i]), ans = max(ans, g[i]);
    ll mx_val = 0;
    for (int i = 2; i <= n; i++)
        mx_val = max(mx_val, f[i - 1]), ans = max(ans, mx_val + g[i] - (C - prefix[0][i]));
    mx_val = 0;
    for (int i = n - 1; i >= 1; i--)
        mx_val = max(mx_val, g[i + 1]), ans = max(ans, mx_val + f[i] - prefix[0][i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main(){
  int S,h,m,s;
  scanf("%d",&S);
  h=S/3600;
  m=(S-h*3600)/60;
  s=(S-m*60-h*3600);
  if(0<=S && S<86400){
    printf("%d:%d:%d\n",h,m,s);
      }
  return 0;
}
 

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

using namespace std;


//int main2(){
//    int X,Y,A,B,C;
//    int t;
//    cin >> X >> Y >> A >> B >> C;
//
//    vector <int> P,Q,R;
//    priority_queue<int,vector<int>,greater<int> > Q_a,Q_b;
//    //input
//    for (int i=0;i<A;i++){
//        cin >>t;
//        if (Q_a.empty() or Q_a.size()<X){
//            Q_a.push(t);
//        }
//        else{
//            if (Q_a.top()<t){
//                Q_a.pop();
//                Q_a.push(t);
//            }
//        }
//    }
//    for (int i=0;i<B;i++){
//        cin >> t;
//        if (Q_b.empty() or Q_b.size()<Y){
//            Q_b.push(t);
//        }
//        else{
//            if(Q_b.top()<t){
//                Q_b.pop();
//                Q_b.push(t);
//            }
//        }
//    }
//    for (int i=0;i<C;i++){
//        cin >> t;
//        R.push_back(t);
//    }
//    //sort
//    sort(R.begin(),R.end(),greater<int>());
//    for ( int i=0;i<C;i++){
//        int a=Q_a.top();
//        int b=Q_b.top();
//        if(a>b){
//            if(b<R[i]){
//                Q_b.pop();
//                Q_b.push(R[i]);
//            }
//        }
//        else{
//            if(a<R[i]){
//                Q_a.pop();
//                Q_a.push(R[i]);
//            }
//        }
//    }
//    int ans=0;
//    while (!Q_a.empty()){
//        ans+=Q_a.top();
//        Q_a.pop();
//    }
//    while (!Q_b.empty()){
//        ans+=Q_b.top();
//        Q_b.pop();
//    }
//    cout << ans<<endl;
//}

int main(){
    int X,Y,A,B,C;
    int t;
    cin >> X >> Y >> A >> B >> C;

    vector <int> P,Q,R;
    priority_queue<int,vector<int>,greater<int> > Q_a,Q_b;
    //input
    for (int i=0;i<A;i++){
        cin >>t;
        if (Q_a.empty() or Q_a.size()<X){
            Q_a.push(t);
        }
        else{
            if (Q_a.top()<t){
                Q_a.pop();
                Q_a.push(t);
            }
        }
    }
    for (int i=0;i<B;i++){
        cin >> t;
        if (Q_b.empty() or Q_b.size()<Y){
            Q_b.push(t);
        }
        else{
            if(Q_b.top()<t){
                Q_b.pop();
                Q_b.push(t);
            }
        }
    }
    for (int i=0;i<C;i++){
        cin >> t;
        R.push_back(t);
    }
    
    while (!Q_a.empty()){
        R.push_back(Q_a.top());
        Q_a.pop();
    }
    while (!Q_b.empty()){
        R.push_back(Q_b.top());
        Q_b.pop();
    }
    sort(R.begin(),R.end(),greater<int>());
    long long ans=0;
    for (int i=0;i<X+Y;i++){
        ans+=R[i];
    }
    cout << ans<<endl;
}


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

using namespace std;

int C, N, Len, CurSum, Total;
int MapData[10000][10000];

int judge(int row, int col) {
	
	if (MapData[row][col] != MapData[row][N-1-col]) {
		return 0;
	}
	if (MapData[row][col] != MapData[N-1-row][col]) {
		return 0;
	}
	if (MapData[row][col] != MapData[N-1-row][N-1-col]) {
		return 0;
	}
	return 1;
}

int main() {
	int d, r, c;
	string str;

	cin >> C >> N;
	for (int i = 0; i < N; ++i) {
		cin >> str;
		for (int j = 0; j < N; ++j) {
			MapData[i][j] = str[j] - '0';
		}
	}
	Len = N / 2;
	CurSum = 0;
	for (int i = 0; i < Len; ++i) {
		for (int j = 0; j < Len; ++j) {
			CurSum += judge(i, j) * 4;
		}
	}
	Total = 0;
	if (CurSum == N*N) {
		++Total;
	}
	for (int i = 1; i < C; ++i) {
		cin >> d;
		for (int m = 0; m < d; ++m) {
			cin >> r >> c;
			--r;
			--c;
			CurSum -= judge(r, c) * 4;
			MapData[r][c] = (MapData[r][c] == 1 ? 0 : 1);
			CurSum += judge(r, c) * 4;
		}
		if (CurSum == N*N) {
			++Total;
		}
	}
	cout << Total << endl;

	return 0;
}



Measured memory_bytes: 11068
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;


int main()
{
    int n, q;
    cin >> n >> q;
    string w[n];
    for (int e = 0; e < n; e++)
    {
        cin >> w[e];
    }
    sort(w, w+n);
    for (int e = 0; e < n; e++)
    {
        cout << w[e];
    }
    return 0;
}


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

using namespace std;

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

const string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

void solve()
{
	int H, W;
	cin >> H >> W;
	string s;
	rep(H, i) rep(W, j)
	{
		cin >> s;
		if (s == "snuke")
		{
			cout << alphabet[j] << i + 1 << endl;
			return;
		}
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    long long n,a,b;
    long long x[100100];
    cin>>n>>a>>b;
    long long ans=0;
    REP(i,n){
        cin>>x[i];
        if(i==0)continue;
        ans+=min(b,(x[i]-x[i-1])*a);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,s,A;
    scanf("%d%d%d",&a,&b,&c);
    s=(a+b+c)/2;
    A=sqrt(s*(s-a)*(s-b)*(s-c));
    printf("%d\n",A);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// e.g. sort(all(a), [](int a1, int a2) { return a1 < a2; });
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  cout << ((a1+a2+a3 >= 22) ? "bust" : "win") << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use smallvec::alloc::collections::BinaryHeap;
use im_rc::HashSet;

#[fastout]
fn main() {
    input! {
    x: usize,
    y: usize,
    z: usize,
    k: usize,
    mut a: [usize; x],
    mut b: [usize; y],
    mut c: [usize; z],
    }
    a.sort_by(|i, j| j.partial_cmp(i).unwrap());
    b.sort_by(|i, j| j.partial_cmp(i).unwrap());
    c.sort_by(|i, j| j.partial_cmp(i).unwrap());
    let mut q = BinaryHeap::new();
    let mut used = HashSet::new();
    q.push((a[0] + b[0] +c[0], 0, 0, 0));
    for _ in 0..k {
        let t = q.pop().unwrap();
        println!("{}", t.0);
        if t.1 + 1 < x {
            let na = (t.0 + a[t.1 + 1] - a[t.1], t.1 + 1, t.2, t.3);
            if !used.contains(&na) {q.push(na)}
            used.insert(na);
        }
        if t.2 + 1 < y {
            let nb = (t.0 + b[t.2 + 1] - b[t.2], t.1, t.2 + 1, t.3);
            if !used.contains(&nb) {q.push(nb)}
            used.insert(nb);
        }
        if t.3 + 1 < z {
            let nc = (t.0 + c[t.3 + 1] - c[t.3], t.1, t.2, t.3 + 1);
            if !used.contains(&nc) {q.push(nc)}
            used.insert(nc);
        }
    }
}


Measured memory_bytes: 4528
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
int n,x;
int b[100000],l[100000],u[100000];
LL dept=0;
vector<pair<int,LL>> v;

bool ok(LL m){
  int fills = min(n,(int)(m/(LL)x));
  LL  res   = m%(LL)x;
  if(fills==n)return true;

  LL defaultdel = 0;
  REP(j,fills){
    int i = v[j].first;
    defaultdel += (LL)l[i]*(LL)b[i]+(LL)(x-b[i])*(LL)u[i];
  }
  REP(j,n){
    int i = v[j].first;
    int nexti = v[fills].first;
    LL del=0;
    if(res < b[i])
      del += (LL)(res)*(LL)l[i];
    else
      del += (LL)l[i]*(LL)b[i]+(LL)(res-b[i])*(LL)u[i];
    if(j >= fills)del += defaultdel;
    else del += defaultdel - ((LL)l[i]*(LL)b[i]+(LL)(x-b[i])*(LL)u[i]) +((LL)l[nexti]*(LL)b[nexti]+(LL)(x-b[nexti])*(LL)u[nexti]);

    if(dept <= del)return true;
  }
  return false;
  
}

int main(){
  cin>>n>>x;
  REP(i,n){
    cin>>b[i]>>l[i]>>u[i];
    dept+=(LL)l[i]*(LL)b[i];
    v.push_back(make_pair(i,(LL)(x-b[i])*(LL)u[i]+(LL)l[i]*(LL)b[i]));
    //cerr<<i<<" "<<v[i].second<<endl;
  }
  sort(ALL(v),[&](pair<int,LL> p1,pair<int,LL> p2){return p1.second > p2.second;});
  LL lb=0,ub=10000000001;
  while(lb<ub){
    LL mid = (lb+ub)/2;
    if(ok(mid)){
      ub = mid;
    }else{
      lb = mid+1;
    }
  }
  cout<<lb<<endl;
  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;




ll mod=1e9+7;
ll dp[2000+4];

vector<pair<ll,ll>>p;

vector<ll> to[100005];
ll inf =1000000007;
int main()
{
  ll n,m,x;
  cin>>n>>m>>x;
  vector<ll>c(n);
  vector<vector<ll>>a(n,vector<ll>(m));
  rep(i,n){
      cin>>c[i];
      rep(j,m)cin>>a[i][j];
  }
  ll ans=1000000007;
  rep(i,1<<n){
      vector<ll>skill(m,0);
      ll sum=0;
      for(ll ii=0;ii<n;ii++){
          if(i>>ii&1){
            sum+=c[ii];
            rep(j,m)skill[j]+=a[ii][j];
          }
      }
      ll ok=1;
      rep(i,m){
          if(skill[i]<x)ok=0;
      }
      if(ok)ans=min(ans,sum);
  }
  if(ans==1000000007){
      cout<<-1<<endl;
      return 0;
  }
  cout<<ans<<endl;
 }

 


 

 




Measured memory_bytes: 5948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    bool judge = false;
    if (S[0] == S[1]) judge = true;
    if (S[1] == S[2]) judge = true;
    if (S[2] == S[3]) judge = true;
    if (judge) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m,k=map(int, readline().rstrip().split())
    aa=list(map(int, readline().rstrip().split()))
    bb=list(map(int, readline().rstrip().split()))
    asum=[0]*n
    bsum=[0]*m
    asum[0]=aa[0]
    bsum[0]=bb[0]
    mp=n-1
    ans=0
    for i in range(1,n):
        asum[i]=(aa[i]+asum[i-1])
    for i in range(1,m):
        bsum[i]=(bb[i]+bsum[i-1])

    for i in range(m+1):
        if i==0:
            x=0
        else:
            x = bsum[i-1]
        while mp>=0:
            if asum[mp]+x <= k:
                break
            else:
                mp-=1
        if mp>=0:
            if asum[mp]+x <= k:
                ans = max(i + mp+1,ans)
        else:
            if x <= k:
                ans = max(i,ans)
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 54640
#include <iostream>
#include <cstdio>
using namespace std;

typedef struct{
  int x,y;
} position;

int main(){
  int x;
  for(;;){
    cin >> x;
    if(x==0)break;
    position p[x+1];
    p[0].x=0;
    p[0].y=0;
    int l=0,b=0,r=0,t=0;
    int n,d;
    for(int i = 1;i<x;++i){
      cin >> n >> d;
      switch(d){
      case 0 : p[i].x=p[n].x-1; p[i].y=p[n].y; if(p[i].x<l)l=p[i].x; break;
      case 1 : p[i].x=p[n].x; p[i].y=p[n].y-1; if(p[i].y<b)b=p[i].y; break;
      case 2 : p[i].x=p[n].x+1; p[i].y=p[n].y; if(p[i].x>r)r=p[i].x; break;
      case 3 : p[i].x=p[n].x; p[i].y=p[n].y+1; if(p[i].y>t)t=p[i].y; break;
      }
    }
    printf("%d %d\n",r-l+1,t-b+1);
  }
}

Measured memory_bytes: 1144
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>

using namespace std;

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

    int A;scanf("%d",&A);
    int B;scanf("%d",&B);
    int C;scanf("%d",&C);
    int X;scanf("%d",&X);
    int count=0;

    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(500*i+100*j+50*k==X){
                    count++;
                }
            }
        }
    }

    printf("%d",count);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ull mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

vi Z_Algorithm(string s){
	int S=s.size();
	vi A(S);
	A[0]=S;
	int i=1,j=0;
	while(i<S){
		while(i+j<S&&s[j]==s[i+j]) j++;
		A[i]=j;
		if(!j){
			i++;
			continue;
		}
		int k=1;
		while(i+k<S&&k+A[k]<j){
			A[i+k]=A[k];
			k++;
		}
		i+=k;j-=k;
	}
	return A;
}

int n;
string s;

vi f(){
	vi a(n,1),z=Z_Algorithm(s);
	for(int i=1;i<n;i++){
		for(int j=1;j<=z[i]/i;j++) a[(j+1)*i-1]=0;
	}
	reverse(s.begin(),s.end());
	return a;
}

int main(){
	cin>>s;
	n=s.size();
	bool B=1;
	for(int i=1;i<n;i++) if(s[0]!=s[i]) B=0;
	if(B){
		cout<<n<<endl<<1<<endl;
		return 0;
	}
	vi l=f(),r=f();
	if(l[n-1]) cout<<1<<endl<<1<<endl;
	else{
		int t=0;
		for(int i=0;i<n-1;i++) t+=l[i]*r[n-i-2];
		cout<<2<<endl<<t<<endl;
	}
}

Measured memory_bytes: 7036
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ull unsigned long long 
#define int long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;
#define ordered_set tree<pair<int, int>, null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>
 
 
 
int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 
 
int gcd (int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int ceiling(int a,int b){
  if(a%b!=0){
    return (a/b)+1;

  }
  else
    return (a/b);
}
 

 void solve()
 {
  int n;
  cin>>n;
  if(n<=1000){
    cout<<1000-n<<endl;
  }

  if(n>1000){
    cout<<(ceiling(n,1000))*1000-(n)<<endl;
  }


  return;
 }


 int32_t main()
 {
  int t;
  t=1;
  while(t--){
    solve();
  }
  return 0;
 }


Measured memory_bytes: 3580
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


m,k = map(int, input().split())
if k>=2**m:
    ans = -1
elif m==0:
    ans = "0 0"
elif m==1:
    if k==1:
        ans = -1
    else:
        ans = "0 1 1 0"
else:
    ans = list(range(2**m)) 
    ans1 = ans[:k] + ans[k+1:] + [k]
    ans2 = [k] + ans[:k] + ans[k+1:]
    ans = ans1 + ans2[::-1]
    ans = " ".join(map(str, ans))
print(ans)

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

int main(){
int n;
long long a;
long long minValue = 1000000;
long long maxValue = -1000000;
long long sum = 0;

cin >> n;

for ( int i = 0; i < n; i++ ){
cin >> a;
if( a < minValue ) minValue = a;
if( a > maxValue ) maxValue = a;
sum += a;
}

cout << minValue << " " << maxValue << " " << sum << endl;

return 0;
}


Measured memory_bytes: 3112
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int m;
    cin >> n >> m;
    vector<string> M(n);
    for (int i = 0; i < n; ++i) {
        cin >> M[i];
    }

    vector<vector<vector<int>>> cnts(4, vector<vector<int>>(n + 2, vector<int>(m + 2, 0)));

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (M[i][j] == '.') {
                cnts[0][i + 1][j + 1] = 1 + cnts[0][i + 1][j];
            }
        }
        for (int j = m - 1; j >= 0; --j) {
            if (M[i][j] == '.') {
                cnts[1][i + 1][j + 1] = 1 + cnts[1][i + 1][j + 1 + 1];
            }
        }
    }

    for (int j = 0; j < m; ++j) {
        for (int i = 0; i < n; ++i) {
            if (M[i][j] == '.') {
                cnts[2][i + 1][j + 1] = 1 + cnts[2][i][j + 1];
            }
        }
        for (int i = n - 1; i >= 0; --i) {
            if (M[i][j] == '.') {
                cnts[3][i + 1][j + 1] = 1 + cnts[3][i + 1 + 1][j + 1];
            }
        }
    }

    int res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (M[i][j] == '.') {
                int cnt = 0;
                for (int k = 0; k < 4; ++k) {
                    cnt += cnts[k][i + 1][j + 1];
                }
                cnt -= 3;
                res = max(res, cnt);
            }
        }
    }

    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 83200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOZ
{
	class MainClass
	{
		static void Main(string[] args)
		{
			while (true)
			{
				var input = Console.ReadLine();
				if (input == "0 0")
					break;
				var arr_input = input.Split(' ').Select(int.Parse).ToArray();
				var n = arr_input[0]; var x = arr_input[1];
				var ans_cnt = 0;
				for (int i = 1; i <= n; i++)
					for (int j = i + 1; j <= n; j++)
						for (int k = j + 1; k <= n; k++)
						{
							var sum = i + j + k;
							if (sum == x) { ans_cnt++; /*Console.WriteLine(i.ToString()+" "+j.ToString()+" "+k.ToString());*/k = n; }
							else if (sum > x) { k = n; }
						}
				Console.WriteLine(ans_cnt);
			}
		}
	}
}



Measured memory_bytes: 18360
n=int(input())
l=list(map(int, input().split()))
inf=10**12
dp=[inf]*n
dp[0]=0
dp[1]=abs(l[0]-l[1])
for i in range(n-2):
	dp[i+2]=min(dp[i]+abs(l[i+2]-l[i]),dp[i+1]+abs(l[i+2]-l[i+1]))
print(dp[-1])

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

int main(void) {
    long long N, D;
    cin >> N >> D;
    D *= D;
    vector< long long > X(N), Y(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (X[i] * X[i] + Y[i] * Y[i] <= D) {
            ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int N = (int)S.size();
    vector<int> s(26), t(26);
    for (int i = 0; i < N; i++) {
        s[S[i] - 'a']++;
        t[T[i] - 'a']++;
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    for (int i = 0; i < 26; i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct UnionFind {
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        // initialize
        let mut v: Vec<usize> = vec![];
        for i in 0..n + 1 {
            v.push(i)
        }
        let mut s: Vec<usize> = vec![1; n + 1];

        UnionFind { parent: v, size: s }
    }

    fn root(&self, x: usize) -> usize {
        if self.parent[x] == x {
            return x;
        } else {
            return self.root(self.parent[x]);
        }
    }

    fn size(&self, a: usize) -> usize {
        let ra = self.root(a);
        self.size[ra]
    }

    fn unite(&mut self, a: usize, b: usize) {
        let mut ra = self.root(a);
        let mut rb = self.root(b);
        if ra == rb {
            return;
        }
        if self.size[ra] < self.size[rb] {
            std::mem::swap(&mut ra, &mut rb)
        };
        self.size[ra] += self.size[rb];
        self.parent[rb] = ra;
    }

    fn same(&self, a: usize, b: usize) -> bool {
        let ra = self.root(a);
        let rb = self.root(b);
        self.parent[a] == self.parent[b]
    }
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut edges: Vec<(usize, usize)> = vec![];
    let mut ans = 0;

    for _ in 0..m {
        let a: usize = read();
        let b: usize = read();
        edges.push((a, b))
    }

    for i in 0..m {
        let mut uf = UnionFind::new(n);
        for j in 0..m {
            let mi = edges[j];
            if i == j {
                continue;
            }
            uf.unite(mi.0, mi.1)
        }
        if uf.size(1) == n {
            ans += 1;
        }
    }
    println!("{}", m - ans);
}


Measured memory_bytes: 2160
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

template <typename T>
T lcm(T a, T b){ return (a/gcd(a, b))*b; }

int main()
{   
    i64 x,y;
    cin >> x >> y;

    int cnt = 1;
    i64 z0 = 1;
    i64 z1 = x;

    while(z1<=y)
    {
        i64 tmp = lcm(z0,z1);
        z0 = z1;
        if(tmp==z1)
            z1 = z1*2;
        else
            z1 = tmp;
      
        if(z1>y) break;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

N, K = map(int, input().split())
*A, = map(int, input().split())
A_pos = list(map(lambda x: max(x, 0), A))
A_pos_cumsum = [0] + list(accumulate(A_pos))
ans = -float('inf')
S = sum(A[0: K])
for i in range(N - K + 1):
    ans = max(ans, max(S, 0) + A_pos_cumsum[i] + (A_pos_cumsum[-1] - A_pos_cumsum[i+K]))
    S = S - A[i] + A[i+K] if i < N - K else 0
print(ans)

Measured memory_bytes: 14528
x = int(input())
ans = 1
if x == 1:
  print(ans)
  exit()
for i in range(x//2):
  if i**2 <= x < (i+1)**2:
    ans = i**2
    break
    
for i in range(3,10):
  for j in range(ans):
    if ans < j**i <= x:
      ans = j**i
      
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int a[10];
	for (int i = 0; i < 10; i++)
	{
		cin>>a[i];
	}
	sort(a,a+10);
	for (int i = 0; i < 3; i++)
	{
		printf("%d\n",a[9-i]);
	}
	return 0;
}

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

void solve()
{
    string n;
    cin>>n;
    for(int i=0;i<n.length();i++)
    {
        if(n[i]=='7')
        {cout<<"Yes"<<endl;return;}
    }
    cout<<"No"<<endl;
}

int main()
{
    int t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long H,count = 0,sum = 1,ans= 0;
    cin >> H;
    while(1){
        if(H == 1)break;
        H /= 2;
        count++;
    }
    for (int i = 0; i < count; i++){
        ans += sum;
        sum *= 2;
    }
    ans += sum;
    cout << ans << endl;
}
    

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

n = ini()
if n%10 == 3:
    print("bon")
elif n%10 in [0, 1, 6, 8]:
    print("pon")
else:
    print("hon")

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

bool isColorful(string s){
    bool f[128] = {};
    for( auto c : s ) {
        if (f[c]) { return false; }
        f[c] = true;
    }
    return true;
}
int main() {
    string s;
    cin >> s;
    string ans = "~";
    for(int i = 0 ; i <= s.size() ; i++){
        for(int j = 0 ; j < 26 ; j++){
            string t = s.substr(0, i) + string(1, j + 'a');
            if( isColorful(t) && t > s ){
                ans = min(t, ans);
            }
        }
    }
    if( ans == "~") cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 384