akhauriyash/Code-Regression huggingface dataset:
//     自己选择的路，跪着也要走完。朋友们，虽然这个世界日益浮躁起来，只
// 要能够为了当时纯粹的梦想和感动坚持努力下去，不管其它人怎么样，我们也
// 能够保持自己的本色走下去。                               ——陈立杰

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

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-' && c != EOF) c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
       return init * flag;
}

template <typename Int>
inline Int read(char &c)       
{
    Int flag = 1;
    c = getchar();
    while ((!isdigit(c)) && c != '-' && c != EOF) c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
       return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

// #define int int64

int h1, m1, h2, m2, k;

signed main() {
    h1 = read<int>();
    m1 = read<int>();
    h2 = read<int>();
    m2 = read<int>();
    k = read<int>();
    write(h2 * 60 + m2 - (h1 * 60 + m1) - k, 10);
    return 0;
}

// Create File Date : 2020--

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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 (b<a) { a=b; return 1; } return 0; }

int main()
{
    int r, g, b, n; cin >> r >> g >> b >> n;
    int ans = 0;
    int rn=0, gn=0, bn=0;
    while(1){
        if(rn*r > n) break;
        int m = n - rn*r;
        gn = 0;
        while(1){
            if(gn*g > m) break;
            int l = m - gn*g;
            if(l%b==0) ans++;
            gn++;
        }
        rn++;
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3536
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    A_sorted = sorted(A)

    for i in range(N):
        if A_sorted[-1] == A[i]:
            print(A_sorted[-2])
        else:
            print(A_sorted[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 14108
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (Math.abs(x - a) > Math.abs(x - b)) {
			pr.println('B');
		} else {
			pr.println('A');
		}
	}

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

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n,w;
        cin >> n >> w;
        int weight[n+1],value[n+1];
        for(int i=0; i<n; i++){
            cin >> weight[i] >> value[i];
        }
        int dp[n+1][w+1];
        for(int i=0; i<=n; i++){
            for(int j=0; j<=w; j++){
                dp[i][j]=0;
            }
        }

        for (int i=0; i<=n; i++){
            for(int j=0; j<=w; j++){
                if(i==0 || j==0) dp[i][j]=0;
                else if(weight[i-1]<=j){
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i-1]]+value[i-1]);
                }
                else{
                    dp[i][j]=dp[i-1][j];
                }
            }
        }

        cout << dp[n][w] << '\n';
        
}


Measured memory_bytes: 79232
#include <iostream>
#define LL long long
#define STR_SIZE 30
using namespace std;

