akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    static PrintWriter out;
    static Scanner sc;

    static void solve() {
        int n = nextInt();

        List<Integer> soutedList = new ArrayList<>();
        List<Integer> originalList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x = nextInt();
            soutedList.add(x);
            originalList.add(x);
        }

        sort(soutedList);

        int left = soutedList.get(n / 2 - 1);
        int right = soutedList.get(n / 2);

        for (int i = 0; i < n; i++) {
            int removedElement = originalList.get(i);
            if (removedElement <= left) {
                out.print(right);
            } else {
                out.print(left);
            }
            out.println();
        }

    }

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

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

    static String nextString() {
        return sc.next();
    }

    static <T extends Comparable<? super T>> void sort(List<T> list) {
        Collections.sort(list);
    }

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        sc = new Scanner(System.in);

        solve();

        out.flush();
        sc.close();
    }

}


Measured memory_bytes: 66880
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
char s[2];
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	scanf( "%s", s ) ;
	if( s[0] >= 'a' && s[0] <= 'z' ) 
		putchar( 'a' ) ;
	else
		putchar( 'A' ) ;
	return 0;
}

Measured memory_bytes: 3656
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


n = inint()

ryuka = [2,1]

for i in range(2,87):
    ryuka.append(ryuka[i-1]+ryuka[i-2])

print(ryuka[n])

Measured memory_bytes: 61484
#include <iostream>
#include <string>
using namespace std;
int S(int A,int B){
	return A*B;}

int main() {
 int A;
 int B;
 int C;
 int D;
 
 
 cin >>A;
 cin >>B;
 cin>>C;
 cin>>D;
 
 if (S(A,B) > S(C,D)){
 	cout << S(A,B) << endl;
 }
 else {
 	cout << S(C,D) <<endl;
 }
 
 	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ll a, b, x, y;
	ll t;

	scanf("%lld", &t);
	a = 1, b = 1;
	while (t--)
	{
		scanf("%lld%lld", &x, &y);
		if (x <= a || y <= b)
		{
// 			ll n;				
// 			n = max((ll)floor(a*1.0 / x + (a%x!=0)), (ll)floor(b*1.0 / y + (b%y!=0)));
// 			a = (ll)n*x,b = (ll)n*y;
			

			ll n = max(a / x + (a%x != 0), b / y + (b%y != 0));
			ll tp1, tp2;
			a = (ll)n*x,b = (ll)n*y;

		}
		else
		{
			a = x, b = y;
		}
	}
	printf("%lld\n", (ll)(a + b));


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	int c = 0;
	while (1)
	{
		cin >> a >> b;
		if (a == 0&&b==0)break;
		if (a>b)
		{
			c = a; a = b; b = c;
		}
		cout <<a<<" "<<b<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
        }

        int r = N - K;
        System.out.println(r / (K - 1) + 1 + (r % (K - 1) != 0 ? 1 : 0));
    }

}


Measured memory_bytes: 51208
#include <stdio.h>
long long a[100001],b[100001];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%lld%lld",a+i,b+i);
	long long add=0;
	for (int i=n;i>=1;--i)
	{
		a[i]+=add;
		add+=(b[i]-a[i]%b[i])%b[i];
	}
	printf("%lld",add);
	return 0;
}


Measured memory_bytes: 1664
#!/usr/bin/env python3
import numpy as np


DEBUG = False
dprint = print if DEBUG else lambda x : x

N, M = [int(str) for str in input().strip().split()]
ps = [[int(str) if str.isdecimal() else str for str in input().strip().split()] for _ in range(M)]

wa_d = dict()
ac_d = dict()
true_count = 0
pena = 0
for i in ps:
    if not i[0] in ac_d:
        if i[1] == 'WA':
            wa_d[i[0]] = wa_d.get(i[0], 0) + 1
        else:
            ac_d[i[0]] = None
            true_count += 1
            pena += wa_d.get(i[0], 0)

print(true_count, pena)

Measured memory_bytes: 41772
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(vec) vec.begin(), vec.end()
typedef long long ll;
typedef long double ld;

