akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc091/tasks/abc091_b
#include <iostream>
#include <map>
using namespace std;

int N, M;
map<string, int> counter;

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        counter[s]++;
    }

    cin >> M;
    for (int i = 0; i < M; ++i) {
        string s;
        cin >> s;
        counter[s]--;
    }

    int res = 0;
    for (auto const &item: counter) {
        res = max(res, item.second);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int n,c[510],s[510],f[510],*d=c,*t=s,*g=f,i;int main(){scanf("%d",&n);for(;d<c+n-1;++d,++t,++g)scanf("%d%d%d",d,t,g);*g=1;while(i<n)for(int a=0,j=i++;j<n||!printf("%d\n",a);)a=(a<s[j]?s[j]:(a/f[j]+(a%f[j]!=0))*f[j])+c[j++];}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


ll gcd( ll m, ll n ) {
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;

  // ユークリッドの方法
  while ( m != n ) {
    if ( m > n ) m = m - n;
    else         n = n - m;
  }
  return m;
}//gcd


unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  ll n;
  cin >> n;
  vector<ll>a(n);
  vector<ll>b(n);

  cin >> a;
  sort(a.begin(), a.end());
  ll ans = 0;

  ll gcdraw = euclidean_gcd(a[0], a[1]);
  ll gcdopt = max (a[0], a[1]);
  ll gcdtmp = 0;


  for (int i = 2; i < n; i++) {
    if (i == 2) {
      gcdraw = euclidean_gcd(gcdraw, a[i]);
      gcdopt = max (  euclidean_gcd(a[0], a[i])  ,   euclidean_gcd(a[1], a[i]) );
    } else {
      gcdtmp = gcdraw;
      gcdraw = euclidean_gcd(gcdraw, a[i]);
      gcdopt = euclidean_gcd(gcdopt, a[i]);
      if (gcdtmp > gcdopt)gcdopt = gcdtmp;
    }
    cerr << "gcdopt : gcdraw = " << gcdopt << " " << gcdraw << endl;
  }


  cout << gcdopt ;

}




















Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, m, a[1123], b[1123], c[1123][15];

    cin >> n >> m;
    REP(i, m)
    {
        cin >> a[i] >> b[i];
        REP(j, b[i])
        cin >> c[i][j];
    }

    int dp[1010][(1 << 12) + 10];
    memset(dp, -1, sizeof(dp));

    dp[0][0] = 0;

    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < (1 << n); j++)
        {
            if (dp[i][j] == -1)
                continue;

            if (dp[i + 1][j] > dp[i][j] || dp[i + 1][j] == -1)
                dp[i + 1][j] = dp[i][j];

            int val = dp[i][j] + a[i];

            int nj = j;
            for (int k = 0; k < b[i]; k++)
                nj |= (1 << (c[i][k] - 1));

            if (dp[i + 1][nj] > val || dp[i + 1][nj] == -1)
                dp[i + 1][nj] = val;
        }
    }

    cout << dp[m][(1 << n) - 1] << endl;

    return 0;
}

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

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

