akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int q;

  	cin >> q;
	for(int i=0;i<q;i++){
		string x, y;
		cin >> x >> y;
        int n, m;
        n = x.size();
        m = y.size();
		int dp[n+1][m+1];
		for(int j=0;j<=n;j++){
          for(int k=0;k<=m;k++){
			dp[j][k] = 0;
			}
		}
		
		for(int j=0;j<n;j++){
			for(int k=0;k<m;k++){
				if(x[j]==y[k]){
					dp[j+1][k+1] = max(dp[j][k+1], max(dp[j+1][k], dp[j][k]+1));
				}else{
					dp[j+1][k+1] = max(dp[j][k+1], max(dp[j+1][k], dp[j][k]));
				}
			}
		}
		
		
		
		cout << dp[n][m] <<endl;
  
	}
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, P;
  cin >> N >> P;
  string s;
  cin >> s;
  if (P == 2 || P == 5) {
    i64 ans = 0;
    rep(i, N) if ((s[i] - '0') % P == 0) {
      ans += i + 1;
    }
    cout << ans << endl;
    return;
  }
  vi32 mod(N);
  int x = 1;
  rrep(i, N) {
    mod[i] = (s[i] - '0') * x % P;
    x = x * 10 % P;
  }
  vi32 acc(N + 1);
  rep(i, N) acc[i + 1] = (acc[i] + mod[i]) % P;
  vi32 cnt(P);
  rep(i, N + 1) cnt[acc[i]]++;
  i64 ans = 0;
  rep(i, P) {
    i64 x = cnt[i];
    ans += x * (x - 1) / 2;
  }
  cout << ans << endl;
}


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

int main(){
	int x, y;
	cin >> x >> y;
	int f = 0;
	for(int i=0; i<=100; i++){
		for(int j=0; j<=100; j++){
			if(i+j == x && 2*i+4*j == y) f = 1;
		}
	}
	if(f == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());

            Console.WriteLine(Lcm(360, x)/x);

            static long Lcm(long a, long b)
            {
                return a / Gcd(a, b) * b;
            }
            static long Gcd(long m, long n)
            {
                if (n == 0) return m;
                return Gcd(n, m % n);
            }
        }
    }
}


Measured memory_bytes: 26872
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

const ll INF = (ll)1e18 + 1;
ll n, k, a[200000] = {}, l = -INF, r = INF;

int main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	stable_sort(a, a + n);
	while (l + 1 < r) {
		ll mid = (l + r) / 2, sum = 0;
		rep(i, n) {
			if (a[i] < 0) {
				ll l2 = -1, r2 = n;
				while (l2 + 1 < r2) {
					ll mid2 = (l2 + r2) / 2;
					if (a[i] * a[mid2] < mid) {
						r2 = mid2;
					}
					else {
						l2 = mid2;
					}
				}
				sum += n - r2;
				if (r2 <= i)sum--;
			}
			else {
				ll l2 = -1, r2 = n;
				while (l2 + 1 < r2) {
					ll mid2 = (l2 + r2) / 2;
					if (a[i] * a[mid2] < mid) {
						l2 = mid2;
					}
					else {
						r2 = mid2;
					}
				}
				sum += l2 + 1;
				if (l2 >= i)sum--;
			}
		}
		if (sum / 2 < k) {
			l = mid;
		}
		else {
			r = mid;
		}
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 2560
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()
a=n1()

import itertools
ite=itertools.combinations(range(n),k)

ans=10**20
for line in ite:
    c=0
    b=a.copy()
    for i in range(1,k):
        if b[line[i]]<=b[line[i-1]]:
            plus=b[line[i-1]]-b[line[i]]+1
            b[line[i]]+=plus
            c+=plus
    ok=1
    for i in range(1,n):
        if b[i-1]<b[i]:
            ok+=1
        else:
            b[i]=b[i-1]
    if ok>=k:
        ans=min(ans,c)
print(ans)

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")


signed main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a) * b << nl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

