akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>

using namespace std;
#define endl '\n'
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define pi acos(-1.0)
#define MAX 1000010
//////////////////////////////////////////////////////////////////////////
/* Custom function starts here */

/* Custom function ends here: */
//////////////////////////////////////////////////////////////////////////////

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  /* MAIN Code STARTS here: */
    int coins, hap;
    int cnt1, cnt5;

    cin >> coins;
    cnt1 = coins/500;
    int rem = coins%500;
    cnt5 = rem/5;
    cout << (cnt1*1000) + (cnt5*5) << endl;

  /* MAIN Code ENDS here: */

}

Measured memory_bytes: 3140
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			if (w == 0 && h == 0)
				break;
			char[][] map = new char[h + 2][w + 2];
			int gx = -1;
			int gy = -1;
			for (char[] m : map) {
				Arrays.fill(m, '.');
			}
			for (int i = 1; i <= h; i++) {
				char[] c = scanner.next().toCharArray();
				for (int j = 1; j <= w; j++) {
					map[i][j] = c[j - 1];
					if (c[j - 1] == '&') {
						gx = j;
						gy = i;
					}
				}
			}

			int[][] cnt = new int[h + 2][w + 2];
			for (int[] c : cnt) {
				Arrays.fill(c, 1 << 24);
			}
			int[][] dxy = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
			Deque<int[]> deque = new ArrayDeque<int[]>();
			deque.offer(new int[] { 0, 0 });
			cnt[0][0] = 0;
			while (!deque.isEmpty()) {
				int[] d = deque.poll();
				int dy = d[0];
				int dx = d[1];
				for (int[] xy : dxy) {
					int py = xy[0] + dy;
					int px = xy[1] + dx;
					int r;
					if (0 <= py && py < h + 2 && 0 <= px && px < w + 2) {
						if (map[dy][dx] == '#' && map[py][px] != '#') {
							r = 1;
						} else {
							r = 0;
						}
						if (cnt[py][px] > cnt[dy][dx] + r) {
							deque.offer(new int[] { py, px });
							cnt[py][px] = cnt[dy][dx] + r;
						}
					}
				}
			}
			System.out.println(cnt[gy][gx]);
		}
	}
}

Measured memory_bytes: 33964
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// type alias
using ll = long long;
using ull = unsigned long long;