void solve(std::string S){
    if(S[2] == S[3] && S[4] == S[5]){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func allAtoi(num []string) []int {
	conv := make([]int, len(num))
	for i, item := range num {
		conv[i], _ = strconv.Atoi(item)
	}
	return conv
}

func main() {
	l := strings.Split(nextLine(), " ")
	meta := allAtoi(l)
	n := meta[0]
	limitW := meta[1]
	items := make([]item, n, n)
	for i := range items {
		d := strings.Split(nextLine(), " ")
		vw := allAtoi(d)
		items[i] = item{v: vw[0], w: vw[1]}
	}
	ans := solve(n, limitW, items)
	fmt.Println(ans)
}

type item struct {
	v int
	w int
}

func solve(n, limitW int, items []item) int {
	dp := make([][]int, n+1, n+1)
	dp[0] = make([]int, limitW+1, limitW+1)
	for i := 1; i <= n; i++ {
		v := items[i-1].v
		w := items[i-1].w
		dp[i] = make([]int, limitW+1, limitW+1)
		for j := 0; j <= limitW; j++ {
			rest := j - w
			if rest >= 0 && dp[i-1][j] < dp[i-1][rest]+v {
				dp[i][j] = dp[i-1][rest] + v
			} else {
				dp[i][j] = dp[i-1][j]
			}
		}
	}
	return dp[n][limitW]
}



Measured memory_bytes: 9572
// Medha's code  :


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double dd;
#define fastio ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 0x3f3f3f3f3f
#define MOD 1000000007

int main() {

    fastio;

    ll n,j,k=1;
    vector<ll> a(3005);
    vector<vector<ll>> dp(3005 , vector<ll> (3005));

    cin >> n;

    for(ll i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    for( ll i = 1; i <= n; i++)
    {
        if(n%2 == 0)
        {
            dp[i][i] = -a[i];
        }

        else dp[i][i] = a[i];
    }


    for(  j = 2 ; j <= n ; j++)
    {
        k = j;
        ll i = 1;
        while( i <= (n-j+1) && j <= n)
        {
            ll h = k-i+1;
           if(( n - h) % 2 == 0)
           {
               dp[i][k] = max(dp[i+1][k] + a[i] , dp[i][k-1] +a[k]);
           }

           else {
               dp[i][k] = min( dp[i+1][k] - a[i] , dp[i][k-1] -a[k]);
           }

           i++;
           k++;
        }
    }

//    for( ll i = 1; i <= n ; i++)
//    {
//        for( ll b = 1 ; b <= n ; b++)
//        {
//            cout << dp[i][b] <<" ";
//        }
//        cout << "\n";
//    }

    cout<< dp[1][n];



    return 0;
}


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);

	for (int i = 0; i < N; i++) cin >> p[i];

	sort(p.begin(), p.end());

	int sum = 0;

	for (int i = 0; i < K; i++) {
		sum += p[i];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;
 
int main(){
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  rep(i, 3) cout << s[i];
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
    int i,a[5],b[5],c,d;
	char mise[5]={'A','B','C','D','E'};
	while(1){
	    c=0;
		scanf("%d %d",&a[0],&b[0]);
	    if(a[0]==0&&b[0]==0) break;
		for(i=1;i<5;i++){
		    scanf("%d %d",&a[i],&b[i]);
		}
		for(i=0;i<5;i++){
		    if(c<a[i]+b[i]){
			    c=a[i]+b[i];
				d=i;
			}
		}
		printf("%c %d\n",mise[d],c);
	}
	return 0;
}

Measured memory_bytes: 2620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using CHY72;

namespace CHY72{
    
    public class PointXY<T>where T:IComparable {
        public T X , Y;
        public bool Flag = false;
        public PointXY(T _X,T _Y) {
            X = _X; Y = _Y;
        }
        public static bool operator ==(PointXY<T> P1, PointXY<T> P2) {
            return (P1.X.CompareTo( P2.X) == 0 && P1.Y.CompareTo (P2.Y) == 0);
        }
        public static bool operator !=(PointXY<T> P1, PointXY<T> P2) {return !(P1 ==P2);}
        public override int GetHashCode() {return X.GetHashCode() ^ Y.GetHashCode();}
        public override bool Equals(object obj) {
            if (obj == null || this.GetType() != obj.GetType()) {return false;}
            return (this == (PointXY<T>)obj);
        }         

    }
    

}    

public class Program {
    static bool ReadLine_1(ref int num1, bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str);
        return (Fin0 && num1 == 0);
    }
    static int  ReadLine_1() {
        return  int.Parse(Console.ReadLine());
    }
    static bool ReadLine_2(ref int num1, ref int num2, char Spliter = ' ', bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str.Split(Spliter)[0]);
        num2 = int.Parse(str.Split(Spliter)[1]);
        return (Fin0 && num1 == 0);
    }
    static int[] ReadLine72(char Spliter = ' ') {
        return Console.ReadLine().Split(Spliter).Select(s => int.Parse(s)).ToArray();
    }

    const int DefaultMax = 727272;

    static bool isRight(char CH) {
        switch (CH) {
            case 'y':case 'u':case 'i':case 'o':case 'p':
            case 'h':case 'j':case 'k':case 'l':
            case 'n':case 'm':
                return true; 
        }
        return false;
    }

    static void Main(string[] args) {
        while (true) {
            char[] ReadC = Console.ReadLine().ToCharArray();
            if (ReadC[0] == '#') return;
            bool CurrentisRight =isRight( ReadC[0]);
            int output = 0;
            for (int i = 1; i < ReadC.Length; i++) {
                if (CurrentisRight != isRight(ReadC[i])) {
                    output++; CurrentisRight = !CurrentisRight; 
                }
            }
            Console.WriteLine(output);
        }
    }
}

Measured memory_bytes: 5664
#! python3
# selection_sort.py

# 各ステップで最小値を選択

n = int(input())
A = [int(x) for x in input().split(' ')]

exc_num = 0
for i in range(n-1):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    if i != minj:
        exc_num += 1
        A[i], A[minj] = A[minj], A[i]

print(' '.join([str(x) for x in A]))
print(exc_num)


Measured memory_bytes: 5608
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 200;

int n;
string s, t, pref[MAXN];

int main() {
	cin >> n;
	cin >> s >> t;
	pref[0] = t[0];
	FOR(i, 1, (int)t.size()) pref[i] = pref[i - 1] + t[i];
	int sol = (int)t.size() + (int)s.size();
	for (int i = (int)s.size() - 1, j = 0; j < min((int)s.size(), (int)t.size()); i--, j++) {
		string tmp = s.substr(i, (int)s.size());
		if (pref[(int)tmp.size() - 1] == tmp) sol = min(sol, (int)t.size() + (int)s.size() - (int)tmp.size());
	}
	printf("%d\n",sol);
	return 0;
}


Measured memory_bytes: 256
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main(void){

    int n, k, *hs;
    long *C1;
    scanf("%d %d", &n, &k);

    hs = malloc(n * sizeof(int));
    C1 = malloc(n * sizeof(long));

    for(int c = getchar(), i = 0; i < n; c = getchar(), ++i){

        while(isspace(c)) c = getchar();
        int valor = 0;
        for(; c >= '0'; c = getchar()) valor = valor * 10 + c - '0';
        hs[i] = valor;
    }

    C1[0] = 0;
    int lim = k < n ? k : n;
    for(int i = 1; i < lim; ++i){

        int hi = hs[i];
        long minimo = LONG_MAX;

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

            int prueba = C1[j] + abs(hi - hs[j]);
            if(prueba < minimo) minimo = prueba;
        }

        C1[i] = minimo;
    }

    for(int i = k; i < n; ++i){

        int hi = hs[i];
        long minimo = LONG_MAX;

        for(int j = i - k; j < i; ++j){

            int prueba = C1[j] + abs(hi - hs[j]);
            if(prueba < minimo) minimo = prueba;
        }

        C1[i] = minimo;
    }

    printf("%li", C1[n - 1]);
}