map<ll, ll> fact(ll n) {
    map<ll, ll> ret;
    for (ll i = 2LL; i * i <= n; ++i) {
        while(n % i == 0){
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    ll n, p;
    cin >> n >> p;

    map<ll, ll> mp = fact(p);
    ll ans = 1;
    for(auto m : mp){
        if (m.second / n >= 1) ans *= pow(m.first, m.second / n);
    }

    cout << ans << endl;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C) {
  if (C >= A and C <= B) {
      cout << YES;
  } else {
      cout << NO;
  }
  cout << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int N,K,i,ai,bi;
    scanf("%d%d",&N,&K);
    if(N%2==0)
    {
        for(i=0;i<K;i++)
        {
            scanf("%d %d",&ai,&bi);
            if(ai>N/2&&bi<=N/2)
            {
                ai=N/2-(N/2-(N-ai)-1);
            }
            else if(ai<=N/2&&bi>N/2)
            {
                bi=N/2-(N/2-(N-bi)-1);
            }
            else if(ai>N/2&&bi>N/2)
            {
                ai=N/2-(N/2-(N-ai)-1);
                bi=N/2-(N/2-(N-bi)-1);
            }
            if(ai==bi)
            {
                ai+=3;
                ai=ai%3;
                if(ai==0)ai=3;
                printf("%d\n",ai);
            }
            else if(ai>bi)
            {
                bi+=3;
                bi=bi%3;
                if(bi==0)bi=3;
                printf("%d\n",bi);
            }
            else if(ai<bi)
            {
                ai+=3;
                ai=ai%3;
                if(ai==0)ai=3;
                printf("%d\n",ai);
            }
        }
    }
    else if(N%2==1)
    {
        for(i=0;i<K;i++)
        {
            scanf("%d %d",&ai,&bi);
            if(ai>N/2+1&&bi<=N/2+1)
            {
                ai=N/2-(ai-N/2-2);
            }
            else if(ai<=N/2+1&&bi>N/2+1)
            {
                bi=N/2-(bi-N/2-2);
            }
            else if(ai>N/2+1&&bi>N/2+1)
            {
                ai=N/2-(ai-N/2-2);
                bi=N/2-(bi-N/2-2);
            }
            if(ai==bi)
            {
                ai+=3;
                ai=ai%3;
                if(ai==0)ai=3;
                printf("%d\n",ai);
            }
            else if(ai>bi)
            {
                bi+=3;
                bi=bi%3;
                if(bi==0)bi=3;
                printf("%d\n",bi);
            }
            else if(ai<bi)
            {
                ai+=3;
                ai=ai%3;
                if(ai==0)ai=3;
                printf("%d\n",ai);
            }
        }
    }
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> bridge(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    bridge.at(i) = make_pair(a, b);
  }
  int total = 0;
  vector<int> line(N);
  for (int i = 0; i < N; i++) {
    line.at(i) = i + 1;
  }
  sort(line.begin(), line.end());
  do {
    if (line.at(0) == 1) {
      for (int i = 0; i < N - 1; i++) {
        bool able = false;
        for (int j = 0; j < M; j++) {
          if (bridge.at(j) == make_pair(line.at(i), line.at(i + 1)) || bridge.at(j) == make_pair(line.at(i + 1), line.at(i))) {
            able = true;
            break;
          }
        }
        if (!able) {
          break;
        }
        if (i == N - 2) {
          total += 1;
        }
      }
    }
  } while (next_permutation(line.begin(), line.end()));
  cout << total << endl;     
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  bool flag = 0;
  rep(i, n+1) {
    rep(j, m+1) {
      if ((n-i)*j+(m-j)*i == l) flag = 1;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		char[] s;
		char tmp;
		int m,h;
		while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		}
		scan.close();
	}
}

Measured memory_bytes: 20692
w = input()
duplex = set(w)
before_w = ''
result = 'Yes'
diff = 0
for i in duplex:
    before_w = w.replace(i, '')
    diff = diff + (len(w) - len(before_w))
    w = before_w
    if diff % 2 == 0:
        pass
    else:
        result = 'No'
        break

print(result)


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

int main (void)
{
	int A[100][100],B[100][100],n,m,l;
	long int C[100][100];
	int i,j,k;
	
	for(i = 0 ; i < 100 ; i ++ )
	{
		for(j = 0 ; j < 100 ; j ++ )
		{
			A[i][j] = 0;
			B[i][j] = 0;
			C[i][j] = 0;
		}
	}
	
	scanf("%d %d %d",&n,&m,&l);
	
	for(i = 0 ; i < n ; i++)
	{
		for(j = 0 ; j < m ; j++)
		{
			scanf("%d",&A[i][j]);
		}
	}
	
	for(i = 0 ; i < m ; i++)
	{
		for(j = 0 ; j < l ; j++)
		{
			scanf("%d",&B[i][j]);
		}
	}
	
	for(i = 0 ; i < n ; i++)
	{
		for(j = 0 ; j < l ; j++)
		{
			for(k = 0 ; k < m ; k++)
			{
				C[i][j] = C[i][j] + A[i][k] * B[k][j];
			}
		}
	}
	
	for(i = 0 ; i < n ; i++)
	{
		for(j = 0 ; j < l ; j++)
		{
			printf("%ld",C[i][j]);
			if(j != l - 1)
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}


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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;


int32_t main() {
	FAST_IO;
	
	int n, m;
	cin >> n >> m;
	int x;
	cin >> x;
	
	int a[n][m];
	int c[n];
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	
	int ans = INF;
	for (int i = 1; i < (1ll<<n); i++) {
		int sum = 0;
		vi v(m, 0);
		for (int j = 0; j < 15; j++) {
			if (i&(1ll<<j)) {
				sum += c[j];
				for (int k = 0; k < m; k++) {
					v[k] += a[j][k];
				}
			}
		}
		
		bool ok = true;
		for (int j = 0; j < m; j++) {
			if (v[j] < x) ok = false;
		}
		
		if (ok) {
			ans = min(ans, sum);
		}
	}
	
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */
int main(){

    int n, m, x;
    set<int> odd, even;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        odd.insert(x);
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> x;
        even.insert(x);
    }

    // ==========================================
    set<int> s;
    set_difference(odd.begin(), odd.end(),
          even.begin(), even.end(),
          inserter(s, s.begin()));

    for (auto const &e: s) {
        cout << e << '\n';
    }
}



Measured memory_bytes: 31200
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val v = LongArray(n) { scanner.nextLong() }

    val ret = v.sorted()
        .map { it.toDouble() }
        .reduce { acc, l -> (acc + l) / 2.0 }
    println(ret)
}

Measured memory_bytes: 34160
n=int(input())
F=[]
P=[]
for _ in range(n):
    b="".join(input().split())
    F.append(int(b, 2))
for _ in range(n):
    inp=list(map(int,input().split()))
    P.append(inp)

ans=-10**18
for i in range(1, 1024):
    earn=0
    for j,f in enumerate(F):
        same=bin(i&f)[2:].zfill(10)
        same=same.count("1")
        earn+=P[j][same]
    ans=max(ans, earn)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    while (cin>>s)
    {
        int a=0,k=0;
        for (int i=0;i<3;i++)
        {
            if (s[i]=='o')
            {
                k++;
            }
        }
        a=700+k*100;
        cout<<a<<endl;
    }
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll a,b,c,d,e,k,check;
  cin >> a>>b>>c>>d>>e>>k;
  if(e-a>k){
    cout << ":("<<endl;
  }else{
    cout << "Yay!"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 200000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

ll N;
ll A[MAX], B[MAX];

int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i] >> B[i];
    }    

    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;

    REP(i, N) {
        pq.push(make_pair(B[i], A[i]));
    }
    bool flag = true;
    ll t = 0;
    REP(i, N) {
        auto a = pq.top().second;
        auto b = pq.top().first;
        pq.pop();
        t += a;
        if (t > b) {
            flag = false;
            break;
        }  
    }

    string S;
    
    if (flag) {
        S = "Yes";
    } else {
        S = "No";
    }

    cout << S << endl;
    return 0;
}


Measured memory_bytes: 9456
#include <stdio.h>
#include <string.h>

int main(void)
{
    int i;
    int isused[26];
    char ans[36];
    char buf, arrow[3];
    char ctos[36];
    int n;
    
    scanf("%d", &n);
    getchar();
    while (n--){
        memset(ans, '\0', sizeof(ans));
        memset(isused, 0, sizeof(isused));
        scanf("%c", &buf);
        isused[buf - 'a'] = 1;
        
        ans[0] = buf;
        while (buf != '\n'){
            
            scanf("%[<>'-]", arrow);
            scanf("%c", &buf);
            
            if (buf != '\n' && isused[buf - 'a'] == 0){
                if (strcmp(arrow, "->") == 0){
                    ans[strlen(ans)] = buf;
                    ans[strlen(ans)] = '\0';
                }
                else if (strcmp(arrow, "<-") == 0){
                    for (i = strlen(ans); i > 0; i--){
                        ans[i] = ans[i - 1];
                    }
                    ans[0] = buf;
                }
                isused[buf - 'a'] = 1;
            }
        }
        printf("%s\n", ans);
    }
    
    return (0);
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

bool solve(long long N, long long d)
{
	while(N%d==0) N/=d;
	return N%d==1;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	long long N, K, ans=2;
	cin>>N; K=N-1;
	if(N==2) {
		cout<<"1\n";
		return 0;
	}
	for(int i=2;1LL*i*i<=N;i++) if(N%i==0) {
		ans+=solve(N,i);
		if(1LL*i*i!=N) ans+=solve(N,N/i);
	}
	for(int i=2;1LL*i*i<=K;i++) if(K%i==0) ans+=1+(1LL*i*i!=K);
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    S = [int(input()) for _ in range(N)]

    S.sort(reverse=True)

    diff_arr = [S[i] - S[i+K-1] for i in range(len(S)-K+1)]
    # [print(S[i], S[i+K-1], i, i+K-1) for i in range(len(S)-K)]
    
    # print(diff_arr)
    # mx_idx = diff_arr.index(min(diff_arr))
    # mn_idx = mx_idx + K - 1

    print(min(diff_arr))

if __name__ == "__main__":
    main()

Measured memory_bytes: 11288
#include <stdio.h>

int main(void)
{
    int a, i, n, max = 0, min = 0;
    
    long int sum = 0;

    scanf("%d", &n);

    max = -1000000;
    min = 1000000;
        

    for (i = 0; i < n; ++i){

        scanf("%d", &a);

        if (max < a)
            max = a;

        if (min > a)
            min = a;
        
        sum += a;  
    }

    printf("%d %d %ld\n", min, max, sum);

    return 0;

}


Measured memory_bytes: 2100
import itertools as it
import sys
sys.setrecursionlimit(10**9)
"""
N=int(input())
D=[]
for i in range(N):
  s,p=input().split()
  D.append((s, int(p), i+1))
D.sort(key=lambda d: (d[0], -d[1], d[2]))

for d in D:
  print(d[2])
"""
N,M=map(int, input().split())
K=[]
S=[]
for i in range(M):
  k,*si=map(int, input().split())
  K.append(k)
  S.append(list(sorted(si)))
P=list(map(int, input().split()))

L=it.product([0,1], repeat=N)
cnt=0
#print(S)
for l in L:
  ok=True
  for i,si in enumerate(S):
    pi=P[i]
    sumS=len(list(filter(lambda it: l[it-1]==1, si)))
    #print(l, sumS)
    if sumS%2 != pi: ok=False
  if ok: cnt += 1
print(cnt)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

bool is_palindrome(const string &S) {
  string S2 = S;
  reverse(all(S2));
  return S == S2;
}

int main(int argc, char *argv[]) {
  string S;
  getline(cin, S);
  i64 N = sz(S);

  bool ans = is_palindrome(S) &&
    is_palindrome(S.substr(0, (N-1)/2)) &&
    is_palindrome(S.substr((N+1)/2, (N-1)/2));

  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
    long long cnt=0;
    cin>>S; int N= S.size();
    for(int i=0;i<N;i++) cnt+=(S[i]=='B');
    int m =N-cnt;
    long long ans =0;
    for(int i=0;i<N;i++) {
        if(S[i]=='B'){
            ans+=1LL*(m-i);
            m++;
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;

int main(){
        string a, b;
        cin >> a >> b;
        int c;
        sscanf((a+b).c_str(), "%d", &c);
        for (int i = 1; i*i <= c; i++) {
                if (i*i == c) {
                        cout << "Yes" << endl;
                        return 0;
                }
        }
        cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    
    public static boolean isATCG(char c) {
        switch(c) {
        case 'A':
            return true;
        case 'C':
            return true;
        case 'G':
            return true;
        case 'T':
            return true;
        default:
            return false;
        }        
    }
    
    
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        char[] input_buf = input.toCharArray();
        
        int tmpMaxCnt = 0;
        int maxCnt = 0;
        for (int i = 0; i < input_buf.length; i++) {
            if ( isATCG(input_buf[i]) ) {
                ++tmpMaxCnt;
            } else {
                if ( tmpMaxCnt > maxCnt ) {
                    maxCnt = tmpMaxCnt;
                    tmpMaxCnt = 0;
                }
            }
            
        }
        
        if ( tmpMaxCnt > maxCnt ) {
            maxCnt = tmpMaxCnt;
        }
        
        System.out.println(maxCnt);
        
        
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
typedef long long int ll;
#define MOD 1000000007
#define MAXN 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
using namespace std;


int main() {
    ll n,m;
    cin >> n >> m;
    ll a[n];
    long double tot=0;
    f(i,0,n){
        cin >> a[i];
        tot+=a[i];
    }
    
    sort(a,a+n,greater<ll>());
    ll d=ceil(tot/(4*m)),ans=0;
    f(i,0,n){
        if(a[i]>=d){
            ans++;
        }
    }
    
    if(ans>=m){
        cout <<"Yes";
    }else{
        cout <<"No";
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
/* function */
/* main */
int main() {
    int n, k;
    cin >> n >> k;
    mint ans = 1;
    if (n > k) { cout << 0 << '\n'; return 0; }
    for (int i = k - n + 1; i <= k; i++) {mint a = i; ans *= a; }
    cout << ans << '\n';
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define LL  long long
#define pii pair<int, int>
#define LIM 1000
#define MOD 1000000007

string grid[LIM+5];
LL dp[LIM+5][LIM+5];

int main(){
    //freopen("ip.txt", "r", stdin);
    int row, col; cin>>row>>col;
    for(int i = 0; i < row; i++) cin>>grid[i];
    dp[0][0] = 1;
    for(int i = 0; i < row; i++){
        for(int j = 0; j < col; j++){
            if(i == 0 && j == 0) continue;
            if(grid[i][j] == '#') dp[i][j] = 0;
            else if(i == 0) dp[i][j] = dp[i][j-1];
            else if(j == 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = (dp[i][j-1] + dp[i-1][j])%MOD;
        }
    }
    cout<<dp[row-1][col-1]<<'\n';
}


Measured memory_bytes: 13344
n = int(input())
d = []
for i in range(n):
  d.append(list(map(int,input().split())))
num = 0
ans = "No"
for i in range(n):
  if d[i][0]==d[i][1]:
    num+=1
    if num == 3:
      ans = "Yes"
      break
  else:
    num = 0
print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

ll N, X;

int main(int argc, char **argv) {
	cin >> N >> X;
	ll n1 = X, n2 = N - X, res = 0;
	while (n2 != 0) {
		res += (n1 / n2) * 2 * n2;
		swap(n1, n2);
		n2 %= n1;
	}
	res += N - n1;
	cout << res << endl;
	return 0;
}


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

#define ll long long
#define ld long double
#define pr pair<ll,ll>
#define loop(i,n) for(ll i=0 ; i<n ; ++i)
#define rep(i,x,n) for(ll i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)
using namespace std;
const ll N=2e2 + 5;
int n,k;
int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
#ifndef ONLINE_JUDGE
   // freopen("in.txt", "rt" , stdin);
    // freopen("out.txt", "wt" , stdout);
#endif // ONLINE_JUDGE
    cin>>n>>k;
    cout<<n-k+1<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
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; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

vvecllong edge;
vecllong memo;

llong search(llong now) {
    if(edge[now].size() == 0) {
        return 0;
    }
    if(memo[now] >= 0) {
        return memo[now];
    }

    llong ret = 0;
    for_each(edge[now].begin(), edge[now].end(), [&ret](llong to) {
        if(memo[to] >= 0) {
            chmax(ret, memo[to]);
        } else {
            chmax(ret, search(to));
        }
    });

    memo[now] = ret + 1;

    return ret + 1;
};

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

    llong N, M;
    cin >> N >> M;

    edge = vvecllong(N + 1, vecllong(0));  // edge[from][to]
    memo = vecllong(N + 1, -1);

    FOR(i, M) {
        llong from, to;
        cin >> from >> to;
        edge[from].push_back(to);
    }

    llong ans = 0;
    FORS(i, 1, N + 1) {
        if(memo[i] >= 0) {
            chmax(ans, memo[i]);
        } else {
            chmax(ans, search(i));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8576
//### In The Name Of GOD ###

// %% Remember; (((He))) is The (((Accepter))) %%

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2 * 1000 * 1000 + 200;
const int MAXN = 1000 + 20;
const int MLOG = 18;
const int NMAX = 1 * 1000;

int xy[MAXN][3];
ld dis[MAXN][MAXN], dist[MAXN], disdis[MAXN];

void dij(int x, int n){
  for(int i = 0; i < n; i++){
    dist[i] = 1e100;
    disdis[i] = 1e100;
  }
  dist[x] = 0;
  disdis[x] = 0;
  for(int k = 0; k < n; k++){
    int i = (int)(min_element(disdis, disdis + n) - disdis);
    disdis[i] = 1e100;
    for(int j = 0; j < n; j++){
      if(dist[i] + dis[i][j] < dist[j]){
        dist[j] = dist[i] + dis[i][j];
        disdis[j] = dist[i] + dis[i][j];
      }
    }
  }
}

signed main(){
  IO;
  cin >> xy[0][0] >> xy[0][1] >> xy[1][0] >> xy[1][1];
  int n;
  cin >> n;
  for(int i = 2; i < n + 2; i++) cin >> xy[i][0] >> xy[i][1] >> xy[i][2];
  for(int i = 0; i < n + 2; i++){
    for(int j = 0; j < n + 2; j++){
      dis[i][j] = max(sqrt( pow((ld)(abs(xy[i][0] - xy[j][0])), ld(2)) + pow((ld)(abs(xy[i][1] - xy[j][1])), ld(2)) ) - xy[i][2] - xy[j][2], (ld)0);
      // cout << i << ' ' << j << ' ' << dis[i][j] << ' ' << sqrt( pow((ld)(abs(xy[i][0] - xy[j][0])), ld(2)) + pow((ld)(abs(xy[i][1] - xy[j][1])), ld(2)) ) - xy[i][2] - xy[j][2] << endl;
    }
  }
  dij(0, n + 2);
  cout << fixed << setprecision(20) << dist[1];
}


Measured memory_bytes: 16384
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]
Mod = 10 ** 9 + 7

danger = []
for i in 1..N do
  danger.push(false)
end
for i in 1..M do
  danger[lines[i][0]-1] = true
end

ways = []
for i in 1..N do
  if danger[i-1] then
    ways[i-1] = 0
  elsif i == 1 then
    ways[i-1] = 1
  elsif i == 2 then
    ways[i-1] = ways[i-2] + 1
  else
    ways[i-1] = ways[i-2] + ways[i-3]
  end
end
    
print ways[N-1] % Mod

Measured memory_bytes: 445884
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n;
ll a[maxn];
void GG()
{
    cout<<-1<<endl; exit(0);
}
int main()
{
    fastio();
    cin>>n;
    rep(i,1,n) cin>>a[i];
    ll x = 0;
    rep(i,3,n) x ^= a[i];
    ll t = a[1] + a[2];
    ll b = (t-x)>>1;
    if(t<x || ((t-x)&1) || (b&x)) GG();
    per(i,62,0){
        if ((x>>i)&1){
            ll tmp = 1LL<<i;
            if((b+tmp) <= a[1])b += tmp;
        }
    }
    if(b>0 && b<=a[1]) cout<<a[1]-b<<endl;
    else GG();
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 1999999999
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

#ifdef INPUT
stringstream input(R"(
2 1
3 2
4 3
)");
#define cin input
#endif

int main()
{
    vector <int> a(3);
    vector <int> b(3);
    for (int i=0; i<3; i++) {
        cin >> a[i] >> b[i];
        if (a[i]>b[i]) {
            swap (a[i],b[i]);
        }
    }

    set< pair<int, int> > m;
    for (int i=0; i<3; i++)
        m.insert(make_pair(a[i], b[i]));

    int n=0;
    for(auto&& x : m) {
        a[n] = x.first;
        b[n] = x.second;
        n++;
    }

    if (a[0]==1&&a[1]==2&&a[2]==3&&b[0]==2&&b[1]==4&&b[2]==4||
    a[0]==1&&a[1]==2&&a[2]==3&&b[0]==2&&b[1]==3&&b[2]==4||
    a[0]==1&&a[1]==2&&a[2]==3&&b[0]==3&&b[1]==4&&b[2]==4||
    a[0]==1&&a[1]==2&&a[2]==2&&b[0]==3&&b[1]==3&&b[2]==4||
    a[0]==1&&a[1]==2&&a[2]==2&&b[0]==4&&b[1]==3&&b[2]==4||
    a[0]==1&&a[1]==2&&a[2]==3&&b[0]==4&&b[1]==3&&b[2]==4)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
        
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>

template <class T>
T calc_number_of_digits(T x) {
    T ret = 0;
    do {
        ++ret;
        x /= 10;
    } while (x);
    
    return ret;
}

template <class T>
T f(T a, T b) {
    return std::max<T>(calc_number_of_digits<T>(a), calc_number_of_digits<T>(b));
}

int main() {
    long long N;
    std::cin >> N;

    auto ret = std::numeric_limits<long long>::max();
    for (long long a = 1; a * a <= N; ++a) {
        if (N % a != 0) {
            continue;
        }

        const auto b = N / a;
        ret = std::min(ret, f(a, b));
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll M, D;
  cin >> M >> D;

  ll ans = 0;
  for (ll m = 1; m <= M; m++)
  {
    for (ll d = 1; d <= D; d++)
    {
      ll d1 = d % 10;
      ll d10 = d / 10;
      if (d1 < 2)
        continue;
      if (d10 < 2)
        continue;
      if (d1 * d10 == m)
        ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 1000010
#define mod 1000000007
int n,f[MAXN],add;
int main()
{
    cin>>n;
    f[n]=n;
    f[n-1]=(long long)n*n%mod;
    for(int i=n-2;i>=1;--i)
    {
        add=(add+f[i+3])%mod;
        f[i]=f[i+1];
        f[i]=(f[i]+(long long)(n-1)*(n-1)%mod)%mod;
        f[i]=(f[i]+add)%mod;
        f[i]=(f[i]+i+1)%mod;
    }
    cout<<f[1]<<endl;
}

Measured memory_bytes: 4096
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<queue>

#define rep(i, n) for(int i; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int>> graph(N);
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<bool> seen;
    seen.resize(N);
    rep(i,N) seen[i]=false;
    queue<int> que1, queN;
    que1.push(0);
    queN.push(N-1);
    seen[0]=true;
    seen[N-1]=true;
    int sum1=1;
    int sumN=1;
    while(!(que1.empty() && queN.empty())){
        int size1 = que1.size();
        int sizeN = queN.size(); 
        //cout << size1 << sizeN << endl;
        for(int i=0; i<size1; i++){
            int j = que1.front();
            que1.pop();
            for(auto x : graph[j]){
                if(seen[x]){
                    continue;
                }else{
                    que1.push(x);
                    seen[x] = true;
                    sum1++;
                }
            }
        }
        for(int i=0; i<sizeN; i++){
            int j = queN.front();
            queN.pop();
            for(auto x : graph[j]){
                if(seen[x]){
                    continue;
                }else{
                    queN.push(x);
                    seen[x] = true;
                    sumN++;
                }
            }
        }
    }
    //cout << sum1 << sumN <<endl;
    if(sum1>sumN){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }

    return 0;
}

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

T1 = S[:N]
T2 = S[N:][::-1]

def window(i, P, L):
    if i == N:
        L.append(P)
        return L
    L = window(i+1, P+[0], L)
    L = window(i+1, P+[1], L)
    return L

L = window(0, [], [])
dic1 = {}
dic2 = {}
for mask in L:
    k1 = ''
    k2 = ''
    r1 = ''
    r2 = ''
    for i in range(N):
        if mask[i]:
            k1 += T1[i]
            k2 += T2[i]
        else:
            r1 += T1[i]
            r2 += T2[i]
    c1 = k1 + '_' + r1
    c2 = k2 + '_' + r2
    if not c1 in dic1.keys():
        dic1[c1] = 1
    else:
        dic1[c1] += 1
    if not c2 in dic2.keys():
        dic2[c2] = 1
    else:
        dic2[c2] += 1

ans = 0
for k1, v1 in dic1.items():
    if k1 in dic2.keys():
        ans += dic2[k1]*v1
print(ans)

Measured memory_bytes: 124740
fun main(args: Array<String>) = println(run {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }

    val rest = n - a.sum()
    when {
        rest >= 0 -> rest
        else -> -1
    }
})

Measured memory_bytes: 39416
<?php
# 標準出力
fscanf(STDIN, "%d %d",$N,$L);
$min = 1000;
$sum = 0;

for ($i = 1; $i <= $N; $i++){
	
	$tmp = $L + $i - 1;
	$sum = $sum + $tmp;
	#一番小さいりんごの味
	if (abs($tmp) < abs($min)){
		
		$min = $tmp;
	}
}
echo $sum - $min;
?>

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	if (s[0] != '1') {
		cout << s[0] << endl;
	}
	else {
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != '1'&&k>=i+1) {
				cout << s[i] << endl;
				return 0;
			}
		}
		cout << "1" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void leap_year(int first_year, int last_year);

int main(void)
{
    int first_year, last_year;
    static int dataset_number = 0; 
    scanf("%d %d", &first_year, &last_year);
    while (1) {
        if (first_year == 0 && last_year == 0) {
            break;
        } else {
            if (dataset_number != 0) {
                printf("\n");
            }
            leap_year(first_year, last_year);
            scanf("%d %d", &first_year, &last_year);
        ++dataset_number;
        }
    }
    return 0;
}

void leap_year(int first_year, int last_year)
{
    int count = 0;
    for (int year = first_year; year <= last_year; ++year) {
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
           printf("%d\n", year);
        } else {
            ++count;
        }
    }
    if (count == last_year - first_year + 1) {
        printf("NA\n");
    }
}

Measured memory_bytes: 1044
/* Read input from STDIN. Print your output to STDOUT*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,i,j,k,l,m,o,p,q,r,s,t;
    cin>>s;
    p=(s/500)*500;
    r=(2*p);
    q=s-p;
    o=(q/5)*5;
    r+=o;
    cout<<r<<endl;
    return 0;
}


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int>p(n);
    rep(i,n){
        int x;
        cin>>x;
        p[x-1]=1+i;
    }
    
    rep(i,n)
      cout<<30000*(i+1)+p[i]/2<<' ';
    
    cout<<endl;
    rep(i,n)
      cout<<30000*(n-i)+(p[i]-1)/2<<' ';
      
    cout<<endl;
    
        
    return 0;
}


Measured memory_bytes: 768
A = int(input())
B = int(input())
C = int(input())
X = int(input())

d = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a * 500 + b * 100 + c * 50 == X:
                d += 1
print(d)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define toup toupper
#define tolow tolower
const int mod = 1000000;
const int maxn = 10000;
typedef long long ll;
using namespace std;

int length(ll n){
	return (int)log10(n) + 1;
}

ll quickpow(ll x, ll y){
	ll res = 1;
	while(y){
		if(y & 1) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}

ll fac(ll x){
	if(x == 0 || x == 1) return 1;
	return x * fac(x - 1);//mod
}

int a[5];

int main(){
	cin >> a[1] >> a[2] >> a[3];
	//int x = a[1], y = a[2], z = a[3];
	sort(a + 1, a + 3 + 1);
	int ans = 0;
	while(a[2] != a[3]){
		a[1]++, a[2]++;
		ans++;
	}
	while(a[1] != a[2] && a[2] - a[1] != 1){
		a[1] += 2;
		ans++;
	}
	if(a[2] - a[1] == 1){
		ans += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [[x-1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]

def can_match(i, A, next_set):
  if not A[i]:
    return
  j = A[i][-1]
  if A[j][-1] == i:
    if i < j:
      next_set.add((i,j))
    else:
      next_set.add((j,i))
      
next_set = set()
for i in range(N):
  can_match(i, A, next_set)
  
day = 0
battle = 0
while next_set:
  day += 1
  current_set, next_set = next_set, set()
  for match in current_set:
    battle += 1
    del A[match[0]][-1]
    can_match(match[0], A, next_set)
    del A[match[1]][-1]
    can_match(match[1], A, next_set)
    
if battle == N*(N-1)//2:
  print(day)
else:
  print(-1)

Measured memory_bytes: 35604
import math
a,b,x = map(int,input().split())
if x >= b*a*a*0.5:
  ans = math.degrees(math.atan((2*(a*a*b-x)/(a**3))))
else:
  ans = 90-math.degrees(math.atan(2*x/(a*b*b)))
print(ans)  

Measured memory_bytes: 3572