int main(int argc, char const *argv[])
{
	LL num = 0L;
	char res[STR_SIZE] = {0};
	int i = 0;
	cin >> num;
	num --;
	while (num >= 0)
	{
		// cout << i << " " <<num << endl;
		res[STR_SIZE - i - 1] = (num % 26) + 'a';
		i ++;
		num /= 26;
		num --;
	}
	for (int j = 0; j <= i; ++j)
	{
		res[j] = res[STR_SIZE + j - i];
		res[STR_SIZE + j - i] = 0;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    double d;
    cin >> d;
    int d_ = (int)d;
    double maxi = sqrt(2) * d;
    if (d_ * d_ + 1 >= d * d) {
        maxi = max((double)d_ + 1, maxi);
    }
    cout << fixed << setprecision(12) << maxi << endl;

    return 0;
}

Measured memory_bytes: 3268
def warshall_floyd(G):
    '''
    G: N * N Array (Adjacency matrix)
    ret: N * N Array (Minimum path)
    '''
    import copy
    ret = copy.deepcopy(G)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                ret[i][j] = min(ret[i][j], ret[i][k] + ret[k][j])
    return ret


INF = 10 ** 10
N, M, L = map(int, input().split())

G = [[INF] * N for _ in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    G[A - 1][B - 1], G[B - 1][A - 1] = C, C

MinG = warshall_floyd(G)
GL = [[1 if MinG[i][j] <= L else INF for j in range(N)] for i in range(N)]
MinGL = warshall_floyd(GL)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    print(-1 if MinGL[s - 1][t - 1] == INF else MinGL[s - 1][t - 1] - 1)


Measured memory_bytes: 73304
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    s = input()
    t = input()

    s_list = sorted(s)
    t_list = sorted(t, reverse=True)
    S = ''.join(s_list)
    T = ''.join(t_list)
    if S < T:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 62056
from bisect import bisect_left
import sys

input = sys.stdin.readline

s = input().strip()
n = len(s)
t = input().strip()

d = [[] for _ in range(26)]
base = ord('a')
for i, c in enumerate(s):
    idx = ord(c) - base
    d[idx].append(i)

string_count = 0
cur = -1
for tt in t:
    cur += 1
    idx = ord(tt) - base
    pos_lst = d[idx]
    lst_len = len(pos_lst)

    if not lst_len:
        print(-1)
        exit()
    pos = bisect_left(pos_lst, cur)  # cur以降で文字ttが見つかる位置
    if lst_len == pos:
        string_count += 1
        cur = pos_lst[0]
    else:
        cur = pos_lst[pos]

    # print(cur, pos_lst, lst_len, string_count * n)

print(string_count * n + cur + 1)


Measured memory_bytes: 7668
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    string s,t;
    while (cin >> s >> t) {
        sort(ALL(s));
        sort(ALL(t));
        int x[129] = {0};
        int y[129] = {0};
        const int n = s.size();
        FOR(i,0,n) {
            const char a = s[i];
            const char b = t[i];
            x[a]++;
            y[b]++;
        }
        VI A,B;
        FOR(i,0,SZ(x)) {
            A.push_back(x[i]);
            B.push_back(y[i]);
        }
        sort(ALL(A));
        sort(ALL(B));
        string ans = "No";
        if (A == B)
            ans = "Yes";
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 916
#include <cstdio>
#include <algorithm>

using namespace std;

int n, c, k, ans = 0, a[100010];

int main() {

    scanf("%d %d %d", &n, &c, &k);

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

    sort(a, a + n);

    for (int i = 0; i < n;) {
        ans++;
        int j = i;
        while (j < n && a[j] <= a[i] + k && j - i < c) {
            j++;
        }
        i = j;
    }

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

    return 0;

}


Measured memory_bytes: 512
#include <stdio.h>
int n, cnt;
int A[1000000];

void shellSort();
void insertionSort(int);

int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
  {
    scanf("%d", A+i);
  }
  shellSort();
  return 0;
}

void insertionSort(int g)
{
  int va;
  int i, j;
  for(i = g; i < n; i++)
  {
    va = A[i];
    j = i-g;

    while(j >= 0 && A[j] > va)
     {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = va;
  }
}
void shellSort()
 {

  int G[100];
  int l = 0, g = 0;
  int i;

  while(3 * g + 1 <= n) {
    g = 3 * g + 1;
    G[l++] = g;

  }

  printf("%d\n", l);
  for(i = l - 1; i >= 0; i--)
   {

    if(i < l - 1) printf(" ");
    printf("%d", G[i]);
    insertionSort(G[i]);
  }
  puts("");


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

  for(i = 0; i < n; i++){
    printf("%d\n", A[i]);
  }
}

Measured memory_bytes: 4520
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	long long int N, L[87], tmp;

	L[0] = 2;
	L[1] = 1;

	cin >> N;
	
	if (N >= 2) {
		for (int i = 2; i <= N; i++) {
			L[i] = L[i - 1] + L[i - 2];
		}
	}
		cout << L[N];

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    s64 A, B, C, K;
    cin >> A >> B >> C >> K;

    if(A >= K) {
        cout << K << endl;
    } else if(A + B >= K) {
        cout << A << endl;
    } else {
        cout << A - (K - A - B) << endl;
    }

    return 0;
}

Measured memory_bytes: 3544
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop(void);

int main(){
  int x,i=0,pp=0;
  char s[100];

  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){

      push(pop() + pop());

    } else if ( s[0] == '-' ){

      pp = pop();
      push(pop() - pp);
      

    } else if ( s[0] == '*' ){

      push(pop() * pop());

    } else if(s[0] == ' '){
    
    }else {
      
      x = atoi(s);
      //x=x-48;

      //printf("*%d\n",x);/*test*/

      push(x);

    }
    i++;
  }


  printf("%d\n",(int)pop());

  return 0;
}


int now = 0;
int value[100];

/*     push    */
void push(int num)
{//printf("**%d\n",num);/*test*/
  if (now < 100){
    value[now] = num;
    now++;
    
  }
  else exit(8);
}