Measured memory_bytes: 1280
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n,k;cin>>n>>k;
  ll ans=1900*k+100*(n-k);
  ans*=pow(2,k);
  cout<<ans<<endl;
}







Measured memory_bytes: 3980
#include<stdio.h>
main(){
    int n,m;
    int MAX_N = 100;
    int MAX_M = 100;
    int a[MAX_N][MAX_M];
    int b[MAX_M];
    int c[MAX_N];
    int i,j;
 
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
 
    for(i=0;i<n;i++){
        c[i] = 0;
    }
 
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            c[i] = c[i] + a[i][j] * b[j];
        }
    }
 
    for(i=0;i<n;i++){
        printf("%d\n",c[i]);
    }
    return 0;
}

Measured memory_bytes: 2800
X,Y = map(int,input().split())
mod = 1000000000+7
if (X+Y)%3 != 0:
    print(0)
    exit()
if X > 2*Y or Y > 2*X:
    print(0)
    exit()
MOD = 10**9 + 7
N = 10**6
fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % MOD
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % MOD
Z1 = (X+Y)//3
Z2 = X-Z1
Z3 = Z1 - Z2
print(comb(Z1,Z2))

Measured memory_bytes: 55660
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>

using namespace std;

int main(void)
{
	int x, a, b;

	cin >> x >> a >> b;

	if (abs(x - a) < abs(x - b))
	{
		cout << "A" << endl;
	}
	else
	{
		cout << "B" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#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 ALL(v) (v).begin(), (v).end()
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
typedef pair<ll, ll> LLARR;
#define INF 999999999

int n;

bool isSum(int *A, int i, int target, int now)
{
	if (target == now)
		return true;
	if (i >= n)
		return false;
	return isSum(A, i + 1, target, now) || isSum(A, i + 1, target, now + A[i]);
}

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

	int A[2001];

	cin >> n;
	REP(i, n)
	{
		cin >> A[i];
	}
	int m;
	cin >> m;

	REP (i,m)
	{
		// mi
		int mi;
		cin >> mi;
		cout << (isSum(A, 0, mi, 0) ? "yes" : "no") << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    ll a;
    cin>>a;
    cout<<a + a*a + a*a*a<<endl;
}

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

int main(){
  int a,b;
  int c=0;
  int cnt=0;
  cin>>a>>b;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec[i];
  }
  for(int i=0;i<a;i++){
    c+=vec[i];
    if(c>b) break;
    cnt++;
  }
  cout<<cnt+1<<endl;}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a,b,c,co=0;
   scanf("%d%d%d",&a,&b,&c);
   for(int i=a;i<=b;i++)
   {
       if(c%i==0)
       {
          co++;
          //printf("%d\n",i);

       }

   }
printf("%d\n",co);


}


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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {

	long long x = pow(10,9) + 7;

	int n;
	cin >> n;
	long long ans = 1;

	REP(i, n) {
		ans = ans*(i + 1)%x;

	}

	ANS(ans);

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d %d",&a,&s);
	if(a+s<10) printf("%d\n",a+s);
	else printf("error\n");
	return 0;
}

