akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;



int main(){
    fast_io
    
    ll h, w;
    cin>>h>>w;
    ll ans=0;

    if(h%2==0) ans=w*h/2;
    else ans=(w*h+1)/2;
    if(h==1||w==1) ans=1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author rahdirigs
 */

#include <bits/stdc++.h>


template <typename T> void s_min(T& a, T b) {
	if (a > b) {
		a = b;
	}
}

using namespace std;

typedef long long ll;

const ll INF = 1e18;

class TaskB {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, k;
		in >> n >> k;
		vector<int> h(n);
		for (int i = 0; i < n; i++) in >> h[i];
		vector<ll> dp(n, 0);
		for (int i = 1; i < n; i++) {
			dp[i] = INF;
			for (int j = 1; j <= min(k, i); j++) {
				s_min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
			}
		}
		out << dp[n - 1];
	}
};


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	TaskB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {

	int a, b;

	cin >> a >> b;

	if (a < b) {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
	}
	else {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
	}

}

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

int main() {
    vector<string> s(3); cin >> s[0] >> s[1] >> s[2];
    int a = 0; int b = 0; int c = 0;
    int n = 0;
    char now;
    bool flag = 1;
    while(flag) {
        switch (n) {
        case 0:
            a++;
            if(a==s[0].length()+1) {
                cout << 'A' << endl;
                return 0;
            }
            now = s[n][a-1];
            break;
        case 1:
            b ++;
            if(b==s[1].length()+1) {
                cout << 'B' << endl;
                return 0;
            }
            now = s[n][b-1];
            break;
        case 2:
            c++;
            if(c==s[2].length()+1) {
                cout << 'C' << endl;
                return 0;
            }
            now = s[n][c-1];
            break;
        }
        switch (now) {
        case 'a':
            n=0;
            break;
        case 'b':
            n=1;
            break;
        case 'c':
            n=2;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;


int main(){


	int a, b; std::cin >> a >> b;
	int ans = a;
	if(a > b)ans--;
	std::cout << ans;

	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    int i;
    int count = 0;
    scanf("%d",&n);
    
    for (i = 0; i <= n; i++)
    {
        count = count + i;
    }

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


    return 0;
}




Measured memory_bytes: 128
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}


void func(void)
{
//DEBUG_OUT("----\n");
    string S;
    cin >> S;

    bool list[26] = {0};
    for(int32 i=0; i<S.length(); i++){
        list[ S[i] - 'a' ] = true;
    }

    bool isNone = true;
    for(int32 i=0; i<26; i++){
        if(list[i] == false){
            cout << (char)('a' + i) << endl;
            return;
        }
    }

    cout << "None" << endl;

    return;
}



Measured memory_bytes: 512
n = int(input())
a = map(lambda x:int(x), input().split())

s = 1
ten18 = 10**18
over = False

for b in a:
  if not over:
    s *= b
  if s > ten18:
    #print(-1)
    over = True
  if b == 0:
    s = 0
    over = False
    break
  
if over:
  print(-1)
else:
  print(s)


Measured memory_bytes: 19276
#include <iostream>
using namespace std;
const int MAX_N = 200;
int yakusu[201];
int main(void){
    int N;
    cin >> N;
    for(int i=1;i<=MAX_N;i++){
        for(int j=i;j<=MAX_N;j+=i){
            yakusu[j]++;
        }
    }
    int ans = 0;
    for(int i=1;i<=N;i++){
        if(yakusu[i] == 8 && i % 2 == 1){
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int a[10005], b[10005];
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
	long long sum = 0;
	for(int i = 1; i <= n; i++)
	{
		if(b[i] > a[i]) {
			sum = sum + (b[i] - a[i]) / 2;
		}
		else if(b[i] < a[i]) {
			sum = sum - (a[i] - b[i]);
		}
	}
	if(sum >= 0) {
		printf("Yes\n");
	}
	else printf("No\n");
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

p = nas()
a = int(p[0])
b = int(p[2])
if p[1] == '+':
    print(a + b)
else:
    print(a - b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    vector<ll> a(n);
    map<ll,ll> mpp;
    ll o=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mpp[a[i]]++;
        if(a[i]==1)
            o=1;
    }
    if(o==1){
        if(mpp[1]==1)
            cout<<1;
        else
            cout<<0;
        return 0;
    }
    sort(a.begin(),a.end());
    set<ll> s;
    ll ans=0;
    for(ll i=0;i<n;i++){
        bool ok=true;
        if(mpp[a[i]]>1){
            s.insert(a[i]);
            continue;
        }
        for(ll j=2;j*j<=a[i];j++){
            if(a[i]%j==0){
                if(s.find(j)!=s.end()){
                    ok=false;
                    break;
                }
                if(j*j!=a[i]){
                    if(s.find(a[i]/j)!=s.end()){
                        ok=false;
                        break;
                    }
                }
            }
        }
        if(ok) ans++;
        s.insert(a[i]);
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 26700
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}


int main(void) {

	int n;
	cin >> n;

	int bef_h = 0, answer = 0, count = 0;

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

		if (bef_h >= h)
			count++;
		else
			count = 0;

		answer = max(answer, count);

		bef_h = h;
	}

	cout << answer << endl;


	return 0;
}

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

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

    int n;
    cin >> n;
    
    int nt = 0, nx = 0, ny = 0;
    bool f = true;
    REP(i, n){
        int t, x, y;
        cin >> t >> x >> y;
        int dt, dx, dy;
        dt = t - nt;
        dx = abs(x - nx);
        dy = abs(y - ny);
        if(dt < dx + dy) f = false;
        if(dt % 2 != (dx + dy) % 2) f = false;
        
        nt = t, nx = x, ny = y;
    }

    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

long[9] cost = [2, 5, 5, 4, 5, 6, 3, 7, 6];
bool[9] canuse;
void main()
{
    long N, M;
    scan(N, M);
    auto A = aryread();
    foreach (a; A)
        canuse[a - 1] = true;
    foreach (i; 0 .. 9)
        foreach (j; 0 .. i)
            if (canuse[i] && cost[i] == cost[j])
                canuse[j] = false;

    auto dp = new long[](N + 6);
    dp[] = long.min;
    dp[0] = 0;
    foreach (i; 0 .. N)
        foreach (j; 0 .. 9)
            if (canuse[j])
            {
                dp[i + cost[j]].maxAssign(dp[i] + 1);
            }

    string s;
    long tmp = N;
    loop: foreach (_; 0 .. dp[N])
        foreach_reverse (j; 0 .. 9)
            if (canuse[j] && cost[j] <= tmp && dp[tmp - cost[j]] + 1 == dp[tmp])
            {
                tmp -= cost[j];
                s ~= '1' + j;
                continue loop;
            }
    writeln(s);
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()

using ll = long long;
constexpr ll INF = 1000000000;

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; }

using namespace std;

//fixed << setprecision(10)

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

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

	int sum = a + b + c;
	if (sum > 21) cout << "bust" << endl;
	else cout << "win" << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static public void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int g = scan.nextInt();
        int b = scan.nextInt();
        scan.close();

        int target = 100 * r + 10 * g + b;
        if (target % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(){
int H, W, i, j;
for (;;){
scanf("%d %d", &H, &W);
if (H == 0 && W == 0 ) break;
for ( i = 1; i < H+1; i++ ){
for ( j = 1; j < W+1; j++)
putchar('#');
putchar('\n');
}
printf("\n");
}
return 0;
}



Measured memory_bytes: 2104
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int h,w,k;
char mp[10][10];
bool check(int r,int c){
    int sum = 0;
    for(int i = 0;i < h; ++i){
        for(int j = 0;j < w; ++j){
            if(((1<<i)&r)||((1<<j)&c)) continue;
            if(mp[i][j] == '#') sum++;
        }
    }
    return sum == k;
}
int main(){
    scanf("%d %d %d",&h,&w,&k); int ans = 0;
    for(int i = 0;i < h; ++i) scanf("%s",mp[i]);
    for(int i = 0;i < (1<<h); ++i){
        for(int j = 0;j < (1<<w); ++j){
            if(check(i,j)) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for( i=a;i<b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const ll MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false);

    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> p(n);
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        p[i]=make_pair(a,b);
    }
    sort(p.begin(),p.end());
    ll ans;
    rep(i,n) {
        if (p[i].second>=k) {
            ans=p[i].first;
            break;
        }
        k-=p[i].second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repk(i,k,n) for (int i = k; i <= (int)(n); i++)
#define MAX 10000
typedef long long ll;

using namespace std;

int cnt;

int main(){
    int A,B;
    cin >> A >> B;

    cnt=1;
    int ans=0;

    while(1){
        if(cnt>=B) break;
        ans++;
        cnt += A-1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
/*
2020-05-03
atcoder ABC
*/

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    ull X;
    cin >> X;

    // ull a, b;
    // a = pow(X, 5);
    // b = pow(Y, 5);
    // ull ans = a - b;
    // cout << ans << endl;

    for(int i = 0; i < 178; i++){
        for(int j = 0; j < 178; j++){
            ull a, b, d, e;
            a = pow(i, 5);
            b = pow(j, 5);
            d = a - b;
            e = a + b;
            if((a - b) == X){
                cout << i << " " << j << endl;
                return 0;
            } else if((a + b) == X){
                cout << i << " -" << j << endl;
                return 0;

            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3932
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int a = fs.nextInt();
        int b = fs.nextInt();

        if (n * a < b) {
            System.out.println(n * a);
        } else {
            System.out.println(b);
        }

    }
}


Measured memory_bytes: 81876
#include<stdio.h>
int main() {
	int h, w,xxx=0;
	char a[110][110] = {};
	int retu[110] = {}, gyou[110] = {};
	scanf("%d%d", &h, &w);
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			scanf(" %c", &a[j][i]);
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (a[j][i] == '#') { goto next; }
		}
		gyou[i] = 1;
		next:
        xxx++;
	}
	for (int i = 1; i <= w; i++) {
		for (int j = 1; j <= h; j++) {
			if (a[i][j] == '#') { goto next2; }
		}
		retu[i] = 1;
	next2:
      xxx++;
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (gyou[i] == 0 && retu[j] ==0 ) { printf("%c",a[j][i] ); }
		}
		if(gyou[i]==0)printf("\n");
	}
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int n,k;
int x[100000];
int length[100000];

int qsort_comp(const void* x,const void* y) {
	int* a=(int*)x;
	int* b=(int*)y;
	if(*a<*b)return 1;
	if(*a>*b)return -1;
	return 0;
}

int main(void) {
	int d_num,cur_d;
	int i,sum;
	scanf("%d",&d_num);
	for(cur_d=0;cur_d<d_num;cur_d++) {
		scanf("%d%d",&n,&k);
		for(i=0;i<n;i++)scanf("%d",&x[i]);
		for(i=0;i<n-1;i++)length[i]=x[i+1]-x[i];
		qsort(length,n-1,sizeof(int),qsort_comp);
		sum=0;
		for(i=k-1;i<n-1;i++)sum+=length[i];
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
void die(string s) { cout << s << endl; exit(0); }
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int H, N; cin >> H >> N;
	vector<int>A(N);
	int sum = 0;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum >= H)print("Yes");
	else print("No");
}


signed main() {
	solve();
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()

using ll = long long;
constexpr ll INF = 1000000000;

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; }

using namespace std;

//fixed << setprecision(10)

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

int main() {
	ll a, b, x; cin >> a >> b >> x;

	if (x >= a + b) {
		cout << 0 << ' ' << 0 << endl;
		return 0;
	}

	if (a - x > 0) {
		cout << a - x << ' ' << b << endl;
	}
	else {
		cout << 0 << ' ' << b - (x - a) << endl;
	}
}



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

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

    string t = "";
    int cnt = 1;

    reverse(s.begin(),s.end());
    bool can = true;

    for(int i; i < s.size(); i++){
        t += s.at(i);
        for(int j = 0; j < 4; j++)
        {
            string d[4] = {"dream","dreamer","erase","eraser"};
            reverse(d[j].begin(),d[j].end());
            
            if(t == d[j]){
                can = true;
                t = "";
                break;
            } else{
                can = false;
            }
        }
    }
    if(can == true){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}
 


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

a,b,h,m = MI()
min = 60*h+m
pi = math.pi
c = pi/30
d  = pi/360
jisin = (a*math.cos(min*c),a*math.sin(min*c))
hunsin = (b*math.cos(min*d),b*math.sin(min*d))
ans = (jisin[0]-hunsin[0])**2+(jisin[1]-hunsin[1])**2
print(ans**0.5)


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

int main() {
  int A1, A2, A3;
  scanf("%d%d%d", &A1, &A2, &A3);
  if (A1 + A2 + A3 >= 22)
    printf("bust");
  else
    printf("win");
  return 0;
}


Measured memory_bytes: 256
import math

a,b,h,m = map(int,input().split())

rad_a = (h/12+ (1/12) * (m/60))*360
rad_b = (m/60)*360

if rad_a == rad_b:
    print(abs(b-a))
elif abs(rad_a - rad_b) == 180:
    print(b+a)
else:
    print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(abs(rad_a-rad_b)))))

Measured memory_bytes: 9580
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
int dp[100000+5];
void solve(int k){
    int y = v[upper_bound(v.begin(), v.end(), k)-v.begin()-1];
    if(k-y<v[0]) {cout << "First"; exit(0);}

}
int main(){
    int n, k, x;
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    for(int i=1; i<=k; i++){
        for(int j=0; j<v.size(); j++){
                if(i-v[j]<0) break;
            if(dp[i-v[j]]==0) {dp[i] = 1; break;}
        }
    }
    if(dp[k]==1) cout <<  "First";
    else cout << "Second";
return 0;
}


Measured memory_bytes: 3960
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define NMAX 1000005

void solve()
{
	ll n;
	cin >> n;
	vector<bool> isdiv(NMAX, false);
	map<ll, ll> mp;
	vll arr(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> arr[i];
		mp[arr[i]]++;
	}
	sort(arr.begin(), arr.end());
    ll out = 0;
	for (ll i = 0; i < n; i++)
	{
		if (isdiv[arr[i]] == false)
		{
			ll j = 2 * arr[i];
			for (; j < NMAX; j += arr[i])
			{
				isdiv[j]  = true;
			}
          	if (mp[arr[i]] == 1)
            {
              out++;
            }
            isdiv[arr[i]]  = true;
		}
	}
	cout << out << "\n";
}


int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

	return 0;
}


Measured memory_bytes: 17416
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int add(string a,string b){//a+b
	int t=min(a.size(),b.size());
	for(int i=t;i>=0;i--){
		bool h=true;
		rep(j,i)if(a[a.size()-i+j]!=b[j])h=false;
		if(h)return b.size()-i;
	}
}
int main(){
	int n;
	while(cin>>n,n){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		sort(all(in));
		n=unique(all(in))-in.begin();
		vector<bool>ha(n,true);
		rep(i,n)rep(j,n)if(i!=j&&in[i].find(in[j])!=string::npos)ha[j]=false;
		vector<string>tmp;
		rep(i,n)if(ha[i])tmp.pb(in[i]);
		in=tmp;n=in.size();
		sort(all(in));
		vvi c(n,vi(n));
		rep(i,n)rep(j,n)c[i][j]=add(in[i],in[j]);
		vvi dp(1<<n,vi(n,inf));
		rep(i,n)dp[1<<i][i]=in[i].size();
		loop(i,1,1<<n)rep(j,n)if(i&1<<j)rep(k,n)if((i&1<<k)==0){
			int t=i^1<<k;
			dp[t][k]=min(dp[t][k],dp[i][j]+c[j][k]);
		}
		int w=(1<<n)-1;
		int out=inf;
		rep(i,n)out=min(out,dp[w][i]);
		cout<<out<<endl;
	}
}

Measured memory_bytes: 2588
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer K = scan.nextInt();
        Integer X = scan.nextInt();
 
        for(int i = X-K+1 ; i < X+K ; i++) 
            System.out.print(i + " ");
    }
}


Measured memory_bytes: 21844
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	static class StringPair {
		final String a, b;

		StringPair(String a, String b) {
			this.a = a;
			this.b = b;
		}

		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + ((a == null) ? 0 : a.hashCode());
			result = prime * result + ((b == null) ? 0 : b.hashCode());
			return result;
		}

		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			StringPair other = (StringPair) obj;
			if (a == null) {
				if (other.a != null)
					return false;
			} else if (!a.equals(other.a))
				return false;
			if (b == null) {
				if (other.b != null)
					return false;
			} else if (!b.equals(other.b))
				return false;
			return true;
		}
	}

	static int n;
	static String s;
	static StringBuilder sbA, sbB;
	static Map<StringPair, Integer> cnts;
	static long ans;

	static void solve() throws Exception {
		n = scanInt();
		s = scanString();
		sbA = new StringBuilder();
		sbB = new StringBuilder();
		cnts = new HashMap<>();
		go1(0);
		ans = 0;
		go2(2 * n);
		out.print(ans);
	}

	static void go1(int i) {
		if (i == n) {
			StringPair key = new StringPair(sbA.toString(), sbB.toString());
			Integer val = cnts.get(key);
			val = val == null ? 1 : val + 1;
			cnts.put(key, val);
		} else {
			char c = s.charAt(i);
			sbA.append(c);
			go1(i + 1);
			sbA.setLength(sbA.length() - 1);
			sbB.append(c);
			go1(i + 1);
			sbB.setLength(sbB.length() - 1);
		}
	}

	static void go2(int i) {
		if (i == n) {
			StringPair key = new StringPair(sbA.toString(), sbB.toString());
			Integer val = cnts.get(key);
			if (val != null) {
				ans += val;
			}
		} else {
			char c = s.charAt(--i);
			sbA.append(c);
			go2(i);
			sbA.setLength(sbA.length() - 1);
			sbB.append(c);
			go2(i);
			sbB.setLength(sbB.length() - 1);
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 140828
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    string s;
    
    cin >> s;
    
    for (int i = 0; i < 4; i++) cout << s[i];
    cout << " ";
    for (int i = 4; i < 12; i++) cout << s[i];
    cout << endl;
}

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

#define vvi vector<vector<int>>
#define V 100010
#define ll long long int

vvi to(V*2);
vector<bool> visited(V*2);
vector<int> cnt(2);

void dfs(int v) {
    if (visited[v]) return;
    visited[v] = true;
    cnt[v/V]++;
    for (int u : to[v]) {
        dfs(u);
    }
}

int main() {

    int N;
    cin >> N;

    int x, y;
    for (int i = 0; i < N; i++) {
        cin >> x >> y;
        y += V;
        to[x].push_back(y);
        to[y].push_back(x);
    }

    ll ans = 0;
    for (int i = 0; i < V * 2; i++) {
        if (visited[i]) continue;
        cnt = vector<int>(2);
        dfs(i);
        ans += (ll)cnt[0]*cnt[1];
    }

    cout << ans - N << endl;

    return 0;
}


Measured memory_bytes: 9984
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {
	long double a, b, c;
	cin >> a >> b >> c;
	long double mon = c / a;

	long double mon2 = (2 * mon) / b;

	if (mon2 <= a) {
		cout << setprecision(20) << atan2(b, mon2) * (180 / pi) << endl;
	}
	else {
		long double mon3 = (2 * mon) / a - b;

		cout << setprecision(20) << atan2(b - mon3, a) * (180 / pi) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int main() {
	int N; cin >> N;
	priority_queue<double> q;
	rep(i, N) {
		double v; cin >> v;
		q.push(-v);
	}
	for (int i = 0; i < N-1; i++) {
		double t = q.top(); t = -t; q.pop();
		double s = q.top(); s = -s; q.pop();
		q.push(-(s+t)/2);
	}
	double ans = q.top(); cout << setprecision(15) << -ans << endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    long long int n,k; cin>>n>>k;
    if(n>=k) n%=k;
    cout<<min(n,k-n)<<"\n";
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = n - 1; i < (int)n; --i)
#define FOR(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define RFOR(i, l, r) for (int i = (int)(r); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

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

    ll idx = -1, ans = 0;
    vector<set<int>> data(26);
    for (int i = 0; i < s.size(); i++) data[s[i] - 'a'].insert(i);
    for (auto ch: t) if (data[ch - 'a'].size() == 0) {
        cout << -1 << endl;
        return 0;
    } else {
        auto it = data[ch - 'a'].upper_bound(idx);
        if (it == data[ch - 'a'].end()) {
            ans += s.size(); idx = -1;
            it = data[ch - 'a'].upper_bound(idx);
        }
        idx = (*it);
    }

    cout << ans + idx + 1 << endl;
    return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

	map<ll, ll> cnt;
	vector<ll> sums(N);
	for (int i = 0; i < N; i++) {
		ll a;
		cin >> a;
		if (i == 0) sums[0] = a;
		else sums[i] = sums[i - 1] + a;

		cnt[sums[i]]++;
	}

	ll ans = 0;
	for (auto x : cnt) {
		//cout << x.first << " " << x.second << endl;
		if (x.first == 0) ans += x.second;
		ans += (x.second) * (x.second - 1) / 2;
	}

	cout << ans << endl;
}



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

using namespace std;

int main()
{
	int N = 0;
	int A = 0;
	int B = 0;
	int taxi = 0;
	int train = 0;
	cin >> N >> A >> B;
	taxi = N * A;
	train = B;
	
	int result = min(taxi, train);
	cout << result;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int n = s.size();
    string ans = s.substr(0,n-8);
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <limits>
#include <vector>

int main()
{
    int N, T;
    std::cin >> N >> T;
    std::vector<int> cs;
    std::vector<int> ts;
    for (int i = 0; i < N; i++) {
        int c, t;
        std::cin >> c >> t;
        cs.emplace_back(c);
        ts.emplace_back(t);
    }
    bool tle = true;
    int min = std::numeric_limits<int>::max();
    for (int i = 0; i < N; i++) {
        int t = ts.at(i);
        int c = cs.at(i);
        if (t <= T) {
            tle = false;
            if (min > c) {
                min = c;
            }
        }
    }
    if (tle) {
        std::cout << "TLE" << std::endl;
    } else {
        std::cout << min << std::endl;
    }
    return 0;
}

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

const long long N = 400100;
const long long MOD = 1000000007;

long long n, m, s, t;
long long a[N], b[N], d[N];
vector<pair<long long, long long> > v[N];
long long dm1[N], dm2[N], n1[N], n2[N];
set<pair<long long, long long> > q;

void calcd(long long s, long long *d, long long *nr) {
    q.insert(pair<long long, long long>(0, s));
    nr[s] = 1;

    while(!q.empty()) {
        long long dis = q.begin()->first, x = q.begin()->second;
        q.erase(q.begin());

        if(dis > d[x])
            continue;

        for(auto it : v[x]) {
            long long nd = dis + it.second, el = it.first;

            if(nd == d[el]) {
                nr[el] = (nr[el] + nr[x]) % MOD;
            }
            if(nd < d[el] || !nr[el]) {
                nr[el] = nr[x];
                d[el] = nd;

                q.insert(pair<long long, long long>(nd, el));
            }
        }
    }
}

long long check(long long a, long long b, long long d) {
    if(dm1[a] + dm2[b] + d != dm1[t])
        return 0;

    if(dm1[a] + d <= dm2[b])
        return 0;
    if(dm2[b] + d <= dm1[a])
        return 0;

    long long rr = (1LL * n1[a] * n2[b]) % MOD;
    rr = (1LL * rr * n1[a]) % MOD;
    rr = (1LL * rr * n2[b]) % MOD;

    return rr;
}

int main() {
    long long i;
    //freopen("ttt", "r", stdin);

    cin >> n >> m >> s >> t;
    for(i = 1; i <= m; ++i) {
        cin >> a[i] >> b[i] >> d[i];
        v[a[i]].push_back(pair<long long, long long>(b[i], d[i]));
        v[b[i]].push_back(pair<long long, long long>(a[i], d[i]));
    }

    calcd(s, dm1, n1);
    calcd(t, dm2, n2);

    long long nrtot = (1LL * n1[t] * n1[t]) % MOD, nr = 0;

    //long longersetie noduri
    for(i = 1; i <= n; ++i) if(dm1[i] == dm2[i] && dm1[i] + dm2[i] == dm1[t]) {
        long long tt = (1LL * n1[i] * n2[i]) % MOD;
        tt = (tt * n1[i]) % MOD;
        tt = (tt * n2[i]) % MOD;
        nr = (1LL * nr + tt) % MOD;
    }

    //muchii
    for(i = 1; i <= m; ++i) {
        nr = (1LL * nr + check(a[i], b[i], d[i]) + check(b[i], a[i], d[i])) % MOD;
    }

    nrtot = (nrtot - nr + MOD) % MOD;
    cout << nrtot;

    return 0;
}


Measured memory_bytes: 41072
#include <stdio.h>

int main(){

    int a,b,k;
    
    scanf("%d",&k);
	scanf("%d %d",&a ,&b);
	for (int i = a ; i <= b ; i++ ){
		if (i%k == 0){
		
		printf("OK\n");
		return 0;
		}
	else
	{
		continue;
		}
	}
		printf("NG\n");
	

	return 0;
}

Measured memory_bytes: 2056
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(){
  char s[11];
  gets(s,11,0);
  int S[strlen(s)];
  long ans = 0;
  long tmp = 0;
  long tmp2 = 0;
  int k = 0;
  for(int i = 0;i < strlen(s);i++) S[i] = (s[i] - '0');
  for(int i = 0;i < pow(2,strlen(s)-1);i++){
    for(int j = strlen(s)-1 ;j >= 0;j--){
      tmp += S[j] * pow(10,k++);
      if((i>>(strlen(s)-j-1)) & 1){
        tmp2 += tmp;
        k = 0;
        tmp = 0;
      }
    }
    tmp2 += tmp;
    ans += tmp2;
    k = 0;
    tmp = 0;
    tmp2 = 0;
  }
  printf("%ld",ans);
  return 0;
}

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

uint64_t lucas(int n)
{
    vector<uint64_t> luc(87);
    luc.at(0) = 2;
    luc.at(1) = 1;

    for (int i=2; i<87; i++){
        luc.at(i) = luc.at(i-1) + luc.at(i-2);
    }

    return luc.at(n);
}

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

    cout << lucas(n) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
stack<string>st;
queue<string>q;

bool isoperator(char ch)
{
    if(ch>='0'&&ch<='9') return false;
    else return true;
}

int calc(int a,int b,char c)
{
    if(c=='+') return a+b;
    if(c=='-') return a-b;
    if(c=='*') return a*b;
    if(c=='/') return a/b;
}

int main()
{
    int $=1;
    //cin>>$;
    while($--)
    {
        string s;
        while(cin>>s) q.push(s);
        while(!q.empty())
        {
            s=q.front();
            q.pop();
            if(s.size()==1&&isoperator(s[0]))
            {
                string a=st.top();
                st.pop();
                string b=st.top();
                st.pop();
                int res=calc(stoi(b),stoi(a),s[0]);
                s=to_string(res);
                st.push(s);
            }
            else st.push(s);
        }
        cout<<st.top()<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/



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

def cal(a):
  return len(str(a))
m = 11
for i in range(1,6):
  for j in range(1,10**i+1):
    if n%j==0:
      m = min(m,max(cal(j),cal(n//j)))
      # print(m)
print(m)

Measured memory_bytes: 9180
loop do
  m, f, r = gets.split.map(&:to_i)
  break if m == -1 && f == -1 && r == -1

  if m == -1 || f == -1
    puts 'F'
    next
  end

  sum = m + f

  g = case sum
      when 80..100
        'A'
      when 65...80
        'B'
      when 50...65
        'C'
      when 30...50
        r >= 50 ? 'C' : 'D'
      else
        'F'
      end

  puts g
end

Measured memory_bytes: 8604
<?php
    for($i=0;$i<3;$i++){
        $array[] = array_map('intval',explode(" ",trim(fgets(STDIN))));
    }
    
    $line[0] = $array[0];
    $line[1] = $array[1];
    $line[2] = $array[2];
    
    $line[3][0] = $array[0][0];
    $line[3][1] = $array[1][0];
    $line[3][2] = $array[2][0];
    $line[4][0] = $array[0][1];
    $line[4][1] = $array[1][1];
    $line[4][2] = $array[2][1];
    $line[5][0] = $array[0][2];
    $line[5][1] = $array[1][2];
    $line[5][2] = $array[2][2];
    
    $line[6][0] = $array[0][0];
    $line[6][1] = $array[1][1];
    $line[6][2] = $array[2][2];
    
    $line[7][0] = $array[0][2];
    $line[7][1] = $array[1][1];
    $line[7][2] = $array[2][0];
    
    
    while($num = intval(trim(fgets(STDIN)))){
        for($i=0;$i<8;$i++){
            for($j=0;$j<3;$j++){
                if($line[$i][$j] == $num){
                    $line[$i][$j] = 0;
                }
            }
        }
    }
    for($i=0;$i<8;$i++){
        if(array_sum($line[$i]) == 0){
            echo "Yes";
            exit;
        }
    }
    echo "No";
    
?>

Measured memory_bytes: 16220
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("input");
    let ab: Vec<i32> = s.trim().split(' ').map(|x| x.parse().unwrap()).collect();

    println!("{}",
        if ab[0] <= 0 && ab[1] >= 0 {
            "Zero"
        }
        else if ab[0] > 0 {
            "Positive"
        }
        else if (ab[1] - ab[0]) % 2 == 0 {
            "Negative"
        }
        else {
            "Positive"
        }
    );
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  LL n, k;
  cin >> n >> k;

  cout << min(n % k, abs(n % k - k)) << endl;
}


Measured memory_bytes: 256