/*   pop   */
int pop(void)
{
	if (now > 0)
		return value[--now];
	else exit(8);
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

int main()
{
  IOS;
  int k, x;
  cin >> k >> x;
  k*=500;
  if (k>=x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main(){
    int n;

    int S[13] = {0};
    int C[13] = {0};
    int H[13] = {0};
    int D[13] = {0};

    scanf("%d" , &n);

    for (int i = 0; i < n*2; i++)
    {
        char c;
        int x;
        scanf("%c", &c);
        scanf("%d", &x);

        switch (c)
        {
        case 'S':
            S[x-1] = 1;
            break;
        case 'H':
            H[x-1] = 1;
            break;
        case 'C':
            C[x-1] = 1;
            break;
        case 'D':
            D[x-1] = 1;
            break;

        default:
            break;
        }
    }

    for (int i = 0; i < 13; i++)
    {
        if (S[i] != 1)
        {
            printf("%c %d\n",'S',i+1);
        }
    }

    for (int i = 0; i < 13; i++)
    {
        if (H[i] != 1)
        {
            printf("%c %d\n",'H',i+1);
        }
    }

    for (int i = 0; i < 13; i++)
    {
        if (C[i] != 1)
        {
            printf("%c %d\n",'C',i+1);
        }
    }

    for (int i = 0; i < 13; i++)
    {
        if (D[i] != 1)
        {
            printf("%c %d\n",'D',i+1);
        }
    }

    return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

long double a, b, c;
ll lA[2010], uA[2010], lB[2010], uB[2010], lC[2010], uC[2010];

void solve() {
	string s;
	cin >> s;
	bool jud = true;
	rep(i, s.length()) {
		if (s[i] != s[s.length() - 1 - i]) jud = false;
	}
	rep(i, (s.length() - 1) / 2) if (s[i] != s[(s.length() - 1) / 2 - 1 - i]) jud = false;
	for (ll i = (s.length() + 3) / 2 - 1; i < s.length(); i++) {
		if (s[i] != s[s.length() + (s.length() + 3) / 2 - 2 - i]) jud = false;
	}
	if (jud) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


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

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using ll = long long int;
using ld = long double;
using vi = vector<int>;
using mii = map<int, int>;
using pii = pair<int, int>;

const int inf = 1e9;
const int N = 100005;
const ll mod = (ll) 1e9 + 7;

ll power(ll a, ll n){
	ll res = 1;
	a %= mod;

	while(n){
		if(n & 1)
			res = res * a % mod;

		n >>= 1;
		a = a * a % mod;
	}
	return res;
}

int32_t main(){
	fio;

	int n;
	cin >> n;
	if(n < 2){
		cout << 0 << '\n';
		return 0;
	}

	ll total = power(10, n);
	ll rem = (power(9, n) + power(9, n)) % mod - power(8, n) + mod;
	rem %= mod;
	ll ans = total - rem + mod;
	ans %= mod;
	cout << ans << '\n';

	return 0;
}

/*

 */


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
    int N,M;
    cin>>N>>M;

    int total{};
    vector<int> votes(N,0);
    for(auto& e : votes) {
        cin>>e;
        total += e;
    }

    sort(votes.begin(), votes.end(), greater<int>());

    if (votes[M-1] * 4*M <  total ) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;

}


Measured memory_bytes: 384
n, m = map(int, input().split())
lMax = 0
rMin = n
for i in range(m):
    l, r = map(int, input().split())
    lMax = max(l, lMax)
    rMin = min(r, rMin)
print(rMin - lMax + 1 if rMin >= lMax else 0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
typedef vector<lint> poly;

const lint mod = 1e9 + 7;
const lint INF = mod * mod;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int x[n], cntx[100010];
    rep(i, 100010) cntx[i] = 0;
    rep(i, n){
        scanf("%d", &x[i]);
        ++cntx[x[i]];
    }

    int num[m][2];
    rep(i, m)rep(j, 2) num[i][j] = 0;
    rep(i, 100010)if(cntx[i]){
        int t = i % m;
        if(cntx[i] % 2) ++num[t][1];
        num[t][0] += cntx[i]/2*2;
    }

    int ans = 0;
    for(int i=0; i*2<=m; ++i) {
        if (i == 0 || i * 2 == m) {
            ans += (num[i][0] + num[i][1]) / 2;
            continue;
        }
        int s = i, t = m-s;
        int nums = num[s][0] + num[s][1], numt = num[t][0] + num[t][1];
        if(nums < numt) swap(s, t), swap(nums, numt);
        ans += numt;
        if(num[s][1] < numt){
            numt -= num[s][1];
            num[s][0] -= numt;
        }
        ans += num[s][0] / 2;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 1792
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

t = inpl()
a = inpl()
b = inpl()
if (a[0] > b[0] and a[1] > b[1]) or (a[0] < b[0] and a[1] < b[1]):
    print(0)
    quit()
c = [0,0]
for i in range(2):
    c[i] = abs(a[i]-b[i]) * t[i]
if c[0] == c[1]:
    print('infinity')
    quit()
if c[0] > c[1]:
    print(0)
else:
    sa = c[1]-c[0]
    tmp = 0
    if c[1]%sa:
        tmp = 1
    print((c[1]-1)//(c[1]-c[0])*2 - tmp)


Measured memory_bytes: 72020
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define INF 2<<29

int main(){
  char s[11];
  int ans=0,temp=0;
  scanf("%s",s);

  for(int i=0;i<strlen(s);i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      temp++;
    }else{
      temp=0;
    }
    if(ans<temp) ans=temp;
  }

  printf("%d\n",ans);
  
  return 0;
}


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

int main() {
   while (1) {
      string s;
      getline(cin, s);
      if (s == ".") break;

      int n = s.size();
      stack<char> stk;
      bool ok = false;
      for (int i = 0; i < n; i++) {
         if (s[i] == '(') stk.push(s[i]);
         if (s[i] == '[') stk.push(s[i]);

         if (s[i] == ')') {
            // )と対応しない
            if (stk.size() == 0 || stk.top() != '(') {
               ok = true;
               break;
            }
            // )と対応する
            stk.pop();
         }
         if (s[i] == ']') {
            // ]と対応しない
            if (stk.size() == 0 || stk.top() != '[') {
               ok = true;
               break;
            }
            // [と対応する
            stk.pop();
         }
      }
      if (!ok && stk.empty()) {
         puts("yes");
      } else {
         puts("no");
      }
   }

   return 0;
}


Measured memory_bytes: 3148
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	if (N < M)cout << 0 << endl;
	else cout << 10 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int solve(string s) {
	int ans=0;
	for(int i=1; i<sz(s); i++) {
		if(s[i]==s[i-1]) {
			ans++;
			while(s[i]==s[i-1]||s[i]==s[i+1])
				s[i]='a'+rng(26);
		}
	}
	return ans;
}

void solve() {
	string s;
	int k;
	cin>>s>>k;
	if(k==1) {
		cout<<solve(s)<<endl;
	} else if(k==2){
		cout<<solve(s+s)<<endl;
	} else if(k&1) {
		int lol=solve(s);
		int tol=solve(s+s+s);
		cout<<lol+(tol-lol)*((k-1)/2)<<endl;
	} else {
		cout<<solve(s+s)+(solve(s+s+s+s)-solve(s+s))*(k/2-1)<<endl;
	}
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t) {
//		cout<<"Case "<<i<<": ";
		solve();
	}
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n; vector<lli> a;
int main() {
  cin >> n; read_n(a, n);
  sort(begin(a), end(a), greater<lli>());
  vector<lli> p;
  for (lli i=0; i<n-1; ++i) {
    if (a[i] == a[i+1]) { p.push_back(a[i]); ++i; }
  }
  cout << (p.size()>=2 ? p[0]*p[1] : 0) << endl;
  return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
ll A[505][505];

const int prime_max = 1000000;
int NP,prime[100000],divp[prime_max];
map<int,int> M;

void cprime() {
	if(NP) return;
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		prime[NP++]=i;
		for(ll j=1LL*i*i;j>=i&&j<prime_max;j+=i) if(divp[j]==0) divp[j]=i;
	}
}

ll LCM(ll a,ll b) {
	if(a==0) return b;
	if(b==0) return a;
	return a/__gcd(a,b)*b;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	cprime();
	
	vector<int> P[2];
	FOR(i,500) {
		P[0].push_back(prime[i]);
		P[1].push_back(prime[999-i]);
	}
	
	FOR(y,500) FOR(x,500) if((x+y)%2==0) {
		i=(x+y)/2;
		j=(x-y)/2+249;
		A[y][x]=1LL*P[0][i]*P[1][j];
	}
	FOR(y,500) FOR(x,500) if((x+y)%2==1) {
		if(y) A[y][x]=LCM(A[y-1][x],A[y][x]);
		if(x) A[y][x]=LCM(A[y][x-1],A[y][x]);
		if(y<499) A[y][x]=LCM(A[y+1][x],A[y][x]);
		if(x<499) A[y][x]=LCM(A[y][x+1],A[y][x]);
		A[y][x]++;
	}
	
	
	FOR(y,N) {
		FOR(x,N) cout<<A[y][x]<<" ";
		cout<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



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

#define g(a,b,c) for(int a=b;a<c;a++)
#define ff(a,b,c) for(int a=c;a>b;a--)
#define ffk(a,b,c) for(int a=b;a<=c;a++)
#define fff(a,b,c) for(int a=c;a>=b;a--)
int main (){
int n,a[10],maxx=0,tong=0;
cin>>n;
for(int i=0;i<n;i++){
	cin>>a[i];
	maxx=max(maxx,a[i]);
	tong+=a[i];
}
if(tong-maxx>maxx){
	cout<<"Yes";
}
else {
	cout<<"No";
}
}


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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()

void solve(){
	ll d,t,s,ds;
	cin>>d>>t>>s;	
	if(t*s>=d)
		cout<<"Yes\n";
	else
		cout<<"No\n";
		
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);  
  solve();  
  return 0;
}

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

namespace ABC166
{
    class Program
    {
        static void Main(string[] args)
        {
            c();
        }

        public static void c()
        {
            long[] nm = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long[] h  = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nm[0], m = nm[1];
            bool[] hi = new bool[n];
            for(long i = 0; i < n; i++)
            {
                hi[i] = true;
            }
            long ans = n;
            for(long i = 0; i < m; i++)
            {
                long[] ab = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                long a = ab[0], b = ab[1];
                if (h[a - 1] < h[b - 1] && hi[a - 1] == true)
                {
                    ans--;
                    hi[a - 1] = false;
                }
                else if (h[a - 1] > h[b - 1] && hi[b - 1] == true)
                {
                    ans--;
                    hi[b - 1] = false;
                }
                else if ( h[a-1] == h[b - 1])
                {
                    if(hi[a-1] == true)
                    {
                        ans--;
                        hi[a - 1] = false;
                    }
                    if(hi[b-1] == true)
                    {
                        ans--;
                        hi[b - 1] = false;
                    }
                }
            }
            
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 50144
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};


// dijikstra
/* int V;
vector<edge> G[10];
int d[10];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
*/

int main(){
    string str;
    cin >> str;
    int num[4];
    REP(i, 4){
        num[i] = str[i] - '0';
    } 
    bitset<3> bs;
    int k = 0;
    while(1){
        bs = k;
        int ans = num[0];
        FOR(i,1, 4){
            if(bs[i - 1]){
                ans += num[i];
            }else{
                ans -= num[i];
            }
        }
        if(ans == 7){
            cout << num[0];
            FOR(i, 1, 4){
                if(bs[i - 1]){
                    cout << '+';
                }else{
                    cout << '-';
                }
                cout << num[i];
            }
            cout << "=7" << endl;
            return 0;
        }
        k++;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main  {
   public static void main(String[] args) throws java.lang.Exception  {
      Scanner sc = new Scanner(System.in);
      
      int m = sc.nextInt();
      int n = sc.nextInt();
      
      if (m > 0 && n > 0) {
     
        int mm = m * (m - 1) / 2 ;
        int nn = n * (n - 1) / 2 ;

        System.out.println(mm + nn);
      
      } else if (m == 0 && n > 0) {
     	int mm = m ;
        int nn = n * (n - 1) / 2 ;

        System.out.println(mm + nn);	
      } else if (m > 0 && n == 0) {
        int mm = m * (m - 1) / 2 ;
        int nn = n ;

        System.out.println(mm + nn);
      } else {

        System.out.println(m + n);
      }
   }        
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<Int>> x(N, vector<Int>(D));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < D; ++j) {
			cin >> x[i][j];
		}
	}

	int res = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			Int dist = 0;
			for (int k = 0; k < D; ++k) {
				dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			Int y = 0;
			while (y * y <= dist) {
				if (y * y == dist) {
					++res;
					break;
				}
				y += 1;
			}
		}
	}
	cout << res << endl;

	return 0;
}


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

int main(){
    string s0,t;
    cin >> s0 >> t;
    vector<set<int>> s(26);
    int n = s0.size();
    rep(i,n){
        s[s0[i]-'a'].insert(i);
    }

    ll ans = 0;
    int now=-1;
    rep(i,t.size()){
        int c = t[i]-'a';
        if(s[c].empty()){ans=-1;break;}
        auto it = s[c].upper_bound(now);
        if(it == s[c].end()){
            now = *s[c].begin();
            ans += n;
        }else{
            now = *it;
        }
    }
    if(ans!=-1)ans+=now+1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>

using namespace std;

int main(){
    int count[4][3][10]={}, n, b, f, r, v;

    scanf("%d\n", &n);

    for(int i=0; i<n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[b-1][f-1][r-1] += v;
    }

    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                printf(" %d", count[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3)
            printf("####################\n");
    }

    return 0;
}


Measured memory_bytes: 2644
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAXN 10
#define INF 0x3f3f3f3f

int D, G;
int P[MAXN + 5], C[MAXN + 5];

int main() {
    scanf("%d %d", &D, &G);

    for (int i = 1; i <= D; ++i) {
        scanf("%d %d", &P[i], &C[i]);
    }

    int Max = (1 << D) - 1, Ans = INF;

    for (int i = 0; i <= Max; ++i) {
        int cnt = 0, rest = G;
        for (int j = D; j >= 1 && rest > 0; --j) {
            if (i & (1 << (j - 1))) {
                int tmp = P[j] * j * 100;
                if (tmp >= rest) {
                    cnt += (rest + 100 * j - 1) / (100 * j);
                    rest = 0;
                    break;
                }else {
                    rest -= tmp + C[j];
                    cnt += P[j];
                }
            }
        }
        if (rest <= 0) {
            Ans = min(Ans, cnt);
        }
    }
    printf("%d", Ans);

    return 0;
}

Measured memory_bytes: 128
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(5)
const int mod=1e9+7;
const int big=1e8+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	string s,t;cin>>s>>t;
	if(s.size()<t.size()){cout<<"UNRESTORABLE"<<endl;return 0;}
	for(int i=s.size()-t.size();i>=0;i--){
		int ok=1;
		for(int j=0;j<t.size();j++){
			if(s[i+j]!='?'&&s[i+j]!=t[j]){ok=0;break;}
		}
		if(ok==1){
			//iから始まる
			for(int j=0;j<s.size();j++){
				if(i<=j&&j<i+t.size()){cout<<t[j-i];}
				else if(s[j]=='?'){cout<<'a';}
				else{cout<<s[j];}
			}
			cout<<endl;
			return 0;
		}
	}
	cout<<"UNRESTORABLE"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main()
{
	int n;
	int i;
	scanf("%d",&n);
	
	int a[n];
	for(i=0;i<n;i++){
		scanf(" %d",&a[i]);
	}
	
	for(i=n-1;i>=1;i--){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[i]);
	return 0;
}

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

int main(){
	int a, b;

	cin >> a >> b;

	if(a<b){
		cout << "a < b" << endl;
	}else if(a > b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  char c1 = S[0], c2;
  for (int i = 1; i < 4; ++i) {
    if (S[i] != c1) {
      c2 = S[i];
      break;
    }
  }
  int count1 = 0, count2 = 0;
  for (int i = 0; i < 4; ++i) {
    if (c1 == S[i])
      ++count1;
    if (c2 == S[i])
      ++count2;
  }
  if (count1 == 2 && count2 == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for(int i=0; i<3; i++){
        if(n%10==7){
            cout<<"Yes"<<endl;
            return 0;
        }
        n/=10;
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main(void){

  char str[10001];
  int joi, ioi, i;

  while(scanf("%s", str) != EOF){
    joi = ioi = 0;
    for(i = 0; i < strlen(str) - 2; i++){
  if(str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I') joi++;
  if(str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I') ioi++;
 }

 printf("%d\n%d\n", joi, ioi);
  }

return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

class Combination_Mod{
    public:
        Combination_Mod(long long MAX, long long MOD) : fact(MAX + 1), inv(MAX + 1), finv(MAX + 1), MAX(MAX + 1), MOD(MOD){
            init();
        }

        void init(){
            fact[0] = fact[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for(long long i = 2; i < MAX; ++i){
                fact[i] = fact[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD % i] *  (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        long long value(long long n, long long r){
            if(n < r || n < 0 || r < 0) return 0;
            return fact[n] * (finv[r] * finv[n - r] % MOD) % MOD;
        }

    private:
        vector<long long> fact;
        vector<long long> inv;
        vector<long long> finv;
        const long long MAX;
        const long long MOD;
};

ll N, M;

signed main(){    
    cin >> N >> M;
    vector<ll> p, q;
    ll m = M;
    for(ll i = 2; i <= M && m > 1; i++){
        ll cnt = 0;
        while(m % i == 0){
            cnt++;
            m /= i;
        }
        if(cnt > 0){
            p.push_back(i);
            q.push_back(cnt);
        }
    }
    m = (ll)p.size();
    Combination_Mod c(200000, MOD);
    ll ans = 1;
    REP(i, m){
        ans *= c.value(q[i] + N - 1, q[i]);
        ans %= MOD;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 4992
<?php

$N = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));

$sum = array_sum($a);
$yosou1 = floor($sum / $N);
$yosou2 = ceil($sum / $N);

$ans1 = 0;
foreach($a as $val){
$num = pow(($val - $yosou1) , 2);
$ans1 += $num;
}

if($ans1 == 0){
echo 0;
}else{
$ans2 = 0;
foreach($a as $val){
$num = pow(($val - $yosou2) , 2);
$ans2 += $num;
}
$ans = min($ans1 , $ans2);
echo $ans;
}

Measured memory_bytes: 3704
S=input()

months=["{:02}".format(m) for m in range(1,13)]

pre_p = S[:2] in months
post_p = S[2:] in months

if pre_p:
    if post_p:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if post_p:
        print("YYMM")
    else:
        print("NA")



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

int main (){
int m,sum=0;
cin>>m;
int a[m];
for(int i=0;i<m;i++)
    cin>>a[i];

for (int i=0 ;i<m;i++)
    for(int j=0;j<m-i-1;j++)
        if (a[j]<a[j+1])
            swap(a[j],a[j+1]);
for (int i=0;i<m;i++){
    if (i%2==0)
        sum+=a[i];
    else
        sum-=a[i];
        

}
cout<<abs(sum)<<endl;
return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>

using ll = long long;

using namespace std;

int main() {
    double l;
    cin >> l;
    cout << fixed << setprecision(15) << l * l * l / 27.  << '\n';
    return 0;
}

Measured memory_bytes: 256
/*input
3
10 2 5
6 3 4
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=4e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int c[maxn],v[maxn];
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    REP(i,n) cin>>v[i];
    REP(i,n) cin>>c[i];
    int mx=0;
    REP(i,(1<<n)){
        int ans=0;
        REP(j,n){
            if(i&(1<<j)) ans+=v[j]-c[j];
        }
        MXTO(mx,ans);
    }
    cout<<mx;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

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

int main (void) {
    int N,X;
    cin>>N>>X;
    vector<ll> x(N);
    REP(i,N) cin>>x[i];
    sort(ALL(x));
    ll g;
    if (N == 1) {
        cout<<abs(X-x[0])<<endl;
        return 0;
    }
    for (int i=1;i<N;i++) {
        ll n = x[i] - x[i-1];
        if (i == 1) g = n;
        else {
            g = gcd(max(g,n),min(g,n));
        }
    }
    ll ans = 0;
    REP(i,N) {
        ll d = abs(X - x[i]);
        ll temp = gcd(max(g,d),min(g,d));
        ans = max(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int n, vi;
    cin >> n;
    map<int, int> even, odd;
    for (int i = 1; i <= n; i++) {
        cin >> vi;
        (i & 1 ? odd[vi] : even[vi])++;
    }

    int key_odd_max1, key_odd_max2, key_even_max1, key_even_max2;
    for (auto oddi : odd) {
        if (oddi.second > odd[key_odd_max1]) key_odd_max1 = oddi.first;
    }
    for (auto eveni : even) {
        if (eveni.second > even[key_even_max1]) key_even_max1 = eveni.first;
    }
    for (auto oddi : odd) {
        if (oddi.first != key_odd_max1 && oddi.second > odd[key_odd_max2]) key_odd_max2 = oddi.first;
    }
    for (auto eveni : even) {
        if (eveni.first != key_even_max1 && eveni.second > even[key_even_max2]) key_even_max2 = eveni.first;
    }

    int ans;
    if (key_odd_max1 != key_even_max1) {
        ans = n - (odd[key_odd_max1] + even[key_even_max1]);
    } else {
        ans = n - max(odd[key_odd_max1] + even[key_even_max2], odd[key_odd_max2] + even[key_even_max1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992