template<class ll>
inline ll getCeilExponent(ll a)
{
	if (a <= 0)
	{
		throw invalid_argument("vaule equal to or less than 0 should not be valid");
	}

	ll index = 0;
	--a;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

template<class ll>
inline ll getFloorExponent(ll a)
{
	if (a <= 0)
	{
		throw invalid_argument("vaule equal to or less than 0 should not be valid");
	}

	ll index = 0;
	a >>= 1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

// computational complexity: o(log(max(a, b))) 
template<class ll>
inline ll getGcd(ll a, ll b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

// computational complexity: o(log(max(a, b))) 
template<class ll>
inline pair<ll, ll> getBezoutsIdentitySolution(ll a, ll b)
{
	if (b == 0)
	{
		return { 1, 0 };
	}
	auto sol = getBezoutsIdentitySolution(b, a % b);
	return { sol.second, sol.first - (a / b) * sol.second };
}

template<class Integer>
inline Integer getPower(Integer base, unsigned exponential)
{
	Integer res = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			res *= base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return res;
}

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

	ll M, K;
	cin >> M >> K;

	ll pow = getPower(2, M);
	
	if (K >= pow)
	{
		cout << -1 << endl;
		return 0;
	}

	if (M == 1)
	{
		if (K == 0)
		{
			cout << "0 0 1 1" << endl;
		}
		if (K == 1)
		{
			cout << -1 << endl;
		}
		return 0;
	}

	for (ll i = 0; i < pow; ++i)
	{
		if (i == K)
		{
			continue;
		}
		cout << i << " ";
	}
	cout << K << " ";

	for (ll i = pow - 1; i >= 0; --i)
	{
		if (i == K)
		{
			continue;
		}
		cout << i << " ";
	}
	cout << K;

	return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> l(m), r(m);
    REP(i, m) cin >> l[i] >> r[i];
    ll left = 0, right = INF;
    REP(i, m){
        left = max(left, l[i]);
        right = min(right, r[i]);
    }
    ll ans = right - left + 1;
    cout << max(ll(0), ans);
    return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;

//Ostao ti je onaj sa powerima
//Ostao ti je onaj "najmanji broj iz 2 seta"
//Mozes li ovaj drugi uraditi za 15 min ? :P

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int a;
cin>>a;
cout<<a+a*a+a*a*a<<endl;
return 0;
}


Measured memory_bytes: 3568
#include<stdio.h>
int main()
{
    int a,b,c;
    char s[101];
    // 整数の入力
    scanf("%d", &a);
    scanf("%d",&b);
    // 文字列の入力
c = a+b;
if(a%3==0){
printf("Possible\n");
}else if(b%3==0){
printf("Possible");
}else if((a+b)%3==0){
printf("Possible");
}else{
printf("Impossible");
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int n;
LL a[100005], s[100005];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i <= n; i++) {
      cin >> a[i];
      s[i] = 0;
    }
    s[n] = a[n];
    for (int i = n - 1; i >= 0; i--) {
      s[i] = a[i] + s[i + 1];
    }

    bool flag = true;
    LL ans = 0, t = 1;
    for (int i = 0; i <= n; i++) {
      if (t >= s[i]) {
        ans += s[i];
      } else {
        ans += t;
        if (t < a[i]) {
          flag = false;
          break;
        }
        t -= a[i];
        t *= 2;
      }
    }

    if (flag) {
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  }
#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 5256
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N, M;
  cin >> N >> M;
  VI broken(N+1); //壊れているブロックのbool表
  REP(i, M){
    int a=0;
    cin >> a;
    broken[a]=1;
  }

  VI dp(N+10);
  dp[0]=1;//取り敢えず0と置く
  if(broken[1]){
    dp[1]=0;
  }else{
    dp[1]=1;
  }//1マス目までの行き方

  FOR(i, 2, N+1){
    if(broken[i]) continue;
    dp[i] = (dp[i-1] + dp[i-2]) % MOD;
  }

  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.PrintWriter;

public class Main{
	static int[] c=new int[26];
	static int[] lastD=new int[26];
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int d=sc.nextInt();
		for(int i=0; i<26; i++){
			c[i]=sc.nextInt();
		}
		int[][] s=new int[d][26];
		for(int i=0; i<d; i++){
			for(int j=0; j<26; j++){
				s[i][j]=sc.nextInt();
			}
		}
		int maxSati=-Integer.MAX_VALUE/2;
		int maxInd=0;
		//j:何日目
		for(int j=0; j<d; j++){
			//i:どの大会をやるか
			for(int i=1; i<=26; i++){
				int sati=0;
				lastD[i-1]=j+1;
				sati+=s[j][i-1];
				sati-=subSati(j+1);
				lastD[i-1]=0;
				if(maxSati<sati){
					maxSati=sati;
					maxInd=i;
				}
			}
			System.out.println(maxInd);
			lastD[maxInd-1]=j+1;
			maxSati=-Integer.MAX_VALUE/2;
			maxInd=0;
		}
	}
	static int subSati(int d){
		int ret=0;
		for(int i=0; i<26; i++){
			ret+=c[i]*(d-lastD[i]);
		}
		return ret;
	}
}


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

signed main(){
    int n,m; cin>>n>>m;
    vector<int> a(m),b(m),from1,toN;
    rep(i,m){
        cin>>a.at(i)>>b.at(i);
        if(a.at(i)==1) from1.push_back(b.at(i));
        if(a.at(i)==n) toN.push_back(b.at(i));
        if(b.at(i)==1) from1.push_back(a.at(i));
        if(b.at(i)==n) toN.push_back(a.at(i));
    }
    sort(all(from1));
    sort(all(toN));
    bool ans=false;
    rep(i,from1.size()){
        if(upper_bound(all(toN),from1.at(i))-lower_bound(all(toN),from1.at(i))>0){
            ans=true;
            break;
        }
    }
    cout<<(ans?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, N, A[1100], B[1100];
int dp[11000];
signed main() {
    cin >> H >> N;
    rep(i, N) { cin >> A[i] >> B[i]; }
    for (int i = 1; i <= H; i++) { dp[i] = INT_MAX; }
    rep(i, N) {
        for (int j = 0; j <= H; j++) {
            chmin(dp[min(j + A[i], H)], dp[j] + B[i]);
        }
    }
    cout << dp[H] << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
using namespace std;

#define lint long long int

int main()
{
    long double a, b;
    cin >> a >> b;
    
    lint ans = a*b;
    cout << ans << endl;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100;


int main(){
  int N = in(), K = in(), x;
  double y, ans = 0;

  rep2(i, 1, N+1){
    x = i;
    y = N;
    while(x < K){
      x *= 2;
      y *= 2;
    }
    ans += 1/y;
  } 
  printf("%.10lf\n", ans);
}

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

typedef long long LL;
const LL N = 10010;
LL a[N], b[N], c[N];
bool v[N];

inline LL gcd(LL a, LL b)
{
    return (b ? gcd(b, a % b) : a);
}

int main()
{
    register LL n, p = 0, num = 0;
    scanf("%lld", &n);
    for (register LL i = n; i >= 0; --i) {
        scanf("%lld", &a[i]);
        p = gcd(p, abs(a[i])), b[i] = a[i];
    }
    for (register LL i = 2, q; i <= n; ++i) {
        if (v[i] == 1) continue;
        if (b[0] % i != 0) goto nxt;
        for (register LL j = 0; j <= n; ++j)
            a[j] = b[j];
        for (register LL j = n; j >= i - 1; --j)
            a[j - (i - 1)] = (a[j] + a[j - (i - 1)]) % i, a[j] = 0;
        for (register LL j = 0; j <= n; ++j) {
            if (a[j] % i != 0) goto nxt;
        }
        c[++num] = i;
        nxt:;
        q = n / i;
        for (register LL j = i; j <= q; ++j)
            v[i * j] = 1;
    }
    for (register LL i = 2; i <= (LL)sqrt(p); ++i) {
        if (p % i == 0) {
            c[++num] = i;
            while (p % i == 0) p = p / i;
        }
    }
    if (p > 1) c[++num] = p;
    sort(c + 1, c + num + 1);
    for (register int i = 1; i <= num; ++i) {
        if (c[i] == c[i - 1]) continue;
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 384
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s <= "2019/04/30"){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.Set;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        Set<Integer> set = new HashSet<>();
        String[] in = br.readLine().split(" ");

        br.close();

        for (String s : in) {
            set.add(Integer.parseInt(s));
        }

        bw.write(set.size() == n ? "YES" : "NO");

        bw.flush();

    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,k;
  cin >> n >> k;
  if(k<=(n+1)/2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


typedef pair<ll, ll> Pair;

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll H, W, N; cin >> H >> W >> N;
  set<Pair> points;
  vector<ll> answer(10);

  answer.at(0) = (H-2) * (W-2);
  for (int _i = 0; _i < N; _i++) {
    ll a, b; cin >> a >> b; a--; b--;
    for (int y = -1; y <= 1; y++) {
      for (int x = -1; x <= 1; x++) {
	ll p = a + y;
	ll q = b + x;
	if (p < 1 || p >= H-1 || q < 1 || q >= W-1) continue;
	int cnt = 0;
	for (int u = -1; u <= 1; u++) {
	  for (int v = -1; v <= 1; v++) {
	    ll s = p + u;
	    ll t = q + v;
	    if (points.count(make_pair(s, t)) == 1) cnt++;
	  }
	}
	answer.at(cnt)--;
	answer.at(cnt+1)++;
      }
    }
    points.emplace(a, b);
  }

  for (int i = 0; i < 10; i++) cout << answer.at(i) << "\n";

  return 0;
}



Measured memory_bytes: 6528
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>
#include <sstream>

#define all_range(C) std::begin(C), std::end(C)



int map[100][100];


int main()
{
	using std::endl;
	using std::cout;
	using std::cin;

	while (true)
	{
		int W,H,t,p;
		cin >> W>>H>>t>>p;
		if (W == 0 && H==0&&t==0&&p==0) { break; }

		for (int i = 0; i < 100; i++)
			for (int j = 0; j < 100; j++)
		{
				map[i][j] = 0;
		}
		
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
		{
			map[i][j] = 1;
		}

		while(t--)
		{
			int d, c;
			cin >> d >> c;

			if (d == 2) {
				for (int h = 0; h < c; h++)
					for (int j = 0; j < W; j++)
				{
					map[2*c-1-h][j] += map[h][j];
				}

				H = std::max(c, H - c);
				for (int h = 0; h < 100; h++)
					for (int j = 0; j < 100; j++)
				{
					if (h < H && j < W) {
						map[h][j] = map[h + c][j];
					}
					else {
						map[h][j] = 0;
					}
				}
			}
			else {
				for (int i = 0; i < H; i++)
					for (int w = 0; w < c; w++)
				{
					map[i][2*c-1 - w] += map[i][w];
				}

				W = std::max(c, W - c);
				for (int i = 0; i < 100; i++)
					for (int w = 0; w < 100; w++)
				{
					if (i < H && w < W) {
						map[i][w] = map[i][w + c];
					}
					else {
						map[i][w] = 0;
					}
				}
			}
		}

		int count = 0;
		while (p--) {
			int h, w;
			cin  >> w >> h;
			count = map[h][w];
			cout << count << endl;
		}
	}

	return 0;
}
#endif



Measured memory_bytes: 3116
#include <iostream>
#include <stdlib.h>
using namespace std;
long long n,m;
long long ans=1;
int main(){
    cin>>n>>m;
    if(abs(n-m)>=2){
        cout<<0;
        return 0;
    }
    if(n==m) ans=2;
    for(int i=1;i<=n;i++){
        ans=(ans*i)%1000000007;
    }for(int i=1;i<=m;i++){
        ans=(ans*i)%1000000007;
    }
    cout<<ans;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
total = 0
for i in range(a+1):
    for k in range(b+1):
        for j in range(c+1):
            total = 500*i + 100*k + 50*j
            if total == x:
                ans += 1
print(ans)


Measured memory_bytes: 3064
N,X,Y=map(int,input().split())
if X > Y:
    exc=X
    X=Y
    Y=exc
L=[0]*N
for i in range(N-1):
    for j in range(i+1,N):
        if i >= Y-1 or j <= X-1 or j-i ==1:
            L[j-i]+=1
        elif i <= X-1 and j >= Y-1:
            L[1+abs(X-1-i)+abs(Y-1-j)]+=1
        elif i >= X-1 and i-(X-1) > (Y-1)-i:
            L[j-i]+=1
        else:
            L1=j-i
            L2=min(j-i,1+abs(X-1-i)+abs(Y-1-j))
            L[min(L1,L2)]+=1

for i in range(1,N):
    print(L[i])




Measured memory_bytes: 49372
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int main(){
		
	int wg;
	
	while(cin>>wg, !cin.eof()){
		
		queue<int> qu;
		int fundoh = 1;
		
		for(int i=0; i < 10; ++i){
		
			if( BIT(wg, i) )
				qu.push(fundoh);
				
			fundoh*=2;
		}
		
		while(!qu.empty()){
			
			cout << qu.front();
			qu.pop();
			
			if(!qu.empty())
				cout << ' ';
		}
		
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
 
const int N = 100009;
int T, n, a[N], ans1, ans2, ans3, ans4, res1, res2, res3, res4;
map<int, int> m1, m2, vis1, vis2;
 
void read(int &x) {
	char c; int f = 1;
	for (c = getchar(); c < '0' || c > '9'; c = getchar()) if (c == '-') f = 0;
	for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	x = f ? x : -x;
}
 
int main() {
	read(n);
	for (int i = 1; i <= n; ++ i) read(a[i]);
	for (int i = 1; i <= n; i += 2) ++ m1[a[i]];
	for (int i = 2; i <= n; i += 2) ++ m2[a[i]];
	for (int i = 1; i <= n; i += 2) {
		if (vis1[a[i]] == 0) vis1[a[i]] = 1;
		else continue;
		if (m1[a[i]] > ans1) ans2 = ans1, res2 = res1, ans1 = m1[a[i]], res1 = a[i];
		else if (m1[a[i]] > ans2) ans2 = m1[a[i]], res2 = a[i];
	}
//	printf("%d %d %d %d\n", ans1, ans2, res1, res2);
	for (int i = 2; i <= n; i += 2) {
		if (vis2[a[i]] == 0) vis2[a[i]] = 1;
		else continue;
		if (m2[a[i]] > ans3) ans4 = ans3, res4 = res3, ans3 = m2[a[i]], res3 = a[i];
		else if (m2[a[i]] > ans4) ans4 = m2[a[i]], res4 = a[i];
	}
//	printf("%d %d %d %d\n", ans3, ans4, res3, res4);
	if (res1 == res3) printf("%d\n", min(n - ans1 - ans4, n - ans2 - ans3));
	else printf("%d\n", n - ans1 - ans3);
	return 0;
}


Measured memory_bytes: 13292
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { ij -> ij.toInt() }
    val a = readLine()!!.split(" ").map { ij -> ij.toLong() }
    val ar = arrayListOf<Long>()
    
    val map = mutableMapOf<Long, Long>()
    val seq = mutableListOf<Long>()
    
    for (i in 0 until m) {
        val (b, c) = readLine()!!.split(" ").map { it.toLong() }
        if (map.containsKey(c)) {
            map[c] = map[c]!! + b
        } else {
            map[c] = b
            seq.add(c)
        }
    }
    
    for (i in a.indices) {
        if (map.containsKey(a[i])) {
            map[a[i]] = map[a[i]]!! + 1
        } else {
            map[a[i]] = 1
            seq.add(a[i])
        }
    }
    
    val s = seq.sorted().reversed()
    var collected = 0L
    
    var ans = 0L
    
    for (i in s.indices) {
        if (collected < n) {
            val mn = Math.min(n - collected, map[s[i]]!!)
            ans += mn * s[i]
//            print("$mn*${s[i]} ")
            collected += mn
        }
    }
    
    
    
//    println()
    
//    println(s)
//    println(map)

//    ar.sort()
//    ar.reverse()
    
    println(ans)
}

Measured memory_bytes: 97988
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << c-d+b << " " << d+c-a << " " << a-d+b << " " << b+c-a << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include<cmath>
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// --------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;
  if(x == 0){
    cout << 1 << "\n";
  }else{
    cout << 0 << "\n";
  }
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdlib>
int main(){
  int sx,sy,tx,ty;
  int dx,dy;
  std::cin >> sx >> sy >> tx >> ty;
  dx=abs(sx-tx);
  dy=abs(sy-ty);
  for(int i=1;i<=dy;i++){
    std::cout << "U";
  }
  for(int j=1;j<=dx;j++){
    std::cout << "R";
  }
  for(int i=1;i<=dy;i++){
    std::cout << "D";
  }
  for(int j=1;j<=dx;j++){
    std::cout << "L";
  }
  std::cout << "L";
  for(int i=1;i<=dy+1;i++){
    std::cout << "U";
  }
  for(int i=1;i<=dx+1;i++){
    std::cout << "R";
  }
  std::cout << "DR";
  for(int i=1;i<=dy+1;i++){
    std::cout << "D";
  }
  for(int i=1;i<=dx+1;i++){
    std::cout << "L";
  }
  std::cout << "U\n";
  return 0;
}


Measured memory_bytes: 256
import { readFileSync } from 'fs'
function main() {
  const input = readFileSync('/dev/stdin', 'utf8')
  const data = input.split('\n').map(v => v.trim())
  const [n, k] = data[0].trim().split(' ').map(v => Number(v))
  const friends = data[1].trim().split(' ').map(v => Number(v))
  let count = 0
  for (let i = 0; i < friends.length; i++) {
    if (friends[i] >= k) count++
  }
  console.log(count)

}
main()

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

const int mod = 1e9 + 7;

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  	int ans = 0;
	int x = 0;
  	rep(i, n){
    	ans = (ans + (ll)a[i] * x) % mod;
      	x = (x + a[i]) % mod;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 4044
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int N, T;
  cin >> N >> T;

  int ans = 9999;
  for(int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if(t > T || ans < c) {
      continue;
    }
    ans = c;
  }
  if(9999 == ans) {
    cout << "TLE" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#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(a) (a).begin(), (a).end()

int N, M;

struct Work {
  int A, B;
};

vector<Work> works;

int main () {
  cin >> N >> M;
  works.resize(N);
  rep(i,N) cin >> works[i].A >> works[i].B;

  sort(all(works), [&](const Work& a, const Work& b) {
      return a.A < b.A;
    });

  ll ans = 0;
  priority_queue<int> pq;
  for(int i = 1, j = 0; i <= M; i++) {
    while(works[j].A == i) {
      pq.push(works[j].B);
      j++;
    }
    if(pq.empty()) continue;

    ans += pq.top();
    pq.pop();
  }

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


Measured memory_bytes: 1660
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main() {
	int n, m;
	int arr[200002];
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}


	int cnt = 0;
	double sum = 0;
	double max = 0;
	for (int i = 0; i < n; i++) {
		sum += (double)(arr[i]+1)/2;
		cnt++;

		if (cnt == m) {
			if (i - m >= 0)
				sum -= (double)(arr[i-m]+1)/2;
			if (max < sum)
				max = sum;
			cnt--;
		}
	}
	printf("%lf", max);
	return 0;
}

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

int sum(int s, int num){
	if(num<10)return num;
	return num%10 + sum(s, num/10);
}


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

for(int i = 1; i <= a; i++){
	if(b <= sum(0,i) && sum(0,i) <= c){
		d += i;
	}
}
cout << d << endl;
return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    string t[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s ;

    rep(i,7){
        if(t[i]==s) cout << 7-i << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
 
  String A = sc.next();
  String B = sc.next();
  String C = sc.next();
  
   if (A.charAt (A.length()-1)==B.charAt(0) && B.charAt(B.length()-1)==C.charAt(0)) {
	   System.out.print("YES");
   }
   else {
	   System.out.print("NO");
   }
   }
}
	

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main() {
  string t;
  cin>>t;
  int l=t.length();
  for(int i=0;i<l;i++){
    if(t.at(i)=='?') cout<<'D';
    else cout<<t.at(i);
  }
  cout<<endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	vector<llong> c(6);
	for(auto &x : c)
		cin >> x;

	llong sum = c[0] + c[1]*5 + c[2]*10 + c[3]*50 + c[4]*100 + c[5]*500;

	cout << (sum >= 1000) << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;



int main() {
	char S[5];
  	rep(i,4) cin>>S[i];
  	char op[3];
  
  	for(int bit=0;bit<(1<<3);bit++){
      	int ans=S[0]-'0';
     	for(int i=0;i<3;i++){
         	 if(bit&(1<<i)){
             	op[i]='+';
               	ans+=S[i+1]-'0';
             }else{
                op[i]='-';
               	ans-=S[i+1]-'0';
             }
        }
      	if(ans==7){
         	break; 
        }
    }
  	
  	cout<<S[0];
  	rep(i,3){
     	cout<<op[i]<<S[i+1]; 
    }
  	cout<<"=7"<<endl;
  	
}

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

int ctoi(const char c){
  if('0' <= c & c <= '9') return (c - '0');
  return -1;
}

int main() {
    int N , A, B;
    scanf("%d%d%d", &N, &A, &B);

    int sum = 0;
    for (int i = 1; i <= N; i++) {
        int tmp = 0;
        string number = to_string(i);

        for (int j = 0; j < number.size(); j++) {
            int x = ctoi(number.at(j));
            tmp += x;
        }
        if (A <= tmp & tmp <= B) {
            sum += i;
        }
        tmp = 0;
    }
    printf("%d", sum);
}

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

int main() {
    int FirstNum,SecondNum;
    string op;
    cin >> FirstNum >> op >> SecondNum;
    if(op == "+"){
        cout <<FirstNum + SecondNum;
    }else if (op =="-"){
        cout <<FirstNum - SecondNum;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;

const double PI = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,M;
    cin>>N>>M;
    vector<pair<int,int>> ab;
    rep(i,N){
        int a,b;
        cin>>a>>b;
        ab.push_back({a,b});
    }
    sort(all(ab));
    priority_queue<ll> pq; 
    int j = 0;
    ll ans = 0;
    for(int i = M-1; i>=0; i--){
        while(j < N){
            if(i + ab[j].first <= M){
                pq.push(ab[j].second);
                j++;
            }
            else break;
        }
        if(pq.empty())continue;
        ans += pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}

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

int n;
long long arr[401];
long long dp[401][401];

long long getrange(int i, int  j){
	return (arr[j] - (i>0 ? arr[i-1]:0));
}

long long solve(int i, int j){
	if(i==j) return 0;
	if(dp[i][j] != -1) return dp[i][j];

	dp[i][j] = 1e17;
	for (int k = i; k < j; ++k){
		dp[i][j] = min(dp[i][j],
					solve(i, k) + solve(k+1, j)+
					getrange(i, k) + getrange(k+1, j));	
	}
	return dp[i][j];
}

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lld", &arr[i]);
	for (int i = 1; i < n; ++i){
		arr[i] += arr[i-1];
	}
	memset(dp, -1, sizeof dp);
	printf("%lld\n", solve(0, n-1));
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int c=0;
  if(s=="RRR"){
    cout << 3;
  }
  else if(s=="RRS"||s=="SRR"){
    cout << 2;
  }
  else if(s=="SSS"){
    cout << 0;
  }
  else{
    cout << 1;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

//
int par_uf[100010],rank_uf[100010];

void init(int n){for(int i=0;i<n;i++){par_uf[i]=i;rank_uf[i]=0;}}
int find(int x){if(par_uf[x]==x)return x;else return find(par_uf[x]);}
void unite(int x,int y){x=find(x);y=find(y);if(x==y)return;if(rank_uf[x]<rank_uf[y])par_uf[x]=y;else{par_uf[y]=x;if(rank_uf[x]==rank_uf[y])rank_uf[x]++;}}
bool same(int x,int y){return find(x)==find(y);}
//

int N,M,h[210];
pair<int,pi> e[20010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N>>M && N){
		rep(i,N)cin>>h[i];
		rep(i,M){
			cin>>e[i].sec.fir>>e[i].sec.sec>>e[i].fir;
			e[i].sec.fir--;e[i].sec.sec--;
		}
		sort(e,e+M);
		
		pi p[210];
		rep(i,N)p[i]=mp(-h[i],i);
		sort(p,p+N);
		
		int ans=0;
		init(N);
		int on[210]={};
		int comp=0;
		rep(i,N){
			on[p[i].sec]=1;
			comp++;
			while(i+1<N && p[i+1].fir==p[i].fir){
				i++;
				on[p[i].sec]=1;
				comp++;
			}
			
			rep(j,M){
				if(on[e[j].sec.fir] && on[e[j].sec.sec]
				&& !same(e[j].sec.fir,e[j].sec.sec)){
					unite(e[j].sec.fir,e[j].sec.sec);
					ans+=e[j].fir;
					comp--;
				}
			}
			
			if(comp!=1){
				ans=0;
				init(N);
				comp=i+1;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1448
def main():
    n = int(input())
    if n < 10 or n % 2 == 1:
        print(0)
    else:
        ans = 0
        i = 10
        while i <= n:
            ans += n // i
            i *= 5
        print(ans)

if __name__ == '__main__':
    main()


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

int main() {
  int N;
  int A[110];
  cin >> N;
  for (int i=0; i<N; i++) cin >> A[i];
  sort(A, A+N);
  int max_A = A[N-1];
  int min_A = A[0];
  int r = max_A - min_A;
  cout << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
using namespace std;

int main()
{
    int h, n;
    cin >> h >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    if (sum < h)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector< vector< ll > > dot(N, vector< ll > (2));//(x,y)
    for(int i=0; i<N; i++){
        cin >> dot[i][0] >> dot[i][1];
    }
    ll ans=5000000000000000000;
    
    for(int a=0; a<N; a++){//x
        for(int b=a+1; b<N; b++){//x
            for(int c=0; c<N; c++){//y
                for(int d=c+1; d<N; d++){//y
                    int cnt=0;
                    ll tmp=abs(dot[a][0]-dot[b][0])*abs(dot[c][1]-dot[d][1]);
                    for(int i=0; i<N; i++){
                        if(min(dot[a][0], dot[b][0])<=dot[i][0] && max(dot[a][0], dot[b][0])>=dot[i][0]){
                            if(min(dot[c][1], dot[d][1])<=dot[i][1] && max(dot[c][1], dot[d][1])>=dot[i][1]) cnt++;
                        }
                    }
                    if(cnt>=K) ans=min(ans, tmp);
                }
            }
        }
    }
    
    cout << ans << endl;
 
    return 0;
}


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

int main()
{
    int n,t;
    cin>>n>>t;
    int mn=INT_MAX;
    for(int i=0;i<n;i++)
    {
       int a,b;
       cin>>a>>b;
       if(b<=t)
        mn=min(mn,a);
    }
    if(mn!=INT_MAX)
        cout<<mn;
    else
        cout<<"TLE"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a, b, c, d, e, f;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    e = a*b;
    f = c*d;
    if(e>f)
    {
        printf("%d", e);
    }
    else
    {
        printf("%d", f);
    }
    return 0;
}

Measured memory_bytes: 2152
import math
import statistics
import collections
a=int(input())
#b,c=int(input()),int(input())
# c=[]
#  for i in b:
#     c.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
g = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))

g.sort()

ma=0
count=1
#最大値求める
for i in range(a-1):
    if g[i]==g[i+1]:
        count+=1
    else:
        ma=max(ma,count)
        count=1

ma=max(ma,count)
count=1
ans=[]
#最大値の位置
for i in range(a-1):
    if g[i]==g[i+1]:
        count+=1
    else:
        if count==ma:
            ans.append(g[i])
        count=1
if count==ma:
    ans.append(g[-1])

for i in ans:
    print(i)


Measured memory_bytes: 26988
def main(n: int):
    ans = 0
    for i in range(1, n + 1):
        if i % 15 == 0:
            continue
        if i % 5 == 0:
            continue
        if i % 3 == 0:
            continue

        ans += i

    print(ans)


if __name__ == "__main__":
    n = int(input())

    main(n)


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

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	int mx = 0, mxp;
	rep(i, n) {
		if(mx < l[i]) {
			mx = l[i];
			mxp = i;
		}
	}
	int others = 0;
	rep(i, n) {
		if(i == mxp) continue;
		others += l[i];
	}
	if(others > mx) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
// B - Two Switches

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans;

	if (B <= C || D <= A) ans = 0;
	else ans = min(B, D) - max(A, C);

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int xl = 0;
  int xr = W;
  int yd = 0;
  int yu = H;
  for (int i = 0; i < N; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) xl = max(xl, x);
    if (a == 2) xr = min(xr, x);
    if (a == 3) yd = max(yd, y);
    if (a == 4) yu = min(yu, y);
  }
  int res = max(xr - xl, 0) * max(yu - yd, 0);
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	while(true){
		
		long long int b, c1, c2, q1, q2;
		
		cin >> q1;
		
		if(q1 == 0){
			break;
		}
		
		cin >> b >> c1 >> c2 >> q2;
		
		long long int ans1, ans2;
		
		if(c1 <= c2){
			ans1 = min(b / c1, q2);
			ans2 = (b - c1 * ans1) / c2;
		}else if(q1 * c1 > b){
			ans1 = min((b - q1 * c2) / (c1 - c2), q2);
			ans2 = (b - c1 * ans1) / c2;
		}else{
			ans1 = min(b / c1, q2);
			ans2 = (b - c1 * ans1) / c2;
		}
		
		
		if(ans1 < 1 || ans2 < 0 || ans1 + ans2 < q1){
			cout << "NA" << endl;
		}else{
			cout << ans1 << " " << ans2 << endl;
		}
		
		//cout << ans1 << " " << ans2 << endl;
	}
	
	return 0;
}

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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define debp(a) cerr << #a << " => " <<"("<<a.fs<<", "<<a.sc<<") " << en;
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debpa(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	char x; cin >> x;
	if (isupper(x)) {
		cout << "A" << endl;
	} else {
		cout << "a" << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
long long dp[3005][3005],mod=998244353;
int main(){
	long long i,j,a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	for(i=a;i<=c;i++){
		for(j=b;j<=d;j++){
			if(i==a&&j==b)
				dp[i][j]=1;
			else if(i==a)
				dp[i][j]=dp[i][j-1]*i%mod;
			else if(j==b)
				dp[i][j]=dp[i-1][j]*j%mod;
			else
				dp[i][j]=(dp[i-1][j]*j%mod+dp[i][j-1]*i%mod-dp[i-1][j-1]*(i-1)%mod*(j-1)%mod+mod)%mod;
		}
	}
	printf("%lld\n",dp[c][d]);
}


Measured memory_bytes: 72108