Measured memory_bytes: 128
// agc046_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

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

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int X;
    cin >> X;
    int ans = 360 / gcd(360, X);
    print(ans);

    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数
int long long GetDigitSum(int long long n){
    if(n < 10){
       return n;
    }
    return GetDigitSum(n/10) + n%10;
} //十進数の桁和
unsigned int long long unsignedGetDigitSum(unsigned int long long n){
    if(n < 10){
       return n;
    }
    return unsignedGetDigitSum(n/10) + n%10;
} //十進数の桁和unsigned
int long long divisorcount(int long long n){
	int long long ans = 1;
	vector<int> x(n + 1);
	int long long num = n; // 素因数分解する変数num 
	for (int long long i = 2; i <= n; i++) {
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			x.at(i)++; //割った個数を配列に足す
			num /= i;
		}
	}
	for (int i = 2; i <= n; i++){
		ans *= x.at(i) + 1; //それぞれを+1して掛けていく
	}
    return ans;
} //約数カウント


int main(){
    int N;
    cin >> N;
    vector<vector<int>> V(N, vector<int>(2));
    for(int i = 0; i < N; i++){
        cin >> V.at(i).at(0) >> V.at(i).at(1);
    }
    bool ans = false;
    for(int i = 0; i < N-2; i++){
        if(V.at(i).at(0) == V.at(i).at(1) && V.at(i+1).at(0) == V.at(i+1).at(1) && V.at(i+2).at(0) == V.at(i+2).at(1)){
            ans = true;
        }
    }
    if(ans == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(A==B){cout<<C<<endl;return 0;}
    else if(A==C){cout<<B<<endl;return 0;}
    else{cout<<A<<endl;return 0;}
} 


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

using namespace std;

int main(){
    int n;
    string st;
    cin >> n; cin >> st;
    vector<short> s(n);

    for(int i = 0; i < n; ++i){
        if(st[i] == 'E') s[i] = 1;
        else             s[i] = 0;
    }

    unsigned int ans;
    ans = accumulate(s.begin(), s.end(), 0) - s[0];
    unsigned int sum = ans;
    for(int i = 0; i < n - 1; ++i){
        sum = sum - s[i + 1] + (1 - s[i]);
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

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

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair

int main(){
    CIN(n,m);
    V v;
    int mmsq = sqrt(m) + 3;
    FOR(i,1,mmsq){
        if(m%i==0){
            v.pb(i);
            v.pb(m/i);
        }
    }
    sort(ALL(v));
    REPR(i,v.size()-1){
        ll k = v[i];
        if(k*n<=m){
            COUT(k);return 0;
        }
    }

}


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

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

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

    if((b-a)%2==0)
        cout << (b-a)/2 << endl;
    else
        cout << min(a-1,n-b)+1+(b-a-1)/2 << endl;

    return 0;
}


Measured memory_bytes: 3548
r = gets.split(' ').first.to_i
rc = []
r.times { rc << gets.split(' ').map(&:to_i) }
rc.map! {|c| c << c.inject(:+) }
rc << rc.transpose.map { |c| c.inject(:+) }
puts rc.map { |c| c.join(' ') }

Measured memory_bytes: 9024
#include<bits/stdc++.h>
#define N 1000005 
#define LL long long 
using namespace std;
int A[N];
char str[N]; 
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	printf("%d %d %d\n",a,b,c);
	return 0; 
} 

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

typedef long long ll;

const int MN = 200010;
const int offset = 100000;

int N;
int A[MN], B[MN], psum[MN];

struct Fenwick {
    vector<int> tree;
    void init() {
        tree = vector<int>(MN + 1, 0);
    }
    void upd(int idx, int val) {
        for(int i = idx + 1; i <= MN; i += (i & -i)) tree[i] += val;
    }
    int quer(int a) {
        int ret = 0;
        for(int i = a + 1; i >= 1; i -= (i & -i)) ret += tree[i];
        return ret;
    }
    int quer(int a, int b) {
        return quer(b) - quer(a - 1);
    }
} fw;

bool check(int x) {
    for(int i = 0; i < N; i++) {
        B[i] = x <= A[i]? 1 : -1;
    }
    for(int i = 0; i < N; i++) {
        psum[i] = B[i];
        if(i) psum[i] += psum[i - 1];
    }
    ll cnt = 0;
    fw.init();
    fw.upd(offset, 1);
    for(int i = 0; i < N; i++) {
        cnt += fw.quer(0, psum[i] + offset);
        fw.upd(psum[i] + offset, 1);
    }
    return cnt >= (1LL * N * (N + 1) / 2 + 1) / 2;
}

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

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

    int s = 0, e = 1e9, p = -1;
    while(s <= e) {
        int m = (s + e)>>1;

        if(check(m)) {
            p = m;
            s = m + 1;
        }
        else e = m - 1;
    }
    printf("%d", p);
}