// 「上の桁から見る」「配るDP」．模範解答を参考にした．

int main(){
    string S;
    int K;
    cin >> S >> K;
    int L = S.size();

    ll dp[1000][100][2];
    rep(i, L+1) rep(j, K+1) rep(k, 2) dp[i][j][k] == 0;
    dp[0][0][0] = 1;

    rep(i, L) rep(j, K+1) rep(k, 2) rep(l, 10){
        int x = S[i] - '0';
        if(k == 0 && l > x) continue;
        
        int ii, jj, kk;
        ii = i + 1;
        jj = (l == 0) ? j : (j+1);
        kk = (k == 0 && l == x) ? 0 : 1;

        if(jj > K) continue;
        dp[ii][jj][kk] += dp[i][j][k];
    }
    cout << dp[L][K][0] + dp[L][K][1] << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n,d;
    string s, t;
    cin >> n >> d;
    ld x, y;
    i32 cnt = 0;
    rep(i,n) {
        cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }

    cout << cnt << '\n';


    //     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3848
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define MAX 10000

using namespace std;
int N, T;
vector<int> c(MAX), t(MAX);
int ans = 10000 ;


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

	for (int i = 1; i <= N; i++) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			if (c[i] < ans) {
				ans = c[i];
			}
		}
	}

	if (ans == 10000)
		cout << "TLE" << endl;
	else
		cout << ans << endl;


	return 0;
}