Measured memory_bytes: 3040
#include <stdio.h>
int main(void){
	int n,i,j,minv,maxv;
	scanf("%d" ,&n);
	int A[n];
	for(i = 0; i < n; i++){
		A[i] = 0;
	}
	for(i = 0; i < n; i++){
		scanf("%d" ,&A[i]);
	}
	minv = A[0];
	maxv = A[1] - A[0];
	for(j = 1; j <= n - 1; j++){
		if(maxv > A[j] - minv){
			maxv = maxv;
		}
		else if(maxv <= A[j] - minv){
			maxv = A[j] - minv;
		}
		if(minv > A[j]){
			minv = A[j];
		}
		else if(minv <= A[j]){
			minv = minv;
		}
	}
	printf("%d\n" ,maxv);
	return 0;
}


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

int main() {
    for (int i=0; i<3000; i++) {
        int x,y;
        cin>>x>>y;
        if(x==0 && y==0) break;
        else if (x>y) cout << y<<" " <<x<<endl;
        else cout<< x<<" " <<y<<endl;
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int n = log10(N)+1;
  int SUM,f = 0;
  vector<int> figure(n);
  for (int i=0;i<n;i++){
  	f = N % (int)pow(10,n-i) / (int)pow(10,n-i-1); 
    SUM += f;
  }
  if (N%SUM == 0)
    cout << "Yes";
  else
    cout << "No";
} 

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

int ctoi(char x){
	return x-'0';
}

int main(){
	ios::sync_with_stdio(false);
	string s; cin>>s;
	
	int sum=0;
	for(int i=0; i<s.size(); i++){
		int x = ctoi(s[i]);
		sum += x;
	}

	if(sum%9==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
typedef vector<int> Ivec;
typedef pair<int, int> Pos;

int main() {
	int a, b;

	scanf("%d %d", &a, &b);

	if (a <= 0 && b >= 0) printf("Zero\n");
	else if (a > 0) printf("Positive\n");
	else if ((b - a + 1) % 2) printf("Negative\n");
	else printf("Positive\n");
	return 0;
}

Measured memory_bytes: 256
C = str(input())
al = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(al)):
    if C == al[i]:
        if i == 25:
            print("a")
        else:
            print(al[i+1])


Measured memory_bytes: 3060
#include<stdio.h>
int row[8],col[8],dpos[15],dneg[15],a[8][8];
int i,j,n,c,r;
void putQueen(int i){
  int j;
  if(i==8){
    printboard();
    return;
  }
  for(j=0;j<8;j++){
    if(col[j]==0 || dpos[i+j]==0 || dneg[i-j+7]==0) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+7]=0;
    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+7]=1;
  }
}

int printboard(){
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(a[i][j] && row[i]!=j) return;
    }
  }
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(row[i]==j){
        printf("Q");
      }
      else printf(".");
    }
    printf("\n");
  }
}

int main(){
  scanf("%d",&n);
  for(i=0;i<15;i++){
    dpos[i]=dneg[i]=1;
  }
  for(i=0;i<8;i++){
    col[i]=row[i]=1;
    for(j=0;j<8;j++){
      a[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
          scanf("%d%d",&r,&c);
    a[r][c]=90;
  }
  putQueen(0);
  return 0;
}


Measured memory_bytes: 2108
n,y=[int(i) for i in input().split()]

def get():
    for num_10000 in range(n+1):
        for num_5000 in range(n-num_10000+1):
            num_1000=n-num_10000-num_5000
            if y==10000*num_10000+5000*num_5000+1000*num_1000:
                return [num_10000,num_5000,num_1000]
    return [-1,-1,-1]
a,b,c=get()

print(a,b,c)

Measured memory_bytes: 9044
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	string t = "abc";
	if(s == t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
N = 1010
ans = [0] * (N +1)
g = [[] for _ in range(N)]

for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b)

#n, m = 6, 9
#g = [[], [2],[3],[4], [5], [1,6,2],[1,2]]
def minCircle(s):
    f = [0] * N
    visited = set()
    q = []
    q.append(s)
    while q:
        p = q.pop()
        for c in g[p]:
            if c not in visited:
                f[c] = p
                visited.add(c)
                q.append(c)
        if s in visited:
            break
    p = f[s]
    ret = []
    ret.append(s)
    while p and p!= s:
        ret.append(p)
        p = f[p]
    return ret

for i in range(1, n+1):
    t = minCircle(i)
    if len(t) > 1 and len(t) < len(ans):
        ans = t
if len(ans) == N+1:
    print(-1)
else:
    print(len(ans))
    for i in ans:
        print(i)


Measured memory_bytes: 50392
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main () {
	let v = procon_read();
	let a:i32 = v[0];
	let b:i32 = v[1];
	if a <= 5 {
		println!("0");
	}else if a > 5 && a <= 12 {
		println!("{}", b/2);
	}else{
		println!("{}", b);
	}
}

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

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if((a < 0 && b > 0) || a == 0 || b == 0)
		printf("Zero\n");
	else if(a > 0)
		printf("Positive\n");
	else if(b < 0){
		if((b - a) % 2 == 0)
			printf("Negative\n");
		else 
			printf("Positive");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, A;
	cin >> N >> A;
	if (N % 500 <= A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		int nam = s.length();
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0;i < nam ;i++){
		    if(s.charAt(i) == '0'){
		       sb.append('0');
		    }else if(s.charAt(i) == '1'){
		       sb.append('1');
		    }else if(s.charAt(i) == 'B'){
		       if (sb.length() >= 1) {
                sb.setLength(sb.length()-1);
            }
		  }
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 25044
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll) 1000000007
#define P pair<ll, ll>



ll h, w, a1[2100][2100], a2[2100][2100], a3[2100][2100], a4[2100][2100], ans = 0;
string s[2100];
int main() {
	cin >> h >> w;
	REP(i, h)cin >> s[i];
	REP(i, 2100)REP(j, 2100) a1[i][j] = -1;
	REP(i, 2100)REP(j, 2100) a2[i][j] = w;
	REP(i, 2100)REP(j, 2100) a3[i][j] = -1;
	REP(i, 2100)REP(j, 2100) a4[i][j] = h;
	REP(i, h) {
		REP(j, w) {
			if (s[i][j] == '#')a1[i][j] = j;
			a1[i][j + 1] = a1[i][j];
		}
	}
	REP(i, h) {
		REPR(j, w - 1) {
			a2[i][j] = a2[i][j + 1];
			if (s[i][j] == '#')a2[i][j] = j;
		}
	}
	REP(j, w) {
		REP(i, h) {
			if (s[i][j] == '#')a3[i][j] = i;
			a3[i + 1][j] = a3[i][j];
		}
	}
	REP(j, w) {
		REPR(i, h - 1) {
			a4[i][j] = a4[i + 1][j];
			if (s[i][j] == '#')a4[i][j] = i;
		}
	}
	REP(i, h) {
		REP(j, w) {
			if (s[i][j] == '.') {
				ans = max(ans, a2[i][j] - a1[i][j] + a4[i][j] - a3[i][j] - 3);
			}
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    unsigned long long ans = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if ((log10(ans) + log10(a[i])) < 18 || ans * a[i] == 1000000000000000000)
        {
            ans *= a[i];
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4004
#include <iostream>
#include <vector>

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    vector<int> H(N);
    rep(i, N) {
        cin >> H[i];
    }

    int ans = 0;
    int cur = 0;
    rep(i, N - 1) {
        if(H[i] >= H[i + 1]) {
            cur++;
            ans = max(ans, cur);
        } else {
            cur = 0;
        }
        IFD cout << i << ": " << cur << endl;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (regex_match(S, regex("RRR"))) return cout << 3 << "\n", 0;
  if (regex_match(S, regex(".*RR.*"))) return cout << 2 << "\n", 0;
  if (regex_match(S, regex(".*R.*"))) return cout << 1 << "\n", 0;
  cout << 0 << "\n";
}

Measured memory_bytes: 3740
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<int>A(N);
    rep(i, N)cin >> A[i];
    bool flag = true;
    for (int num : A) {
        if (num % 2 == 0) {
            if (num % 3 == 0 || num % 5 == 0) {
                continue;
            }
            else {
                flag = false;
            }
        }
    }
    cout << (flag ? "APPROVED" : "DENIED") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>

using namespace std;

const int MAXN=2003;

int tot;
long long primeCube[2161];
bool notPrime[2161];

void getPrimeCube() {//得到2161以下的素数的立方
    memset(notPrime,false,sizeof(notPrime));
    tot=0;
    for(int i=2;i<2161;++i) {
        if(!notPrime[i]) {
            primeCube[tot++]=1LL*i*i*i;
            for(int j=i<<1;j<2161;j+=i) {
                notPrime[j]=true;
            }
        }
    }
}

int n,ans;
long long cur,tar,cube;
map<long long,int> cnt;
map<long long,int>::iterator it;

int main() {
    getPrimeCube();
    while(1==scanf("%d",&n)) {
        cnt.clear();
        for(int i=0;i<n;++i) {
            scanf("%lld",&cur);
            for(int j=0;j<tot;++j) {
                cube=primeCube[j];
                while(cur%cube==0) {
                    cur/=cube;
                }
            }
            ++cnt[cur];//此时cur表示最小的值使得原数除以他后是立方数
        }
        ans=0;
        for(it=cnt.begin();it!=cnt.end();++it) {
            if(it->first==1) {//如果原数中存在立方数，则只算入一个
                ans+=min(1,it->second);
            }
            else {
                tar=it->first * it->first;//通过将该数平方的方法找到其指数在模3域下的目标数（目标数即该数和计算后的数相乘是立方数）【但是这样会溢出，貌似数据中并不存在这样的数据】
                for(int j=0;j<tot;++j) {
                    cube=primeCube[j];
                    while(tar%cube==0) {
                        tar/=cube;
                    }
                }
                ans+=max(it->second,cnt[tar]);//取这两个数个数最多的加入答案
                it->second=0;
                cnt[tar]=0;//置0，防止重复统计
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

int main()
{
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

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

Measured memory_bytes: 3720
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val seg = mutableListOf<Pair<Int, Int>>()
    for (i in 0 until m) {
        val a = sc.nextInt() - 1
        val b = sc.nextInt() - 1
        seg.add(a to b)
    }
    var ans = 0
    var right = -1
    seg.sortBy { it.second }
    for ((a, b) in seg) {
        if (right < a) {
            ans++
            right = b - 1
        }
    }
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 69616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	h := nextInt()
	w := nextInt()

	if h == 1 || w == 1 {
		fmt.Println(1)
		return
	}

	if (h*w)%2 == 0 { //どちらか偶数の場合
		fmt.Println(h * w / 2)
		return
	}

	// どちらも奇数の場合
	fmt.Println(h*(w/2) + (h / 2) + 1)
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int p[n],i,c=0;
  for(i=0;i<n;i++)
  {
   cin>>p[i]; 
  }
  for(i=1;i<n-1;i++)
  {
    if( (p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]<p[i-1] && p[i]>p[i+1]) ) c++;
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) {
        new Main().run();
    }

    void solve() {
        int N = in.nextInt();
        int Max = 0;
        int result = 0;
        for(int i = 0 ; i < N ; i ++) {
            int A = in.nextInt();
            int B = in.nextInt();
            if (A > Max) {
                Max = A;
                result = A + B;
            }
        }
        out.println(result);
    }

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

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

}

Measured memory_bytes: 42824
n, m, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

# 机Aの本の積分金額配列
ap = Array.new(1,0)
a.each{|i| ap << ap.last + i}

b = gets.chomp.split.map(&:to_i)
# 机Bの本の積分金額配列
bp = Array.new(1,0)
b.each{|i| bp << bp.last + i}

ans = 0
j = m
# 机Aに関してのみ走査
# apは0冊~N冊までの積分金額配列なので 0..n で走査
(0..n).each do |i| 
  break if ap[i] > k
  # 金額K以下で、机Bから何冊目まで購入できるか
  while bp[j] > k-ap[i]
    j -= 1
  end
  ans = i+j if i+j > ans
end

p ans
    

Measured memory_bytes: 49368
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

S=input()
S=">"+S
n=len(S)
data=[0]*n
start=0
minv=0
for i in range(1,n):
    if S[i]=='<':
        data[i]=data[i-1]+1
    if S[i]=='>':
        if S[i-1]=='<':
            # print(minv)
            for k in range(start+1,i):
                data[k]-=minv
            data[start]=max(data[start],data[start+1]+1)
            # print(data,i,minv)
            data[i]=0
            minv=0
            start=i-1
        else:
            data[i]=data[i-1]-1
            minv=min(minv,data[i])
# print(data)
# print(minv,start)
for i in range(start+1,n):
    data[i]-=minv
data[start]=max(data[start],data[start+1]+1)
if S[1]=='<':
    data[0]=0
print(sum(data))
# print(data)

Measured memory_bytes: 48624