Measured memory_bytes: 384
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
	vector<int> x(n), y(n);
	vector<P> ball(n);
	rep(i, n) {
		cin >> x[i] >> y[i];
		if(x[i] < y[i]) swap(x[i], y[i]);
		ball[i] = make_pair(x[i], y[i]);
	}
	sort(all(x));
	sort(all(y));
	int ans = (x[n - 1] - x[0]) * (y[n - 1] - y[0]);
	sort(all(ball));
	int rrange = x[n - 1] - y[0];
	priority_queue<int , vector<int>, greater<int>> pque;
	priority_queue<int> pque2;
	pque.push(ball[n - 1].sc);
	pque2.push(ball[n - 1].sc);
	for(int i = n - 2; i >= 0; --i) {
		int bmax = max(ball[i].fr, pque2.top());
		int bmin = min(ball[0].fr, pque.top());
		chmin(ans, rrange * (bmax - bmin));
		pque.push(ball[i].sc);
		pque2.push(ball[i].sc);
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 9836
#include<iostream>
#define N 100001
using namespace std;

struct Node {
	int p, l, r, sib;
};
Node t[N];

void preparse(int u) {
	if (u<0) return;
	cout << " " << u;
	preparse(t[u].l);
	preparse(t[u].r);
}

void inparse(int u) {
	if (u<0) return;
	inparse(t[u].l);
	cout << " " << u;
	inparse(t[u].r);
}

void postparse(int u) {
	if (u<0) return;
	postparse(t[u].l);
	postparse(t[u].r);
	cout << " " << u;
}

int main() {
	int n, id, c;
	cin >> n;
	for (int i = 0; i<n; i++)t[i].l = -1, t[i].p = -1, t[i].r = -1, t[i].sib = -1;
	for (int i = 0; i<n; i++) {
		cin >> id;
		for (int j = 0; j<2; j++) {
			cin >> c;
			if (c >= 0)t[c].p = id;
			if (j == 0) t[id].l = c;
			else t[id].r = c;
		}
	}

	int root;
	for (int i = 0; i<n; i++) if (t[i].p == -1) root = i;

	cout << "Preorder" << "\n";
	preparse(root);
	cout << "\n";
	cout << "Inorder" << "\n";
	inparse(root);
	cout << "\n";
	cout << "Postorder" << "\n";
	postparse(root);
	cout << "\n";

	return 0;
}

Measured memory_bytes: 3024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int max_value;
  int second_max_value;
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  max_value = max(v.at(0), v.at(1));
  second_max_value = min(v.at(0), v.at(1));
  for (int i = 2; i < n; i++) {
    int x = v.at(i);
    if (max_value <= x) {
      second_max_value = max_value;
      max_value = x;
    } else if (second_max_value < x) {
      second_max_value = x;
    }
  }
  for (int x : v) {
    if (x == max_value) {
      cout << second_max_value << '\n';
    } else {
      cout << max_value << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
			int N = int.Parse(Console.ReadLine());
			var W = new string[N];
			for (int i = 0; i < N; i++)
			{
				W[i] = Console.ReadLine();
                if (i > 0)
				{
					if (W[i][0] != W[i - 1][W[i - 1].Length - 1])
					{
						Console.WriteLine("No");
						return;
					}
				}
			}
			Console.WriteLine(W.Length == W.Distinct().Count() ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

ll conbination(ll a, ll b)
{
    ll ret = 1;
    for (int i = 0; i < b; i++)
    {
        ret *= (a - i);
    }

    for (int i = 0; i < b; i++)
    {
        ret /= (b - i);
    }
    return ret;
}
void solve(long long N, long long K)
{
    ll maxFriend = conbination(N - 1, 2LL);
    if (maxFriend < K)
    {
        cout << -1 << endl;
        return;
    }

    vector<pair<ll, ll>> ans;
    int cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int j = i; j <= N; j++)
        {
            if (i == j)
                continue;
            if (j == N)
            {
                ans.push_back(make_pair(i, j));
            }
            else if (cnt < K)
            {
                cnt++;
            }
            else
            {
                ans.push_back(make_pair(i, j));
            }
        }
    }
    cout << ans.size() << endl;
    for (auto &&i : ans)
    {
        cout << i.first << " " << i.second << endl;
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); long count = 0;
		int[] a = new int[n+1]; int[] b = new int[n];

		for(int i = 0; i < n+1; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		for(int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		for(int i = 0; i < n; i++) {
			if(a[i] >= b[i]) {
				count += b[i];
			}else {
				b[i] -= a[i];
				count += a[i];
				if(a[i+1] > b[i]) {
					a[i+1] -= b[i];
					count += b[i];
				}else {
					count += a[i+1];
					a[i+1] = 0;
				}

			}
		}
		System.out.println(count);

		sc.close();
	}

}

Measured memory_bytes: 50204
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n,a,b = map(int,input().split())

if a%2 == b%2:
    print((b-a)//2)
    sys.exit()
else:
    c = min(a-1,n-b) + 1
    ans = c + (b-a-1)//2
    print(ans)
    sys.exit()

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

bool isPrime(int x) {
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			return false;
		}
	}
	return true;
}
int main()
{
	int n;
	cin >> n;
	for(int i = 2; i <= 55555; i++){
		if(i%5 != 1) continue;
		if(isPrime(i)){
			cout << i << endl;
			n--;
		} 
		if(n == 0) break;
	} 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c <= 21) {
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define two pair<int,int>
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

int main(){
   int x,a; cin>>x>>a;
   if(x >= a) cout<<10<<endl;
   else
   cout<<0<<endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int frower[7][2] = {{0,0},{2,380},{3,550},{5,850},{10,1520},{12,1870},{15,2244}};
  int dp[51] = {0};
  for(int i=1; i<51; i++){dp[i] = 100000;}
  for(int i=0; i<51; i++){
    for(int j=1; j<7; j++){
      if(frower[j][0]<=i){
	dp[i] = min(dp[i],dp[i-frower[j][0]]+frower[j][1]);
      }
    }
  }
  int n;
  while(cin>>n,n){
    cout <<dp[n/100]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
s = list(input())
t = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(t)):
    if s.count(t[i]) == 0:
        print(t[i])
        exit()
print('None')

Measured memory_bytes: 3956
#include<iostream>
#define MOD (1000000000+7)
using namespace std;
typedef long long ll;
ll cm[2500][2500];
ll cmb(ll n,ll m){
  if(n<m)return 0;
  if(cm[n][m])return cm[n][m];
  if(n==m||m==0)return 1;
  if(m==1)return n;
  return cm[n][m]=(cmb(n-1,m-1)+cmb(n-1,m))%MOD;
}
int main(){
  ll n,k;
  cin >> n >> k;
  for(ll i=1;i<=k;i++){
    ll ans;
    ans=(cmb(k-1,i-1)*cmb(n-k+1,i))%MOD;
    cout << ans<<endl;
  }
}


Measured memory_bytes: 39680
<?php

$inputCount = 2;
$count = 0;

$stdins = array();
while(true)
{
    $stdin = trim(fgets(STDIN));
    if ($stdin === '')
    {
        var_dump($stdins);
        return;
    }  
    $stdins[] = $stdin;
    
    $count += 1;
    if ($count == 2) {
        break;
    }
}

if ($stdins[0] > $stdins[1]) {
    echo "GREATER";
} else if ($stdins[0] < $stdins[1]) {
    echo "LESS";
} else {
    echo "EQUAL";
}

Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int N,M;
  while(cin>>N>>M,N){
    int num[M+10][730]={};
    int r;cin>>r;
    for(int i=0;i<r;i++){
      int t,n,m,s;cin>>t>>n>>m>>s;
      if(s)num[m][t-535]++;
      else num[m][t-535+1]--;
    }
    int q;cin>>q;
    for(int i=0;i<q;i++){
      int ans=0;
      int ts,te,mm;cin>>ts>>te>>mm;
      ts-=535;
      te-=535;
      int now=0;
      for(int i=0;i<730;i++){
	int mae=now;
	now+=num[mm][i];
	//	cout<<now<<" "<<i<<":"<<" ";
	if(ts<i&&i<=te&&now>0){
	  // cout<<now<<" "<<i<<endl;
	  if(mae==0)ans--;
	  ans++;
	}
      }
      cout<<ans<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 30676
// https://atcoder.jp/contests/abc104/tasks/abc104_c

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int D_MAX = 10;
const int P_I_MAX = 100;
const int C_I_MAX = 1e6;
const int INF = 1e9;

int D, G;
int p[D_MAX];
int c[D_MAX];

int v[D_MAX];

void solve() {
  REP(i, D) v[i] = (i + 1) * 100;
  int ans = INF;
  REP(s, 1 << D) {
    // printf("s: %d\n", s);
    int pb = 0;
    int sc = 0;
    REP(i, D) if (s >> i & 1) {
      pb += p[i];
      sc += v[i] * p[i] + c[i];
      // printf("  v: %d, pb: %d, sc:%d \n", v[i], p[i], v[i] * p[i] + c[i]);
    }
    for (int i = D - 1; i >= 0; i--) if (!(s >> i & 1)) {
      if (sc >= G) break;
      int r = G - sc;
      int pb2 = min((r - 1) / v[i] + 1, p[i] - 1);
      pb += pb2;
      sc += v[i] * pb2;
      // printf("  v: %d, pb: %d, sc:%d \n", v[i], pb2, v[i] * pb2);
    }
    // printf("pb: %d, sc:%d \n", pb, sc);
    if (sc >= G) ans = min(ans, pb);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &D, &G);
  REP(i, D) scanf("%d%d", p + i, c + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    // ?
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };

    // stdinの生成 値の読み込み開始
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    // ?
    ($next:expr) => {};
    // ?
    ($next:expr, ) => {};

    // 変数名:型の読み込みの繰り返し
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    // 値を読み込むベース 型,の繰り返し
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    // 配列の読み込み
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    // 文字列Vec<char>の読み込み
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    // usize1?の読み込み
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // 指定した型で読み込み
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        nums: [usize;2],
    };

    println!("{}", solve(nums[0], nums[1]));
}

fn solve(a: usize, b: usize) -> &'static str {
    if a <= 8 && b <= 8 {
        return "Yay!";
    } else {
        return ":(";
    }
}
macro_rules! tests {
    ($($test_name:ident:$name:ident($( $args:expr ),*) => $expected:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $test_name() {
                    assert_eq!($expected,super::$name($($args),*));
                }
            )*
        }
    }
}


tests! {
    //テスト名:[引数]=>expected
    test1:solve(5, 4) => "Yay!",
    test2:solve(8, 8) => "Yay!",
    test3:solve(11, 11) => ":(",
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, x, n) for(int i = x; i <= n; ++i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
 
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
 
using namespace std;

int a[N];
int dp[N];

int main()
{
	barnarnar
	int n, k;
	cin >> n >> k;
	forn(i, n)  cin >> a[i];
	forn(i, N)  dp[i] = inf;
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	forr(i, 2, n - 1)
	{
	    for(int j = i - 1; j >= max(0, i - k); j--)
	        dp[i] = min(abs(a[i] - a[j]) + dp[j], dp[i]);
	}
	cout << dp[n - 1];
    return 0;
}









Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
int ans;

const int mod = 1000000007;
int cost[101][2];
int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n;
    cin >> n;

    vector<string> v1;
    map<string,int> one,two;

    set<string> ss;

    for(int i = 0; i < n; i++)
    {
      string s;
      cin >> s;
      v1.push_back(s);
      one[s]++;
      ss.insert(s);
    }


    int m;
    cin >> m;

    vector<string> v2;

    for(int i = 0; i < m; i++)
    {
      string s;
      cin >> s;
      v2.push_back(s);
      two[s]++;
      ss.insert(s);
    }


    for(auto &s : ss)
    {
     
     ans = max(ans,one[s]-two[s]);
    }

    cout << ans;










    return 0; 
}


Measured memory_bytes: 3668
N, M = map(int, input().split())
temp = [list(map(int, input().split())) for i in range(M)]
cities = []
for x, city in enumerate(temp):
    cities.append([x+1, city[0], city[1]])
#  print(cities)
#  [[1, 1, 32], [2, 2, 63], [3, 1, 12]]

#  [市番号, 所属県, 誕生年]

prefectures = [[] for i in range(N)]
for city in cities:
    prefectures[city[1]-1].append(city)
#  print(prefectures)
#  [[[1, 1, 32], [3, 1, 12]], [[2, 2, 63]]]

ID_list = []

for prefecture in prefectures:
    prefecture.sort(key=lambda x:x[2])
    #  print(prefecture)
    #  [[3, 1, 12], [1, 1, 32]]
    #  [[2, 2, 63]]
    for x, city in enumerate(prefecture):
        ID_list.append([city[0], city[1], x+1])

ID_list.sort()
#  print(ID_list)
#  [[1, 1, 2], [2, 2, 1], [3, 1, 1]]

#  [市番号, 所属県, 県内で何番目に誕生したか]

for ID in ID_list:
    temp = '{0:06d}'.format(ID[1])
    temp = temp + '{0:06d}'.format(ID[2])
    print(temp)





Measured memory_bytes: 57864
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n,odd=0,two=0,four=0;
  ll a[200010];
  std::cin >> n;
  for(int i=0; i<n; i++){
    std::cin >> a[i];
    if(a[i]%4==0) four++;
    else if(a[i]%2==0) two++;
    else odd++;
  }

  if(two==0){
    if(odd<=four+1){
      std::cout << "Yes" << '\n';
      return 0;
    }
  }

  if(odd<=four) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<random>
class  card
{
public:
	char suit;
	int num;
};
using namespace std;
int main()
{
	int n;
	cin >> n;
	card* B = new card[n];
	card* I = new card[n];
	//card* P = new card[n];
	for (int i = 0; i < n; i++)
	{
		string temp;
		cin >> temp;

		B[i].num = temp[1] - 48;
		B[i].suit = temp[0];
		I[i].num = temp[1] - 48;
		I[i].suit = temp[0];
		//P[i].num = temp[1] - 48;
		//P[i].suit = temp[0];
	}
	//bubbleSort
	int end = n;
	int lastswap = n;
	while (lastswap != 1)
	{
		lastswap = 1;
		for (int i = 0; i < end - 1; i++)
		{
			if (B[i].num > B[i + 1].num)
			{
				swap(B[i], B[i + 1]);
				lastswap = i + 1;
			}

		}
		if (lastswap != 1)
			end = lastswap;

	}


	for (int i = 0; i < n; i++)
	{
		if (i == n - 1)
			cout << B[i].suit << B[i].num << endl;
		else
			cout << B[i].suit << B[i].num << " ";
	}
	cout << "Stable" << endl;

	//insertionSort

	for (int i = 0; i < n; i++)
	{
		int minIndex = i;
		for (int j = i; j < n; j++)
		{
			if (I[j].num < I[minIndex].num)
			{
				minIndex = j;
			}
		}
		swap(I[i], I[minIndex]);
	}


	for (int i = 0; i < n; i++)
	{
		if (i == n - 1)
			cout << I[i].suit << I[i].num << endl;
		else
			cout << I[i].suit << I[i].num << " ";
	}

	bool foo = true;
	for (int i = 0; i < n; i++)
	{
		if (I[i].suit != B[i].suit)
		{
			foo = false;
			cout << "Not stable" << endl;
			break;
		}
	}

	if (foo == true)
		cout << "Stable" << endl;



	delete[] B;
	delete[] I;



	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n, m;
  cin >> n >> m;
  int c = 1900*m + 100*(n - m);
  cout << pow(2,m)*c << endl;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    if(i == 0){
        for(int i = 0; i < w + 2; i++){
          cout << "#";
        }
        cout << endl;
    }
    for(int i = 0; i < w; i++){
      char word;
      cin >> word;
      if(i == 0){
        cout << "#";
      }
      cout << word;
      if(i == w -1){
        cout << "#" << endl;
      }
    }
    if(i == h - 1){
      for(int i = 0; i < w + 2; i++){
        cout << "#";
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
import bisect
n=int(input())
List = [int(i) for i in input().split()]
List=sorted(List)
ans = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    tmp1 = List[i]
    tmp2 = List[j]
    a=bisect.bisect_left(List,tmp1+tmp2)
    ans += a -j-1
print(ans)

Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys
from heapq import heappush, heappop, heapify
from collections import deque
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    T = INT()
    for t in range(T):
        solve()
    return

def solve():
    # 解説PDFの指針
    N = INT()
    left_camel = []
    right_camel = []
    ans = 0
    for k, l, r in ZIP(N):
        if l >= r:
            left_camel.append((l-r, k))
            ans += r
        else:
            right_camel.append((r-l, N-k))
            ans += l
    left_camel.sort(key=lambda x: x[1])
    right_camel.sort(key=lambda x: x[1])
    left_camel = deque(left_camel)
    right_camel = deque(right_camel)
    # print(left_camel, right_camel)
    for camels in [left_camel, right_camel]:
        S = []
        while len(camels) > 0 and camels[0][1] == 0:
            camels.popleft()
        for j in range(1, N+1):
            while len(camels) > 0 and camels[0][1] == j:
                heappush(S, camels.popleft())
            while len(S) > j:
                heappop(S)
        while S:
            ans += heappop(S)[0]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71228
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()

k = int(input())
a, b = get_ints()

flag = False
for i in range(a, b+1):
  if i%k==0:
    flag = True
    break
if flag:
  print("OK")
else:
  print("NG")

Measured memory_bytes: 61752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int h = Integer.parseInt(str[0]);
        int w = Integer.parseInt(str[1]);

        String[] mp = new String[h];
        for (int i = 0; i < h; i++) mp[i] = br.readLine();

        String[][] ans = new String[h][w];

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {

                int cnt = 0;

                if (mp[i].charAt(j) == '#') {
                    ans[i][j] = "#";
                } else{
                    for (int x = -1; x <= 1; x++) {
                        for (int y = -1; y <= 1; y++) {
                            int dx = j + x;
                            int dy = i + y;
                            if (0 <= dx && dx < w && 0 <= dy && dy < h) {
                                if (mp[dy].charAt(dx) == '#') cnt++;
                            }
                        }
                    }

                    ans[i][j] = Integer.toString(cnt);
                }
            }
        }
        for( int i =0 ;i < h; i++){
            System.out.println(String.join("", ans[i]));
        }
    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
 
int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  set<int> S;
  rep(i,N) S.insert(A[i]);
  if(S.size()==N) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

int main() {
  int m;
  cin >> m;
  double n = m;
  if (m % 2 == 0) {
    cout << 0.5 << endl;
  }
  else {
    cout << (n + 1) / (2 * n) << endl;
  }
}


Measured memory_bytes: 256
h, w = gets.chomp.split.map(&:to_i)
table = Array.new(26, 0)
a = h.times.map{gets.chomp}
a.each do |c|
  c.each_char do |cc|
    table[cc.ord - "a".ord] += 1
  end
end
c4 = 0
c2 = 0
c1 = 0
table.each do |d|
  while d > 0
  if(d / 4 > 0)
    c4 += d / 4 
    d %= 4
  elsif(d % 2 == 0)
    c2 += d
    d %= 2 
  else
    c1 += d
    d = 0
  end
  end
end
if((h%2) == 0 and (w%2) == 0)
  puts (c1 <= 0 and c2 <= 0)? "Yes" : "No"
elsif(h % 2 == 1 and w %2 == 0 )
  puts (c1 <= 0 and c2 <= (w))? "Yes" : "No"
elsif(h%2 == 0 and w %2 == 1)
  puts (c1 <= 0 and c2 <= (h))? "Yes" : "No"
else
  puts (c1 <= 1 and c2 <= (h + w - 2))? "Yes" : "No"
end

Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int  a, b, d, X, Y;
  double  c;
//  long long  a, b, c, d, X, Y;
  int D, G;
  //char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[101]={};
//  char s[10000000000000000001]={};
  char s[2][100001]={};
  int len=0;
//  int N, M;
//  int A[1000000001]={};
  long long  A[101]={};
//  long int A[1001]={};
  long long  B[101]={};
  long long  C[101]={};
  int i,j,k;
  int flag=0;
  double tmp=0;
  int min=0;
  int cnt=0;
  double ans=1000;
  int max=0;

  int  Cen_X=0;
  int  Cen_Y=0;
  long long  H=0;
  
  //  int ans=0;
  int str_len=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  int ans_o[1001]={};
  double N[1001]={};
  int ans_e[100001]={};
  
//  scanf("%lld %lld", &a, &b);
  scanf("%d", &a);
  if((a==3)||(a==5)||(a==7)){printf("YES\n");
                             return 0;
                            }
//        printf("%d\n",a+(b/2));
    
      
//  if(flag==0)   printf("TLE\n");
    printf("NO\n");
  
return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())


def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a




def lcm(a, b):
    return a * b // gcd(a, b)



c_d = lcm(c, d)




ans = b - a + 1 - (b // d - (a - 1) // d) -\
    (b // c - (a - 1) // c) +\
    (b // c_d - (a - 1) // c_d)



print(ans)

Measured memory_bytes: 38384
/*
	Powered by C++11.
	Author : Alex_Wei.
*/

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

//#pragma GCC optimize(3)
//#define int long long

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

// Templates start.

namespace IO{
	char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#ifdef __WIN32
		#define gc getchar()
	#else
		#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
	#endif
	#define pc(x) (*O++=x)
	#define flush() fwrite(obuf,O-obuf,1,stdout)

	inline int read(){
		int x=0,sign=0; char s=gc;
		while(!isdigit(s))sign|=s=='-',s=gc;
		while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=gc;
		return sign?-x:x;
	}
	void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}
}

namespace math{
	const int mod=998244353;
	const int maxn=1e6+5;

	ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%mod; m=m*m%mod,b>>=1;} return s;}
	ll inv(ll x){return ksm(x,mod-2);}

	ll fc[maxn],ifc[maxn];
	void init_m(int n){
		fc[0]=1; for(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%mod;
		ifc[n]=inv(fc[n]); for(int i=n-1;i>=0;i--)ifc[i]=ifc[i+1]*(i+1)%mod;
	}
	ll C(ll n,ll m){return fc[n]*ifc[m]%mod*ifc[n-m]%mod;}
}

// Templates end. Please give me more points.

using namespace IO;
//using namespace math;

const int N=1e5+5;

ll buc[N],n,q,a,b,c;
ll ans;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a,buc[a]++,ans+=a;
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>b>>c;
		ans+=buc[b]*(c-b);
		buc[c]+=buc[b],buc[b]=0;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4328
class max_heap:
    def __init__(self, vals):
        self.vals=vals
        self.index_max = len(self.vals)

    def size(self):
        return self.index_max

    def check(self, i):
        assert(i >= 1)
        assert(i <= self.index_max)

    def val_at(self, i):
        self.check(i)
        return self.vals[i-1]

    def left_idx(self, i):
        self.check(i)
        t = 2*i
        if t <= self.index_max:
            return t
        else:
            return None

    def right_idx(self, i):
        self.check(i)
        t = 2*i + 1
        if t <= self.index_max:
            return t
        else:
            return None

    def parent_idx(self, i):
        self.check(i)
        t = i//2
        if t > 0:
            return t
        else:
            return None

    def swap(self, i, j):
        self.check(i); self.check(j)
        self.vals[i-1], self.vals[j-1] = self.vals[j-1], self.vals[i-1]

    def max_heapify(self, i):
        self.check(i)
        l_idx = self.left_idx(i)
        r_idx = self.right_idx(i)
        swap_target = None

        if (l_idx is not None) and (self.val_at(l_idx) > self.val_at(i)):
            swap_target = l_idx
            # print('leftval, ival  ', self.val_at(l_idx), self.val_at(i), self.val_at(l_idx)>self.val_at(i))
            if r_idx is not None and self.val_at(r_idx) > self.val_at(l_idx):
                swap_target = r_idx
        elif r_idx is not None and self.val_at(r_idx) > self.val_at(i):
            swap_target = r_idx

        if swap_target is not None:
            # print('swap:', i, swap_target)
            self.swap(i, swap_target)
            self.max_heapify(swap_target)

    def build_max_heap(self):
        for i in reversed(range(1, self.size()//2+1)):
            # print('tgt: ', i)
            # print(self.vals)
            self.max_heapify(i)

    def show(self):
        return ''.join(map(lambda x: ' '+str(x), self.vals))


if __name__ == "__main__":
    H = int(input())   # in [1, 500,000]
    vals_str = input()   # |val|<=2,000,000,000 = 2e9
    vals = list(map(int, vals_str.split(' ')))
    mh = max_heap(vals)
    mh.build_max_heap()
    print(mh.show())

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll  long long int
vector<ll> v;
multiset<ll> ms;
multiset<ll>::iterator it;
ll a[MAXX];
int main()
{
	FAST;
	ll n, t, m, o = 1, z, p;
	cin >> n >> m;
	if(m % n == 0){
		cout << m + n;
	}
	else{
		 cout << m -n;
	}
	

}

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

using namespace std;

void Main() {
    long long N;
    cin >> N;
    vector<vector<long long>> A(N, vector<long long>(N, 0));
    for (long long i = 0; i < N; ++i) {
        for (long long j = 0; j < N; ++j) {
            cin >> A[i][j];
        }
    }

    set<pair<long long, long long>> remove;
    for (long long i = 0; i < N - 1; ++i) {
        for (long long j = i + 1; j < N; ++j) {
            long long aij = A[i][j];
            for (long long k = 0; k < N; ++k) {
                if (i == k || j == k) {
                    continue;
                }
                if (A[i][k] + A[k][j] == aij) {
                    remove.insert(make_pair(i, j));
                }
                else if (A[i][k] + A[k][j] < aij) {
                    cout << -1 << endl;
                    return;
                }
            }
        }
    }

    long long ans = 0;
    for (long long i = 0; i < N - 1; ++i) {
        for (long long j = i + 1; j < N; ++j) {
            ans += A[i][j];
        }
    }
    for (auto e : remove) {
        ans -= A[e.first][e.second];
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 7100